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

HR ABAP - BDC For Uploading Absence Data Into PA30 Transaction.

REPORT zhr_absence_rec
NO STANDARD PAGE HEADING LINE-SIZE 255.

INCLUDE bdcrecx1.

TYPES : BEGIN OF ty_upload,
pernr TYPE char10, " Person No.
begda TYPE char10, " Begin Date
endda TYPE char10, " End Date
subty TYPE char04, " Sub-Type
beguz TYPE char6, " Start Time
enduz TYPE char6, " End Time
stdaz TYPE char10, " No. of Hr
END OF ty_upload,

tt_upload TYPE STANDARD TABLE OF ty_upload.

DATA : t_upload TYPE STANDARD TABLE OF ty_upload INITIAL SIZE 0,
* T_ERROR TYPE STANDARD TABLE OF TY_UPLOAD INITIAL SIZE 0,

t_bdcdata TYPE STANDARD TABLE OF bdcdata INITIAL SIZE 0,

*Workarea Declerations
*Upload Data
w_upload TYPE ty_upload,

*BDC data
w_bdcdata TYPE bdcdata.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS : p_flname TYPE ibipparms-path.
SELECTION-SCREEN END OF BLOCK b1.

INITIALIZATION.

*Clear Workareas
CLEAR : w_upload,
w_bdcdata.

REFRESH : t_upload,
t_bdcdata.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_flname.

* F4 help for the file path
PERFORM sub_get_f4help.

START-OF-SELECTION.

*Upload the data
PERFORM sub_upload_data.

*Populating the data
PERFORM sub_fill_bdcdata.

*&---------------------------------------------------------------------*
*& Form SUB_GET_F4HELP
*----------------------------------------------------------------------*
FORM sub_get_f4help .
CLEAR p_flname.

CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = sy-repid
dynpro_number = '1000'
field_name = ' '
IMPORTING
file_name = p_flname.

ENDFORM. " SUB_GET_F4HELP
*&---------------------------------------------------------------------*
*& Form SUB_UPLOAD_DATA
*----------------------------------------------------------------------*
FORM sub_upload_data .
DATA : l_flname TYPE string.
l_flname = p_flname.

CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = l_flname
filetype = 'ASC'
has_field_separator = 'X'
TABLES
data_tab = t_upload .

ENDFORM. " SUB_UPLOAD_DATA
*&---------------------------------------------------------------------*
*& Form SUB_FILL_BDCDATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text *----------------------------------------------------------------------*
FORM sub_fill_bdcdata .

CLEAR w_upload.
PERFORM open_group.
LOOP AT t_upload INTO w_upload.
REFRESH : t_bdcdata.

PERFORM bdc_dynpro USING 'SAPMP50A' '1000'.

PERFORM bdc_field USING 'BDC_OKCODE' '=INS'.
PERFORM bdc_field USING 'RP50G-PERNR' w_upload-pernr.

PERFORM bdc_field USING 'RP50G-TIMR6' 'X'.
PERFORM bdc_field USING 'RP50G-BEGDA' w_upload-begda.

PERFORM bdc_field USING 'RP50G-ENDDA' w_upload-endda.
PERFORM bdc_field USING 'BDC_CURSOR' 'RP50G-SUBTY'.

PERFORM bdc_field USING 'RP50G-CHOIC' '2001'.
PERFORM bdc_field USING 'RP50G-SUBTY' w_upload-subty.

PERFORM bdc_dynpro USING 'MP200000' '2000'.
PERFORM bdc_field USING 'BDC_CURSOR' 'P2001-BEGDA'.

PERFORM bdc_field USING 'BDC_OKCODE' '/00'.
PERFORM bdc_field USING 'P2001-BEGDA' w_upload-begda.

PERFORM bdc_field USING 'P2001-ENDDA' w_upload-endda.
PERFORM bdc_field USING 'P2001-BEGUZ' w_upload-beguz.

PERFORM bdc_field USING 'P2001-ENDUZ' w_upload-enduz.
PERFORM bdc_dynpro USING 'MP200000' '2000'.

PERFORM bdc_field USING 'BDC_CURSOR' 'P2001-BEGDA'.
PERFORM bdc_field USING 'BDC_OKCODE' '=UPD'.

PERFORM bdc_field USING 'P2001-BEGDA' w_upload-begda.
PERFORM bdc_field USING 'P2001-ENDDA' w_upload-endda.

PERFORM bdc_field USING 'P2001-STDAZ' w_upload-stdaz.
PERFORM bdc_transaction USING 'PA30'. CLEAR w_upload.

ENDLOOP.

PERFORM close_group.
ENDFORM. " SUB_FILL_BDCDATA



ALSO READ:



Bank Report For Employees In HR ABAP.

REPORT ZHR_BANK MESSAGE-ID zmsg.
*----------------------------------------------------------------*
* TABLES *
*----------------------------------------------------------------*
TABLES: bnka,
pa0001,
pa0009,
t569v,
t549a,
t549q.

*-----------------------------------------------------------------*
* T Y P E P O O L S *
*-----------------------------------------------------------------*
TYPE-POOLS : slis.
************************************************************************
* DECLARATION OF INTERNAL TABLES *
************************************************************************

types: begin of ty_pa0000,
pernr type pa0000-pernr,
end of ty_pa0000.

* Internal Table for string the Bank Data
TYPES : BEGIN OF ty_pa0009,
pernr LIKE pa0009-pernr,
waers LIKE pa0009-waers,
zlsch LIKE pa0009-zlsch,
banks LIKE pa0009-banks,
bankl LIKE pa0009-bankl,
bankn LIKE pa0009-bankn,
ZWECK LIKE pa0009-ZWECK,
iban LIKE pa0009-iban,
END OF ty_pa0009.

TYPES: BEGIN OF ty_bnka,
bankl TYPE bnka-bankl,
banka TYPE bnka-banka,
END OF ty_bnka.

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_pa0002,
pernr TYPE pa0002-pernr,
nachn TYPE pa0002-nachn,
vorna TYPE pa0002-vorna,
END OF ty_pa0002.

types: begin of ty_pa0185,
pernr type pa0185-pernr,
begda type pa0185-begda,
endda type pa0185-endda,
ICTYP type pa0185-ICTYP,
ICNUM type pa0185-ICNUM,
end of ty_pa0185.

*Internal table for storing field names for displaing in list

TYPES : BEGIN OF ty_final,
sno(5) TYPE c ,
pernr(8) TYPE c, "Personnel Number
ename(40) TYPE c, "Emp Name
amount TYPE pa0008-bet01,
bankn(18) TYPE c, "customer bank acc no.
bankl(15) TYPE c, "BANK KEY
banka(60) TYPE c, "BANK NAME
waers(5) TYPE c,
ZWECK(40) TYPE c,
iban(34) TYPE c,
icnum(30) type c,
curr(5) type c,
cell_colour type lvc_t_scol, "Cell colour
END OF ty_final.

