Google Search - Blog...........

Comparison Report For The Employee Salaries In HR ABAP

REPORT zhr_comparitive_statement MESSAGE-ID zmsg.

TYPE-POOLS:slis.

TABLES: pa0001.

TYPES : BEGIN OF ty_month ,
mnr LIKE t247-mnr,
ktx LIKE t247-ktx,
ltx LIKE t247-ltx,
END OF ty_month.

DATA: v_mon(2) TYPE n,
v_year(4) TYPE n,
v_date TYPE sy-datum,
v_begda TYPE sy-datum,
v_endda TYPE sy-datum,
v_mon1(2) TYPE n,
v_date1 TYPE sy-datum,
v_begda1 TYPE sy-datum,
v_endda1 TYPE sy-datum.

DATA: v_col TYPE i.


TYPES: BEGIN OF ty_pa0000,
pernr TYPE pa0001-pernr,
END OF ty_pa0000.

TYPES: BEGIN OF ty_pa0002,
pernr TYPE pa0001-pernr,
vorna TYPE pa0002-vorna,
nachn TYPE pa0002-nachn,
END OF ty_pa0002.

DATA:sno TYPE i.

TYPES: BEGIN OF ty_pa0001,
pernr TYPE pa0001-pernr,
werks TYPE pa0001-werks,
persg TYPE pa0001-persg,
persk TYPE pa0001-persk,
btrtl TYPE pa0001-btrtl,
abkrs TYPE pa0001-abkrs,
END OF ty_pa0001.

TYPES: BEGIN OF ty_pa0008.
INCLUDE STRUCTURE p0008.
TYPES: END OF ty_pa0008.


DATA: BEGIN OF wagetypes,
lga LIKE p0008-lga01,
bet LIKE p0008-bet01,
END OF wagetypes.

DATA: lfs_0008 LIKE p0008.


TYPES: BEGIN OF ty_final,
sno TYPE i,
pernr TYPE pa0001-pernr,
vorna TYPE pa0002-vorna,
nachn TYPE pa0002-nachn,
amount1 TYPE pa0008-bet01, " basic
amount2 TYPE pa0008-bet01, " HRA
amount3 TYPE pa0008-bet01, " Transport
amount4 TYPE pa0008-bet01, " Telephne Allowance
amount5 TYPE pa0008-bet01, "Total Gross
amount11 TYPE pa0008-bet01, " basic
amount12 TYPE pa0008-bet01, " HRA
amount13 TYPE pa0008-bet01, " Transport
amount14 TYPE pa0008-bet01, " Telephne Allowance
amount15 TYPE pa0008-bet01, "Total Gross
diff TYPE pa0008-bet01, "Difference
amount21 TYPE pa0008-bet01, " basic
amount22 TYPE pa0008-bet01, " HRA
amount23 TYPE pa0008-bet01, " Transport
amount24 TYPE pa0008-bet01, " Telephne Allowance
amount25 TYPE pa0008-bet01, "Total Gross
END OF ty_final.

DATA: it_month TYPE TABLE OF ty_month WITH HEADER LINE,
it_final TYPE TABLE OF ty_final WITH HEADER LINE,
it_fieldcat TYPE slis_t_fieldcat_alv ,
it_events type slis_t_event,
wa_events type slis_alv_event,
es_selfield TYPE slis_selfield,
wa_fieldcat LIKE LINE OF it_fieldcat,
it_list type slis_t_listheader with header line,
it_pa0000 TYPE TABLE OF ty_pa0000 WITH HEADER LINE,
it_pa0001 TYPE TABLE OF ty_pa0001 WITH HEADER LINE,
it_pa0002 TYPE TABLE OF ty_pa0002 WITH HEADER LINE,
it_pa0008 TYPE TABLE OF ty_pa0008 WITH HEADER LINE,
it_pa0008_new TYPE TABLE OF ty_pa0008 WITH HEADER LINE.


SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

PARAMETERS: p_mnr(2) TYPE n,
p_mnr1(2) TYPE n.

SELECTION-SCREEN END OF BLOCK b1 .

SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
SELECT-OPTIONS : s_pernr FOR pa0001-pernr.
SELECTION-SCREEN END OF BLOCK b2 .

AT SELECTION-SCREEN .

