Sie sind auf Seite 1von 12

How to Store Simulation Payroll Result for any Reconciliation

By Sai Kumar Bonakurthi, HCL Technologies This document tells us how to capture runtime pay results and store in custom table during the simulation payroll for any reconciliation. Note: Here I am using Australia Payroll, for any country payroll logic is same. For this first of all we have to create the Payroll Function and insert the function into payroll schema after final processing step of the schema. Create a payroll function using T.code PE04. The Naming convention should be Z_ if we use only Z it allows only to store in standard package

Now pass the function description. There is option available to create function to corresponding to any countries. Select the Country.

Add Input parameter to the Function..

Select the Program

There are two ways to write our code for the newly created Function. y y By using Enhancements spots By using access key

Here we would be using enhancements spots. Choose the Enhancement spot from the Program.

Select Show implements enhancement options Place the cursor on the spot and select Create implementation (Edit->Enhancement operation>Create Implementation). Create Enhancement implementation. A spot will be created to write our custom code.

Create a table to store the data.

The below code is to take the data form RT table from final result of the simulation payroll and store the data in the table at runtime for the wage types that maintained in the Set or wage type maintenance table.

We have the condition here this will run for the T.Code PC00_M13_CALC_SIMU' and the data in the table will be store and modify for next time run. Note : Data will store for one month only ie. Let say we run the simulation payroll for the month of Aug 09 all the related amount will be store in the ztable that are maintained in SET. If we run for AUG the data will be over write the existing one. Then if we run the simulation payroll for the Sep 09 the all the data store for the Aug be cleared and only sep 09 will be available. *---------------------------------------------------------------------- * DATA : it_final TYPE TABLE OF zhrtr_aus_wt_du , wa_final TYPE zhrtr_aus_wt_du. DATA : r_wages TYPE hrpayjp_range_lgart, w_wages TYPE pjpsk_range_lgart. DATA :it_ab_wage TYPE TABLE OF rgsb4, wa_ab_wage TYPE rgsb4. DATA : lv_check TYPE i. DATA : wa_rt TYPE pc207 . IF tst_on = 'X' and sy-tcode = 'PC00_M13_CALC_SIMU' . SELECT SINGLE * FROM zhrtr_aus_wt_du INTO wa_final WHERE begda = PNPDISBD . if sy-subrc ne 0. DELETE FROM zhrtr_aus_wt_du. endif. CALL FUNCTION 'G_SET_GET_ALL_VALUES' EXPORTING client = sy-mandt setnr = 'ZAUS_WAGE' class = '0000' no_descriptions = ' ' no_rw_info ='' TABLES set_values = it_ab_wage EXCEPTIONS set_not_found = 1 OTHERS = 2. IF it_ab_wage IS NOT INITIAL. LOOP AT it_ab_wage INTO wa_ab_wage. w_wages-sign = 'I'. w_wages-option = 'EQ'. w_wages-low = wa_ab_wage-from. append w_wages to r_wages. ENDLOOP. CLEAR it_final. LOOP AT rt INTO wa_rt WHERE lgart IN r_wages. wa_final-pernr = p0000-pernr. wa_final-begda = PNPDISBD. wa_final-lgart = wa_rt-lgart. wa_final-betrg = wa_rt-betrg. APPEND wa_final TO it_final. ENDLOOP. IF it_final IS NOT INITIAL. MODIFY zhrtr_aus_wt_du FROM TABLE it_final. IF sy-subrc = 0. COMMIT WORK. ENDIF. ENDIF. ENDIF. ENDIF. endform.

ENDENHANCEMENT. *$*$-End: (1 )------------------------------------------------------ $*$* Now insert the Function into the Schema.

To Create a Set to maintain the wage use the T.code GS01

Now maintain the wage types in Set values.

TYPE-POOLS: slis. TABLES p0002. DATA : it_final TYPE TABLE OF zhrtr_aus_wt_du , wa_final TYPE zhrtr_aus_wt_du. DATA :it_ab_wage TYPE TABLE OF rgsb4, wa_ab_wage TYPE rgsb4. DATA : wa_fieldcat TYPE lvc_s_fcat, it_fieldcat TYPE lvc_t_fcat. DATA: it_fcat TYPE slis_t_fieldcat_alv, wa_fcat TYPE slis_fieldcat_alv, g_save TYPE c VALUE 'A'. DATA : dyn_table TYPE REF TO data, dyn_line TYPE REF TO data. DATA : g_repid TYPE sy-repid. FIELD-SYMBOLS: <fs_final> TYPE STANDARD TABLE, <wa_final> TYPE any, <data> TYPE any. CONSTANTS : c_30 TYPE char2 VALUE '30', c_13 TYPE char2 VALUE '13', c_2 TYPE char1 VALUE '2', c_7 TYPE char1 VALUE '7', c_p TYPE char1 VALUE 'P'. SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001. SELECT-OPTIONS s_pernr FOR p0002-pernr MATCHCODE OBJECT perm. SELECTION-SCREEN END OF BLOCK b1. INCLUDE ZHRREP_AUS_DUMMY_WT_FORMS.