* To colour a cell.
data ls_cellcolour type lvc_s_scol.

DATA: v_tabix TYPE i.
* Work area and Internal tables declaration
DATA: wa_pa0001 TYPE ty_pa0001,
wa_pa0002 TYPE ty_pa0002,
wa_pa0009 TYPE ty_pa0009,
wa_pa0185 TYPE ty_pa0185,
wa_bnka TYPE ty_bnka,
wa_final TYPE ty_final,
it_pa0001 TYPE TABLE OF ty_pa0001,
it_pa0000 TYPE TABLE OF ty_pa0000,
it_pa0185 TYPE TABLE OF ty_pa0185,
it_pa0002 TYPE TABLE OF ty_pa0002,
it_pa0009 TYPE TABLE OF ty_pa0009,
it_bnka TYPE TABLE OF ty_bnka,
it_final TYPE TABLE OF ty_final.

* for getting wagetype amount
DATA : it_rgdir TYPE STANDARD TABLE OF pc261,
wa_itrgdir TYPE pc261,
it_result TYPE pay99_result,
wa_rt TYPE pc207.

DATA: w_molga TYPE t500l-molga,
w_seqnr TYPE cdseq,
w_relid TYPE relid_pcl2,
wagetype TYPE char15.

*For ALV fieldcatlog
DATA : it_fieldcat TYPE slis_t_fieldcat_alv,
*For ALV fieldcatlog
wa_fieldcat TYPE slis_fieldcat_alv,
*For ALV output layout
it_layout TYPE slis_layout_alv,
wa_layout TYPE slis_layout_alv,
it_events TYPE slis_t_event,
wa_events TYPE slis_alv_event,
i_sort TYPE slis_t_sortinfo_alv,
wa_sort TYPE slis_sortinfo_alv,
it_list TYPE slis_t_listheader WITH HEADER LINE.

DATA : v_permo TYPE t549a-permo.

DATA : cs_prnt TYPE slis_print_alv.


DATA: v_pernr TYPE pa0001-pernr,
v_werks TYPE pa0001-werks,
v_btrtl TYPE pa0001-btrtl,
v_persg TYPE pa0001-persg,
v_persk TYPE pa0001-persk,
v_abkrs TYPE pa0001-abkrs.

*************************************************************************
** 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 b2 WITH FRAME TITLE text-002.
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 b2 .

SELECTION-SCREEN END OF BLOCK b1 .

************************************************************************
* AT SELECTION SCREEN *
************************************************************************

IF NOT s_pernr[] IS INITIAL.
SELECT pernr
FROM pa0001
INTO v_pernr
WHERE pernr IN s_pernr.
IF sy-subrc NE 0.
MESSAGE e000 WITH 'Enter a valid Personnel Number'.
ENDIF.
ENDSELECT.
ENDIF.

IF NOT s_werks[] IS INITIAL.
SELECT werks
FROM pa0001
INTO v_werks
WHERE pernr IN s_werks.
IF sy-subrc NE 0.
MESSAGE e000 WITH 'Enter a valid Personnel Area'.
ENDIF.
ENDSELECT.
ENDIF.

IF NOT s_btrtl[] IS INITIAL.
SELECT btrtl
FROM pa0001
INTO v_btrtl
WHERE pernr IN s_btrtl.
IF sy-subrc NE 0.
MESSAGE e000 WITH 'Enter a valid Personnel Subarea'.
ENDIF.
ENDSELECT.
ENDIF.

IF NOT s_persg[] IS INITIAL.
SELECT persg
FROM pa0001
INTO v_persg
WHERE pernr IN s_persg.
IF sy-subrc NE 0.
MESSAGE e000 WITH 'Enter a valid Employee Group'.
ENDIF.
ENDSELECT.
ENDIF.

IF NOT s_persk[] IS INITIAL.
SELECT persk
FROM pa0001
INTO v_persk
WHERE pernr IN s_persk.
IF sy-subrc NE 0.
MESSAGE e000 WITH 'Enter a valid Employee Subgroup'.
ENDIF.
ENDSELECT.
ENDIF.

IF NOT p_abkrs IS INITIAL.
SELECT abkrs
FROM pa0001
INTO v_abkrs
WHERE pernr = p_abkrs.
IF sy-subrc NE 0.
MESSAGE e000 WITH 'Enter a valid Payroll Area'.
ENDIF.
ENDSELECT.
ENDIF.

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 *
************************************************************************
START-OF-SELECTION.


perform get_pa0000.

PERFORM get_pa0001.

END-OF-SELECTION.

*To build ALV fieldcatlog
PERFORM build_fieldcatlog.

*For ALV Layout
PERFORM alv_layout.

PERFORM get_events.

PERFORM top_of_page.
*To diaplay output in ALV grid format
PERFORM display_alv.
*&---------------------------------------------------------------------*
*& Form BUILD_FIELDCATLOG
*----------------------------------------------------------------------*
FORM build_fieldcatlog .


wa_fieldcat-fieldname = 'SNO'.
wa_fieldcat-reptext_ddic = 'Serial Number'.
wa_fieldcat-just = 'C'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'ZWECK'.
wa_fieldcat-reptext_ddic = 'Bank Name'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'IBAN'.
wa_fieldcat-reptext_ddic = 'IBAN Number'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'ENAME'.
wa_fieldcat-reptext_ddic = 'Employee Name'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'PERNR'.
wa_fieldcat-reptext_ddic = 'Personnel Number'.
wa_fieldcat-just = 'C'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'ICNUM'.
wa_fieldcat-reptext_ddic = 'Iquma Number'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'AMOUNT'.
wa_fieldcat-reptext_ddic = 'Amount'.
wa_fieldcat-do_sum = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'CURR'.
wa_fieldcat-reptext_ddic = 'Currency'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

ENDFORM. " BUILD_FIELDCATLOG

*&---------------------------------------------------------------------*
*& Form ALV_LAYOUT
*----------------------------------------------------------------------*
FORM alv_layout .

it_layout-colwidth_optimize = 'X'.
it_layout-totals_text = 'Totals'(201).
it_layout-zebra = 'X'.
it_layout-coltab_fieldname = 'CELL_COLOUR'.

ENDFORM. " ALV_LAYOUT
*&---------------------------------------------------------------------*
*& Form DISPLAY_ALV
*----------------------------------------------------------------------*
FORM display_alv .

cs_prnt-no_print_listinfos = 'X'. "gs_test-prnt_no_listinfo.


CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
is_layout = it_layout
it_fieldcat = it_fieldcat
it_events = it_events
is_print = cs_prnt
TABLES
t_outtab = it_final
EXCEPTIONS
program_error = 1
OTHERS = 2.


ENDFORM. " DISPLAY_ALV
*&---------------------------------------------------------------------*
*& Form GET_PA0001
*----------------------------------------------------------------------*
FORM get_pa0001 .

SELECT pernr
werks
persg
persk
btrtl
abkrs
FROM pa0001
INTO TABLE it_pa0001
for all entries in it_pa0000
WHERE pernr = it_pa0000-pernr
and begda le p_endda
and endda ge p_begda
AND werks IN s_werks
AND persg IN s_persg
AND persk IN s_persk
AND btrtl IN s_btrtl
AND abkrs = p_abkrs.

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

SELECT pernr
vorna
nachn
FROM pa0002
INTO TABLE it_pa0002
FOR ALL ENTRIES IN it_pa0001
WHERE pernr = it_pa0001-pernr
and begda le p_endda
and endda ge p_begda.

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

SELECT pernr
waers
zlsch
banks
bankl
bankn
ZWECK
iban
FROM pa0009
INTO TABLE it_pa0009
FOR ALL ENTRIES IN it_pa0001
WHERE pernr = it_pa0001-pernr
and begda le p_endda
and endda ge p_begda
AND zlsch eq 'E'.

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

SELECT bankl
banka
FROM bnka
INTO TABLE it_bnka
FOR ALL ENTRIES IN it_pa0009
WHERE bankl = it_pa0009-bankl.

IF sy-subrc = 0.
SORT it_bnka BY bankl.
ENDIF.

select pernr
begda
endda
ictyp
icnum
from pa0185
into table it_pa0185
for all entries in it_pa0001
where pernr = it_pa0001-pernr
and ictyp = '08'
and begda le p_endda
and endda ge p_begda.


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

ENDIF.


LOOP AT it_pa0009 INTO wa_pa0009.
wa_final-pernr = wa_pa0009-pernr.

READ TABLE it_pa0002 INTO wa_pa0002 WITH KEY pernr = wa_pa0009-pernr.
IF sy-subrc = 0.
CONCATENATE wa_pa0002-nachn
wa_pa0002-vorna
INTO wa_final-ename.
ENDIF.

wa_final-bankn = wa_pa0009-bankn.
wa_final-waers = wa_pa0009-waers.
wa_final-ZWECK = wa_pa0009-ZWECK.
wa_final-iban = wa_pa0009-iban.

READ TABLE it_bnka INTO wa_bnka WITH KEY bankl = wa_pa0009-bankl.
IF sy-subrc = 0.
wa_final-banka = wa_bnka-banka.
wa_final-bankl = wa_bnka-bankl.
ENDIF.

READ TABLE it_pa0185 INTO wa_pa0185 WITH KEY pernr = wa_pa0009-pernr.
IF sy-subrc = 0.
wa_final-icnum = wa_pa0185-icnum.
ENDIF.

wa_final-curr = 'SAR'.
PERFORM get_amount.


ENDLOOP.

data: v_iban type pa0009-iban.

sort it_final by iban.
*----populate colors for the field
loop at it_final into wa_final.

if sy-tabix = '1'.
v_iban = wa_final-iban.
else.

check v_iban = wa_final-iban.
ls_cellcolour-fname = 'IBAN'.
ls_cellcolour-color-col = '5'.
ls_cellcolour-color-int = '1'.
ls_cellcolour-color-inv = '0'.
ls_cellcolour-nokeycol = 'X'.
append ls_cellcolour to wa_final-cell_colour.
modify it_final from wa_final.
clear : wa_final.

endif.
endloop.

sort it_final by pernr.

ENDFORM. " GET_PA0001
*&---------------------------------------------------------------------*
*& Form GET_AMOUNT
* this is to fil the amount for the employee
*----------------------------------------------------------------------*
FORM get_amount .

DATA: l_pernr LIKE pa0001-pernr.


CALL FUNCTION 'CU_READ_RGDIR'
EXPORTING
persnr = wa_pa0009-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 fpend = p_endda.
CHECK sy-subrc = 0 and wa_itrgdir-ocrsn is initial.
w_seqnr = wa_itrgdir-seqnr.

SELECT SINGLE
relid
FROM t500l
INTO w_relid
WHERE molga = w_molga.

l_pernr = wa_final-pernr .


CALL FUNCTION 'PYXX_READ_PAYROLL_RESULT'
EXPORTING
clusterid = w_relid
employeenumber = l_pernr " wa_final-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.

READ TABLE it_rgdir INTO wa_itrgdir WITH KEY fpend = p_endda.
CHECK sy-subrc = 0 and wa_itrgdir-ocrsn is initial.
w_seqnr = wa_itrgdir-seqnr.

SELECT SINGLE relid FROM t500l INTO w_relid WHERE molga = w_molga.

l_pernr = wa_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.


LOOP AT it_result-inter-rt INTO wa_rt.
wagetype = wa_rt-lgart.
CLEAR: wa_rt-lgart.
CASE wagetype.
WHEN '/559'.
wa_final-amount = wa_rt-betrg.
ENDCASE.
ENDLOOP.
check wa_final-amount is not initial.

v_tabix = v_tabix + 1.
wa_final-sno = v_tabix.

APPEND wa_final TO it_final.
CLEAR wa_final.

ENDFORM. " GET_AMOUNT
*&---------------------------------------------------------------------*
*& 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 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.
it_list-typ = 'H'.
it_list-key = space.
it_list-info = 'Salary Payments'.
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
*&---------------------------------------------------------------------*
*& Form GET_PA0000
*----------------------------------------------------------------------*
form GET_PA0000 .


select pernr
from pa0000
into table it_pa0000
where pernr in s_pernr
and stat2 = '3'.

endform. " GET_PA0000


ALSO READ:

- BDC For Uploading Absence Data Into PA30 Transaction.

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

- Upload Job & Position Relations Through PO03.

- BDC To Upload The OM Relations Through T-code PO13.

- Function Modules To Read Benefits Data In HR ABAP.

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

.....Back To MAIN INDEX.


Cash Payment Report In HR ABAP

REPORT zhr_cash_payment_report MESSAGE-ID zmsg.

*----------------------------------------------------------------*
* TABLES *
*----------------------------------------------------------------*
TABLES: bnka,
pa0001,
pa0009,
t569v,
t549a,
t549q.

*-----------------------------------------------------------------*
* T Y P E P O O L S *
*-----------------------------------------------------------------*
TYPE-POOLS : slis.
************************************************************************
* DECLARATION OF INTERNAL TABLES *
************************************************************************

