Skip to Content

Indirect valuation of Wage type using BAdI : HR_INDVAL


     This document explains the implementing procedure of Business Add-In : HR_INDVAL for indirect valuation/calculation of wage types in info type 0008.  Indirect valuation module can be used to determine amount for a wage type depending on other wage types or the pay scale structure.  ABAP code for calculation should be mentioned in the method DO_INDIRECT_VALUATION

Overview of Business requirement

     Standard indirect evaluation modules are supplied by SAP to meet basic requirements of indirect valuation.  Custom module should be created and activated only if the standard modules does not fit to the requirement.  BAdI HR_INDVAL is filter dependent and custom module will act as the filter value.

    Custom module is used to calculate HRA (House rent allowance) based on % of employee BASIC salary.   HRA is calculated based on the employee master parameters Employee group, Employee subgroup and City type to which employee belongs.   Custom Z table is used to create the master data for maintaining HRA% to BASIC salary based on above parameters.  Indirect valuation module use Z table records to calculate the HRA amount.

     Custom table for HRA% to BASIC maintained as


Create Custom Indirect evaluation module

     Custom module can be created using the IMG Path : SAP IMG -> Personnel Management -> Personnel Administration -> Payroll data -> Indirect Valuation -> Create Indirect valuation module.  This module will appear as the value for filter type PADIV_MODULE while creating BAdI implementation.


Create BAdI Implementation

  • Create BAdI implementation using IMG path :  SAP IMG -> Personnel Management -> Personnel Administration -> Payroll data -> Indirect Valuation -> BAdI : Maintain Indirect Valuation Module.  Implementation can also be created using transaction code SE19.  Initial screen will display existing valuation modules. 


  • Select ‘New’ button to create an implementation.


  • Subsequent screen displaying new implementation


  • Click on “+” button to add custom module (ZHRA) as value to filter type PADIV_MODULE


  • Go to “Interface” tab and double click on the method “DO_INDIRECT_VALUATION” to implement the method.


  • Write the code for indirect valuation (calculation) and activate the method & BAdI implementation.  Some part of Sample code for calculating the HRA based on custom Z table mentioned below.

TYPES : BEGIN OF ty_lgart,

            lgart TYPE lgart,

            betxx TYPE pad_amt7s,

          END OF ty_lgart.

  DATA : lt_p0008 TYPE p0008_tab,

         lt_p0001 TYPE p0001_tab,

         lt_p0006 TYPE p0006_tab,

         lt_zival TYPE STANDARD TABLE OF zhcm_003_ival, “Z table with HRA% to Basic”

         lt_lgart TYPE STANDARD TABLE OF ty_lgart.

  DATA : wa_p0008 TYPE p0008,

         wa_p0001 TYPE p0001,

         wa_p0006 TYPE p0006,

         wa_zival TYPE zhcm_003_ival,   “Z table with HRA% to Basic”

         wa_lgart TYPE ty_lgart.

  DATA : lv_subrc TYPE sy-subrc,

         lv_persg TYPE persg,

         lv_persk TYPE persk,

         lv_busrt TYPE busrt,

         lv_bet01 TYPE pad_amt7s,

         lv_no    TYPE n LENGTH 2,

         lv_lgart TYPE c LENGTH 15,

         lv_betxx TYPE c LENGTH 15.

  DATA : lr_struct_descr TYPE REF TO cl_abap_structdescr.

  FIELD-SYMBOLS : <fs_lgart> TYPE lgart,

                  <fs_betxx> TYPE pad_amt7s,

                  <fs_components> LIKE LINE OF cl_abap_structdescr=>components,

                  <fs_comp>       TYPE any.

  lr_struct_descr ?= cl_abap_typedescr=>describe_by_data(

                                             p_data = wa_p0008 ).

  CLEAR : lv_subrc.


** Read infotype 0001 to Employee organization assignment details **




      tclas           = tclas

      pernr           = pernr

      infty           = ‘0001’

      begda           = begda

      endda           = endda


      subrc           = lv_subrc


      infty_tab       = lt_p0001


      infty_not_found = 1

      undefined_error = 2

      OTHERS          = 3.


** Read IT 0006 using HR_INDVAL_READ_INFOTYPE and output in lt_p0006

** Read IT 0008 using HR_INDVAL_READ_INFOTYPE and output in lt_p0008


        CLEAR : wa_p0001.

        READ TABLE lt_p0001 INTO wa_p0001 INDEX 1.

        IF sy-subrc EQ 0.

          MOVE wa_p0001-persg TO lv_persg.   “Employee group

          MOVE wa_p0001-persk TO lv_persk.   “Employee subgroup


        CLEAR : wa_p0006.

        READ TABLE lt_p0006 INTO wa_p0006 WITH KEY subty = ‘1’.

        IF sy-subrc EQ 0.

          MOVE wa_p0006-busrt TO lv_busrt.   “City type”



