.
TYPE-POOLS:slis.
*----------------------------------------------------------------*
* TABLES *
*----------------------------------------------------------------*
TABLES:pa0001,
t569v,
t549a,
t549q.
DATA : v_permo TYPE t549a-permo.
DATA: v_col TYPE i.
TYPES: BEGIN OF ty_pa0000,
pernr TYPE pa0001-pernr,
begda TYPE pa0001-begda,
endda TYPE pa0001-endda,
massn TYPE pa0000-massn,
massg TYPE pa0000-massg,
stat2 TYPE pa0000-stat2,
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.
TYPES: BEGIN OF ty_pa0001,
pernr TYPE pa0001-pernr,
bukrs TYPE pa0001-bukrs,
werks TYPE pa0001-werks,
persg TYPE pa0001-persg,
persk TYPE pa0001-persk,
btrtl TYPE pa0001-btrtl,
abkrs TYPE pa0001-abkrs,
kostl TYPE pa0001-kostl,
orgeh TYPE pa0001-orgeh,
plans TYPE pa0001-plans,
stell TYPE pa0001-stell,
END OF ty_pa0001.
TYPES : BEGIN OF ty_final,
sno TYPE i,
pernr TYPE p0001-pernr, "Personnel Number
vorna TYPE p0002-vorna, "Emp Name
nachn TYPE p0002-nachn,
jdate TYPE pa0001-begda,
kostl TYPE pa0001-kostl,
amount1 TYPE pa0008-bet01,
amount2 TYPE pa0008-bet01,
amount3 TYPE pa0008-bet01,
amount4 TYPE pa0008-bet01,
amount5 TYPE pa0008-bet01,
amount6 TYPE pa0008-bet01,
amount7 TYPE pa0008-bet01,
amount8 TYPE pa0008-bet01,
amount9 TYPE pa0008-bet01,
total TYPE pa0008-bet01,
total1 TYPE pa0008-bet01,
total2 TYPE pa0008-bet01,
END OF ty_final.
TYPES: BEGIN OF ty_pa0041.
INCLUDE STRUCTURE p0041.
TYPES: END OF ty_pa0041.
TYPES: BEGIN OF ty_pa0045.
INCLUDE STRUCTURE p0045.
TYPES: END OF ty_pa0045.
DATA: v_date TYPE sy-datum VALUE '20100101'.
DATA: BEGIN OF dates,
dar LIKE p0041-dar01,
dat LIKE p0041-dat01,
END OF dates.
DATA : sno TYPE i.
DATA: 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_pa0041 TYPE TABLE OF ty_pa0041 WITH HEADER LINE,
it_pa0045 TYPE TABLE OF ty_pa0045 WITH HEADER LINE,
it_final TYPE TABLE OF ty_final WITH HEADER LINE,
it_fieldcat TYPE slis_t_fieldcat_alv,
wa_fieldcat TYPE slis_fieldcat_alv,
it_layout TYPE slis_layout_alv,
it_events TYPE slis_t_event,
wa_events TYPE slis_alv_event,
it_list TYPE slis_t_listheader WITH HEADER LINE,
it_rgdir TYPE TABLE OF pc261 WITH HEADER LINE,
it_result TYPE pay99_result ,
wa_itrgdir TYPE pc261,
wa_rt TYPE pc207,
w_molga TYPE t500l-molga,
w_seqnr TYPE cdseq,
w_relid TYPE relid_pcl2,
wagetype TYPE char15.
*************************************************************************
** SELECTION-SCREEN *
*************************************************************************
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE text-002.
PARAMETERS:p_abkrs TYPE pa0001-abkrs .
PARAMETERS: p_pabrp TYPE t569v-pabrp,
p_pabrj TYPE t569v-pabrj,
p_begda TYPE pa0001-begda,
p_endda TYPE pa0001-endda.
PARAMETERS: r1 RADIOBUTTON GROUP g1 DEFAULT 'X' USER-COMMAND aaa,
r2 RADIOBUTTON GROUP g1.
SELECTION-SCREEN END OF BLOCK b3 .
SELECTION-SCREEN BEGIN OF BLOCK b5 WITH FRAME TITLE text-004.
PARAMETERS: r3 RADIOBUTTON GROUP g2 DEFAULT 'X' USER-COMMAND aaa,
r4 RADIOBUTTON GROUP g2,
r5 RADIOBUTTON GROUP g2.
SELECTION-SCREEN END OF BLOCK b5 .
SELECTION-SCREEN BEGIN OF BLOCK b4 WITH FRAME TITLE text-003.
SELECT-OPTIONS: s_pernr FOR pa0001-pernr,
s_werks FOR pa0001-werks, "Personnel Area
s_btrtl FOR pa0001-btrtl, "Personnel Subarea
s_persg FOR pa0001-persg, "Employee Group
s_persk FOR pa0001-persk. "Employee Subgroup
SELECTION-SCREEN END OF BLOCK b4 .
SELECTION-SCREEN END OF BLOCK b1 .
AT SELECTION-SCREEN OUTPUT.
IF r1 = 'X'.
PERFORM get_data_from_current_period.
LOOP AT SCREEN.
IF screen-name = 'P_PABRP'
OR screen-name = 'P_PABRJ'
OR screen-name = 'P_BEGDA'
OR screen-name = 'P_ENDDA'.
screen-input = 0.
ENDIF.
MODIFY SCREEN.
ENDLOOP.
ELSEIF r2 = 'X'.
PERFORM get_data_from_period.
LOOP AT SCREEN.
IF screen-name = 'P_BEGDA'
OR screen-name = 'P_ENDDA'.
screen-input = 0.
ENDIF.
MODIFY SCREEN.
ENDLOOP.
ENDIF.
START-OF-SELECTION.
PERFORM get_data.
END-OF-SELECTION.
PERFORM process_data.
PERFORM build_alv.
perform get_events.
perform top_of_page.
PERFORM display_alv.
*&---------------------------------------------------------------------*
*& 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 'JDATE' 'Joining Date'.
PERFORM fill_cat USING 'KOSTL' 'Cost Center'.
IF r3 = 'X'.
PERFORM fill_cat USING 'AMOUNT1' 'HRA Approved'.
PERFORM fill_cat USING 'AMOUNT2' 'HRA Repayed'.
PERFORM fill_cat USING 'AMOUNT3' 'HRA Balance'.
ELSEIF r4 = 'X'.
PERFORM fill_cat USING 'AMOUNT4' 'Staff Adv Approved'.
PERFORM fill_cat USING 'AMOUNT5' 'Staff Adv Repayed'.
PERFORM fill_cat USING 'AMOUNT6' 'Staff Adv Balance'.
ELSEIF r5 = 'X'.
PERFORM fill_cat USING 'AMOUNT7' 'Staff Loan Approved'.
PERFORM fill_cat USING 'AMOUNT8' 'Staff Loan Repayed'.
PERFORM fill_cat USING 'AMOUNT8' 'Staff Loan Balance'.
ENDIF.
ENDFORM. " BUILD_ALV
*&---------------------------------------------------------------------*
*& Form PROCESS_DATA
*----------------------------------------------------------------------*
FORM process_data .
DELETE ADJACENT DUPLICATES FROM it_pa0001 COMPARING pernr.
LOOP AT it_pa0001.
it_final-pernr = it_pa0001-pernr.
it_final-kostl = it_pa0001-kostl.
READ TABLE it_pa0002 WITH KEY pernr = it_pa0001-pernr.
IF sy-subrc = 0.
it_final-vorna = it_pa0002-vorna.
it_final-nachn = it_pa0002-nachn.
ENDIF.
READ TABLE it_pa0041 WITH KEY pernr = it_pa0001-pernr.
IF sy-subrc = 0.
DO 12 TIMES VARYING dates-dar FROM it_pa0041-dar01 NEXT it_pa0041-dar02
VARYING dates-dat FROM it_pa0041-dat01 NEXT it_pa0041-dat02.
CHECK dates-dar IS NOT INITIAL.
IF dates-dar = '01'.
it_final-jdate = dates-dat.
ENDIF.
ENDDO.
ENDIF.
READ TABLE it_pa0045 WITH KEY pernr = it_pa0001-pernr
dlart = '0300'.
IF sy-subrc = 0.
it_final-amount1 = it_pa0045-darbt.
ENDIF.
READ TABLE it_pa0045 WITH KEY pernr = it_pa0001-pernr
dlart = '0400'.
IF sy-subrc = 0.
it_final-amount4 = it_pa0045-darbt.
ENDIF.
READ TABLE it_pa0045 WITH KEY pernr = it_pa0001-pernr
dlart = '0500'.
IF sy-subrc = 0.
it_final-amount7 = it_pa0045-darbt.
ENDIF.
PERFORM get_rt_data.
it_final-total = it_final-amount1 + it_final-amount4 + it_final-amount7.
it_final-total1 = it_final-amount2 + it_final-amount5 + it_final-amount8.
it_final-total2 = it_final-amount3 + it_final-amount6 + it_final-amount9.
sno = sno + 1.
it_final-sno = sno.
APPEND it_final .
CLEAR it_final .
ENDLOOP.
ENDFORM. " PROCESS_DATA
*&---------------------------------------------------------------------*
*& Form DISPLAY_ALV
*----------------------------------------------------------------------*
FORM display_alv .
DATA: wa_layout TYPE slis_layout_alv.
wa_layout-colwidth_optimize = 'X'.
wa_layout-zebra = 'X'.
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 GET_DATA
*----------------------------------------------------------------------*
FORM get_data .
SELECT pernr
begda
endda
massn
massg
stat2
FROM pa0000
INTO TABLE it_pa0000
WHERE pernr IN s_pernr
AND stat2 = '3'
AND begda LE p_endda
AND endda GE p_begda.
IF sy-subrc = 0.
DELETE ADJACENT DUPLICATES FROM it_pa0000 COMPARING pernr.
SELECT pernr
bukrs
werks
persg
persk
btrtl
abkrs
kostl
orgeh
plans
stell
FROM pa0001
INTO TABLE it_pa0001
FOR ALL ENTRIES IN it_pa0000
WHERE pernr = it_pa0000-pernr
AND abkrs = p_abkrs
AND begda LE p_endda
AND endda GE p_begda
AND werks IN s_werks
AND btrtl IN s_btrtl
AND persg IN s_persg
AND persk IN s_persk.
IF sy-subrc = 0.
SELECT pernr
vorna
nachn
FROM pa0002
INTO TABLE it_pa0002
FOR ALL ENTRIES IN it_pa0000
WHERE pernr = it_pa0000-pernr
AND begda LE p_endda
AND endda GE p_begda.
SELECT *
FROM pa0041
INTO CORRESPONDING FIELDS OF TABLE it_pa0041
FOR ALL ENTRIES IN it_pa0001
WHERE pernr = it_pa0001-pernr
AND begda LE p_endda
AND endda GE p_begda.
IF r3 = 'X'.
SELECT *
FROM pa0045
INTO CORRESPONDING FIELDS OF TABLE it_pa0045
FOR ALL ENTRIES IN it_pa0001
WHERE pernr = it_pa0001-pernr
AND begda LE p_endda
AND endda GE p_begda
AND dlart = '0300' .
ELSEIF r4 = 'X'.
SELECT *
FROM pa0045
INTO CORRESPONDING FIELDS OF TABLE it_pa0045
FOR ALL ENTRIES IN it_pa0001
WHERE pernr = it_pa0001-pernr
AND begda LE p_endda
AND endda GE p_begda
AND dlart = '0400' .
ELSE.
SELECT *
FROM pa0045
INTO CORRESPONDING FIELDS OF TABLE it_pa0045
FOR ALL ENTRIES IN it_pa0001
WHERE pernr = it_pa0001-pernr
AND begda LE p_endda
AND endda GE p_begda
AND dlart = '0500'.
ENDIF.
ENDIF.
ENDIF.
CALL FUNCTION 'HR_HCP_ADD_MONTH_TO_DATE'
EXPORTING
im_monthcount = '03'
im_date = v_date
IMPORTING
ex_date = v_date.
CALL FUNCTION 'OIL_LAST_DAY_OF_MONTH'
EXPORTING
i_date = v_date
IMPORTING
e_last_day = v_date.
ENDFORM. " GET_DATA
*&---------------------------------------------------------------------*
*& Form GET_DATA_FROM_CURRENT_PERIOD
*----------------------------------------------------------ι-----------*
FORM get_data_from_current_period .
SELECT SINGLE * FROM t569v
WHERE abkrs = p_abkrs
AND vwsaz = '01'.
IF sy-subrc = 0.
p_pabrp = t569v-pabrp.
p_pabrj = t569v-pabrj.
ENDIF.
SELECT SINGLE * FROM t549a WHERE abkrs = p_abkrs.
IF sy-subrc = 0.
v_permo = t549a-permo.
ELSE.
IF r2 = 'X'.
MESSAGE e000 WITH 'Enter a valid Payroll Period'.
ENDIF.
ENDIF.
SELECT SINGLE * FROM t549q WHERE permo = v_permo
AND pabrj = t569v-pabrj
AND pabrp = t569v-pabrp.
IF sy-subrc = 0.
p_begda = t549q-begda.
p_endda = t549q-endda.
ENDIF.
ENDFORM. " GET_DATA_FROM_CURRENT_PERIOD
*&---------------------------------------------------------------------*
*& Form GET_DATA_FROM_PERIOD
*----------------------------------------------------------------------*
FORM get_data_from_period .
SELECT SINGLE * FROM t549a WHERE abkrs = p_abkrs.
v_permo = t549a-permo.
SELECT SINGLE * FROM t549q WHERE permo = v_permo
AND pabrj = p_pabrj
AND pabrp = p_pabrp.
IF sy-subrc = 0.
p_begda = t549q-begda.
p_endda = t549q-endda.
ENDIF.
ENDFORM. " GET_DATA_FROM_PERIOD
*&---------------------------------------------------------------------*
*& Form FILL_CAT
*----------------------------------------------------------------------*
FORM fill_cat USING value(p_0151)
value(p_0152).
v_col = v_col + 1.
wa_fieldcat-col_pos = v_col.
wa_fieldcat-fieldname = p_0151.
wa_fieldcat-tabname = 'IT_FINAL'.
wa_fieldcat-reptext_ddic = p_0152.
IF wa_fieldcat-fieldname = 'AMOUNT1' OR
wa_fieldcat-fieldname = 'AMOUNT2' OR
wa_fieldcat-fieldname = 'AMOUNT3' OR
wa_fieldcat-fieldname = 'AMOUNT4' OR
wa_fieldcat-fieldname = 'AMOUNT5' OR
wa_fieldcat-fieldname = 'AMOUNT6' OR
wa_fieldcat-fieldname = 'AMOUNT7' OR
wa_fieldcat-fieldname = 'AMOUNT8' OR
wa_fieldcat-fieldname = 'AMOUNT9' .
wa_fieldcat-do_sum = 'X'.
ENDIF.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
ENDFORM. " FILL_CAT
*&---------------------------------------------------------------------*
*& Form GET_RT_DATA
*----------------------------------------------------------------------*
FORM get_rt_data .
DATA: l_pernr LIKE pa0001-pernr.
CALL FUNCTION 'CU_READ_RGDIR'
EXPORTING
persnr = it_final-pernr
IMPORTING
molga = w_molga
TABLES
in_rgdir = it_rgdir
EXCEPTIONS
no_record_found = 1
OTHERS = 2.
IF r1 = 'X'.
IF NOT w_molga IS INITIAL.
CALL FUNCTION 'CD_READ_LAST'
EXPORTING
begin_date = p_begda
end_date = p_endda
IMPORTING
out_seqnr = w_seqnr
TABLES
rgdir = it_rgdir
EXCEPTIONS
no_record_found = 1
OTHERS = 2.
ENDIF.
SORT it_rgdir BY fpend DESCENDING.
READ TABLE it_rgdir INTO wa_itrgdir WITH KEY fpbeg = p_begda
fpend = p_endda.
IF sy-subrc = 0.
w_seqnr = wa_itrgdir-seqnr.
ENDIF.
SELECT SINGLE
relid
FROM t500l
INTO w_relid
WHERE molga = w_molga.
l_pernr = it_final-pernr .
CALL FUNCTION 'PYXX_READ_PAYROLL_RESULT'
EXPORTING
clusterid = w_relid
employeenumber = l_pernr
sequencenumber = w_seqnr
read_only_international = 'X'
CHANGING
payroll_result = it_result
EXCEPTIONS
illegal_isocode_or_clusterid = 1
error_generating_import = 2
import_mismatch_error = 3
subpool_dir_full = 4
no_read_authority = 5
no_record_found = 6
versions_do_not_match = 7
error_reading_archive = 8
error_reading_relid = 9
OTHERS = 10.
ELSEIF r2 = 'X'.
IF NOT w_molga IS INITIAL.
CALL FUNCTION 'CD_READ_LAST'
EXPORTING
begin_date = p_begda
end_date = p_endda
IMPORTING
out_seqnr = w_seqnr
TABLES
rgdir = it_rgdir
EXCEPTIONS
no_record_found = 1
OTHERS = 2.
ENDIF.
SORT it_rgdir BY fpend DESCENDING.
* For Offcycle Payyroll
READ TABLE it_rgdir INTO wa_itrgdir WITH KEY fpbeg = p_begda
fpend = p_endda.
IF sy-subrc = 0.
w_seqnr = wa_itrgdir-seqnr.
ENDIF.
SELECT SINGLE relid FROM t500l INTO w_relid WHERE molga = w_molga.
l_pernr = it_final-pernr .
CALL FUNCTION 'PYXX_READ_PAYROLL_RESULT'
EXPORTING
clusterid = w_relid
employeenumber = l_pernr
sequencenumber = w_seqnr
read_only_international = 'X'
CHANGING
payroll_result = it_result
EXCEPTIONS
illegal_isocode_or_clusterid = 1
error_generating_import = 2
import_mismatch_error = 3
subpool_dir_full = 4
no_read_authority = 5
no_record_found = 6
versions_do_not_match = 7
error_reading_archive = 8
error_reading_relid = 9
OTHERS = 10.
ENDIF.
IF p_begda LE v_date.
LOOP AT it_result-inter-rt INTO wa_rt.
wagetype = wa_rt-lgart.
CASE wagetype.
WHEN '1LRP'.
it_final-amount2 = wa_rt-betrg.
WHEN '/LRP'.
it_final-amount3 = wa_rt-betrg.
WHEN '2LRP'.
it_final-amount5 = wa_rt-betrg.
WHEN '/LLB'.
it_final-amount6 = wa_rt-betrg.
WHEN '3LRP'.
it_final-amount8 = wa_rt-betrg.
WHEN '930B'.
it_final-amount9 = wa_rt-betrg.
ENDCASE.
ENDLOOP.
ELSE.
LOOP AT it_result-inter-rt INTO wa_rt.
wagetype = wa_rt-lgart.
CASE wagetype.
WHEN '9100'.
it_final-amount2 = wa_rt-betrg.
WHEN '910B'.
it_final-amount3 = wa_rt-betrg.
WHEN '9200'.
it_final-amount5 = wa_rt-betrg.
WHEN '920B'.
it_final-amount6 = wa_rt-betrg.
WHEN '9300'.
it_final-amount8 = wa_rt-betrg.
WHEN '930B'.
it_final-amount9 = wa_rt-betrg.
ENDCASE.
ENDLOOP.
ENDIF.
ENDFORM. " GET_RT_DATA
*&---------------------------------------------------------------------*
*& 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
*&---------------------------------------------------------------------*
*& 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 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 = 'Loans Detail 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.
clear it_list.
it_list-typ = 'S'.
it_list-key = space.
concatenate 'Payroll Area:' p_abkrs into it_list-info separated by space.
append it_list to it_list.
it_list-typ = 'S'.
it_list-key = space.
concatenate 'Payroll Period:' p_begda+4(2) '.' p_begda+6(2) '.' p_begda+0(4) ' ' '-' ' '
p_endda+4(2) '.' p_endda+6(2) '.' p_endda+0(4) into it_list-info.
append it_list to it_list.
endform. " write_header
ALSO READ:
- Gosi Calculation Report In HR ABAP.
- Employee Pay Details Report In HR ABAP.
- Employee Existence Check Report.
- Send Employee Payslip As An E-Mail Attachment.
- Time Quota For An Employee In HR ABAP.
.....Back To Sub-Index On HR ABAP.
.....Back To MAIN INDEX.
No comments:
Post a Comment