* Internal Table for string the Bank Data
TYPES : BEGIN OF ty_pa0009,
pernr LIKE pa0009-pernr,
waers LIKE pa0009-waers,
zlsch LIKE pa0009-zlsch,
banks LIKE pa0009-banks,
bankl LIKE pa0009-bankl,
bankn LIKE pa0009-bankn,
zweck like pa0009-zweck,
iban like pa0009-iban,
END OF ty_pa0009.

TYPES: BEGIN OF ty_bnka,
bankl TYPE bnka-bankl,
banka TYPE bnka-banka,
END OF ty_bnka.

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_pa0002,
pernr TYPE pa0002-pernr,
nachn TYPE pa0002-nachn,
vorna TYPE pa0002-vorna,
END OF ty_pa0002.

*Internal table for storing field names for displaing in list
TYPES : BEGIN OF ty_final,
sno(5) TYPE c ,
pernr(8) TYPE c, "Personnel Number
ename(40) TYPE c, "Emp Name
amount TYPE pa0008-bet01,
bankn(18) TYPE c, "customer bank acc no.
bankl(15) TYPE c, "BANK KEY
zweck(60) TYPE c, "BANK NAME
waers(5) TYPE c,
iban(34) TYPE c,
* sign(100) type c,
icnum(30) TYPE c,
END OF ty_final.
TYPES: BEGIN OF ty_pa0185,
pernr TYPE pa0185-pernr,
begda TYPE pa0185-begda,
endda TYPE pa0185-endda,
ictyp TYPE pa0185-ictyp,
icnum TYPE pa0185-icnum,
END OF ty_pa0185.

DATA: v_tabix TYPE i.
* Work area and Internal tables declaration
DATA: wa_pa0001 TYPE ty_pa0001,
wa_pa0002 TYPE ty_pa0002,
wa_pa0009 TYPE ty_pa0009,
wa_bnka TYPE ty_bnka,
wa_final TYPE ty_final,
it_pa0001 TYPE TABLE OF ty_pa0001,
it_pa0002 TYPE TABLE OF ty_pa0002,
it_pa0009 TYPE TABLE OF ty_pa0009,
it_pa0185 TYPE TABLE OF ty_pa0185,
wa_pa0185 TYPE ty_pa0185,
it_bnka TYPE TABLE OF ty_bnka,
it_final TYPE TABLE OF ty_final.

* for getting wagetype amount
DATA : it_rgdir TYPE STANDARD TABLE OF pc261,
wa_itrgdir TYPE pc261,
it_result TYPE pay99_result,
wa_rt TYPE pc207.

DATA: w_molga TYPE t500l-molga,
w_seqnr TYPE cdseq,
w_relid TYPE relid_pcl2,
wagetype TYPE char15.

*For ALV fieldcatlog
DATA : it_fieldcat TYPE slis_t_fieldcat_alv,
*For ALV fieldcatlog
wa_fieldcat TYPE slis_fieldcat_alv,
*For ALV output layout
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.

DATA : v_permo TYPE t549a-permo.

DATA: v_pernr TYPE pa0001-pernr,
v_werks TYPE pa0001-werks,
v_btrtl TYPE pa0001-btrtl,
v_persg TYPE pa0001-persg,
v_persk TYPE pa0001-persk,
v_abkrs TYPE pa0001-abkrs.

*************************************************************************
** 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 b2 WITH FRAME TITLE text-002.
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 b2 .

SELECTION-SCREEN END OF BLOCK b1 .

************************************************************************
* AT SELECTION SCREEN *
************************************************************************

IF NOT s_pernr[] IS INITIAL.
SELECT pernr
FROM pa0001
INTO v_pernr
WHERE pernr IN s_pernr.
IF sy-subrc NE 0.
MESSAGE e000 WITH 'Enter a valid Personnel Number'.
ENDIF.
ENDSELECT.
ENDIF.

IF NOT s_werks[] IS INITIAL.
SELECT werks
FROM pa0001
INTO v_werks
WHERE pernr IN s_werks.
IF sy-subrc NE 0.
MESSAGE e000 WITH 'Enter a valid Personnel Area'.
ENDIF.
ENDSELECT.
ENDIF.

IF NOT s_btrtl[] IS INITIAL.
SELECT btrtl
FROM pa0001
INTO v_btrtl
WHERE pernr IN s_btrtl.
IF sy-subrc NE 0.
MESSAGE e000 WITH 'Enter a valid Personnel Subarea'.
ENDIF.
ENDSELECT.
ENDIF.

IF NOT s_persg[] IS INITIAL.
SELECT persg
FROM pa0001
INTO v_persg
WHERE pernr IN s_persg.
IF sy-subrc NE 0.
MESSAGE e000 WITH 'Enter a valid Employee Group'.
ENDIF.
ENDSELECT.
ENDIF.

IF NOT s_persk[] IS INITIAL.
SELECT persk
FROM pa0001
INTO v_persk
WHERE pernr IN s_persk.
IF sy-subrc NE 0.
MESSAGE e000 WITH 'Enter a valid Employee Subgroup'.
ENDIF.
ENDSELECT.
ENDIF.

IF NOT p_abkrs IS INITIAL.
SELECT abkrs
FROM pa0001
INTO v_abkrs
WHERE pernr = p_abkrs.
IF sy-subrc NE 0.
MESSAGE e000 WITH 'Enter a valid Payroll Area'.
ENDIF.
ENDSELECT.
ENDIF.

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 *
************************************************************************
START-OF-SELECTION.

PERFORM get_pa0001.

END-OF-SELECTION.

*To build ALV fieldcatlog
PERFORM build_fieldcatlog.

*For ALV Layout
PERFORM alv_layout.

PERFORM get_events.

PERFORM top_of_page.
*To diaplay output in ALV grid format
PERFORM display_alv.
*&---------------------------------------------------------------------*
*& Form BUILD_FIELDCATLOG
*----------------------------------------------------------------------*
FORM build_fieldcatlog .

wa_fieldcat-fieldname = 'SNO'.
wa_fieldcat-reptext_ddic = 'Serial Number'.
wa_fieldcat-just = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'ZWECK'.
wa_fieldcat-reptext_ddic = 'Bank Name'.
wa_fieldcat-just = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'IBAN'.
wa_fieldcat-reptext_ddic = 'IBAN Number'.
wa_fieldcat-just = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'ENAME'.
wa_fieldcat-reptext_ddic = 'Employee Name'.
wa_fieldcat-just = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'PERNR'.
wa_fieldcat-reptext_ddic = 'Personnel Number'.
wa_fieldcat-just = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'ICNUM'.
wa_fieldcat-reptext_ddic = 'Iquama Numbe'.
wa_fieldcat-just = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'AMOUNT'.
wa_fieldcat-reptext_ddic = 'Amount'.
wa_fieldcat-just = 'X'.
wa_fieldcat-do_sum = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'WAERS'.
wa_fieldcat-reptext_ddic = 'Currency'.
wa_fieldcat-just = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