IF p_mnr IS NOT INITIAL AND
p_mnr1 IS NOT INITIAL AND
p_mnr1 LT p_mnr.

MESSAGE s000 WITH 'Enter From Month always Less Than To Month'.
ENDIF.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_mnr.

PERFORM get_f4_month.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_mnr1.

PERFORM get_f4_month.
p_mnr1 = p_mnr.

START-OF-SELECTION.

v_mon = p_mnr.
v_year = sy-datum+0(4).
v_date+0(4) = sy-datum+0(4).
v_date+4(2) = p_mnr.
v_date+6(2) = '01'.

v_mon1 = p_mnr1.
v_date1+0(4) = sy-datum+0(4).
v_date1+4(2) = p_mnr1.
v_date1+6(2) = '01'.

PERFORM get_data.

PERFORM get_emp_salary_data.


END-OF-SELECTION.

PERFORM process_data.
PERFORM build_alv.

perform get_events.

perform top_of_page.

PERFORM display_alv.

*&---------------------------------------------------------------------*
*& Form GET_DATES
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_V_MON text
* -->P_V_YEAR text
* -->P_V_DATE text
* <--P_V_BEGDA text * <--P_V_ENDDA text *----------------------------------------------------------------------* FORM get_dates USING v_mon v_year v_date TYPE sy-datum CHANGING v_begda TYPE sy-datum v_endda TYPE sy-datum. DATA: i_month TYPE fcmnr, i_year TYPE gjahr. i_month = v_mon. i_year = v_year . CALL FUNCTION 'OIL_MONTH_GET_FIRST_LAST' EXPORTING i_month = i_month i_year = i_year i_date = v_date IMPORTING e_first_day = v_begda e_last_day = v_endda EXCEPTIONS wrong_date = 1 OTHERS = 2. ENDFORM. " GET_DATES *&---------------------------------------------------------------------* *& Form GET_F4_MONTH *----------------------------------------------------------------------* FORM get_f4_month . REFRESH : it_month, it_fieldcat. SELECT * FROM t247 INTO CORRESPONDING FIELDS OF TABLE it_month WHERE spras = 'E'. wa_fieldcat-fieldname = 'MNR'. wa_fieldcat-reptext_ddic = 'Month No'. APPEND wa_fieldcat TO it_fieldcat. CLEAR :wa_fieldcat. wa_fieldcat-fieldname = 'KTX'. wa_fieldcat-reptext_ddic = 'Month Code'. APPEND wa_fieldcat TO it_fieldcat. CLEAR :wa_fieldcat. wa_fieldcat-fieldname = 'LTX'. wa_fieldcat-reptext_ddic = 'Month Name'. APPEND wa_fieldcat TO it_fieldcat. CLEAR :wa_fieldcat. CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT' EXPORTING i_tabname = 'IT_MONTH' it_fieldcat = it_fieldcat[] IMPORTING es_selfield = es_selfield TABLES t_outtab = it_month EXCEPTIONS program_error = 1 OTHERS = 2. IF sy-subrc EQ 0. READ TABLE it_month INDEX es_selfield-tabindex. p_mnr = it_month-mnr. ENDIF. ENDFORM. " GET_F4_MONTH *&---------------------------------------------------------------------* *& Form BUILD_ALV *----------------------------------------------------------------------* FORM build_alv . REFRESH : it_fieldcat. PERFORM fill_cat USING 'SNO' 'Serial No'. PERFORM fill_cat USING 'PERNR' 'Personnel No'. PERFORM fill_cat USING 'VORNA' 'First Name'. PERFORM fill_cat USING 'NACHN' 'Last Name'. PERFORM fill_cat USING 'AMOUNT21' 'Basic Diff'. PERFORM fill_cat USING 'AMOUNT22' 'HRA Diff'. PERFORM fill_cat USING 'AMOUNT23' 'Trans Diff'. PERFORM fill_cat USING 'AMOUNT24' 'Telephone Diff'. PERFORM fill_cat USING 'AMOUNT25' 'Total Diff'. ENDFORM. " BUILD_ALV *&---------------------------------------------------------------------* *& Form DISPLAY_ALV *----------------------------------------------------------------------* FORM display_alv . DATA: wa_layout TYPE slis_layout_alv. CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING i_callback_program = sy-repid is_layout = wa_layout it_fieldcat = it_fieldcat it_events = it_events TABLES t_outtab = it_final EXCEPTIONS program_error = 1 OTHERS = 2. ENDFORM. " DISPLAY_ALV *&---------------------------------------------------------------------* *& Form FILL_CAT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->P_0240 text
* -->P_0241 text
*----------------------------------------------------------------------*
FORM fill_cat USING value(p_0240)
value(p_0241).

