Download Android App of sapabap-vamsi

sapabap-vamsi : Download Android App for Mobiles

Sunday, September 18, 2011

Annual Salary


*&---------------------------------------------------------------------*
*& Report  ZANNUAL_SALARY
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  ZANNUAL_SALARY NO STANDARD PAGE HEADING LINE-SIZE 231
                                       LINE-COUNT 60
                                       MESSAGE-ID z00.

INFOTYPES: 2010,
           0008,
           0001,
           2001.

TABLES : pernr,                                                         "Standard Selections for HR Master Data Reporting
         t001p,                                                         "Personnel Area/Subarea
         pa2010,                                                        "HR Time Record: Infotype 2010 (Employee Remuneration Info.)
         pa0009,                                                        "HR Master Record: Infotype 0009 (Bank Details)
         pa0008,                                                        "HR Master Record: Infotype 0008 (Basic Pay)
         pa0001,                                                        "HR Master Record: Infotype 0001 (Org. Assignment)
         pc207,                                                         "Payroll Results: Results Table
         t512t,                                                         "Wage Type Texts
         t012t,
         hrpy_rgdir,                                                    "Directory for Payroll Results
         q0008,
         pa2001,                                                        "HR Time Record: Infotype 2001 (Absences)
         pa2006,
         ZHR_BARGAINS.                                                        "HR Time Record: Infotype 2006 (Absence Quotas)


DATA:    v_btext          LIKE t001p-btext,                             "Personnel Subarea Text
         v_btrtl          LIKE pa0001-btrtl,
         v_werks          LIKE t001p-werks,
         v_molga          LIKE t001p-molga,
*        v_totalemp(4)    TYPE n  VALUE 0,
         v_lgart          LIKE t512t-lgart,
         v_kztxt          LIKE t512t-kztxt,
         v_tstid          LIKE pa0587-tstid,
         v_burks          LIKE t500p-bukrs,
         g_molga(2)       TYPE n VALUE 40,                              "Since the country grping for INDIA is 40.
         v_wage           LIKE t512t-lgart,
         v_wagetext       LIKE t512t-kztxt,
         p_v_wage         LIKE t512t-lgart,
         p_v_wagetext     LIKE t512t-kztxt.

DATA:    str1(100)        TYPE c VALUE 'SHREE PRECOATED STEELS LTD,SANASWADI',
         str2(34)         TYPE c VALUE 'WAGES REGISTER FOR THE MONTH OF:',
         str3(10)         TYPE c VALUE 'DIVISION :',
         str4(8)          TYPE c VALUE 'PAGE NO:',
         str5(14)         TYPE c VALUE 'tot.EARN    =',
         str6(14)         TYPE c VALUE 'LOP         =',
         str7(14)         TYPE c VALUE 'GROSS SALARY=',
         str8(14)         TYPE c VALUE 'TOT.DED     =',
         str9(14)         TYPE c VALUE 'ARREARS     =',
         str10(14)        TYPE c VALUE 'NET SALARY  =',
         v_month(2)       TYPE n,
         v_year           TYPE pa0001-btrtl,
*         v_month_spell    TYPE pa0001-uname,
         v_month_spell(15) TYPE c,
         v_count(4)       TYPE n VALUE 0,
         v_count1(4)      TYPE n VALUE 0,
         v_pymonth(2)     TYPE n,
         v_pyyear(4)      TYPE n,
         name(40)         TYPE c,
         par_month        TYPE n LENGTH 2,
         par_year         TYPE n LENGTH 4,
         in_month         TYPE n LENGTH 2,
         in_year          TYPE n LENGTH 4,
         days             TYPE t009b-butag,
*         ta               TYPE t009b-butag,
         ta               TYPE p DECIMALS 2,
         v_lop            TYPE pa2001-kaltg,
         v_space          TYPE c LENGTH 5.

DATA  i_month LIKE pa0001-btrtl.
DATA  i_year  LIKE pa0001-uname.
DATA  p_period1 TYPE n LENGTH 6.
DATA  p_period2 TYPE n LENGTH 6.

DATA  e_date TYPE n LENGTH 8.
DATA  s_date TYPE n LENGTH 8.
DATA  s1_date TYPE n LENGTH 8.
DATA  e1_date TYPE n LENGTH 8.
DATA  a_date TYPE n LENGTH 8.
DATA  b_date TYPE n LENGTH 8.


DATA : filename TYPE string.
DATA:    l_actual         VALUE space,
         l_wagetyp        LIKE  t512t-lgart,
         l1_wagetyp       LIKE  q0008-lgart.



DATA:    BEGIN OF it_0001 OCCURS 0,

           pernr       LIKE pa0001-pernr,                               "Personnel number
           werks       LIKE pa0001-werks,                               "personnel area
           molga       LIKE t001p-molga,                                "country grouping
           bukrs       LIKE t500p-bukrs,                                "company code
           abkrs       LIKE pa0001-abkrs,                               "PAYROLL AREA
           ename       LIKE pa0001-ename,                               "Formatted Name of Employee or Applicant
           btrtl       LIKE pa0001-btrtl,                               "Personnel Subarea
           kaltg       LIKE pa2001-kaltg,
           persg       LIKE pa0001-persg,
           persk       LIKE pa0001-persk,                               "Employee Subgroup
           plans       LIKE pa0001-plans,
           otype       LIKE pa0001-otype,
           trfgr       LIKE pa0008-trfgr,
           trfst       LIKE pa0008-trfst,
           pfnumber    LIKE pa0587-eepfn,
           esinumber   LIKE pa0588-esino,
           pannumber   LIKE pa0185-icnum,                               "pannumber ictyp 02
           bank        LIKE t012t-text1,
           acno        LIKE pa0009-bankn,
           division    LIKE t001p-btext,
*           nwd         LIKE t009b-butag,
*           p_days      LIKE t009b-butag,
           nwd         TYPE p DECIMALS 2,
           p_days      TYPE p DECIMALS 2,
           designation LIKE t528t-plstx,
           jobgroup(10),                                                "like pa0008-trfgr,
           fat_nam     LIKE pa0001-ename,
           begda       LIKE pa0001-begda,
           name1       like t500p-name1,
         END OF it_0001.

DATA : it_0001a LIKE it_0001 OCCURS 0 WITH HEADER LINE.
DATA: BEGIN OF it_0021 OCCURS 0,

pernr     LIKE pa0021-pernr,
fanam     LIKE pa0021-fanam,
favor     LIKE pa0021-favor,
fam_nam   TYPE c LENGTH 40,
famsa     LIKE pa0021-famsa,
fgbdt     LIKE pa0021-fgbdt,

END OF it_0021.





DATA:    BEGIN OF it_2010 OCCURS 0,

           pernr       LIKE pa2010-pernr,                               "Personnel number
           stdaz       LIKE pa2010-stdaz,                               "Bank Account Number
           lgart       LIKE pa2010-lgart,                               "wage type
           p_period    LIKE pc261-fpper,                                "period

         END OF it_2010.

DATA:    BEGIN OF it_0587 OCCURS 0,

           pernr       LIKE pa0587-pernr,
           begda       LIKE pa0587-begda,
           eepfn       LIKE pa0587-eepfn,

         END OF it_0587.

DATA:    it_t012t      LIKE  t012t OCCURS 0 WITH HEADER LINE.
DATA :   it_0588       LIKE pa0588 OCCURS 0 WITH HEADER LINE.
DATA :   it_2006       LIKE pa2006 OCCURS 0 WITH HEADER LINE.          "itab fro HR Time Record: Infotype 2006 (Absence Quotas)


DATA:    BEGIN OF it_0009 OCCURS 0,

            pernr      LIKE pa0009-pernr,                               "Personnel number
            bankn      LIKE pa0009-bankn,                               "Bank Account Number
            bankl      LIKE pa0009-bankl,                               "Bank Key
            bank       LIKE t012t-text1,

         END OF it_0009.

DATA:    BEGIN OF it_rgdir  OCCURS 0,

            pernr      LIKE hrpy_rgdir-pernr,                           "Personnel Number
            abkrs      LIKE hrpy_rgdir-abkrs,                           "Payroll Area
            fpper      LIKE hrpy_rgdir-fpper,                           "For-period for payroll
            fpend      LIKE hrpy_rgdir-fpend,                           "End of payroll period (for-period)
            inper      LIKE hrpy_rgdir-inper,                           "In-period for payroll
            srtza      LIKE hrpy_rgdir-srtza,                           "Indicator: Status of record
            permo      LIKE hrpy_rgdir-permo,                           "Period parameters
            molga      LIKE hrpy_rgdir-molga,                           "Country Grouping
            ename      LIKE pa0001-ename,
            stdaz      LIKE pa2010-stdaz,
            btrtl      LIKE pa0001-btrtl,
            p_period   LIKE pc261-fpper,

         END OF it_rgdir.

DATA:    it_display    TYPE zhr_payslip OCCURS 0 WITH HEADER LINE.

DATA : IT_DISPLAY1 LIKE ZHR_BARGAINS OCCURS 0 WITH HEADER LINE.