ENDFORM. " BUILD_FIELDCATLOG
*&---------------------------------------------------------------------*
*& Form ALV_LAYOUT
*----------------------------------------------------------------------*
FORM alv_layout .

it_layout-totals_text = 'Totals'(201).
it_layout-zebra = 'X'.

ENDFORM. " ALV_LAYOUT
*&---------------------------------------------------------------------*
*& Form DISPLAY_ALV
*----------------------------------------------------------------------*
FORM display_alv .

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
is_layout = it_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_PA0001
*----------------------------------------------------------------------*
FORM get_pa0001 .

SELECT pernr
werks
persg
persk
btrtl
abkrs
FROM pa0001
INTO TABLE it_pa0001
WHERE pernr IN s_pernr
AND begda LE p_endda
AND endda GE p_begda
AND werks IN s_werks
AND persg IN s_persg
AND persk IN s_persk
AND btrtl IN s_btrtl
AND abkrs = p_abkrs.

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

SELECT pernr
vorna
nachn
FROM pa0002
INTO TABLE it_pa0002
FOR ALL ENTRIES IN it_pa0001
WHERE pernr = it_pa0001-pernr
AND begda LE p_endda
AND endda GE p_begda.

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

SELECT pernr
waers
zlsch
banks
bankl
bankn
zweck
iban
FROM pa0009
INTO TABLE it_pa0009
FOR ALL ENTRIES IN it_pa0001
WHERE pernr = it_pa0001-pernr
AND zlsch = ' '
AND begda LE p_endda
AND endda GE p_begda.

IF sy-subrc = 0.

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

SELECT bankl
banka
FROM bnka
INTO TABLE it_bnka
FOR ALL ENTRIES IN it_pa0009
WHERE bankl = it_pa0009-bankl.

IF sy-subrc = 0.
SORT it_bnka BY bankl.
ENDIF.


SELECT pernr
begda
endda
ictyp
icnum
FROM pa0185
INTO TABLE it_pa0185
FOR ALL ENTRIES IN it_pa0001
WHERE pernr = it_pa0001-pernr
AND ictyp = '08'
AND begda LE p_endda
AND endda GE p_begda.


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


ENDIF.
ENDIF.


LOOP AT it_pa0009 INTO wa_pa0009.

wa_final-pernr = wa_pa0009-pernr.
READ TABLE it_pa0002 INTO wa_pa0002 WITH KEY pernr = wa_pa0009-pernr.
IF sy-subrc = 0.
CONCATENATE wa_pa0002-vorna
wa_pa0002-nachn
INTO wa_final-ename.
ENDIF.

wa_final-bankn = wa_pa0009-bankn.
wa_final-waers = wa_pa0009-waers.
wa_final-zweck = wa_pa0009-zweck.
wa_final-iban = wa_pa0009-iban.

IF wa_final-zweck IS INITIAL.
wa_final-zweck = 'Not Available'.
ENDIF.
IF wa_final-iban IS INITIAL.
wa_final-iban = 'Not Available'.
ENDIF.

READ TABLE it_bnka INTO wa_bnka WITH KEY bankl = wa_pa0009-bankl.
IF sy-subrc = 0.
wa_final-bankl = wa_bnka-bankl.
* wa_final-banka = wa_bnka-banka.

ENDIF.

READ TABLE it_pa0185 INTO wa_pa0185 WITH KEY pernr = wa_pa0009-pernr.
IF sy-subrc = 0.
wa_final-icnum = wa_pa0185-icnum.
ELSE.
wa_final-icnum = 'Not Available'.
ENDIF.

PERFORM get_amount.

ENDLOOP.

ENDFORM. " GET_PA0001
*&---------------------------------------------------------------------*
*& Form GET_AMOUNT
*----------------------------------------------------------------------*
FORM get_amount .

DATA: l_pernr LIKE pa0001-pernr.

CALL FUNCTION 'CU_READ_RGDIR'
EXPORTING
persnr = wa_pa0009-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 fpend = p_endda.
CHECK sy-subrc = 0 AND wa_itrgdir-ocrsn IS INITIAL.
w_seqnr = wa_itrgdir-seqnr .


SELECT SINGLE
relid
FROM t500l
INTO w_relid
WHERE molga = w_molga.

l_pernr = wa_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 fpend = p_endda.
CHECK sy-subrc = 0 AND wa_itrgdir-ocrsn IS INITIAL.
w_seqnr = wa_itrgdir-seqnr.

SELECT SINGLE relid FROM t500l INTO w_relid WHERE molga = w_molga.

l_pernr = wa_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.


LOOP AT it_result-inter-rt INTO wa_rt.
wagetype = wa_rt-lgart.
CLEAR: wa_rt-lgart.
CASE wagetype.
WHEN '/557'.
wa_final-amount = wa_rt-betrg.
ENDCASE.
ENDLOOP.

CHECK wa_final-amount IS NOT INITIAL.
v_tabix = v_tabix + 1.
wa_final-sno = v_tabix.

APPEND wa_final TO it_final.
CLEAR wa_final.

ENDFORM. " GET_AMOUNT
*&---------------------------------------------------------------------*
*& 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 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 = 'Cash Payments 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:

- 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.

- BDC To Upload The OM Relations Through T-code PO13.

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

.....Back To MAIN INDEX.


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.


Employee Deduction Report In HR ABAP

REPORT zhr_deduction_report MESSAGE-ID zmsg.

*----------------------------------------------------------------*
* TABLES *
*----------------------------------------------------------------*
TABLES:pa0001,
t569v,
t549a,
t549q.
*-----------------------------------------------------------------*
* T Y P E P O O L S *
*-----------------------------------------------------------------*
TYPE-POOLS : slis.

************************************************************************
* DECLARATION OF INTERNAL TABLES *
************************************************************************
DATA : v_permo TYPE t549a-permo.


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_pa0008.
INCLUDE STRUCTURE p0008.
TYPES: END OF ty_pa0008.

TYPES: BEGIN OF ty_pa2010,
pernr TYPE pa2010-pernr,
begda TYPE pa2010-begda,
endda TYPE pa2010-endda,
lgart TYPE pa2010-lgart,
anzhl TYPE pa2010-anzhl,
END OF ty_pa2010.

TYPES: BEGIN OF ty_pa2001.
INCLUDE STRUCTURE p2001.
TYPES: END OF ty_pa2001.

TYPES: BEGIN OF ty_pa2006.
INCLUDE STRUCTURE p2006.
TYPES: END OF ty_pa2006.

