0% found this document useful (1 vote)
137 views4 pages

Program Code

This document defines data types and internal tables used to process payroll result data from an uploaded file. It declares variables for the file name, payroll result structures, and a table to store the processing output. On selection screen input, it validates the selected file, uploads the data, reads payroll sequences for each employee, and updates any records where the wage type is missing. Processing results are appended to the output table.

Uploaded by

Rodrigo Ferreira
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
Download as txt, pdf, or txt
0% found this document useful (1 vote)
137 views4 pages

Program Code

This document defines data types and internal tables used to process payroll result data from an uploaded file. It declares variables for the file name, payroll result structures, and a table to store the processing output. On selection screen input, it validates the selected file, uploads the data, reads payroll sequences for each employee, and updates any records where the wage type is missing. Processing results are appended to the output table.

Uploaded by

Rodrigo Ferreira
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1/ 4

TABLES pernr.

INFOTYPES:0001.
TYPES :BEGIN OF ty_output,
result TYPE char20,
pernr TYPE pernr_d,
END OF ty_output.
TYPES: BEGIN OF lty_file,
pernr TYPE pernr_d,
seqnr TYPE cdseq,
END OF lty_file.
* *--- internal table declaration.
DATA : lt_rgdir1 TYPE TABLE OF pc261,
lt_rt TYPE TABLE OF pc207,
lo_par1 TYPE REF TO cl_hr_pay_result,
gt_output TYPE TABLE OF ty_output,
lt_v0 TYPE TABLE OF pc20c,
gv_v0(1) TYPE c,
lt_file TYPE TABLE OF lty_file,
lt_table TYPE TABLE OF lty_file,
lt_p0001 TYPE STANDARD TABLE OF p0001,
ls_p0001 TYPE p0001,
lt_return TYPE bapiret2_t.
*--- Work Area Declaration.
DATA : ls_rt1 TYPE pc207,
ls_v0 TYPE pc20c,
ls_rgdir TYPE pc261,
ls_payresult TYPE payus_result,
ls_payresult2 TYPE payus_result,
lv_subrc TYPE sy-subrc,
gs_output LIKE LINE OF gt_output,
ls_file TYPE lty_file.
DATA: lv_filename TYPE string,
lv_file TYPE string,
lv_result TYPE string.
REFRESH : lt_rgdir1,lt_rt.
CLEAR : ls_rgdir,ls_payresult,ls_rt1, lv_filename.
** File Selection
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS : p_file TYPE rlgrap-filename.
SELECTION-SCREEN END OF BLOCK b1.
** Wage type radio Buttons
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
PARAMETERS : rdb_3ina RADIOBUTTON GROUP rad1 USER-COMMAND com DEFAULT 'X',
rdb_3udf RADIOBUTTON GROUP rad1.
SELECTION-SCREEN END OF BLOCK b2.
**SELECTION-SCREEN BEGIN OF BLOCK frmpaydt WITH FRAME TITLE tfrmpayd
** NO INTERVALS.
**PARAMETERS p_seqnr LIKE pc261-seqnr. "OBLIGATORY.
**PARAMETERS p_fpbeg LIKE pc261-fpbeg. "OBLIGATORY.
**PARAMETERS p_payid LIKE pc261-payid ."OBLIGATORY.
**SELECTION-SCREEN END OF BLOCK frmpaydt.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
*--- Get the File Name from presentation server.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
field_name = 'P_FILE'
IMPORTING
file_name = p_file.
AT SELECTION-SCREEN ON p_file.
CLEAR: lv_file, lv_result.
MOVE p_file TO lv_file.
*--- Checks if a File Exists
CALL METHOD cl_gui_frontend_services=>file_exist
EXPORTING
file = lv_file
RECEIVING
result = lv_result
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
wrong_parameter = 3
not_supported_by_gui = 4.
IF sy-subrc IS INITIAL AND lv_result IS INITIAL.
MESSAGE ID 'FES' TYPE 'E' NUMBER '000'.
ENDIF.
PERFORM chk_file_format.
AT SELECTION-SCREEN OUTPUT.
AT SELECTION-SCREEN.
START-OF-SELECTION.
IF p_file IS INITIAL.
MESSAGE 'Provide file path' TYPE 'S'.
ELSE.
CLEAR lv_filename.
lv_filename = p_file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = lv_filename
TABLES
data_tab = lt_table
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17.
IF sy-subrc NE 0.
MESSAGE 'File Open Error' TYPE 'S'.
ELSE.
PERFORM upload_file.
ENDIF.
ENDIF.
**GET pernr.
LOOP AT lt_file INTO ls_file.
*--- Call FM to read the sequence number
CALL FUNCTION 'CU_READ_RGDIR'
EXPORTING
persnr = ls_file-pernr
TABLES
in_rgdir = lt_rgdir1
EXCEPTIONS
no_record_found = 1
OTHERS = 2.
IF sy-subrc EQ 0.
SORT lt_rgdir1 BY fpend.
ENDIF.
IF NOT lt_rgdir1 IS INITIAL.
DELETE lt_rgdir1 WHERE seqnr NE ls_file-seqnr.
LOOP AT lt_rgdir1 INTO ls_rgdir.
*--- Check for all the Payroll Sequence.
CALL FUNCTION 'PYXX_READ_PAYROLL_RESULT'
EXPORTING
employeenumber = ls_file-pernr
sequencenumber = ls_rgdir-seqnr
read_only_buffer = space
read_only_international = space
check_read_authority = space
CHANGING
payroll_result = ls_payresult
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.
IF sy-subrc EQ 0.
*--- Get the Payroll Result Table from the payroll Cluster
MOVE-CORRESPONDING ls_payresult-inter TO ls_payresult2-inter.
MOVE-CORRESPONDING ls_payresult-evp TO ls_payresult2-evp.
MOVE-CORRESPONDING ls_payresult-nat TO ls_payresult2-nat.
APPEND LINES OF ls_payresult-inter-v0 TO lt_v0.
APPEND LINES OF ls_payresult-inter-rt TO lt_rt.
LOOP AT lt_rt INTO ls_rt1.
IF ls_rt1-lgart EQ '3UDF'.
IF ls_rt1-v0znr IS INITIAL OR ls_rt1-v0typ IS INITIAL.
ls_rt1-v0znr = '01' .
ls_rt1-v0typ = 'T' .
MODIFY ls_payresult2-inter-rt FROM ls_rt1 INDEX sy-tabix TRANSPO
RTING v0znr v0typ.
CALL FUNCTION 'PYXX_WRITE_PAYROLL_RESULT'
EXPORTING
clusterid = 'RU'
employeenumber = ls_file-pernr
sequencenumber = ls_rgdir-seqnr
payroll_result = ls_payresult2
client = sy-mandt
EXCEPTIONS
illegal_isocode_or_clusterid = 1
error_generating_export = 2
export_error = 3
subpool_dir_full = 4
no_update_authority = 5
incomplete_result_imported = 6
OTHERS = 7.
IF sy-subrc EQ 0.
* Update from buffer to database
CALL FUNCTION 'HR_FLUSH_BUFFER_UPDATE_PCLX'
EXPORTING
test = space
client = sy-mandt
EXCEPTIONS
insert_error = 1
no_update_authority = 2
OTHERS = 3.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
IF sy-subrc EQ 0.
gs_output-result = 'Update Successful'.
gs_output-pernr = ls_file-pernr.
APPEND gs_output TO gt_output.
COMMIT WORK.
ELSE.
gs_output-result = 'Update Failed'.
gs_output-pernr = ls_file-pernr.
APPEND gs_output TO gt_output.
ENDIF.
ENDIF.
ELSE.
gs_output-result = 'No Updates'.
gs_output-pernr = ls_file-pernr.
APPEND gs_output TO gt_output.
ENDIF.
ENDIF.
ENDLOOP.

You might also like