DATA:    it_2001 LIKE pa2001 OCCURS 10 WITH HEADER LINE.
DATA:    it_2001a LIKE pa2001 OCCURS 10 WITH HEADER LINE.
DATA:    it_2001b LIKE pa2001 OCCURS 10 WITH HEADER LINE.
DATA :   it_0008       LIKE pa0008 OCCURS 0 WITH HEADER LINE.
DATA :   it_008        LIKE pa0008 OCCURS 0 WITH HEADER LINE.
DATA:    it_payroll    TYPE payin_result OCCURS 0 WITH HEADER LINE,     "Internal tab for reading payroll
         wa_payroll    LIKE LINE OF it_payroll.                         "Work area for reading payroll


DATA:    it_ls_result  TYPE pay99_result.

DATA:    wa_rt         LIKE LINE OF it_ls_result-inter-rt.
DATA:    wa_epf        LIKE LINE OF it_ls_result-inter-rt.


DATA:    it_t512t      LIKE  t512t OCCURS 0 WITH HEADER LINE,           "Internal tab for wagetype text
         wa_t512t      LIKE LINE OF it_t512t.                           "Work area for wagetype text


DATA:    it_temp       LIKE it_rgdir OCCURS 0 WITH HEADER LINE.
DATA:    wa_rgdir      LIKE LINE OF it_rgdir.

DATA: g_fm_name        TYPE rs38l_fnam.                                 "Name of Function Module
DATA: fm_name TYPE rs38l_fnam.
DATA : sfname  TYPE tdsfname.
DATA : sbegda  LIKE pa0001-begda.
DATA : p_days TYPE p DECIMALS 2.

data : T11 TYPE P,
      T22 TYPE P.


*&---------------------------------------------------------------------*
*&                        SELECTION-SCREEN                             *
*&---------------------------------------------------------------------*

SELECTION-SCREEN: BEGIN OF BLOCK b2 WITH  FRAME TITLE text-002.
SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH  FRAME TITLE text-001.
SELECTION-SCREEN SKIP 1.

PARAMETERS :       p_period LIKE pc261-fpper OBLIGATORY,                "Month for which payslip is to be received
                   p_area LIKE pa0001-abkrs OBLIGATORY.                 "The Personnel Subarea for which the report is to be received

*                   p_area LIKE pa0001-btrtl OBLIGATORY.                 "The Personnel Subarea for which the report is to be received
*SELECT-OPTIONS :   s_pernr  FOR pa0001-pernr.                           "The Personnel Number range for which the report is to be received
*PARAMETERS   p_fname   LIKE ibipparms-path OBLIGATORY.

SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN:END OF BLOCK b1.
SELECTION-SCREEN:END OF BLOCK b2.

SELECTION-SCREEN: BEGIN OF BLOCK b14 WITH  FRAME TITLE text-007.
SELECTION-SCREEN: BEGIN OF BLOCK b10 WITH  FRAME TITLE text-006.
SELECTION-SCREEN SKIP 1.

PARAMETERS : c_range AS CHECKBOX USER-COMMAND r, "DEFAULT 'X'.         "range for which payslip is to be received
             c_group AS CHECKBOX USER-COMMAND r.                       "staff and workers for which payslip is to be received

SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN:END OF BLOCK b10.
SELECTION-SCREEN:END OF BLOCK b14.


SELECTION-SCREEN BEGIN OF BLOCK b9 WITH FRAME TITLE text-040.

SELECT-OPTIONS: s_pernr   FOR  pa0001-pernr MODIF ID b9.                 "range of employees

SELECTION-SCREEN END OF BLOCK b9.


SELECTION-SCREEN: BEGIN OF BLOCK b3 WITH FRAME TITLE text-009.

PARAMETERS : c_staf AS CHECKBOX  MODIF ID b3 USER-COMMAND r,
             c_work AS CHECKBOX  MODIF ID b3 USER-COMMAND r.

SELECTION-SCREEN:END OF BLOCK b3.



AT SELECTION-SCREEN OUTPUT.

  IF c_range EQ ' ' .
    LOOP AT SCREEN .
      IF screen-group1 = 'B9'.
        screen-active = 0.
        MODIFY SCREEN.
      ENDIF.
    ENDLOOP.
  ELSE.
    LOOP AT SCREEN .
      IF screen-group1 = 'B9'.
        screen-active = 1.
        MODIFY SCREEN.
      ENDIF.
    ENDLOOP.
  ENDIF.

  IF c_group EQ ' ' .
    LOOP AT SCREEN .
      IF screen-group1 = 'B3'.
        screen-active = 0.
        MODIFY SCREEN.
      ENDIF.
    ENDLOOP.
  ELSE.
    LOOP AT SCREEN .
      IF screen-group1 = 'B3'.
        screen-active = 1.
        MODIFY SCREEN.
      ENDIF.
    ENDLOOP.
  ENDIF.


START-OF-SELECTION.

  PERFORM get_month .                                                   "To spell month as given in parameter.
  PERFORM get_0001_data.                                                "To get the employee name and personal area
  PERFORM get_lgart_data.                                               "To fetch lgart data frm t512t
  PERFORM get_rgdir_data.                                               "To fetch all fields frm rgdir depending on it_2010-pernr
  PERFORM get_0008_data.                                                "To fetch employee designation
  PERFORM get_pfnum.                                                    "To fetch PF Number of employee
  PERFORM get_esinum.                                                   "To fetch ESI Number of employee
  PERFORM get_bank.                                                     "To fetch BANK Details of employee
  PERFORM get_division.                                                 "To fetch DIVISION Details of employee
  PERFORM calender_days.                                                "To get the number of days in a month.
  PERFORM pannumber_data  .                                             "To get the pannumber data of an employee
  PERFORM leaves_data  .                                                "To get the leaves data of an employee for a year.
  PERFORM get_payroll_data.                                             "to fetch values frm payin_result-inter-rt table
  PERFORM total_earning.
  PERFORM get_form_name .                                               "To get the function module o/p of smartform
  PERFORM call_form.                                                    "Calling the function module
  PERFORM download.
*INITIALIZATION.

*&---------------------------------------------------------------------*
*&                        TOP-OF-PAGE                                  *
*&---------------------------------------------------------------------*
TOP-OF-PAGE.
  PERFORM header_data.

*&---------------------------------------------------------------------*
*&                        END-OF-SELECTION                             *
*&---------------------------------------------------------------------*
END-OF-SELECTION.
  PERFORM it_display.

*&---------------------------------------------------------------------*
*&      Form  get_month
*&---------------------------------------------------------------------*
FORM get_month.

  DATA: l_year(4) TYPE n.
  l_year  = p_period+0(4).
  v_month = p_period+4(2).

  CASE v_month.

    WHEN '10'.
      v_month_spell = 'January'.
      in_month     = '01'.
      in_year      = l_year + 1.
      v_year        = l_year + 1.
      v_pymonth     = 01.
    WHEN '11'.
      v_month_spell = 'February'.
      in_month     = '02'.
      in_year      = l_year + 1.
      v_year        = l_year + 1.
      v_pymonth     = 02.
    WHEN '12'.
      v_month_spell = 'March'.
      in_month     = '03'.
      in_year      = l_year + 1.
      v_year        = l_year + 1.
      v_pymonth     = 03.
    WHEN '01'.
      v_month_spell = 'April'.
      in_month     = '04'.
      in_year      = l_year.
      v_year        = l_year.
      v_pymonth     = 04.
    WHEN '02'.
      v_month_spell = 'May'.
      in_month     = '05'.
      in_year      = l_year.
      v_year        = l_year.
      v_pymonth     = 05.
    WHEN '03'.
      v_month_spell = 'June'.
      in_month     = '06'.
      in_year      = l_year.
      v_year        = l_year.
      v_pymonth     = 06.
    WHEN '04'.
      v_month_spell = 'July'.
      in_month     = '07'.
      in_year      = l_year.
      v_year        = l_year.
      v_pymonth     = 07.
    WHEN '05'.
      v_month_spell = 'August'.
      in_month     = '08'.
      in_year      = l_year.
      v_year        = l_year.
      v_pymonth     = 08.
    WHEN '06'.
      v_month_spell = 'September'.
      in_month     = '09'.
      in_year      = l_year.
      v_year        = l_year.
      v_pymonth     = 09.
    WHEN '07'.
      v_month_spell = 'October'.
      in_month     = '10'.
      in_year      = l_year.
      v_year        = l_year.
      v_pymonth     = 10.
    WHEN '08'.
      v_month_spell = 'November'.
      in_month     = '11'.
      in_year      = l_year.
      v_year        = l_year.
      v_pymonth     = 11.
    WHEN '09'.
      v_month_spell = 'December'.
      in_month     = '12'.
      in_year      = l_year.
      v_year        = l_year.
      v_pymonth     = 12.
  ENDCASE.




ENDFORM.                    "get_month
*&---------------------------------------------------------------------*
*&      Form  GET_0001_DATA                                            *
*&---------------------------------------------------------------------*
*       TO GET EMPLOYEE NUMBER,FULLNAME                                *
*----------------------------------------------------------------------*