TYPES: BEGIN OF ty_pa0045.
INCLUDE STRUCTURE p0045.
TYPES: END OF ty_pa0045.

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

TYPES: BEGIN OF ty_pa0041.
INCLUDE STRUCTURE p0041.
TYPES: END OF ty_pa0041.

TYPES: BEGIN OF ty_pa0014.
INCLUDE STRUCTURE p0014.
TYPES: END OF ty_pa0014.

DATA: lfs_0008 LIKE p0008.

DATA: BEGIN OF dates,
dar LIKE p0041-dar01,
dat LIKE p0041-dat01,
END OF dates.

data: sno type i.

*Internal table for storing field names for displaing in list
TYPES : BEGIN OF ty_final,
sno type i,
pernr TYPE p0001-pernr, "Personnel Number
ename TYPE p0001-ename, "Emp Name
gosi_9 TYPE pa0008-bet01,
bank TYPE pa0008-bet01,
other TYPE pa0008-bet01,
advrec TYPE pa0008-bet01,
ghouse TYPE pa0008-bet01,
dfpp TYPE pa0008-bet01,
homeloan TYPE pa0008-bet01,
persloan TYPE pa0008-bet01,
saladv TYPE pa0008-bet01,
total1 TYPE pa0008-bet01,
END OF ty_final.

DATA: it_final TYPE TABLE OF ty_final WITH HEADER LINE.

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_pa0008 TYPE TABLE OF ty_pa0008 WITH HEADER LINE,
it_pa0008_01 TYPE TABLE OF ty_pa0008 WITH HEADER LINE,
it_pa0041 TYPE TABLE OF ty_pa0041 WITH HEADER LINE,
it_pa0014 TYPE TABLE OF ty_pa0014 WITH HEADER LINE,
it_pa0045 TYPE TABLE OF ty_pa0045 WITH HEADER LINE,
it_pa2001 TYPE TABLE OF ty_pa2001 WITH HEADER LINE,
it_pa2006 TYPE TABLE OF ty_pa2006 WITH HEADER LINE,
it_pa2010 TYPE TABLE OF ty_pa2010 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,
v_total TYPE pa0008-bet01,
v_pernr TYPE pa0001-pernr,
v_werks TYPE pa0001-werks,
v_btrtl TYPE pa0001-btrtl,
v_persg TYPE pa0001-persg,
v_persk TYPE pa0001-persk,
v_abkrs TYPE pa0001-abkrs.


*For ALV fieldcatlog
DATA : it_fieldcat TYPE slis_t_fieldcat_alv,
*For ALV fieldcatlog
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.
*************************************************************************
** 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 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 *
************************************************************************
START-OF-SELECTION.

PERFORM get_pa0000_data.

IF NOT it_pa0000[] IS INITIAL.

PERFORM get_pa0001_data.

PERFORM get_pa0002_data.

PERFORM get_pa0008_data.

ENDIF.

END-OF-SELECTION.


PERFORM process_data.

END-OF-SELECTION.

*To build ALV fieldcatlog
PERFORM build_fieldcatlog.

*For ALV Layout
PERFORM alv_layout.

PERFORM get_events.

PERFORM top_of_page.

*To diaplay output in ALV grid format
PERFORM display_alv.

*&---------------------------------------------------------------------*
*& 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 BUILD_FIELDCATLOG
*&---------------------------------------------------------------------*
FORM build_fieldcatlog .

wa_fieldcat-fieldname = 'PERNR'.
wa_fieldcat-reptext_ddic = 'Employee Number'.
wa_fieldcat-just = 'L'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'ENAME'.
wa_fieldcat-reptext_ddic = 'Employee Name'.
wa_fieldcat-just = 'L'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'BANK'.
wa_fieldcat-reptext_ddic = 'Bank Deductions'.
wa_fieldcat-do_sum = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'OTHER'.
wa_fieldcat-reptext_ddic = 'Other Deductions'.
wa_fieldcat-do_sum = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'ADVREC'.
wa_fieldcat-reptext_ddic = 'Advance Recovery'.
wa_fieldcat-do_sum = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'DFPP'.
wa_fieldcat-reptext_ddic = 'Difference from Previous Period'.
wa_fieldcat-do_sum = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'GHOUSE'.
wa_fieldcat-reptext_ddic = 'Guest House Deductions'.
wa_fieldcat-do_sum = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'GOSI_9'.
wa_fieldcat-reptext_ddic = 'GOSI 9% deductions'.
wa_fieldcat-do_sum = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'HOMELOAN'.
wa_fieldcat-reptext_ddic = 'Home Loan Repay'.
wa_fieldcat-do_sum = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'PERSLOAN'.
wa_fieldcat-reptext_ddic = 'Pers Loan Repay'.
wa_fieldcat-do_sum = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'SALADV'.
wa_fieldcat-reptext_ddic = 'Advance Recovery'.
wa_fieldcat-do_sum = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'TOTAL1'.
wa_fieldcat-reptext_ddic = 'Total Deductions'.
wa_fieldcat-do_sum = 'X'.
wa_fieldcat-emphasize = 'C710'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

ENDFORM. " BUILD_FIELDCATLOG
*&---------------------------------------------------------------------*
*& Form ALV_LAYOUT
*----------------------------------------------------------------------*
FORM alv_layout .

it_layout-colwidth_optimize = 'X'.
it_layout-totals_text = 'Totals'.
it_layout-subtotals_text = 'Totals'.
it_layout-zebra = 'X'.


ENDFORM. " ALV_LAYOUT
*&---------------------------------------------------------------------*
*& Form DISPLAY_ALV
*----------------------------------------------------------------------*
FORM display_alv .

DATA: is_print TYPE slis_print_alv.

is_print-no_print_listinfos = 'X'.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
is_layout = it_layout
it_fieldcat = it_fieldcat
it_events = it_events
is_print = is_print
TABLES
t_outtab = it_final
EXCEPTIONS
program_error = 1
OTHERS = 2.


ENDFORM. " DISPLAY_ALV
*&---------------------------------------------------------------------*
*& 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 = 'Employee Total Deductions 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 sy-uzeit INTO it_list-info SEPARATED BY space.
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
*&---------------------------------------------------------------------*
*& Form GET_PA0000_DATA
*----------------------------------------------------------------------*
FORM get_pa0000_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.
ENDIF.

ENDFORM. " GET_PA0000_DATA
*&---------------------------------------------------------------------*
*& Form GET_PA0001_DATA
*----------------------------------------------------------------------*
FORM get_pa0001_data .


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 *
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.

ENDIF.

ENDFORM. " GET_PA0001_DATA
*&---------------------------------------------------------̻-----------*
*& Form GET_PA0002_DATA
*----------------------------------------------------------------------*
FORM get_pa0002_data .

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.