INITIALIZATION. g_repid = sy-repid. START-OF-SELECTION. PERFORM f_build_filedcat. PERFORM f_create_itab_dynamically. PERFORM f_get_data. PERFORM display. *&--------------------------------------------------- ------------------* *& Include ZFORMS_SK *&--------------------------------------------------------------------- * *&--------------------------------------------------------------------- * *& Form F_BUILD_FILEDCAT *&--------------------------------------------------------------------- * FORM f_build_filedcat . CALL FUNCTION 'G_SET_GET_ALL_VALUES' EXPORTING client = sy-mandt setnr = 'ZAUS_WAGE' class = '0000' no_descriptions = ' ' no_rw_info ='' TABLES set_values = it_ab_wage EXCEPTIONS set_not_found = 1 OTHERS = 2. SELECT * FROM zhrtr_aus_wt_du INTO TABLE it_final WHERE pernr IN s_pernr. *PERNR wa_fieldcat-col_pos = 1. wa_fieldcat-fieldname = 'PERNR'. APPEND wa_fieldcat TO it_fieldcat. CLEAR wa_fieldcat. *BEGDA wa_fieldcat-fieldname = 'BEGDA'. APPEND wa_fieldcat TO it_fieldcat. CLEAR wa_fieldcat. *PERNR * wa_fcat-col_pos = 1. wa_fcat-fieldname = 'PERNR'. wa_fcat-seltext_l = 'Personnel No'. APPEND wa_fcat TO it_fcat. CLEAR wa_fcat. *BEGDA * wa_fcat-col_pos = 2. wa_fcat-fieldname = 'BEGDA'. wa_fcat-seltext_l = 'Date'. wa_fcat-datatype = 'DD.MM.YYYY'. APPEND wa_fcat TO it_fcat. CLEAR wa_fcat. LOOP AT it_ab_wage INTO wa_ab_wage. CLEAR wa_fieldcat. wa_fieldcat-col_pos = sy-tabix. wa_fieldcat-fieldname = wa_ab_wage-from . wa_fcat-col_pos = sy-tabix. wa_fcat-fieldname = wa_ab_wage-from .

IF wa_fieldcat-fieldname CA '/'. TRANSLATE wa_fieldcat-fieldname USING '/ '. CONDENSE wa_fieldcat-fieldname NO-GAPS. ENDIF. wa_fcat-fieldname = wa_ab_wage-from. IF wa_fcat-fieldname CA '/'. TRANSLATE wa_fcat-fieldname USING '/ '. CONDENSE wa_fcat-fieldname NO-GAPS. ENDIF. wa_fieldcat-intlen = c_30 . wa_fcat-seltext_l = wa_ab_wage-from. APPEND wa_fieldcat TO it_fieldcat. CLEAR wa_fieldcat. APPEND wa_fcat TO it_fcat. CLEAR wa_fcat. ENDLOOP. ENDFORM. " F_BUILD_FILEDCAT *&--------------------------------------------------------------------- * *& Form F_CREATE_ITAB_DYNAMICALLY *&------------------------------------------------------------------ ---* FORM f_create_itab_dynamically . * Create dynamic internal table and assign to Field-Symbol CALL METHOD cl_alv_table_create=>create_dynamic_table EXPORTING it_fieldcatalog = it_fieldcat IMPORTING ep_table = dyn_table. ASSIGN dyn_table->* TO <fs_final>. * Create dynamic work area and assign to Field Symbol CREATE DATA dyn_line LIKE LINE OF <fs_final> . ASSIGN dyn_line->* TO <wa_final> . ENDFORM. " F_CREATE_ITAB_DYNAMICALLY *&--------------------------------------------------------------------- * *& Form F_GET_DATA *&--------------------------------------------------------------------- * FORM f_get_data . FIELD-SYMBOLS : <fs_pernr> TYPE ANY, <fs_begda> TYPE ANY, <fs_lgart> TYPE ANY. DATA : l_lgart TYPE char4. SORT it_final BY pernr. LOOP AT it_final INTO wa_final. *PERNR ASSIGN COMPONENT 'PERNR' OF STRUCTURE <wa_final> TO <fs_pernr> . <fs_pernr> = wa_final-pernr. IF wa_final-lgart+0(1) EQ '/'. l_lgart = wa_final-lgart+1(3). ENDIF. *begda ASSIGN COMPONENT 'BEGDA' OF STRUCTURE <wa_final> TO <fs_begda> . CONCATENATE wa_final-begda+6(2) wa_final-begda+4(2) wa_final-

begda+0(4) INTO <fs_begda> SEPARATED BY '.'. * <fs_begda> = wa_final-begda. * READ TABLE it_ab_wage INTO wa_ab_wage with key pernr = <fs-pernr> LGART = l_lgart. * if sy-subrc eq 0. ASSIGN COMPONENT l_lgart OF STRUCTURE <wa_final> TO <fs_lgart>. <fs_lgart> = wa_final-betrg. CLEAR l_lgart. AT END OF pernr. INSERT <wa_final> INTO TABLE <fs_final>. FREE : <wa_final>. ENDAT. ENDLOOP. ENDFORM. " F_GET_DATA *&--------------------------------------------------------------------- * *& Form DISPLAY *&--------------------------------------------------------------------- * FORM display . CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING * * * * * * i_callback_program = g_repid is_layout = wa_layout i_callback_user_command = g_user_command it_fieldcat = it_fcat is_variant = wa_variant i_save = g_save it_events = it_events[]

TABLES t_outtab = <fs_final> EXCEPTIONS program_error =1 . IF sy-subrc <> 0. EXIT. ELSE. LEAVE LIST-PROCESSING. ENDIF. CLEAR g_repid. ENDFORM. " DISPLAY

"#EC * "#EC *

Das könnte Ihnen auch gefallen