Thursday, 13 April 2017

Calculate Annual Salary by reducing Total Allowance in SF





  METHOD if_hrsfi_comp_field_extractor~get_field_value.
    DATA:
      ls_p0008  TYPE p0008,
      lv_salary TYPE p0008-ansal.

    CLEAR ev_field_value.

    READ TABLE it_p0008 INTO ls_p0008 WITH KEY subty '0'.
    CHECK sy-subrc EQ 0.

    CASE iv_field_id.
      WHEN 'LOCAL_CURRENCY_CODE'.
        " Is a conversion needed here?  How does SFSF handle USD5?
        ev_field_value ls_p0008-waers.
        RETURN.
      WHEN 'EMPLOYMENT_PERCENTAGE'.
        CALL METHOD cl_hrsfi_comp_utilities=>convert_number_to_string
          EXPORTING
            iv_number ls_p0008-bsgrd
          IMPORTING
            ev_string ev_field_value.
        RETURN.
      WHEN 'CUR_SALARY'.
        CALL METHOD cl_hrsfi_comp_utilities_salary=>get_salary
          EXPORTING
            iv_leading_pernr iv_leading_pernr
            iv_frequency     cl_hrsfi_comp_constants=>cv_payroll_frequency_annual
            iv_keydate       iv_keydate
            is_p0001         is_p0001
            is_p0008         ls_p0008
          IMPORTING
            ev_salary        lv_salary.
        DATAlv_tot_alw TYPE pa9012-tot_alw.
        SELECT tot_alw UP TO ROWS FROM pa9012 INTO lv_tot_alw
                                 WHERE pernr iv_leading_pernr
                                   AND endda >= sy-datum
                                   AND begda <= sy-datum.
        ENDSELECT.
        IF sy-subrc EQ AND lv_salary GT 0.
          lv_salary lv_salary lv_tot_alw.
        ENDIF.
        CALL METHOD cl_hrsfi_comp_utilities=>convert_number_to_string
          EXPORTING
            iv_number   lv_salary
            iv_currency ls_p0008-waers
          IMPORTING
            ev_string   ev_field_value.
      WHEN 'SALARY_TYPE'.

        CALL METHOD cl_hrsfi_comp_utilities_salary=>get_payroll_frequency_text
          EXPORTING
            iv_leading_pernr iv_leading_pernr
            iv_frequency     cl_hrsfi_comp_constants=>cv_payroll_frequency_annual
            iv_keydate       iv_keydate
            iv_language      iv_language
            is_p0001         is_p0001
            is_p0008         ls_p0008
          IMPORTING
            ev_field_value   ev_field_value.

      WHEN 'UNITS_PER_YEAR'.
        ev_field_value '1.00'.

      WHEN OTHERS.
    ENDCASE.


  ENDMETHOD.




No comments:

Post a Comment