ENDFORM. " GET_PA0002_DATA
*&---------------------------------------------------------------------*
*& Form GET_PA0008_DATA
*----------------------------------------------------------------------*
FORM get_pa0008_data .

SELECT *
FROM pa0008
INTO CORRESPONDING FIELDS OF TABLE it_pa0008
FOR ALL ENTRIES IN it_pa0000
WHERE pernr = it_pa0000-pernr
AND begda between p_begda and p_endda.


SELECT *
FROM pa0008
INTO CORRESPONDING FIELDS OF TABLE it_pa0008_01
FOR ALL ENTRIES IN it_pa0000
WHERE pernr = it_pa0000-pernr.

ENDFORM. " GET_PA0008_DATA
*&---------------------------------------------------------------------*
*& Form PROCESS_DATA
*----------------------------------------------------------------------*
FORM process_data .



LOOP AT it_pa0001.

it_final-pernr = it_pa0001-pernr.

READ TABLE it_pa0002 WITH KEY pernr = it_pa0001-pernr.
IF sy-subrc = 0.
CONCATENATE it_pa0002-vorna it_pa0002-nachn INTO it_final-ename.
ENDIF.

PERFORM get_rt_data.

sno = sno + 1.

it_final-sno = sno.

APPEND it_final .
CLEAR it_final .
ENDLOOP.


ENDFORM. " PROCESS_DATA
*&---------------------------------------------------------------------*
*& 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.


LOOP AT it_result-inter-rt INTO wa_rt.
wagetype = wa_rt-lgart.
CASE wagetype.

WHEN '2130'.
IF wa_rt-betrg LT 0.
wa_rt-betrg = wa_rt-betrg * ( -1 ).
ENDIF.
it_final-total1 = it_final-total1 + wa_rt-betrg.
it_final-bank = wa_rt-betrg .

WHEN '2030'.
IF wa_rt-betrg LT 0.
wa_rt-betrg = wa_rt-betrg * ( -1 ).
ENDIF.
it_final-total1 = it_final-total1 + wa_rt-betrg.
it_final-advrec = wa_rt-betrg .

WHEN '2080'.
IF wa_rt-betrg LT 0.
wa_rt-betrg = wa_rt-betrg * ( -1 ).
ENDIF.
it_final-total1 = it_final-total1 + wa_rt-betrg.
it_final-other = wa_rt-betrg .

WHEN '2090'.
IF wa_rt-betrg LT 0.
wa_rt-betrg = wa_rt-betrg * ( -1 ).
ENDIF.
it_final-total1 = it_final-total1 + wa_rt-betrg.
it_final-ghouse = wa_rt-betrg .

WHEN '2040'.
IF wa_rt-betrg LT 0.
wa_rt-betrg = wa_rt-betrg * ( -1 ).
ENDIF.
it_final-total1 = it_final-total1 + wa_rt-betrg.
it_final-other = wa_rt-betrg .

WHEN '2000'.
IF wa_rt-betrg LT 0.
wa_rt-betrg = wa_rt-betrg * ( -1 ).
ENDIF.
it_final-total1 = it_final-total1 + wa_rt-betrg.
it_final-gosi_9 = wa_rt-betrg .

WHEN '9100'.
IF wa_rt-betrg LT 0.
wa_rt-betrg = wa_rt-betrg * ( -1 ).
ENDIF.
it_final-total1 = it_final-total1 + wa_rt-betrg.
it_final-homeloan = wa_rt-betrg .

WHEN '9200'.
IF wa_rt-betrg LT 0.
wa_rt-betrg = wa_rt-betrg * ( -1 ).
ENDIF.
it_final-total1 = it_final-total1 + wa_rt-betrg.
it_final-persloan = wa_rt-betrg .

WHEN '9300'.
IF wa_rt-betrg LT 0.
wa_rt-betrg = wa_rt-betrg * ( -1 ).
ENDIF.
it_final-total1 = it_final-total1 + wa_rt-betrg.
it_final-saladv = wa_rt-betrg .

WHEN '9160'.
IF wa_rt-betrg LT 0.
wa_rt-betrg = wa_rt-betrg * ( -1 ).
ENDIF.
it_final-total1 = it_final-total1 + wa_rt-betrg.
it_final-dfpp = wa_rt-betrg .

ENDCASE.

ENDLOOP.

ENDFORM. " GET_RT_DATA


ALSO READ:

- Comparison Report For The Employee Salaries In HR ABAP.

- 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.

.....Back To Sub-Index On HR ABAP.

.....Back To MAIN INDEX.


Time Quota For An Employee In HR ABAP

DATA : cumulatedvalues TYPE TABLE OF bapihrquotacv WITH HEADER LINE.

CALL FUNCTION 'BAPI_TIMEQUOTA_GETDETAILEDLIST'
EXPORTING
employeenumber = pernr-pernr
quotaselectionmod = '1'
wayofcalculation = 'D'
validitybegin = '18000101'
validityend = '99991231'
TABLES
cumulatedvalues = cumulatedvalues.

IF NOT cumulatedvalues[] IS INITIAL.

READ TABLE cumulatedvalues INDEX 1.
IF sy-subrc = 0.
* it_final-lent = cumulatedvalues-entitle.
* it_final-bal = cumulatedvalues-rest.
ENDIF.
ENDIF.


ENDFORM. " GET_TIME_QUOTA


ALSO READ:

- Employee Deduction Report In HR ABAP.

- Comparison Report For The Employee Salaries In HR ABAP.

- Cash Payment Report In HR ABAP.

- Bank Report For Employees In HR ABAP.

- BDC For Uploading Absence Data Into PA30 Transaction.

.....Back To Sub-Index On HR ABAP.

.....Back To MAIN INDEX.


HR ABAP - Send Employee Payslip As An E-Mail Attachment.

REPORT zhr_email_emp_payslip.

TABLES: pernr.


INFOTYPES: 0000,
0001,
0002,
0008.


TYPES: BEGIN OF ty_pa0000,
pernr LIKE pa0000-pernr,
begda LIKE pa0000-begda,
endda LIKE pa0000-endda,
END OF ty_pa0000.

TYPES: BEGIN OF ty_final,
pernr LIKE pa0001-pernr,
END OF ty_final.


DATA: it_pa0000 TYPE TABLE OF p0000 WITH HEADER LINE,
it_pa0001 TYPE TABLE OF p0001 WITH HEADER LINE,
it_pa0002 TYPE TABLE OF p0002 WITH HEADER LINE,
it_pa0008 TYPE TABLE OF p0008 WITH HEADER LINE.

* SSF Decleration
DATA: l_form TYPE tdsfname VALUE 'ZHR_PAYSILP_EMPLOYEE',
lf_fm_name TYPE rs38l_fnam.



GET pernr.

