Calculate and Default wage type amount in infotype 0008 (Basic Salary)

By Rajesh Badita, Arshiya International Ltd

1.       Introduction

To calculate amount for wage type “1010” called special allowance based on some parameters and to default the same amount in infotype 0008 in Process After Input (PAI) Event on screen .

This can be implemented through USER-EXIT “ PBAS0001”. This user-exit is used for defaulting values or keying validations checks to transaction “PA40” or “PA30” for any PA or Recruitment infotypes

2.       Steps

Go to CMOD transaction and create project say ‘ZHR_PA’.

Assign enhancement  “PBAS0001”

Click on components push button and double click on function exit “EXIT_SAPFP50M_002”

Now double click on “ZXPADU02”  which is include program.

Implement ABAP logic:

Create a  structure “ZTBLGART” as shown in below screenshot


TYPE-POOLS: abap.
DATA: lw_p0000 
TYPE p0000,
      lw_p0002 
TYPE p0002,
      lw_p0008 
TYPE p0008,
      lw_p0023 
TYPE p0023,
      lv_spa 
TYPE pc207-betrg,
      gt_p0000 
TYPE TABLE OF p0000,
      gw_p0000 
TYPE p0000.
DATA: lv_retirement_date 
LIKE p0002-gbdat.

DATA: wa_0008 
TYPE p0008,
      lv_wgetype 
TYPE pa0008-lga01,
      lv_payment 
TYPE t510-betrg,
      lv_syindex 
TYPE n LENGTH 2.

DATA: lv_cal_begda 
TYPE begda,
      lv_cal_endda 
TYPE endda,
      lv_cnt 
TYPE i,
      gt_pa2001 
TYPE TABLE OF pa2001.
DATA return TYPE bapireturn1.

DATA: dy_table 
TYPE REF TO data,
    dy_line  
TYPE REF TO data,
    xfc 
TYPE lvc_s_fcat,
    ifc 
TYPE lvc_t_fcat.
DATA : idetails TYPE abap_compdescr_tab,
     xdetails 
TYPE abap_compdescr.
DATA : ref_table_des TYPE REF TO cl_abap_structdescr.
DATA: lv_basic 
TYPE ansal_15.
FIELD-SYMBOLS <fs_betrg> TYPE ztblgart.
FIELD-SYMBOLS: <dyn_table> 
TYPE STANDARD TABLE,
             <dyn_wa>,
             <dyn_field>.
FIELD-SYMBOLS <fs_amount> TYPE ANY.
FIELD-SYMBOLS: <l_betrg> 
TYPE pad_amt7s,
               <l_lgart> 
TYPE lgart.

IF sy-tcode = 'PA40' OR sy-tcode = 'PA30'.
  
CASE innnn-infty.
    
WHEN '0008'.
      
IF ( ( ipsyst-ioper EQ insert OR ipsyst-ioper EQ copy OR ipsyst-ioper EQ 'MOD' OR sy-ucomm EQ 'UPD' ).
        
DATA lv_field TYPE char40.
        
CALL METHOD cl_hr_pnnnn_type_cast=>prelp_to_pnnnn
          
EXPORTING
            prelp = innnn
          
IMPORTING
            pnnnn = lw_p0008.
        
CLEAR lv_spa.
        
PERFORM default_spl_allow USING lw_p0008
                                  
CHANGING lv_spa.

*** Finding Wage Type field number for the Wage Type 1010
        
DO 40 TIMES VARYING lv_wgetype FROM lw_p0008-lga01 NEXT lw_p0008-lga02.
          
IF lv_wgetype = '1010'.
            lv_syindex = sy-index.
            
CONCATENATE 'lw_p0008-bet' lv_syindex INTO lv_field.
            
ASSIGN (lv_field) TO <fs_amount>.
            <fs_amount> = lv_spa.
            EXIT.
          ENDIF.
        ENDDO.
        
IF lv_spa IS NOT INITIAL.
* Get the structure of the table.
          ref_table_des ?=
              cl_abap_typedescr=>describe_by_name( 
'ZTBLGART' ).
          idetails[] = ref_table_des->components[].
          
LOOP AT idetails INTO xdetails.
            
CLEAR xfc.
            xfc-fieldname = xdetails-name .
*    xfc-datatype = xdetails-type_kind.
            
CASE xdetails-type_kind.
              
WHEN 'C'.
                xfc-datatype = 
'CHAR'.
              
WHEN 'N'.
                xfc-datatype = 
'NUMC'.
              
WHEN 'D'.
                xfc-datatype = 
'DATE'.
              
WHEN 'P'.
                xfc-datatype = 
'PACK'.
              
WHEN OTHERS.
                xfc-datatype = xdetails-type_kind.
            ENDCASE.
            xfc-inttype = xdetails-type_kind.
            xfc-intlen = xdetails-length.
            xfc-decimals = xdetails-decimals.
            
APPEND xfc TO ifc.
          ENDLOOP.

* Create dynamic internal table and assign to FS
          
CALL METHOD cl_alv_table_create=>create_dynamic_table
            
EXPORTING
              it_fieldcatalog  = ifc
              i_length_in_byte = 
'X'
            
IMPORTING
              ep_table         = dy_table.
          
ASSIGN dy_table->* TO <dyn_table>.
          
ASSIGN ('(MP000800)TBLGART[]'TO <dyn_table>.
* Create dynamic work area and assign to FS
          
CREATE DATA dy_line LIKE LINE OF <dyn_table>.
          
ASSIGN dy_line->* TO <dyn_wa>.

          
LOOP AT <dyn_table> ASSIGNING <dyn_wa>.
            
ASSIGN COMPONENT 'LGART' OF STRUCTURE <dyn_wa> TO <l_lgart>.
            
IF <l_lgart> = '1010'.
              
ASSIGN COMPONENT 'BETRG' OF STRUCTURE <dyn_wa> TO <l_betrg>.
              <l_betrg> = lv_spa.
              EXIT.
            ENDIF.
          ENDLOOP.

          
CALL METHOD cl_hr_pnnnn_type_cast=>pnnnn_to_prelp
            
EXPORTING
              pnnnn = lw_p0008
            
IMPORTING
              prelp = innnn.
        ENDIF.
      ENDIF.
  ENDCASE.
ENDIF.

Click here to continue...

Please send us your feedback/suggestions at webmaster@SAPTechnical.COM 

HomeContribute About Us Privacy Terms Of Use • Disclaimer • SafeCompanies: Advertise on SAPTechnical.COM | Post JobContact Us  

Graphic Design by Round the Bend Wizards

footer image footer image