FORM get_0001_data .

  IF c_range EQ 'X'. "IS NOT INITIAL.

    SELECT pernr ename btrtl werks persg abkrs plans persk otype
         FROM pa0001
         INTO CORRESPONDING FIELDS OF TABLE it_0001
         WHERE abkrs = p_area                          "WHERE btrtl = p_area
         AND persg = '1'                               "'R'
         AND abkrs IN ('S1')                          "('MH', 'YM', 'BM', 'YW','BW').
         AND pernr IN s_pernr
         AND endda > sy-datum.

    IF sy-subrc <> 0.
*      MESSAGE i001.
      LEAVE TO LIST-PROCESSING.
      EXIT.
    ENDIF.

  ELSEIF c_group EQ 'X'.

    IF c_staf EQ 'X'.

      SELECT pernr ename btrtl werks persg abkrs plans persk otype
         FROM pa0001
         INTO CORRESPONDING FIELDS OF TABLE it_0001
         WHERE abkrs = p_area                          "WHERE btrtl = p_area
         AND persg = '1'                               "'R'
         AND abkrs IN ('S1')                          "('MH', 'YM', 'BM', 'YW','BW').
         AND pernr IN s_pernr
         AND endda > sy-datum.


      SELECT * FROM pa0008 INTO TABLE it_0008
               FOR ALL ENTRIES IN it_0001
               WHERE pernr = it_0001-pernr
               AND trfst IN ('E1','E2','E3','E4','E5','E6','E7','E8','E9','J1','J2','J3','SS','WM').

      LOOP AT it_0001.
        LOOP AT it_0008
        WHERE pernr = it_0001-pernr
        AND trfst <> 'GR'.
          MOVE-CORRESPONDING it_0001 TO it_0001a.
          MOVE it_0008-trfst TO it_0001a-trfst.
          APPEND it_0001a.
        ENDLOOP.
      ENDLOOP.

      it_0001[] = it_0001a[].


      IF sy-subrc <> 0 .
        MESSAGE i016.
        LEAVE LIST-PROCESSING.

      ENDIF.


    ELSE. " c_staf EQ 'X'.


      SELECT pernr ename btrtl werks persg abkrs plans persk otype
         FROM pa0001
         INTO CORRESPONDING FIELDS OF TABLE it_0001
         WHERE abkrs = p_area                        "WHERE btrtl = p_area
         AND persg = '1'                             "'R'
*         AND persk = '09'                           "'SE'
         AND abkrs IN ('S1')                        "('MH', 'YM', 'BM', 'YW','BW').
*         and trfst in ( 'GR' )
         AND pernr IN s_pernr
         AND endda > sy-datum.


      SELECT * FROM pa0008 INTO TABLE it_0008
      FOR ALL ENTRIES IN it_0001
      WHERE pernr = it_0001-pernr
      AND trfst IN ('GR','GR1','GR2','GR3','GR4','GR5').



      LOOP AT it_0001.
        LOOP AT it_0008
        WHERE pernr = it_0001-pernr
        AND trfst = 'GR'.
          MOVE-CORRESPONDING it_0001 TO it_0001a.
          MOVE it_0008-trfst TO it_0001a-trfst.
          APPEND it_0001a.
        ENDLOOP.
      ENDLOOP.

      it_0001[] = it_0001a[].

      IF sy-subrc <> 0 .

        MESSAGE i016.
        LEAVE LIST-PROCESSING.

      ENDIF.

    ENDIF.

  ENDIF.

  SORT it_0001 BY pernr.

ENDFORM.                    " GET_0001_DATA
*&---------------------------------------------------------------------*
*&      Form  get_rgdir_data                                           *
*&---------------------------------------------------------------------*
*       TO GET EMPLOYEE AMOUNT FOR PARTICULAR PERIOD                   *
*----------------------------------------------------------------------*
FORM get_rgdir_data .

  SELECT pernr abkrs fpper inper srtza permo molga
         FROM hrpy_rgdir
         INTO CORRESPONDING FIELDS OF TABLE it_rgdir
         FOR ALL ENTRIES IN it_0001
         WHERE pernr = it_0001-pernr
         AND abkrs IN ('S1')                                    "AND abkrs IN ('MH', 'YM', 'BM', 'YW','BW')
         AND fpper EQ p_period AND inper EQ p_period.

  CLEAR it_rgdir.
ENDFORM.                    " get_rgdir_data

*&---------------------------------------------------------------------*
*&      Form  get_lgart_data                                           *
*&---------------------------------------------------------------------*
*         TO GET WAGETYPE                                 *
*----------------------------------------------------------------------*

FORM get_lgart_data .

  SELECT * FROM t512t
           INTO TABLE it_t512t
           WHERE sprsl = sy-langu
           AND molga = '40'.
ENDFORM.                    " get_lgart_data
*&---------------------------------------------------------------------*
*&      Form  get_payroll_data                                         *
*&---------------------------------------------------------------------*
*       TO GET PAYROLL DATA                                            *
*----------------------------------------------------------------------*
FORM get_payroll_data .

  DATA : l_subty  TYPE pa2006-subty.

  DATA: v_pabrj  TYPE pabrj,
        v_pabrp  TYPE pabrp.

  LOOP AT it_0001.

    it_display-ec           =   it_0001-pernr.
    it_display-ename        =   it_0001-ename.
    it_display-jobgrade     =   it_0001-jobgroup.
    it_display-pfnumber     =   it_0001-pfnumber.
    it_display-esinumber    =   it_0001-esinumber.
    it_display-bank         =   it_0001-bank.
    it_display-acno         =   it_0001-acno.
    it_display-pannumber    =   it_0001-pannumber.
    it_display-division     =   it_0001-division.                                  "dept.
    it_display-designation  =   it_0001-designation.
    it_display-nwd          =   it_0001-nwd.
    it_display-p_days       =   it_0001-p_days.
    it_display-btrtl        =   it_0001-btrtl.
    it_display-name1        =   it_0001-name1.

    APPEND it_display.

    CLEAR it_display.

  ENDLOOP.

  LOOP AT it_2006.

    IF it_2006-subty = '01'.
      it_2006-subty = 'CL'.
      MODIFY it_2006.
    ENDIF.

    IF it_2006-subty = '02'.
      it_2006-subty = 'SL'.
      MODIFY it_2006.
    ENDIF.

    IF it_2006-subty = '03'.
      it_2006-subty = 'PL'.
      MODIFY it_2006.
    ENDIF.

  ENDLOOP.


  LOOP AT it_display.

    LOOP AT it_2006
    WHERE pernr = it_display-ec.


      IF it_2006-subty = 'CL'.                                         " casual leave
        it_display-l_c_open   = it_2006-anzhl.
      ENDIF.

      IF it_2006-subty = 'SL'.                                                " sick leave
        it_display-l_s_open   = it_2006-anzhl .
      ENDIF.

      IF it_2006-subty = 'PL'.                                                  "Privilege leave
        it_display-l_e_open  = it_2006-anzhl.
      ENDIF.

      MODIFY it_display.

    ENDLOOP.
  ENDLOOP.

  LOOP AT it_display.
    LOOP AT it_2001
    WHERE pernr = it_display-ec.

      IF it_2001-subty = 'CL'.
*        it_display-l_c_open   = it_display-l_c_open - it_2001-abwtg.
        it_display-l_c_open   = it_display-l_c_open - it_2001-kaltg.

      ENDIF.
      IF it_2001-subty = 'SL'.
*        it_display-l_s_open   = it_display-l_s_open - it_2001-abwtg.
        it_display-l_s_open   = it_display-l_s_open - it_2001-kaltg.

      ENDIF.
      IF it_2001-subty = 'PL'.
*        it_display-l_e_open  = it_display-l_e_open - it_2001-abwtg.
        it_display-l_e_open  = it_display-l_e_open - it_2001-kaltg.

      ENDIF.
      MODIFY it_display.
    ENDLOOP.
  ENDLOOP.



  it_2001[] = it_2001b[].
  it_2001a[] = it_2001b[].

  LOOP AT it_2001.
    it_2001-endda = it_2001-endda+0(6).
    MODIFY it_2001.
  ENDLOOP.

  p_period1 = p_period1 - 1.

  LOOP AT it_2001.
    IF it_2001-endda <> p_period1.
      DELETE it_2001 INDEX sy-tabix.
    ENDIF.
  ENDLOOP.

  SORT it_2001a BY subty.
  DELETE ADJACENT DUPLICATES FROM it_2001a COMPARING subty.

  LOOP AT it_2001a.
*    it_2001a-abwtg = 0.
    it_2001a-kaltg = 0.
    MODIFY it_2001a.
    LOOP AT it_2001
    WHERE pernr = it_2001a-pernr AND
    subty = it_2001a-subty.
    it_2001a-kaltg = it_2001a-kaltg + it_2001-kaltg.
*      it_2001a-abwtg = it_2001a-abwtg + it_2001-abwtg.
      MODIFY it_2001a.
    ENDLOOP.
  ENDLOOP.

  LOOP AT it_display.

    LOOP AT it_2001a WHERE pernr = it_display-ec.

      IF it_2001a-subty = 'PL'.
*        it_display-l_e_availed = it_2001a-abwtg.
        it_display-l_e_availed = it_2001a-kaltg.

      ENDIF.

      IF it_2001a-subty = 'CL'.