rp-provide-from-last p0000 space pn-begda pn-endda.
IF pnp-sw-found = '1'.
IF p0000-stat2 = '3'.
MOVE p0000-pernr TO it_pa0000-pernr.
MOVE pn-begda TO it_pa0000-begda.
MOVE pn-endda TO it_pa0000-endda.
APPEND it_pa0000.
CLEAR it_pa0000.
ENDIF.
ENDIF.

END-OF-SELECTION.


PERFORM get_time_quota.

PERFORM call_smartform.

*&---------------------------------------------------------------------*
*& Form CALL_SMARTFORM
*----------------------------------------------------------------------*
FORM call_smartform .

*data:
* Data declaration for mail
DATA: i_objbin LIKE solisti1 OCCURS 0 WITH HEADER LINE,
i_reclist LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
i_objtxt LIKE solisti1 OCCURS 0 WITH HEADER LINE,
i_objpack LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
i_objhead LIKE solisti1 OCCURS 0 WITH HEADER LINE,
i_tline TYPE TABLE OF tline WITH HEADER LINE,
i_record LIKE solisti1 OCCURS 0 WITH HEADER LINE,
wa_doc_chng LIKE sodocchgi1,
l_lines TYPE sy-tabix.

DATA: it_otfdata TYPE TABLE OF itcoo WITH HEADER LINE.

DATA : output_options TYPE ssfcompop.

DATA: control_parameters TYPE ssfctrlop,
job_output_info TYPE ssfcrescl.

DATA: v_pabrp TYPE pabrp,
v_pabrj TYPE pabrj.

IF pnptimr9 = 'X'.
v_pabrp = pnpdispp.
v_pabrj = pnpdispj.
ELSE.
v_pabrp = pnppabrp.
v_pabrj = pnppabrj.
ENDIF.


output_options-tddest = 'LOCL'.
output_options-tdarmod = '1'.
output_options-tdnoprev = 'X'.
output_options-tdnoprint = 'X'.
*OUTPUT_OPTIONS-TDPRINTER = 'PRINTER'.

control_parameters-getotf = 'X'.
control_parameters-no_dialog = 'X'.
control_parameters-device = 'PRINTER'.
control_parameters-preview = ''.


CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = l_form
IMPORTING
fm_name = lf_fm_name
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3.

LOOP AT it_pa0000.


CALL FUNCTION lf_fm_name "'/1BCDWB/SF00000062'
EXPORTING
control_parameters = control_parameters
output_options = output_options
pernr = it_pa0000-pernr
abkrs = pnpabkrs-low
pabrp = v_pabrp
pabrj = v_pabrj
IMPORTING
* DOCUMENT_OUTPUT_INFO =
job_output_info = job_output_info
* JOB_OUTPUT_OPTIONS =
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5
.

REFRESH : it_otfdata[],
i_objtxt,
i_objpack,
it_otfdata,
i_tline,
i_record,
i_reclist.

it_otfdata[] = job_output_info-otfdata[].

CLEAR : i_objbin, i_reclist, i_objtxt.
REFRESH : i_objbin, i_reclist, i_objtxt.

*Populate values for mail text.
i_objtxt = 'Employee Payslip'.
APPEND i_objtxt.

DESCRIBE TABLE i_objtxt LINES l_lines.
READ TABLE i_objtxt INDEX l_lines.
wa_doc_chng-doc_size = l_lines * 255.
wa_doc_chng-obj_name = 'EMAIL'.
wa_doc_chng-obj_descr = 'Employee Payslip'.

* Main Text
CLEAR : i_objpack.
i_objpack-head_start = 1.
i_objpack-head_num = 0.
i_objpack-body_start = 1.
i_objpack-doc_type = 'RAW'.
i_objpack-body_num = l_lines.
APPEND i_objpack.
CLEAR i_objpack.

*Convert output of script to OTF data
CLEAR: i_tline, l_lines.
REFRESH i_tline.

* Convert OTF to PDF
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
max_linewidth = 132
IMPORTING
bin_filesize = l_lines
TABLES
otf = it_otfdata
lines = i_tline
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
OTHERS = 4.

IF sy-subrc <> 0 OR
l_lines IS INITIAL.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.

REFRESH : i_record.

*Format OTF data
CALL FUNCTION 'QCE1_CONVERT'
TABLES
t_source_tab = i_tline
t_target_tab = i_record
EXCEPTIONS
convert_not_possible = 1
OTHERS = 2.
IF sy-subrc <> 0.
WRITE : / 'Error in conversion of pdf lines'(015).
ENDIF.

APPEND LINES OF i_record TO i_objbin.
*Creation of the entry for the compressed attachment
DESCRIBE TABLE i_objbin LINES l_lines.
CLEAR i_objpack.
i_objpack-transf_bin = 'X'.
i_objpack-head_start = 1.
i_objpack-head_num = 1.
i_objpack-body_start = 1.
i_objpack-body_num = l_lines.
i_objpack-obj_name = 'Employee Payslip'.
i_objpack-obj_descr = 'Employee Payslip'.
i_objpack-doc_size = l_lines * 255 .
i_objpack-doc_type = 'PDF'.
APPEND i_objpack.

CLEAR i_objpack.

DATA: l_usrid_long TYPE pa0105-usrid_long.

CLEAR : l_usrid_long.

SELECT SINGLE usrid_long
FROM pa0105
INTO l_usrid_long
WHERE pernr = it_pa0000-pernr
AND subty = '0010'.

IF sy-subrc EQ 0.
i_reclist-receiver = l_usrid_long. "'ravi.me1231@gmail.com'.
i_reclist-rec_type = 'U'.
i_reclist-com_type = 'INT'.
APPEND i_reclist.
ELSE.
WRITE:/ 'No email id is maintained for this personnel number' , it_pa0000-pernr.
ENDIF.

IF NOT i_reclist[] IS INITIAL.
*sending report output and script output as mail
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = wa_doc_chng
put_in_outbox = 'X'
commit_work = 'X'
TABLES
packing_list = i_objpack
object_header = i_objhead
contents_bin = i_objbin
contents_txt = i_objtxt
receivers = i_reclist
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
document_type_not_exist = 3
operation_no_authorization = 4
parameter_error = 5
x_error = 6
enqueue_error = 7
OTHERS = 8.

ENDIF.

ENDLOOP.


ENDFORM. " CALL_SMARTFORM


ALSO READ:

- Time Quota For An Employee In HR ABAP.

- Employee Deduction Report In HR ABAP.

- Comparison Report For The Employee Salaries In HR ABAP.

- Cash Payment Report In HR ABAP.

- Bank Report For Employees In HR ABAP.

.....Back To Sub-Index On HR ABAP.

.....Back To MAIN INDEX.