v_col = v_col + 1.
wa_fieldcat-col_pos = v_col.
wa_fieldcat-fieldname = p_0240.
wa_fieldcat-tabname = 'IT_FINAL'.
wa_fieldcat-reptext_ddic = p_0241.

IF wa_fieldcat-fieldname = 'AMOUNT21' OR
wa_fieldcat-fieldname = 'AMOUNT22' OR
wa_fieldcat-fieldname = 'AMOUNT23' OR
wa_fieldcat-fieldname = 'AMOUNT24' OR
wa_fieldcat-fieldname = 'AMOUNT25' .
wa_fieldcat-do_sum = 'X'.
ENDIF.

APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.


ENDFORM. " FILL_CAT
*&---------------------------------------------------------------------*
*& Form GET_DATA
*----------------------------------------------------------------------*
FORM get_data .

SELECT pernr
FROM pa0000
INTO TABLE it_pa0000
WHERE pernr IN s_pernr
AND stat2 = '3'.

IF sy-subrc = 0.

SELECT pernr
werks
persg
persk
btrtl
abkrs
FROM pa0001
INTO TABLE it_pa0001
FOR ALL ENTRIES IN it_pa0000
WHERE pernr = it_pa0000-pernr.

IF sy-subrc = 0.
SORT it_pa0001 BY pernr.
DELETE ADJACENT DUPLICATES FROM it_pa0001 COMPARING pernr.
ENDIF.

SELECT pernr
vorna
nachn
FROM pa0002
INTO TABLE it_pa0002
FOR ALL ENTRIES IN it_pa0000
WHERE pernr = it_pa0000-pernr.

IF sy-subrc = 0.
SORT it_pa0001 BY pernr.
ENDIF.

ENDIF.
ENDFORM. " GET_DATA
*&---------------------------------------------------------------------*
*& Form PROCESS_DATA
*----------------------------------------------------------------------*
FORM process_data .

LOOP AT it_pa0001.

READ TABLE it_pa0002 WITH KEY pernr = it_pa0001-pernr.
IF sy-subrc = 0.
it_final-pernr = it_pa0002-pernr.
it_final-vorna = it_pa0002-vorna.
it_final-nachn = it_pa0002-nachn.
ENDIF.
READ TABLE it_pa0008 WITH KEY pernr = it_pa0001-pernr.
IF sy-subrc = 0.
CLEAR : lfs_0008.

MOVE-CORRESPONDING it_pa0008 TO lfs_0008.

DO 40 TIMES VARYING wagetypes-lga FROM lfs_0008-lga01 NEXT lfs_0008-lga02
VARYING wagetypes-bet FROM lfs_0008-bet01 NEXT lfs_0008-bet02.

CHECK wagetypes-lga IS NOT INITIAL.

CASE wagetypes-lga.

WHEN '1000'. " Basic pay
it_final-amount11 = wagetypes-bet.
WHEN '1010'.
it_final-amount12 = wagetypes-bet.
WHEN '1020'.
it_final-amount13 = wagetypes-bet.
WHEN '1030'.
it_final-amount14 = wagetypes-bet.
ENDCASE.
ENDDO.

it_final-amount15 = it_final-amount11 + it_final-amount12 + it_final-amount13
+ it_final-amount14.

READ TABLE it_pa0008_new WITH KEY pernr = it_pa0001-pernr.
IF sy-subrc = 0.
CLEAR : lfs_0008.

MOVE-CORRESPONDING it_pa0008_new TO lfs_0008.

DO 40 TIMES VARYING wagetypes-lga FROM lfs_0008-lga01 NEXT lfs_0008-lga02
VARYING wagetypes-bet FROM lfs_0008-bet01 NEXT lfs_0008-bet02.

CHECK wagetypes-lga IS NOT INITIAL.

CASE wagetypes-lga.