** Read infotype 0008 work area and convert to internal table


        lv_no = ’01’.


          CONCATENATE ‘LGA’ lv_no INTO lv_lgart.

          CONCATENATE ‘BET’ lv_no INTO lv_betxx.

          READ TABLE lr_struct_descr->components ASSIGNING <fs_components>

                                              WITH KEY name = lv_lgart.

          IF sy-subrc EQ 0.

            UNASSIGN <fs_comp>.

            ASSIGN COMPONENT <fs_components>-name

                             OF STRUCTURE wa_p0008 TO <fs_comp>.

            IF sy-subrc EQ 0.

              ASSIGN <fs_comp> TO <fs_lgart>.

              UNASSIGN <fs_components>.

              READ TABLE lr_struct_descr->components ASSIGNING <fs_components>

                                                  WITH KEY name = lv_betxx.

              IF sy-subrc EQ 0.

                UNASSIGN <fs_comp>.

                ASSIGN COMPONENT <fs_components>-name

                             OF STRUCTURE wa_p0008 TO <fs_comp>.

                IF sy-subrc EQ 0.

                  ASSIGN <fs_comp> TO <fs_betxx>.

                  MOVE <fs_lgart> TO wa_lgart-lgart.

                  MOVE <fs_betxx> TO wa_lgart-betxx.

                  IF wa_lgart NE ” AND wa_lgart-betxx NE 0.

                    APPEND wa_lgart TO lt_lgart.








          ADD 1 TO lv_no.



** Calculate Basic pay for HRA calculation (Currently hardcoded)  **


        LOOP AT lt_lgart INTO wa_lgart WHERE ( lgart EQ ‘9001’ OR

                                             lgart EQ ‘9002’ ).

          ADD wa_lgart-betxx TO lv_bet01.



** Calculate HRA amount based on Z table                          **


    IF lv_busrt EQ ‘M’ OR lv_busrt EQ ‘S’ OR lv_busrt EQ ‘O’.

      IF ( lv_persg IS NOT INITIAL AND

           lv_persk IS NOT INITIAL AND

           lv_busrt IS NOT INITIAL AND

           lv_bet01 GT 0 ).

        CLEAR : wa_zival.

        SELECT SINGLE * FROM zhcm_003_ival

        INTO wa_zival

        WHERE lgart     = lgart

        AND   persg     = lv_persg

        AND   persk     = lv_persk

        AND   city_type = lv_busrt

        AND   endda     >= endda

        AND   begda     &lt;= begda.

        IF sy-subrc EQ 0.

          CLEAR : lv_mod10.

          MOVE-CORRESPONDING valuation_input TO valuation_output.

          valuation_output-amount = ( lv_bet01 * wa_zival-rate_perc ) / 100.    


**        Error : HRA Calculation Table not maintained”



                  msgty = ‘E’

                  msgid = ‘ZHCM’

                  msgno = ‘002’.

              move 4 to subrc.

              MESSAGE ID ‘ZHCM’ TYPE ‘E’ NUMBER ‘002’

                      RAISING error_indval.




**       “Error : Invalid City type in Infotype 0006”



              msgty = ‘E’

              msgid = ‘ZHCM’

              msgno = ‘001’.

          move 4 to subrc.

          MESSAGE ID ‘ZHCM’ TYPE ‘E’ NUMBER ‘001’

                  RAISING error_indval.


Wage type assignment to Indirect valuation module

     Wage type (in this scenario – Wage type for HRA) need to be linked with the indirect valuation module, to activate the calculation implemented in BAdI.  Wage type can be linked with Module using the IMG Path : SAP IMG -> Payroll -> Payroll : &lt;country> -> Reimbursements, Allowances & Perks -> Maintain Wage type characteristics.  This can also be accessed through transaction code OH13




Note : ABAP source code and scenario mentioned above are only for representational purpose.  Source code may change according to the actual business requirement.

You must be Logged on to comment or reply to a post.
  • I have followed the same procedure as mentioned above for the indirect valuation . Its working fine in basic infotype 8 but my wage type isn’t getting generated in payslip , although it was displaying earlier before making any changes in badi ‘ HR_INVAL’ . Please suggest me solution regarding any other configuration of this custom indirect evaluation module which i am missing in this case.


  • i Need to check wage type in indirect valuation which table i have to access to check it, could you please tell me which table or any helpful t-code