*        it_display-l_c_availed = it_2001a-abwtg.
        it_display-l_c_availed = it_2001a-kaltg.

      ENDIF.

      IF it_2001a-subty = 'SL'.
*        it_display-l_s_availed = it_2001a-abwtg.
        it_display-l_s_availed = it_2001a-kaltg.

      ENDIF.
      MODIFY it_display.

    ENDLOOP.
  ENDLOOP.


  LOOP AT it_display.

    it_display-l_e_balance = it_display-l_e_open - it_display-l_e_availed .
    it_display-l_c_balance = it_display-l_c_open - it_display-l_c_availed .
    it_display-l_s_balance = it_display-l_s_open - it_display-l_s_availed .

    MODIFY it_display.
  ENDLOOP.




  PERFORM get_008_data.

  LOOP AT it_display.

    LOOP AT it_rgdir WHERE pernr = it_display-ec
                     AND   fpper = p_period AND inper = p_period.

      v_pabrj = it_rgdir-inper(4).
      v_pabrp = it_rgdir-inper+4(2).

      PERFORM get_rt_data USING  v_pabrj
                                 v_pabrp.
      CLEAR: v_pabrj,
             v_pabrp.

    ENDLOOP.

    CLEAR: it_rgdir.

  ENDLOOP.
*****************************************************RR*************************
SELECT * FROM ZHR_BARGAINS INTO CORRESPONDING FIELDS OF TABLE it_display1
  WHERE ZEMPNO = it_0001-pernr.

t11 = it_display1-ztotal * ( 60 / 100 ).
t22 = it_display1-ztotal * ( 40 / 100 ).
*****************************************************RR**************************



ENDFORM.                    " get_payroll_data

FORM get_rt_data    USING  p_v_pabrj
                           p_v_pabrp.


  CLEAR   it_payroll.
  REFRESH it_payroll.

  CALL FUNCTION 'HR_GET_PAYROLL_RESULTS'
    EXPORTING
      pernr                               = it_rgdir-pernr
      permo                               = it_rgdir-permo
      pabrj                               = p_v_pabrj
      pabrp                               = p_v_pabrp

     actual                              = l_actual

    TABLES
      result_tab                          = it_payroll                        "deep structure
    EXCEPTIONS
     no_results                          = 1
     error_in_currency_conversion        = 2
     t500l_entry_not_found               = 3
     period_mismatch_error               = 4
     t549q_entry_not_found               = 5
     internal_error                      = 6
     wrong_structure_of_result_tab       = 7
     OTHERS                              = 8
            .
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

  IF sy-subrc = 0.
    LOOP AT it_payroll INTO wa_payroll WHERE evp-fpper = it_rgdir-fpper
                                       AND   evp-inper = it_rgdir-inper.

      IF  ( wa_payroll-evp-fpper NE wa_payroll-evp-inper ).
        CONTINUE.
      ENDIF.
      IF  ( wa_payroll-evp-srtza EQ 'A' OR wa_payroll-evp-srtza EQ 'P' ).

        IF ( wa_payroll-evp-permo = '01' AND  wa_payroll-evp-inper = p_period ).        "for monthly emp
          PERFORM rt.
        ELSEIF  wa_payroll-evp-permo = '03'.                                            " for weekly emp
          IF ( v_pymonth =  wa_payroll-evp-fpend+4(2) AND v_year = wa_payroll-evp-fpend(4) ).
            PERFORM rt.
          ENDIF.

        ENDIF.

      ENDIF.
      CLEAR wa_payroll.

    ENDLOOP.

  ENDIF.

ENDFORM.                    " get_rt_data
*&---------------------------------------------------------------------*
*&      Form  rt
*&---------------------------------------------------------------------*
FORM rt .

  DATA:     l_wagetyp   LIKE   t512t-lgart,
            l_ot        LIKE   pc207-betrg,
            l_ns2       LIKE   pc207-betrg,
            l_ns3       LIKE   pc207-betrg,
            l_ns        LIKE   pc207-betrg,
            l_total     LIKE   pc207-betrg,
            l_netwages  LIKE   pc207-betrg,
            l_loan      LIKE   pc207-betrg,
            l_total1    LIKE   pc207-betrg.


  LOOP AT it_payroll-inter-rt  INTO wa_rt WHERE lgart = '9001'  OR lgart = '9002' OR
                                                lgart = '9003'  OR lgart = '9004' OR
                                                lgart = '9005'  OR lgart = '9006' OR
                                                lgart = '9007'  OR lgart = '9008' OR
                                                lgart = '9009'  OR lgart = '9010' OR
                                                lgart = '9011'  OR lgart = '9012' OR
                                                lgart = '9013'  OR lgart = '9014' OR
                                                lgart = '9015'  OR lgart = '9016' OR
                                                lgart = '9017'  OR lgart = '9018' OR
                                                lgart = '9019'  OR lgart = '9020' OR
                                                lgart = '9021'  OR lgart = '9022' OR
                                                lgart = '9023'  OR
                                                lgart = '9024'  OR lgart = '9028' OR
                                                lgart = '9029'  OR lgart = '9030' OR
                                                lgart = '9031'  OR lgart = '9032' OR
                                                lgart = '9033'  OR lgart = '9034' OR
                                                lgart = '9035'  OR lgart = '9036' OR
                                                lgart = '9037'  OR lgart = '9101' OR
******************************************rupali******************************************
                                                lgart = '9040'  or lgart = '9041' or
******************************************rupali****************************************

                                                lgart = '9102'  OR lgart = '9103' OR
                                                lgart = '9104'  OR lgart = '9105' OR
                                                lgart = '9106'  OR lgart = '9107' OR
                                                lgart = '9108'  OR lgart = '9109' OR
                                                lgart = '9110'  OR lgart = '9111' OR
                                                lgart = '9112'  OR lgart = '9113' OR
                                                lgart = '9114'  OR lgart = '9115' OR
                                                lgart = '9116'  OR lgart = '9117' OR
                                                lgart = '9118'  OR lgart = '9119' OR
                                                lgart = '9120'  OR lgart = '9121' OR
                                                lgart = '9122'  OR lgart = '9124' OR
                                                lgart = '9125'  OR lgart = '9126' OR
                                                lgart = '9127'  OR lgart = '9128' OR
                                                lgart = '9200' OR
                                                lgart = '/3F1'  OR lgart = '/3P1' OR
                                                lgart = '1000'  OR lgart = '6000' OR
                                                lgart = '6001'  OR lgart = '6002' OR
                                                lgart = '6010'  OR lgart = 'PBS1' OR
                                                lgart = '/101'  OR lgart = '/560' OR
                                                lgart = '/561' OR
                                                lgart = '/110'  OR lgart = '9124' OR
                                                lgart = '/552'  OR lgart = '/ZF5' OR
                                                lgart = '/3W1'  OR
                                                lgart = '2009'  or lgart = '2011'  or
                                                lgart = '1003'  or lgart = '1001' or
                                                lgart = '1005'  or lgart = '1006' or
                                                lgart = '1006'  or lgart = '1008' or
                                                lgart = '2013'  or lgart = '2015' or
                                                lgart = '2019'  or lgart = '2021' or
                                                lgart = '2025'  or lgart = '2027' or
                                                lgart = '2029'  or lgart = '2031' or
                                                lgart = '2033'  or lgart = '2035' or
                                                lgart = '2037'  or lgart = '2039' or
                                                lgart = '2041'  or lgart = '2043' or
                                                lgart = '1004'  or lgart = '2023'.
