Registration

Dear SAP Community Member,
In order to fully benefit from what the SAP Community has to offer, please register at:
http://scn.sap.com
Thank you,
The SAP Community team.
Skip to end of metadata
Go to start of metadata

Purpose:

Example for the steps given in this document: http://scn.sap.com/docs/DOC-28362

Overview:

Defining interface and file format along with sample code to be written in file format.

Example:

Scenario:

To process employee’s time data i.e. reading ZL table of PCL2 (B2) and computing added hours for each wage type for an employee, updating Infotype 0415, updating payroll
record to next payroll period, sending the file to
application server. File has a header, body and a trailer record.

Assumptions:  Required configurations for executing PU12 are done.

Implementation Steps:

Define the interface format as per the master data and time data to be read. Here PCL2 (ZL) is read.

As only time data needs to be evaluated the attributes of the interface format should be like below:

2. Define the file format

Four blocks were used:
1. Begin of file: To define header structure of file (depends on the requirement). No user-exit implemented at this level.
2. During Processing of employee: To implement processing logic of calculating hours for a wage-type for an employee. (This can be entirely requirement specific).
User exit implemented at structure level for easy access to structure data.

Code Snippet of Report ZFIR_PYFILE:
Note: zfir_pyfile_1 is the include generated while defining file format and contains the types of all data being read at interface format and also structures defined at file format level.

REPORT ZFIR_PYFILE.
*C--File structures sent as output to remain dynamic
TYPE-POOLS pintf.
INCLUDE zfir_pyfile_1.
FORM process_data USING fp_p01 fp_p02 fp_p03 fp_p04 fp_p05 fp_p06 fp_p07 fp_p08 fp_p09 fp_p10 fp_p11 fp_p12 fp_p13 fp_p14 fp_p15 fp_return_value.
*Your coding here
*ZL can be read here and all computations can be performed in this subroutine
*Contents of struc2 can be easily accessed as STRUC2- field name
ENDFORM.                    "PROCESS_DATA

Note: Any further subroutines created are in the same program ZFIR_PYFILE

3. After Processing Employee Data: After all the periods for an employee gets processed this block gets executed, once for each employee by default.

Code Snippet:

FORM update_data_blk3 USING fp_p01 fp_p02 fp_p03 fp_p04 fp_p05 fp_p06 fp_p07 fp_p08 fp_p09 fp_p10 fp_p11 fp_p12 fp_p13 fp_p14 fp_p15 fp_return_value.
*coding here
*If any Infotype is to be updated for an employee, data of the employee can be gathered here. However, updation of Infotype should be done in the next block End_of_file
ENDFORM.

4. End of file: This block gets called after the entire employee’s data for all the employees gets processed.

Code Snippet:

FORM prcs_end_of_file USING  fp_01 fp_02 fp_03 fp_04 fp_05 fp_06 fp_07 fp_08 fp_09 fp_10 fp_11 fp_12 fp_13 fp_14 fp_15 fp_return_value.
*Your coding here*
*Infotype updation, updating payroll with next period, sending data to application server, email functionality etc. can be handled here*

ENDFORM.                    "PRCS_END_OF_FILE

Execute:

With Payroll control records being maintained, on entering payroll area the current period dates can be seen by pressing enter. However, to run in some other
period ‘Other Period’ option has to be selected.

The screen can be scrolled down to see the export statistics as shown in the screenshot above.

Related Content:

Related Documents

http://scn.sap.com/docs/DOC-28362

 
  • No labels