BREAK dungbv7.
1. Understanding business requirements
The process of configuring the payroll schema is indeed a long and complicated one. The regulations of salary calculation are different in each country and each company, so quietly often there are many cases when the standard configuration of the SAP system can't satisfy all the business requirements.
In those situations, we will have to create custom functions to fulfill these requirements. However, the custom functions' processing logs are often neglected. This makes custom functions become black boxes and it'll be a challenge for users to identify if there were errors issued inside custom functions or not.
This post will show you how to create processing logs for a custom function.
2. Understanding system configuration
Before we get to know how to create processing logs, we need a custom function first.
I've always liked the PITAB function, this function is used to back up data from internal tables such as IT, RT and then reload these backup tables into IT, RT at appropriate times.
Function PITAB has many applications. For example, when running Correction Run, we can save the RT table at the end of the first Regular Run and then reload it in the “Adjustment Check” Run.
Unfortunately, PITAB does not support backing up all internal tables, in case I want to back up the WPBP table, PITAB can't support it.
So, I will create a custom function named ZITAB that simulates the workflow of PITAB and helps me to backup and reload the content of table WPBP.
The steps are summarized as follows:
- Step 1: Create ZITAB function in Tcode PE04
- Step 2: Create parameters for this function and the values that can be passed in
- Step 3: Write processing code for ZITAB function
FORM fuzitab. "formerly ASBTB process internal table
CASE as-parm1.
WHEN 'D '.
CASE as-parm2.
WHEN 'WPBP'.
REFRESH awpbp.
WHEN OTHERS.
ENDCASE.
WHEN 'L '.
CASE as-parm2.
WHEN 'WPBP'.
wpbp[] = awpbp[].
WHEN OTHERS.
ENDCASE.
WHEN 'S '.
CASE as-parm2.
WHEN 'WPBP'.
awpbp[] = wpbp[].
WHEN OTHERS.
ENDCASE.
WHEN OTHERS.
RETURN.
ENDCASE.
ENDFORM. "ENDFORM FUZITAB.
Let’s check the result, table WPBP of the Regular Run is brought into the "Adjustment Check" Run:
WPBP of Regular Run inside Special Run:
WPBP of "Adjustment Check" Run:
Now it’s time to add processing logs into my ZITAB.
- Step 1: Mark the list of internal tables that will appear in the Input and Output section of the function.
Once again access to the tcode PE04.
Fill in the names of the internal tables corresponding to the parameter values, such as:
Continue to do the same with Output Parameter:
Note: A list of all internal tables that can print in the Payroll log can be viewed here.
- Step 2: Write log issued from processing
Every function in the payroll driver exports its processing logs into table PTEXT.
I will write a fairly simple log processing, consisting of only 1 line:
IF prt_prot EQ 'X'. "Display log
CLEAR ptext.
ptext-tlevel = '1'.
ptext-tintensiv1 = '0'.
ptext-text2+8(4) = '-->'.
ptext-tlength2 = '20'.
ptext-tintensiv2 = '0'.
ptext-empty_lines = 1.
CASE as-parm1.
WHEN 'L'.
ptext-text1 = 'Table has been saved'.
CASE as-parm2.
WHEN 'WPBP'.
ptext-text2(6) = 'WPBP'.
ptext-text2+13(6) = 'AWPBP'.
WHEN OTHERS.
ENDCASE.
WHEN 'S'.
ptext-text1 = 'Table has been loaded'.
CASE as-parm2.
WHEN 'WPBP'.
ptext-text2(6) = 'AWPBP'.
ptext-text2+13(6) = 'WPBP'.
WHEN OTHERS.
ENDCASE.
WHEN OTHERS.
ENDCASE.
ptext-tlength1 = strlen( ptext-text1 ).
APPEND ptext.
ENDIF.
Ok, so let's see the final result
The ZITAB function has the same log as the standard PITAB function:
If you double-click into the Processing folder, you will see this:
Ok, that is all for today. Thanks for reading 😀
May the best solution be with you