.

    READ TABLE it_t512t WITH KEY lgart = wa_rt-lgart INTO wa_t512t.
    IF sy-subrc = 0.
      l_wagetyp = wa_rt-lgart.

      CASE l_wagetyp.
        WHEN '9001'.
          it_display-basic = it_display-basic + wa_rt-betrg.

        WHEN '9002'.
          it_display-fda = it_display-fda + wa_rt-betrg.

        WHEN '9003'.
          it_display-hra = it_display-hra + wa_rt-betrg.

        WHEN '9004'.
          it_display-convey = it_display-convey + wa_rt-betrg.

        WHEN '9005'.
          it_display-edu_all = it_display-edu_all + wa_rt-betrg.

        WHEN '9006'.
          it_display-per_all = it_display-per_all + wa_rt-betrg.

        WHEN '9007'.
          it_display-med_all = it_display-med_all + wa_rt-betrg.

        WHEN '9008'.
          it_display-lta = it_display-lta + wa_rt-betrg.

        WHEN '9009'.
          it_display-p_p_all = it_display-p_p_all + wa_rt-betrg.

        WHEN '9010'.
          it_display-soft_fur = it_display-soft_fur + wa_rt-betrg.

        WHEN '9011'.
          it_display-prof_per = it_display-prof_per + wa_rt-betrg.

        WHEN '9012'.
          it_display-wash_all = it_display-wash_all + wa_rt-betrg.

        WHEN '9013'.
          it_display-perf_amt = it_display-perf_amt + wa_rt-betrg.

        WHEN '9014'.
          it_display-toni_all = it_display-toni_all + wa_rt-betrg.

        WHEN '9015'.
          it_display-atte_bon = it_display-atte_bon + wa_rt-betrg.

        WHEN '9016'.
          it_display-ot = it_display-ot + wa_rt-betrg.

        WHEN '9017'.
          it_display-adv_bexp = it_display-adv_bexp + wa_rt-betrg.

        WHEN '9018'.
          it_display-medi_cla = it_display-medi_cla + wa_rt-betrg.

        WHEN '9019'.
          it_display-lta_re = it_display-lta_re + wa_rt-betrg.

        WHEN '9020'.
          it_display-prod_ince = it_display-prod_ince + wa_rt-betrg.

        WHEN '9021'.
          it_display-bonus = it_display-bonus + wa_rt-betrg.

        WHEN '9022'.
          it_display-exgra = it_display-exgra + wa_rt-betrg.

        WHEN '9023'.
          it_display-pbs_sal = it_display-pbs_sal + wa_rt-betrg.

        WHEN '9024'.
          it_display-coup_ern = it_display-coup_ern + wa_rt-betrg.

        WHEN '9028'.
          it_display-dist_all = it_display-dist_all + wa_rt-betrg.

        WHEN '9029'.
          it_display-tel_all = it_display-tel_all + wa_rt-betrg.

        WHEN '9030'.
          it_display-gratu = it_display-gratu + wa_rt-betrg.

        WHEN '9031'.
          it_display-sal_adv = it_display-sal_adv + wa_rt-betrg.

        WHEN '9032'.
          it_display-vouch = it_display-vouch + wa_rt-betrg.

        WHEN '9033'.
          it_display-oth_pay = it_display-oth_pay + wa_rt-betrg.

        WHEN '9035'.
          it_display-leave_enc = it_display-leave_enc + wa_rt-betrg.      "wage type description in smartform is stipend

        WHEN '9036'.
          it_display-inc_amt = it_display-inc_amt + wa_rt-betrg.

*        WHEN '9037'.
*          it_display-pbs_sal = it_display-pbs_sal + wa_rt-betrg.
******************************************rupali******************************************
        WHEN '9040'.
           it_display-CAA = it_display-caa + wa_rt-betrg.

        WHEN '9041'.
          it_display-host_all = it_display-host_all + wa_rt-betrg.
******************************************rupali****************************************


        WHEN '6001'.
          it_display-sal_adv1 = it_display-sal_adv1 + wa_rt-betrg.

        WHEN '6002'.
          it_display-loan = it_display-loan + wa_rt-betrg.

        WHEN '6003'.
          it_display-pbs = it_display-pbs + wa_rt-betrg.

        WHEN '/552'.
          it_display-prevm_sal = it_display-prevm_sal + wa_rt-betrg.

        WHEN '/ZF5'.
          it_display-prevmpf = it_display-prevmpf + wa_rt-betrg.

        WHEN '/3W1'.
          it_display-lab_welf = it_display-lab_welf + wa_rt-betrg.


        WHEN '/3F1'.
          it_display-epf =  it_display-epf + wa_rt-betrg.                        "pf

        WHEN '/3P1'.
          it_display-ptax = it_display-ptax + wa_rt-betrg.                   "prof tax

        WHEN '9101'.
          it_display-lic = wa_rt-betrg.
          it_display-lic = it_display-lic * -1.
        WHEN '9102'.
          it_display-soci = wa_rt-betrg.
          it_display-soci = it_display-soci * -1.
        WHEN '9103'.
          it_display-medi_pre = wa_rt-betrg.                                             "Medi claim
          it_display-medi_pre = it_display-medi_pre * -1.
        WHEN '9122'.
          it_display-cant_exp = wa_rt-betrg.                                            " canteen  expences
          it_display-cant_exp = it_display-cant_exp * -1.
        WHEN '9104'.
          it_display-coup_ded = wa_rt-betrg.                                            " canteen coupans
          it_display-coup_ded = it_display-coup_ded * -1.
        WHEN '9105'.
          it_display-tel_rec = wa_rt-betrg.
          it_display-tel_rec = it_display-tel_rec * -1.
        WHEN '9106'.
          it_display-mseb = wa_rt-betrg.
          it_display-mseb = it_display-mseb * -1.
        WHEN '9107'.
          it_display-hrent = wa_rt-betrg.
          it_display-hrent = it_display-hrent * -1.
        WHEN '9108'.
          it_display-nopa_rec = wa_rt-betrg.
          it_display-nopa_rec = it_display-nopa_rec * -1.

        WHEN '9110'.
          it_display-fest_cont = wa_rt-betrg.
          it_display-fest_cont = it_display-fest_cont * -1.
        WHEN '9111'.
          it_display-fina_assi = wa_rt-betrg.
          it_display-fina_assi = it_display-fina_assi * -1.
        WHEN '9112'.
          it_display-sal_adv2 = wa_rt-betrg.
          it_display-sal_adv2 = it_display-sal_adv2 * -1.
        WHEN '9113'.
          it_display-fest_adv = wa_rt-betrg.
          it_display-fest_adv = it_display-fest_adv * -1.
        WHEN '9114'.
          it_display-exp_adv = wa_rt-betrg.
          it_display-exp_adv = it_display-exp_adv * -1.
        WHEN '9115'.
          it_display-comp_loan = wa_rt-betrg.                            "bnk ln inst.
          it_display-comp_loan = it_display-comp_loan * -1.
        WHEN '9117'.
          it_display-lic1 = wa_rt-betrg.
          it_display-lic1 = it_display-lic1 * -1.
        WHEN '9118'.
          it_display-lic2 = wa_rt-betrg.
          it_display-lic2 = it_display-lic2 * -1.
        WHEN '9119'.
          it_display-lic3 = wa_rt-betrg.
          it_display-lic3 = it_display-lic3 * -1.
        WHEN '9120'.
          it_display-lic4 = wa_rt-betrg.
          it_display-lic4 = it_display-lic4 * -1.
        WHEN '9200'.
          it_display-inc_tax = wa_rt-betrg.
          it_display-inc_tax = it_display-inc_tax * -1.
**********************change on11/07/2007 for gross net salary
        WHEN '/101'.
          it_display-totearn = wa_rt-betrg.

        WHEN '/560'.
          it_display-netsalary = wa_rt-betrg.

        WHEN '/561'.
          it_display-pending = wa_rt-betrg.

        WHEN '9124'.
          it_display-bank_recv1 = wa_rt-betrg.                        " Bank Recovery
          it_display-bank_recv1 = it_display-bank_recv1 * -1.

        WHEN '9125'.
          it_display-bank_recv2 = wa_rt-betrg.                        " Bank Recovery 1
          it_display-bank_recv2 = it_display-bank_recv2 * -1.

        WHEN '9126'.
          it_display-bank_recv3 = wa_rt-betrg.                        " Bank Recovery 2
          it_display-bank_recv3 = it_display-bank_recv3 * -1.

        WHEN '9127'.
          it_display-bank_recv4 = wa_rt-betrg.                        " Bank Recovery 3
          it_display-bank_recv4 = it_display-bank_recv4 * -1.

        WHEN '9128'.
          it_display-bank_recv5 = wa_rt-betrg.                        " Bank Recovery 4
          it_display-bank_recv5 = it_display-bank_recv5 * -1.

        when '1003'.
          it_display-penlicded = wa_rt-betrg.
        when '1004'.
          it_display-pensocided = wa_rt-betrg.
        when '2011'.
          it_display-penmedi_preded = wa_rt-betrg.
        when '2019'.
          it_display-pencant_expded = wa_rt-betrg.
        when '2021'.
          it_display-pencoup_ded = wa_rt-betrg.
        when '2025'.
          it_display-pentel_recded = wa_rt-betrg.
        when '2023'.
          it_display-penmsebded = wa_rt-betrg.
        when '2027'.
          it_display-penhrentded = wa_rt-betrg.

        when '2033'.
          it_display-penfest_contded = wa_rt-betrg.
        when '2031'.
          it_display-penfina_assided = wa_rt-betrg.
        when '1008'.
          it_display-pensal_advded = wa_rt-betrg.
        when '2029'.
          it_display-penfest_adv = wa_rt-betrg.
        when '2013'.
          it_display-penexp_advded = wa_rt-betrg.
        when '2015'.
          it_display-pencomp_loanded = wa_rt-betrg.
        when '1001'.
          it_display-penlic1ded = wa_rt-betrg.
        when '1005'.
          it_display-penlic2ded = wa_rt-betrg.
        when '1006'.
          it_display-penlic3ded = wa_rt-betrg.
        when '1007'.
          it_display-penlic4ded = wa_rt-betrg.
        when '2009'.
          it_display-peninc_taxded = wa_rt-betrg.
        when '2037'.
          it_display-penb1ded = wa_rt-betrg.
        when '2039'.
          it_display-penb2ded = wa_rt-betrg.
        when '2041'.
          it_display-penb3ded = wa_rt-betrg.
        when '2043'.
          it_display-penb4ded = wa_rt-betrg.

      ENDCASE.
      CLEAR: wa_rt-betrg.



    ENDIF.
    CLEAR wa_t512t.
  ENDLOOP.
  it_display-totearn   = it_display-totearn + it_display-prevm_sal + it_display-prevmpf .
  it_display-prevm_sal = it_display-prevm_sal  + it_display-prevmpf.

  it_display-lic       = it_display-lic - it_display-penlicded.
  it_display-soci      = it_display-soci - it_display-pensocided.
  it_display-medi_pre  = it_display-medi_pre - it_display-penmedi_preded.
  it_display-coup_ded  = it_display-coup_ded - it_display-pencoup_ded.
  it_display-cant_exp  = it_display-cant_exp - it_display-pencant_expded.
  it_display-tel_rec   = it_display-tel_rec - it_display-pentel_recded.
  it_display-mseb      = it_display-mseb - it_display-penmsebded.
  it_display-hrent     = it_display-hrent - it_display-penhrentded.
  it_display-comp_loan = it_display-comp_loan - it_display-pencomp_loanded.
  it_display-fest_cont = it_display-fest_cont - it_display-penfest_contded.
  it_display-fina_assi = it_display-fina_assi - it_display-penfina_assided.
  it_display-sal_adv2  = it_display-sal_adv2 - it_display-pensal_advded.
  it_display-fest_adv  = it_display-fest_adv - it_display-penfest_adv.
  it_display-exp_adv   = it_display-exp_adv - it_display-penexp_advded.
  it_display-bank_recv1        = it_display-bank_recv1 - it_display-penb1ded.
  it_display-bank_recv2        = it_display-bank_recv2 - it_display-penb2ded.
  it_display-bank_recv3        = it_display-bank_recv3 - it_display-penb3ded.
  it_display-bank_recv4        = it_display-bank_recv4 - it_display-penb4ded.
  it_display-lic1      = it_display-lic1 - it_display-penlic1ded.
  it_display-lic2      = it_display-lic2 -  it_display-penlic2ded.
  it_display-lic3      = it_display-lic3 - it_display-penlic3ded.
  it_display-lic4      = it_display-lic4 - it_display-penlic4ded.
  it_display-inc_tax   = it_display-inc_tax - it_display-peninc_taxded.

  it_display-bank_recv = it_display-bank_recv + it_display-bank_recv1 + it_display-bank_recv2 + it_display-bank_recv3 + it_display-bank_recv4 + it_display-bank_recv5 .

  it_display-totded         = it_display-epf +
                              it_display-ptax +
                              it_display-lic +
                              it_display-soci +
                              it_display-medi_pre +
                              it_display-coup_ded +
                              it_display-cant_exp +
                              it_display-tel_rec +
                              it_display-mseb +
                              it_display-hrent +
                              it_display-nopa_rec +
                              it_display-comp_loan +
                              it_display-fest_cont +
                              it_display-fina_assi +
                              it_display-sal_adv2 +
                              it_display-fest_adv +
                              it_display-exp_adv +
                              it_display-bank_recv1 +
                              it_display-bank_recv2 +
                              it_display-bank_recv3 +
                              it_display-bank_recv4 +
                              it_display-bank_recv5 +
                              it_display-lic1 +
                              it_display-lic2 +
                              it_display-lic3 +
                              it_display-lic4 +
                              it_display-inc_tax +
                              it_display-prevmpf +
                              it_display-lab_welf.
