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

...Previous

Subroutine logic:

*----------------------------------------------------------------------*
***INCLUDE ZXPADF02 .
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*&      Form  DEFAULT_SPL_ALLOW
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_LW_P0008  text
*      <--P_LV_SPA  text
*----------------------------------------------------------------------*
FORM default_spl_allow USING p_p0008 TYPE p0008
                       
CHANGING p_betrg type pc207-betrg.
  
TABLES t511.
  DATA: 
BEGIN OF lwa_wage,
          lgart 
TYPE p0008-lga01,
          betrg 
TYPE p0008-bet01,
        
END OF lwa_wage,
        
BEGIN OF lwa_indbw,
          indbw 
TYPE p0008-ind01,
        
END OF lwa_indbw,
        
BEGIN OF lwa_betrg,
          bet 
TYPE p0008-bet01,
        
END OF lwa_betrg.

  DATA: lit_ptbindbw 
TYPE TABLE OF ptbindbw,
        lwa_ptbindbw 
TYPE ptbindbw.

  DATA: l_date 
TYPE d.

  DATA: 
BEGIN OF lt_ptbindbw OCCURS 20,
          seqnr(3).                      
" sequence number
          
INCLUDE STRUCTURE ptbindbw.
  DATA: 
END OF lt_ptbindbw.

  
DATA lw_lgart TYPE lgart.

  DATA: lv_basic 
TYPE betrg,
        lv_hra 
TYPE betrg,
        lv_conv 
TYPE betrg,
        lv_educ 
TYPE betrg,
        lv_gross 
TYPE betrg,
        lv_car 
TYPE betrg,
        lv_med 
TYPE betrg,
        lv_food 
TYPE betrg,
        lv_attire 
TYPE betrg,
        lv_cca 
TYPE betrg,
        lv_fuel 
TYPE betrg,
        lv_lta 
TYPE betrg,
        lv_bonus 
TYPE betrg,
        lv_gratuity 
TYPE betrg,
        lv_pf 
TYPE betrg.


  DATA: gw_p0001 
TYPE p0001,
        gw_p0007 
TYPE p0007,
        gw_p0014 
TYPE p0014,
        gw_p0015 
TYPE p0015.

  DATA: gt_p0001 
TYPE TABLE OF p0001,
        gt_p0007 
TYPE TABLE OF p0007,
        gt_p0014 
TYPE TABLE OF p0014,
        gt_p0015 
TYPE TABLE OF p0015.

  CLEAR: lv_basic, lv_hra, lv_conv, lv_educ, lv_gross, lv_car, lv_med, lv_food, lv_attire, lv_cca, lv_fuel,
         lv_lta, lv_gratuity, lv_pf, lv_bonus.

  
REFRESH gt_p0001.
  
CALL FUNCTION 'HR_READ_INFOTYPE'
    
EXPORTING
*     TCLAS                 = 'A'
      pernr                 = p_p0008-pernr
      infty                 = 
'0001'
*     BEGDA                 = '18000101'
*     ENDDA                 = '99991231'
*     BYPASS_BUFFER         = ' '
*     LEGACY_MODE           = ' '
*   IMPORTING
*     SUBRC                 =
    
TABLES
      infty_tab             = gt_p0001
   
EXCEPTIONS
     infty_not_found       = 
1
     
OTHERS                2
            .
  
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

  
SORT gt_p0001 DESCENDING BY endda.
  
READ TABLE gt_p0001 INTO gw_p0001 INDEX 1.

  
REFRESH gt_p0007.
  
CALL FUNCTION 'HR_READ_INFOTYPE'
    
EXPORTING
*     TCLAS                 = 'A'
      pernr                 = p_p0008-pernr
      infty                 = 
'0007'
*     BEGDA                 = '18000101'
*     ENDDA                 = '99991231'
*     BYPASS_BUFFER         = ' '
*     LEGACY_MODE           = ' '
*   IMPORTING
*     SUBRC                 =
    
TABLES
      infty_tab             = gt_p0007
   
EXCEPTIONS
     infty_not_found       = 
1
     
OTHERS                2
            .
  
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

  
SORT gt_p0007 DESCENDING BY endda.
  
READ TABLE gt_p0007 INTO gw_p0007 INDEX 1.


  
REFRESH lit_ptbindbw.
  
DO 40 TIMES VARYING lwa_wage-lgart FROM p_p0008-lga01
                                          
NEXT p_p0008-lga02
                    VARYING lwa_indbw-indbw 
FROM p_p0008-ind01
                                           
NEXT p_p0008-ind02
                    VARYING lwa_betrg-bet 
FROM p_p0008-bet01
                                         
NEXT p_p0008-bet02.

    
IF lwa_wage-lgart IS NOT INITIAL.
      
MOVE-CORRESPONDING lwa_wage TO lwa_ptbindbw.
      
MOVE-CORRESPONDING lwa_indbw TO lwa_ptbindbw.
      
MOVE lwa_betrg-bet TO lwa_ptbindbw-betrg.
      
APPEND lwa_ptbindbw TO lit_ptbindbw.
    ELSE.
      EXIT.
    ENDIF.
  ENDDO.

  
CALL FUNCTION 'RP_EVALUATE_INDIRECTLY_P0008'
    
EXPORTING
      ppernr                       = gw_p0001-pernr
      pmolga                       = 
'40'            " gw_molga
      pbegda                       = p_p0008-begda
      pp0001                       = gw_p0001
      pp0007                       = gw_p0007
      pp0008                       = p_p0008