WHEN '1000'. " Basic pay
it_final-amount1 = wagetypes-bet.
WHEN '1010'.
it_final-amount2 = wagetypes-bet.
WHEN '1020'.
it_final-amount3 = wagetypes-bet.
WHEN '1030'.
it_final-amount4 = wagetypes-bet.
ENDCASE.
ENDDO.

it_final-amount5 = it_final-amount1 + it_final-amount2 + it_final-amount3
+ it_final-amount4.

it_final-diff = it_final-amount5 - it_final-amount15.

it_final-amount21 = it_final-amount1 - it_final-amount11.
it_final-amount22 = it_final-amount2 - it_final-amount12.
it_final-amount23 = it_final-amount3 - it_final-amount13.
it_final-amount24 = it_final-amount4 - it_final-amount14.
it_final-amount25 = it_final-amount5 - it_final-amount15.

check it_final-amount5 ne '0'
and it_final-amount15 ne '0'.

check it_final-diff ne '0'. .

sno = sno + 1.

it_final-sno = sno.

APPEND it_final.
CLEAR it_final.
ENDIF.
ENDIF.

ENDLOOP.

ENDFORM. " PROCESS_DATA
*&---------------------------------------------------------------------*
*& Form GET_EMP_SALARY_DATA
*----------------------------------------------------------------------*
FORM get_emp_salary_data .

PERFORM get_dates USING v_mon v_year v_date
CHANGING v_begda v_endda.
*---old remuneration data
SELECT *
FROM pa0008
INTO CORRESPONDING FIELDS OF TABLE it_pa0008
FOR ALL ENTRIES IN it_pa0001
WHERE pernr = it_pa0001-pernr
AND begda LE v_endda
AND endda GE v_begda.

IF sy-subrc = 0.
SORT it_pa0008 BY pernr.
ENDIF.

PERFORM get_dates USING v_mon1 v_year v_date1
CHANGING v_begda1 v_endda1.
*---new remuneration data
SELECT *
FROM pa0008
INTO CORRESPONDING FIELDS OF TABLE it_pa0008_new
FOR ALL ENTRIES IN it_pa0001
WHERE pernr = it_pa0001-pernr
AND begda LE v_endda1
AND endda GE v_begda1.


ENDFORM. " GET_EMP_SALARY_DATA
*&---------------------------------------------------------------------*
*& Form write_header
*----------------------------------------------------------------------*
form write_header .

refresh it_list.
clear it_list.

clear it_list.
it_list-typ = 'H'.
it_list-key = space.
it_list-info = 'Comparative Statement Report'.
append it_list to it_list.

****** REPORT PROGRAM NAME AND CLIENT ****************
it_list-typ = 'S'.
it_list-key = space.
concatenate 'Report...:' sy-repid into it_list-info separated by space.
append it_list to it_list.

****** USER NAME *************************************
clear it_list.
it_list-typ = 'S'.
it_list-key = space.
concatenate 'User.....:' sy-uname into it_list-info separated by space.
append it_list to it_list.

****** DATE / TIME STAMP *****************************
clear it_list.
it_list-typ = 'S'.
it_list-key = space.
concatenate 'Date/Time:' ' ' sy-datum+6(2) '/' sy-datum+4(2) '/' sy-datum+0(4)
' ' '/' ' ' sy-uzeit+0(2) ':' sy-uzeit+2(2) ':' sy-uzeit+4(2)
into it_list-info.
append it_list to it_list.



endform. " write_header
*&---------------------------------------------------------------------*
*& Form top_of_page
*----------------------------------------------------------------------*
form top_of_page .

perform write_header.

*--- Get the comments on the top of page.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = it_list[].

endform. " top_of_page
*&---------------------------------------------------------------------*
*& Form get_events
*----------------------------------------------------------------------*
form get_events .

*---top of page for the first block
wa_events-name = 'TOP_OF_PAGE'.
wa_events-form = 'TOP_OF_PAGE'.
append wa_events to it_events.
clear wa_events.

endform. " get_events


ALSO READ:

- Cash Payment Report In HR ABAP.

- Bank Report For Employees In HR ABAP.

- BDC For Uploading Absence Data Into PA30 Transaction.

- HR Master Data Update Using T-Code CAT2 With BAPI.

- Upload Job & Position Relations Through PO03.

.....Back To Index On HR ABAP.

.....Back To MAIN INDEX.


No comments:

Post a Comment