*                              it_display-bank_recv .  MODIFY it_display.
  modify it_display.
  CLEAR wa_rt.

ENDFORM.                    " rt


FORM header_data .


  ULINE AT 1(229).
ENDFORM.                    " header_data

FORM it_display .

ENDFORM.                    " IT_DISPLAY

FORM total_earning .

  SELECT * FROM pa0008 INTO TABLE it_0008
                       FOR ALL ENTRIES IN it_rgdir
                       WHERE pernr = it_rgdir-pernr and
                             endda > sy-datum.

  LOOP AT it_display.
    LOOP AT it_0008 WHERE pernr = it_display-ec.



      it_display-totearn1 = it_0008-bet01 + it_0008-bet02 + it_0008-bet03 +
                           it_0008-bet04 + it_0008-bet05 + it_0008-bet06 +
                           it_0008-bet07 + it_0008-bet08 + it_0008-bet09 +
                           it_0008-bet10 + it_0008-bet11 + it_0008-bet12 +
                           it_0008-bet13 - it_display-perf_amt.

*    ENDIF.
      MODIFY it_display.
    ENDLOOP.
  ENDLOOP.
DELETE ADJACENT DUPLICATES FROM IT_DISPLAY COMPARING EC.

SORT IT_DISPLAY BY EC."DIVISION.

ENDFORM.                    " total_earning



FORM get_form_name .
  DATA : l_formname TYPE rs38l_fnam.

  sfname = 'ZANNUAL_SALARY'.
  CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
    EXPORTING
      formname                 = sfname
*   VARIANT                  = ' '
*   DIRECT_CALL              = ' '
    IMPORTING
      fm_name                  = fm_name
    EXCEPTIONS
      no_form                  = 1
      no_function_module       = 2
      OTHERS                   = 3.
  IF sy-subrc <> 0.
*    WRITE: / 'ERROR 1'.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

  IF sy-subrc = 0.
*    ent_retco = 0.
  ENDIF.



ENDFORM.                    " get_form_name

FORM call_form .


*  CALL FUNCTION  fm_name
*
*    EXPORTING
**   ARCHIVE_INDEX              =
**   ARCHIVE_INDEX_TAB          =
**   ARCHIVE_PARAMETERS         =
**   CONTROL_PARAMETERS         =
**   MAIL_APPL_OBJ              =
**   MAIL_RECIPIENT             =
**   MAIL_SENDER                =
**   OUTPUT_OPTIONS             =
**   USER_SETTINGS              = 'X'
*      in_year                    = in_year
*      v_month_spell              = v_month_spell
** IMPORTING
**   DOCUMENT_OUTPUT_INFO       =
**   JOB_OUTPUT_INFO            =
**   JOB_OUTPUT_OPTIONS         =
*    TABLES
*      it_display                 = it_display
** EXCEPTIONS
**   FORMATTING_ERROR           = 1
**   INTERNAL_ERROR             = 2
**   SEND_ERROR                 = 3
**   USER_CANCELED              = 4
**   OTHERS                     = 5
*            .
*  IF sy-subrc <> 0.
** MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
**         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
*  ENDIF.


CALL FUNCTION '/1BCDWB/SF00000367'
* EXPORTING
*   ARCHIVE_INDEX              =
*   ARCHIVE_INDEX_TAB          =
*   ARCHIVE_PARAMETERS         =
*   CONTROL_PARAMETERS         =
*   MAIL_APPL_OBJ              =
*   MAIL_RECIPIENT             =
*   MAIL_SENDER                =
*   OUTPUT_OPTIONS             =
*   USER_SETTINGS              = 'X'
* IMPORTING
*   DOCUMENT_OUTPUT_INFO       =
*   JOB_OUTPUT_INFO            =
*   JOB_OUTPUT_OPTIONS         =
  TABLES
    IT_DISPLAY                 = it_display
    IT_DISPLAY1                = it_display1
* EXCEPTIONS
*   FORMATTING_ERROR           = 1
*   INTERNAL_ERROR             = 2
*   SEND_ERROR                 = 3
*   USER_CANCELED              = 4
*   OTHERS                     = 5
          .
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.






ENDFORM.                    " call_form
*&---------------------------------------------------------------------*
*&      Form  GET_PFNUM
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM get_pfnum .

  SELECT pernr begda eepfn FROM pa0587
                INTO CORRESPONDING FIELDS OF TABLE it_0587
                FOR ALL ENTRIES IN it_rgdir
                WHERE pernr = it_rgdir-pernr AND
                      ENDDA > SY-DATUM.

  LOOP AT it_0001.
    READ TABLE it_0587 WITH KEY pernr = it_0001-pernr.
    IF sy-subrc = 0.

      it_0001-pfnumber = it_0587-eepfn.

    ELSEIF sy-subrc <> 0.

      it_0001-pfnumber = ' '.

    ENDIF.
    MODIFY it_0001.
    CLEAR it_0001.
  ENDLOOP.

ENDFORM.                    " GET_PFNUM
*&---------------------------------------------------------------------*
*&      Form  GET_ESINUM
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM get_esinum .

  SELECT pernr esino
         FROM pa0588
         INTO CORRESPONDING FIELDS OF
         TABLE it_0588
         FOR ALL ENTRIES IN it_rgdir
         WHERE pernr = it_rgdir-pernr
         AND   ENDDA > SY-DATUM.
  LOOP AT it_0001.
    READ TABLE it_0588 WITH KEY pernr = it_0001-pernr.

    IF sy-subrc = 0.

      it_0001-esinumber = it_0588-esino.

    ELSEIF sy-subrc <> 0.

      it_0001-esinumber = ' '.

    ENDIF.
    MODIFY it_0001.
    CLEAR it_0001.
  ENDLOOP.