*    IMPORTING
*      pendda                       = v_endda
    
TABLES
      ptbindbw                     = lit_ptbindbw
    
EXCEPTIONS
      error_at_indirect_evaluation = 
1.

  
CLEAR lwa_ptbindbw.
  
READ TABLE lit_ptbindbw INTO lwa_ptbindbw WITH KEY lgart = '1002'.
  
IF sy-subrc EQ 0.
    
MOVE lwa_ptbindbw-betrg TO lv_basic.
  ENDIF.

  
CLEAR lwa_ptbindbw.
  
READ TABLE lit_ptbindbw INTO lwa_ptbindbw WITH KEY lgart = '1006'.
  
IF sy-subrc EQ 0.
    
MOVE lwa_ptbindbw-betrg TO lv_hra.
  ENDIF.

  
CLEAR lwa_ptbindbw.
  
READ TABLE lit_ptbindbw INTO lwa_ptbindbw WITH KEY lgart = '1008'.
  
IF sy-subrc EQ 0.
    
MOVE lwa_ptbindbw-betrg TO lv_conv.
  ENDIF.

  
CLEAR lwa_ptbindbw.
  
READ TABLE lit_ptbindbw INTO lwa_ptbindbw WITH KEY lgart = '1007'.
  
IF sy-subrc EQ 0.
    
MOVE lwa_ptbindbw-betrg TO lv_educ.
  ENDIF.


  
CLEAR lwa_ptbindbw.
  
READ TABLE lit_ptbindbw INTO lwa_ptbindbw WITH KEY lgart = '1005'.
  
IF sy-subrc EQ 0.
    
MOVE lwa_ptbindbw-betrg TO lv_med.
  ENDIF.

  
CLEAR lwa_ptbindbw.
  
READ TABLE lit_ptbindbw INTO lwa_ptbindbw WITH KEY lgart = '1012'.
  
IF sy-subrc EQ 0.
    
MOVE lwa_ptbindbw-betrg TO lv_food.
  ENDIF.


  
CLEAR lwa_ptbindbw.
  
READ TABLE lit_ptbindbw INTO lwa_ptbindbw WITH KEY lgart = '1015'.
  
IF sy-subrc EQ 0.
    
MOVE lwa_ptbindbw-betrg TO lv_fuel.
  ENDIF.

  lv_gross = p_p0008-ansal / 
12.


  
REFRESH gt_p0015.
  
CALL FUNCTION 'HR_READ_INFOTYPE'
    
EXPORTING
*     TCLAS                 = 'A'
      pernr                 = p_p0008-pernr
      infty                 = 
'0015'
*     BEGDA                 = '18000101'
*     ENDDA                 = '99991231'
*     BYPASS_BUFFER         = ' '
*     LEGACY_MODE           = ' '
*   IMPORTING
*     SUBRC                 =
    
TABLES
      infty_tab             = gt_p0015
   
EXCEPTIONS
     infty_not_found       = 
1
     
OTHERS                2
            .
  
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

  
LOOP AT gt_p0015 INTO gw_p0015 WHERE begda LE p_p0008-endda
                                   
AND endda GE p_p0008-begda.

    
IF gw_p0015-lgart EQ '1004' OR gw_p0015-lgart EQ '1028'.
      lv_lta = gw_p0015-betrg / 
12.

    
ELSEIF gw_p0015-lgart EQ '1001'.
      lv_bonus = gw_p0015-betrg / 
12.
    ENDIF.
  ENDLOOP.
  lv_pf = ( lv_basic * 
12 ) / 100.
  lv_gratuity = ( ( 
15 * lv_basic ) / 26 ) / 12.

  p_betrg = lv_gross - ( lv_basic + lv_hra + lv_conv + lv_educ + lv_med + lv_food +
                         lv_fuel + lv_lta + lv_pf + lv_gratuity ).

  
CALL FUNCTION 'HR_IN_ROUND_AMT'
    
EXPORTING
      amount        = p_betrg
      rndoff        = 
'100'
     rndlmt        = 
'N'
   
IMPORTING
     retamt        = p_betrg
*     DLTAMT        =
            .

ENDFORM.                    
" DEFAULT_SPL_ALLOW
*&---------------------------------------------------------------------*
*&      Form  re511
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_MOLGA    text
*      -->P_LGART    text
*      -->P_ENDDA    text
*----------------------------------------------------------------------*
FORM re511 USING p_molga TYPE molga        
                 p_lgart 
TYPE lgart
                 p_endda 
TYPE endda.


  
IF ( t511-molga NE p_molga ) OR
     ( t511-lgart 
NE p_lgart ) OR
     ( t511-endda 
LE p_endda ) OR
     ( t511-begda 
GE p_endda ).

    
SELECT FROM t511
       
WHERE molga = p_molga
         
AND lgart = p_lgart
         
AND endda GE p_endda
         
AND begda LE p_endda.
    ENDSELECT.

    
IF sy-subrc NE 0.
      
CLEAR t511.
    ENDIF.
  ENDIF.                 .

ENDFORM.                         

3.       Desired Result:

 Go to PA30 and create infotype 0008 record for an employee

Now press enter or click on save button after entering other components like basic, hra, conveyance etc, user exit will be called and calculates special allowance component automatically based on other wage types amounts. Hence it defaults calculated amount for wage type ‘1010’ in infotype 0008 as shown in below screenshot.

 

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