ENDFORM.                    " GET_ESINUM
*&---------------------------------------------------------------------*
*&      Form  GET_BANK
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM get_bank .

  SELECT pernr bankl bankn
         FROM pa0009
         INTO CORRESPONDING FIELDS OF
         TABLE it_0009
         FOR ALL ENTRIES IN it_rgdir
         WHERE pernr = it_rgdir-pernr
         AND bankl NE space
         AND bankn NE space
         AND ENDDA > SY-DATUM.

  LOOP AT it_0009.

    SELECT SINGLE text1 FROM t012t
                 INTO it_0009-bank
                 WHERE hbkid = it_0009-bankl.

    IF sy-subrc = 0.
      MODIFY it_0009 TRANSPORTING bank.
      CLEAR it_0009.
    ENDIF.
  ENDLOOP.

  LOOP AT it_0001.

    READ TABLE it_0009 WITH KEY pernr = it_0001-pernr.

    IF sy-subrc = 0.

      it_0001-bank = it_0009-bank.
      it_0001-acno = it_0009-bankn.

      MODIFY it_0001 TRANSPORTING bank acno.
      CLEAR it_0001.

    ENDIF.

  ENDLOOP.


  IF sy-subrc <> 0 .

*    MESSAGE i001.
    LEAVE LIST-PROCESSING.
  ENDIF.

ENDFORM.                    " GET_BANK

*&---------------------------------------------------------------------*
*&      Form  get_division
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM get_division .

  LOOP AT it_0001.

    SELECT SINGLE btext FROM t001p
                 INTO it_0001-division
                 WHERE btrtl = it_0001-btrtl.
    MODIFY it_0001.
    CLEAR it_0001.

  ENDLOOP.

  LOOP AT it_0001.

    SELECT SINGLE stext FROM hrp1000
    INTO it_0001-designation
                 WHERE otype = it_0001-otype and
                       objid = it_0001-plans.
    MODIFY it_0001.

    SELECT SINGLE name1 FROM t500p
                 INTO it_0001-name1
                 WHERE persa = it_0001-werks.
    MODIFY it_0001.
    CLEAR it_0001.

  ENDLOOP.

ENDFORM.                    " get_division

**&---------------------------------------------------------------------*
*&      Form  calender_days
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM calender_days .

  LOOP AT it_0001.

    SELECT SINGLE begda INTO it_0001-begda
    FROM pa0000 WHERE pernr = it_0001-pernr AND
    massn = 'X1'.

    MODIFY it_0001.
  ENDLOOP.


  CALL FUNCTION 'NUMBER_OF_DAYS_PER_MONTH_GET'
    EXPORTING
      par_month = in_month
      par_year  = in_year
    IMPORTING
      par_days  = days.

  LOOP AT it_0001.
    it_0001-nwd = days.
    MODIFY it_0001 TRANSPORTING nwd.
    CLEAR it_0001.
  ENDLOOP.

  PERFORM get_leave_date.

  v_pymonth = v_pymonth - 1.

  CONCATENATE v_year v_pymonth INTO p_period1 .

  PERFORM present_days.

  SELECT *  FROM pa2001 INTO TABLE it_2001
            FOR ALL ENTRIES IN it_0001
             WHERE pernr = it_0001-pernr
             AND subty IN ('LOP','HALF').


  LOOP AT it_2001.
    IF it_2001-subty = 'HALF'.
*      it_2001-abwtg = it_2001-abwtg / 2.
      it_2001-kaltg = it_2001-kaltg / 2.
      MODIFY it_2001.
    ENDIF.
    it_2001-endda = it_2001-endda+0(6).
    MODIFY it_2001.
  ENDLOOP.

  LOOP AT it_2001.
    IF it_2001-endda <> p_period1.
      DELETE it_2001 INDEX sy-tabix.
    ENDIF.
  ENDLOOP.


  LOOP AT it_0001.
    LOOP AT it_2001
    WHERE pernr = it_0001-pernr.
      ta   = ta + it_2001-kaltg."it_2001-abwtg.
      CLEAR it_2001.
    ENDLOOP.
    IF it_0001-p_days = ' '.
      it_0001-p_days = it_0001-nwd - ta.
      MODIFY it_0001.
    ELSE.
      it_0001-p_days = it_0001-p_days - ta.
      MODIFY it_0001.
    ENDIF.
    CLEAR it_0001.
    CLEAR ta.

  ENDLOOP.


ENDFORM.                    " calender_days
*&---------------------------------------------------------------------*
*&      Form  get_0008_data
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM get_0008_data .



ENDFORM.                    " get_0008_data
*&---------------------------------------------------------------------*
*&      Form  get_008_DATA
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM get_008_data .

  LOOP AT it_display.

    SELECT * FROM pa0008
            INTO CORRESPONDING FIELDS OF it_008
            WHERE pernr = it_display-ec.
    ENDSELECT.

*loop at it_display.

    v_wage = it_008-lga01.
    IF v_wage = ' '.
      MOVE it_display-bet01 TO v_space.
      MOVE space TO v_space.
      MOVE v_space TO it_display-bet01.
    ELSE.
      MOVE it_008-bet01 TO it_display-bet01.
      PERFORM wage_text USING v_wage CHANGING v_wagetext.
      MOVE v_wagetext TO it_display-ltx01.
      CLEAR p_v_wage.
      CLEAR p_v_wagetext.


    ENDIF.

    v_wage = it_008-lga02.
    IF v_wage = ' '.
      MOVE it_display-bet02 TO v_space.
      MOVE space TO v_space.
      MOVE v_space TO it_display-bet02.
    ELSE.
      MOVE it_008-bet02 TO it_display-bet02.
      PERFORM wage_text USING v_wage CHANGING v_wagetext.
      MOVE v_wagetext TO it_display-ltx02.
      CLEAR p_v_wage.
      CLEAR p_v_wagetext.
    ENDIF.

    v_wage = it_008-lga03.
    IF v_wage = ' '.
      it_display-bet03 = space.
    ELSE.
      MOVE it_008-bet03 TO it_display-bet03.
      PERFORM wage_text USING v_wage CHANGING v_wagetext.
      MOVE v_wagetext TO it_display-ltx03.
      CLEAR p_v_wage.
      CLEAR p_v_wagetext.
    ENDIF.

    v_wage = it_008-lga04.
    IF v_wage = ' '.
      it_display-bet04 = space.
    ELSE.
      MOVE it_008-bet04 TO it_display-bet04.
      PERFORM wage_text USING v_wage CHANGING v_wagetext.
      MOVE v_wagetext TO it_display-ltx04.
      CLEAR p_v_wage.
      CLEAR p_v_wagetext.
    ENDIF.

    v_wage = it_008-lga05.
    IF v_wage = ' '.
      MOVE it_display-bet05 TO v_space.
      MOVE space TO v_space.
      MOVE v_space TO it_display-bet05.
      it_display-bet05 = space.

    ELSE.
      MOVE it_008-bet05 TO it_display-bet05.
      PERFORM wage_text USING v_wage CHANGING v_wagetext.
      MOVE v_wagetext TO it_display-ltx05.
      CLEAR p_v_wage.
      CLEAR p_v_wagetext.
    ENDIF.

    v_wage = it_008-lga06.
    IF v_wage = ' '.
      it_display-bet06 = space.
      MOVE it_display-bet06 TO v_space.
      MOVE space TO v_space.
      MOVE v_space TO it_display-bet06.
    ELSE.
      MOVE it_008-bet06 TO it_display-bet06.
      PERFORM wage_text USING v_wage CHANGING v_wagetext.
      MOVE v_wagetext TO it_display-ltx06.
      CLEAR p_v_wage.
      CLEAR p_v_wagetext.
    ENDIF.

    v_wage = it_008-lga07.
    IF v_wage = ' '.
      MOVE it_display-bet07 TO v_space.
      MOVE space TO v_space.
      MOVE v_space TO it_display-bet07.
      MOVE v_space TO it_display-wa.

    ELSE.
      MOVE it_008-bet07 TO it_display-bet07.
      PERFORM wage_text USING v_wage CHANGING v_wagetext.
      MOVE v_wagetext TO it_display-ltx07.
      CLEAR p_v_wage.
      CLEAR p_v_wagetext.
    ENDIF.

    v_wage = it_008-lga08.
    IF v_wage = ' '.
      MOVE it_display-bet08 TO v_space.
      MOVE space TO v_space.
      MOVE v_space TO it_display-bet08.

    ELSE.
      MOVE it_008-bet08 TO it_display-bet08.
      PERFORM wage_text USING v_wage CHANGING v_wagetext.
      MOVE v_wagetext TO it_display-ltx08.
      CLEAR p_v_wage.
      CLEAR p_v_wagetext.
    ENDIF.


    v_wage = it_008-lga09.
    IF v_wage = ' '.
      MOVE it_display-bet09 TO v_space.
      MOVE space TO v_space.
      MOVE v_space TO it_display-bet09.

    ELSE.
      MOVE it_008-bet09 TO it_display-bet09.
      PERFORM wage_text USING v_wage CHANGING v_wagetext.
      MOVE v_wagetext TO it_display-ltx09.
      CLEAR p_v_wage.
      CLEAR p_v_wagetext.

    ENDIF.
    v_wage = it_008-lga10.
    IF v_wage = ' '.
      MOVE it_display-bet10 TO v_space.
      MOVE space TO v_space.
      MOVE v_space TO it_display-bet10.

    ELSE.
      MOVE it_008-bet10 TO it_display-bet10.
      PERFORM wage_text USING v_wage CHANGING v_wagetext.
      MOVE v_wagetext TO it_display-ltx10.
      CLEAR p_v_wage.
      CLEAR p_v_wagetext.
    ENDIF.

    v_wage = it_008-lga11.
    IF v_wage = ' '.
      MOVE it_display-bet11 TO v_space.
      MOVE space TO v_space.
      MOVE v_space TO it_display-bet11.
    ELSE.
      MOVE it_008-bet11 TO it_display-bet11.
      PERFORM wage_text USING v_wage CHANGING v_wagetext.
      MOVE v_wagetext TO it_display-ltx11.
      CLEAR p_v_wage.
      CLEAR p_v_wagetext.
    ENDIF.

*if it_008-lga01 =
    APPEND it_008.

    MODIFY it_display TRANSPORTING bet01 ltx01 bet02 ltx02
                                   bet03 ltx03 bet04 ltx04
                                   bet05 ltx05 bet06 ltx06
                                   bet07 ltx07 bet08 ltx08
                                   bet09 ltx09 bet10 ltx10
                                   bet11 ltx11.
  ENDLOOP.

ENDFORM.                    " get_008_DATA
*&---------------------------------------------------------------------*
*&      Form  wage_text
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM wage_text  USING    p_v_wage
                CHANGING p_v_wagetext.


  READ TABLE it_t512t WITH KEY lgart = p_v_wage.

  p_v_wagetext = it_t512t-kztxt.
  CLEAR it_t512t-kztxt.



ENDFORM.                    " wage_text
*&---------------------------------------------------------------------*
*&      Form  leaves_data
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM leaves_data .

  REFRESH it_2001.

  LOOP AT it_rgdir.

    SELECT * FROM pa2006
             INTO CORRESPONDING FIELDS OF it_2006
             WHERE pernr = it_rgdir-pernr.

      APPEND it_2006.
    ENDSELECT.

    SELECT *  FROM pa2001
              INTO CORRESPONDING FIELDS OF it_2001
              WHERE pernr = it_rgdir-pernr
              AND subty IN ('SL', 'PL', 'CL').
      APPEND it_2001.
    ENDSELECT.
  ENDLOOP.

  it_2001a[] = it_2001[].
  it_2001b[] = it_2001[].

  SORT it_2001a BY subty.
  DELETE ADJACENT DUPLICATES FROM it_2001a COMPARING subty.

  LOOP AT it_2001.
    it_2001-endda = it_2001-endda+0(6).
    MODIFY it_2001.
  ENDLOOP.


  LOOP AT it_2001.
    IF it_2001-endda = p_period1.
      DELETE it_2001 INDEX sy-tabix.
    ENDIF.
  ENDLOOP.

  p_period1 = p_period1 + 1.

  LOOP AT it_2001.
    IF it_2001-endda = p_period1.
      DELETE it_2001 INDEX sy-tabix.
    ENDIF.
  ENDLOOP.

  SORT it_2001a BY subty.

  LOOP AT it_2001a.
    it_2001a-kaltg = 0."it_2001a-abwtg = 0.
    MODIFY it_2001a.
    LOOP AT it_2001
    WHERE pernr = it_2001a-pernr
    AND subty = it_2001a-subty.
    it_2001a-kaltg = it_2001a-kaltg + it_2001-kaltg.

*      it_2001a-abwtg = it_2001a-abwtg + it_2001-abwtg.
      MODIFY it_2001a.
    ENDLOOP.
  ENDLOOP.

ENDFORM.                    " leaves_data

*&---------------------------------------------------------------------*
*&      Form  pannumber_data
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM pannumber_data .

  LOOP AT it_0001.

    SELECT icnum
           FROM pa0185
           INTO it_0001-pannumber
           WHERE pernr = it_0001-pernr
           AND  ictyp = '02'
           AND  ENDDA > SY-DATUM.
      MODIFY  it_0001 TRANSPORTING pannumber.
    ENDSELECT.

  ENDLOOP.
* read it_display where

ENDFORM.                    " pannumber_data
*&---------------------------------------------------------------------*
*&      Form  GET_SPOUSE_FATHER_NAME
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM get_spouse_father_name .

  LOOP AT it_0001.

    SELECT pernr favor fanam FROM pa0021
           INTO TABLE it_0021
           WHERE pernr = it_0001-pernr
           AND famsa = '11'.

    CONCATENATE it_0021-fanam it_0021-favor INTO it_0001-fat_nam SEPARATED BY space.


  ENDLOOP.

  LOOP AT it_display.

    READ TABLE it_0001 WITH KEY pernr = it_display-ec.

    MOVE it_0001-fat_nam TO it_display-father.


  ENDLOOP.




ENDFORM.                    " GET_SPOUSE_FATHER_NAME
*&---------------------------------------------------------------------*
*&      Form  DOWNLOAD
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM download .


ENDFORM.                    " DOWNLOAD
*&---------------------------------------------------------------------*
*&      Form  PRESENT_DAYS
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM present_days .

  LOOP AT it_0001.

    IF p_period1 = it_0001-begda+0(6).

      CALL FUNCTION 'DATE_GET_MONTH_LASTDAY'
        EXPORTING
          i_date = it_0001-begda
        IMPORTING
          e_date = sbegda.


      p_days = sbegda+6(2) - it_0001-begda+6(2).

      it_0001-p_days =  p_days + 1 .
      MODIFY it_0001.
    ENDIF.
  ENDLOOP.


ENDFORM.                    " PRESENT_DAYS
*&---------------------------------------------------------------------*
*&      Form  GET_LEAVE_DATE
*&---------------------------------------------------------------------*
*       text  LEAVES CALCULATION WHICH STARTS IN LAST MONTH AND ENDS IN PAY MONTH
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM get_leave_date .

  CONCATENATE v_year v_pymonth INTO p_period1 .

  v_pymonth = v_pymonth - 1.

  CONCATENATE v_year v_pymonth '01' INTO s_date.

  v_pymonth = v_pymonth + 1.

  IF days = '30'.
    CONCATENATE v_year v_pymonth '30' INTO e_date.
  ENDIF.

  IF days = '31'.
    CONCATENATE v_year v_pymonth '31' INTO e_date.
  ENDIF.

  IF days = '28'.
    CONCATENATE v_year v_pymonth '28' INTO e_date.
  ENDIF.

  IF days = '29'.
    CONCATENATE v_year v_pymonth '29' INTO e_date.
  ENDIF.

  SELECT *  FROM pa2001 INTO TABLE it_2001a
            FOR ALL ENTRIES IN it_0001
             WHERE pernr = it_0001-pernr
             AND subty IN ('LOP','HALF', 'SL', 'CL', 'PL','CL2','SPL') AND
             begda >= s_date AND endda <= e_date.

  v_pymonth = v_pymonth - 1.

  IF days = '30'.
    CONCATENATE v_year v_pymonth '30' INTO e_date.
  ENDIF.

  IF days = '31'.
    CONCATENATE v_year v_pymonth '31' INTO e_date.
  ENDIF.

  v_pymonth = v_pymonth + 1.

  CONCATENATE v_year v_pymonth '01' INTO e1_date.

  CONCATENATE v_year v_pymonth '01' INTO a_date.

  IF days = '30'.
    CONCATENATE v_year v_pymonth '30' INTO b_date.
  ENDIF.

  IF days = '31'.
    CONCATENATE v_year v_pymonth '31' INTO b_date.
  ENDIF.

  LOOP AT it_2001a
          WHERE begda BETWEEN s_date AND e_date AND
                endda BETWEEN a_date AND b_date.

    it_2001a-begda = e1_date.

    MODIFY it_2001a.

    MOVE-CORRESPONDING it_2001a TO it_2001b.
    APPEND it_2001b.
  ENDLOOP.

  REFRESH it_2001a.

  SELECT *  FROM pa2001 INTO TABLE it_2001a
            FOR ALL ENTRIES IN it_0001
             WHERE pernr = it_0001-pernr
             AND subty IN ('LOP','HALF', 'SL', 'CL', 'PL','CL2','SPL') AND
             begda >= a_date.

  v_pymonth = v_pymonth + 1.

  CONCATENATE v_year v_pymonth '01' INTO s_date.

  IF days = '30'.
    CONCATENATE v_year v_pymonth '31' INTO e_date.
  ENDIF.

  IF days = '31'.
    CONCATENATE v_year v_pymonth '30' INTO e_date.
  ENDIF.


  LOOP AT it_2001a
          WHERE begda BETWEEN a_date AND b_date AND
                endda BETWEEN s_date AND e_date.
    it_2001a-endda = b_date.
    MODIFY it_2001a.

    MOVE-CORRESPONDING it_2001a TO it_2001b.
    APPEND it_2001b.

  ENDLOOP.


  LOOP AT it_2001b.

*    it_2001b-abwtg = ( it_2001b-endda - it_2001b-begda ) + 1.
    it_2001b-kaltg = ( it_2001b-endda - it_2001b-begda ) + 1.

    MODIFY it_2001b.
  ENDLOOP.

  REFRESH it_2001a.

ENDFORM.                    " GET_LEAVE_DATE


No comments:

Post a Comment