Hr abap- macro

there is a problem in hr abap with the macros like rp-provide from frst and rp-provide from last. is there any solution in the form of sample codes it will be very helpful.
the exact problem with the code is that
rp-provide from last and frst are providing the same data from the table which is the last record, but which is not the desired function of the rp-provide from frst.
if there are any solutions to the problem please mail me the solution.
thank you
ramesh

Hello,
Instead of using the rp-provide from last you can use the provide statement only. See attached a program here using the rp-read-infotype macro you can have a better control.
AUTHOR      :   shekhar s kulkarni
DATE        :   18th july 2003
DESCRIPTION :
DEV REQUEST :
MODIFICATION LOGS
VERSION
DATE
REQUEST NO
DESCRIPTION
REPORT zpyr_overseasemplist.
*Declaration for type pool
TYPE-POOLS :slis.
*Declaration for tables
TABLES : pa0000,pa0008, zhrrole, zhrband, zhrrole_assg,t001p,t503t,t500p
,t005h,t591s.
<b>*Declaration for infotypes
INFOTYPES : 0000,0001,9009,0008,9001,9015.</b>
*Declaration data for alv list
DATA: lv_tmplt LIKE disvariant VALUE 'ZPYR_ELIGIBLESALARY',
      lv_fieldcat TYPE slis_t_fieldcat_alv,
      lv_ls_layout TYPE slis_layout_alv,
      driver LIKE sy-repid,
      wa_lv_fieldcat TYPE slis_fieldcat_main,
      farben TYPE slis_specialcol_alv,             "color display
      it_events TYPE slis_t_event,
      wa_events TYPE slis_alv_event,
      gs_extract1 LIKE disextract.
DATA: BEGIN OF it_leavedate OCCURS 0.
        INCLUDE STRUCTURE hida.
DATA: END OF it_leavedate.
*Declaration data for program zpyr_overseasemplist
DATA : BEGIN OF it_overseas OCCURS 0,
        empno LIKE pa0008-pernr,
        name LIKE pa0001-ename,
        c_role_desc LIKE zhrrole-zrole_desc,
        band LIKE zhrband-zband_desc,
        perband LIKE pa0008-trfgr,
        category LIKE pa0001-ename,
        country LIKE t591s-stext,
        currency LIKE pa0008-waers,
        pu LIKE pa0001-btrtl,
        du LIKE pa9009-du_cd,
        location LIKE t500p-name1,
        region LIKE t005h-bezei,
        doj LIKE  sy-datum,
        start_period LIKE sy-datum,
        end_period LIKE sy-datum,
        basic LIKE pa0008-bet01,
        hra LIKE pa0008-bet01,
        insurance LIKE pa0008-bet01,
        oda LIKE pa0008-bet01,
        car_all LIKE pa0008-bet01,
        gross_1 LIKE pa0008-bet01,
        bonus LIKE pa0008-bet01,
        cpi LIKE pa0008-bet01,
        gross_2 LIKE pa0008-bet01,
        provision LIKE pa0008-bet01,
        tax LIKE pa0008-bet01,
        total LIKE pa0008-bet01,
        gross LIKE pa0008-bet01,
END OF it_overseas.
DATA : BEGIN OF it_empoverseas OCCURS 0,
        empno LIKE pa0008-pernr,
        name LIKE pa0001-ename,
        category LIKE pa0001-ename,
        country LIKE t591s-stext,
        currency LIKE pa0008-waers,
        gross LIKE pa0008-bet01,
END OF it_empoverseas.
*Declaration data for program
DATA : gc_startdate TYPE pa0008-begda,
       gc_enddate TYPE pa0008-endda,
       lc_dt TYPE sy-datum,
       li_tdt TYPE i,
       li_days TYPE i,
       lf_mon_bonus TYPE pa0008-bet01,
       gc_chkdate TYPE pa0000-begda,
       lc_flag TYPE c.
DATA: BEGIN OF ppbwla OCCURS 10.
        INCLUDE STRUCTURE pbwla.
DATA: END OF ppbwla.
***********************Selection screen *******************************
SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
PARAMETERS: p_pabrp LIKE qppnp-pabrp,
            p_pabrj LIKE qppnp-pabrj.
PARAMETERS: p_prcnt LIKE pa0008-bet01 DEFAULT '8',
            p_bprcnt LIKE pa0008-bet01 DEFAULT '50'.
SELECTION-SCREEN END OF BLOCK blk1.
**********************Initialization*********************************
INITIALIZATION.
  lv_ls_layout-group_change_edit  = 'X'.
  lv_ls_layout-get_selinfos = 'X'.
  driver = 'ZPYR_OVERSEASEMPLIST'.
  p_pabrp = sy-datum+4(2).
  p_pabrj = sy-datum+0(4).
*********************Start of selection*****************************
START-OF-SELECTION.
  PERFORM data_selection.      "Data selection from tables
  PERFORM alv_listdisplay.     "alv grid display
END-OF-SELECTION.
*&      Form  INIT_FIELDCAT
      Intialization of text for columns in the internal table
FORM init_fieldcat.
  LOOP AT lv_fieldcat INTO wa_lv_fieldcat.
    CASE wa_lv_fieldcat-fieldname.
      WHEN 'EMPNO'.
        wa_lv_fieldcat-seltext_l = 'Emp Number'.
        wa_lv_fieldcat-ddictxt = 'L'.
        wa_lv_fieldcat-ddic_outputlen = 13.
        MODIFY lv_fieldcat FROM wa_lv_fieldcat.
      WHEN 'DOJ'.
        wa_lv_fieldcat-seltext_l = 'Join Date'.
        wa_lv_fieldcat-ddictxt = 'L'.
        wa_lv_fieldcat-ddic_outputlen = 13.
        MODIFY lv_fieldcat FROM wa_lv_fieldcat.
      WHEN 'NAME'.
        wa_lv_fieldcat-seltext_l = 'Name'.
        wa_lv_fieldcat-ddictxt = 'L'.
        wa_lv_fieldcat-ddic_outputlen = 13.
        MODIFY lv_fieldcat FROM wa_lv_fieldcat.
      WHEN 'BAND'.
        wa_lv_fieldcat-seltext_l = 'Job Band'.
        wa_lv_fieldcat-ddictxt = 'L'.
        wa_lv_fieldcat-ddic_outputlen = 13.
        MODIFY lv_fieldcat FROM wa_lv_fieldcat.
      WHEN 'PERBAND'.
        wa_lv_fieldcat-seltext_l = 'Personal Band'.
        wa_lv_fieldcat-ddictxt = 'L'.
        wa_lv_fieldcat-ddic_outputlen = 13.
        MODIFY lv_fieldcat FROM wa_lv_fieldcat.
      WHEN 'COUNTRY'.
        wa_lv_fieldcat-seltext_l = 'Country'.
        wa_lv_fieldcat-ddictxt = 'L'.
        wa_lv_fieldcat-ddic_outputlen = 13.
        MODIFY lv_fieldcat FROM wa_lv_fieldcat.
      WHEN 'CURRENCY'.
        wa_lv_fieldcat-seltext_l = 'Currency'.
        wa_lv_fieldcat-ddictxt = 'L'.
        wa_lv_fieldcat-ddic_outputlen = 13.
        MODIFY lv_fieldcat FROM wa_lv_fieldcat.
      WHEN 'BASIC'.
        wa_lv_fieldcat-seltext_l = 'Basic'.
        wa_lv_fieldcat-ddictxt = 'L'.
        wa_lv_fieldcat-ddic_outputlen = 13.
        MODIFY lv_fieldcat FROM wa_lv_fieldcat.
      WHEN 'HRA'.
        wa_lv_fieldcat-seltext_l = 'HRA'.
        wa_lv_fieldcat-ddictxt = 'L'.
        wa_lv_fieldcat-ddic_outputlen = 13.
        MODIFY lv_fieldcat FROM wa_lv_fieldcat.
      WHEN 'INSURANCE'.
        wa_lv_fieldcat-seltext_l = 'Insurance'.
        wa_lv_fieldcat-ddictxt = 'L'.
        wa_lv_fieldcat-ddic_outputlen = 13.
        MODIFY lv_fieldcat FROM wa_lv_fieldcat.
      WHEN 'ODA'.
        wa_lv_fieldcat-seltext_l = 'ODA'.
        wa_lv_fieldcat-ddictxt = 'L'.
        wa_lv_fieldcat-ddic_outputlen = 13.
        MODIFY lv_fieldcat FROM wa_lv_fieldcat.
      WHEN 'CAR_ALL'.
        wa_lv_fieldcat-seltext_l = 'Car Allow.'.
        wa_lv_fieldcat-ddictxt = 'L'.
        wa_lv_fieldcat-ddic_outputlen = 13.
        MODIFY lv_fieldcat FROM wa_lv_fieldcat.
      WHEN 'GROSS_1'.
        wa_lv_fieldcat-seltext_l = 'Total excl. Bonus & CPI'.
        wa_lv_fieldcat-ddictxt = 'L'.
        wa_lv_fieldcat-ddic_outputlen = 13.
        MODIFY lv_fieldcat FROM wa_lv_fieldcat.
      WHEN 'BONUS'.
        wa_lv_fieldcat-seltext_l = 'Bonus'.
        wa_lv_fieldcat-ddictxt = 'L'.
        wa_lv_fieldcat-ddic_outputlen = 13.
        MODIFY lv_fieldcat FROM wa_lv_fieldcat.
      WHEN 'CPI'.
        wa_lv_fieldcat-seltext_l = 'CPI'.
        wa_lv_fieldcat-ddictxt = 'L'.
        wa_lv_fieldcat-ddic_outputlen = 13.
        MODIFY lv_fieldcat FROM wa_lv_fieldcat.
      WHEN 'GROSS_2'.
        wa_lv_fieldcat-seltext_l = 'Total incl. Bonus & CPI'.
        wa_lv_fieldcat-ddictxt = 'L'.
        wa_lv_fieldcat-ddic_outputlen = 13.
        MODIFY lv_fieldcat FROM wa_lv_fieldcat.
      WHEN 'PU'.
        wa_lv_fieldcat-seltext_l = 'PU'.
        wa_lv_fieldcat-ddictxt = 'L'.
        wa_lv_fieldcat-ddic_outputlen = 13.
        MODIFY lv_fieldcat FROM wa_lv_fieldcat.
      WHEN 'DU'.
        wa_lv_fieldcat-seltext_l = 'DU'.
        wa_lv_fieldcat-ddictxt = 'L'.
        wa_lv_fieldcat-ddic_outputlen = 13.
        MODIFY lv_fieldcat FROM wa_lv_fieldcat.
      WHEN 'LOCATION'.
        wa_lv_fieldcat-seltext_l = 'Location'.
        wa_lv_fieldcat-ddictxt = 'L'.
        wa_lv_fieldcat-ddic_outputlen = 13.
        MODIFY lv_fieldcat FROM wa_lv_fieldcat.
      WHEN 'REGION'.
        wa_lv_fieldcat-seltext_l = 'Region'.
        wa_lv_fieldcat-ddictxt = 'L'.
        wa_lv_fieldcat-ddic_outputlen = 13.
        MODIFY lv_fieldcat FROM wa_lv_fieldcat.
      WHEN 'PROVISION'.
        wa_lv_fieldcat-seltext_l = 'Bonus @ 100 %'.
        wa_lv_fieldcat-ddictxt = 'L'.
        wa_lv_fieldcat-ddic_outputlen = 13.
        MODIFY lv_fieldcat FROM wa_lv_fieldcat.
      WHEN 'TAX'.
        wa_lv_fieldcat-seltext_l = 'Tax'.
        wa_lv_fieldcat-ddictxt = 'L'.
        wa_lv_fieldcat-ddic_outputlen = 13.
        MODIFY lv_fieldcat FROM wa_lv_fieldcat.
      WHEN 'TOTAL'.
        wa_lv_fieldcat-seltext_l = 'Total Bonus Cost @ 100%'.
        wa_lv_fieldcat-ddictxt = 'L'.
        wa_lv_fieldcat-ddic_outputlen = 13.
        MODIFY lv_fieldcat FROM wa_lv_fieldcat.
      WHEN 'START_PERIOD'.
        wa_lv_fieldcat-seltext_l = 'Start Period'.
        wa_lv_fieldcat-ddictxt = 'L'.
        wa_lv_fieldcat-ddic_outputlen = 13.
        MODIFY lv_fieldcat FROM wa_lv_fieldcat.
      WHEN 'END_PERIOD'.
        wa_lv_fieldcat-seltext_l = 'End Period'.
        wa_lv_fieldcat-ddictxt = 'L'.
        wa_lv_fieldcat-ddic_outputlen = 13.
        MODIFY lv_fieldcat FROM wa_lv_fieldcat.
      WHEN 'CATEGORY'.
        wa_lv_fieldcat-seltext_l = 'Category'.
        wa_lv_fieldcat-ddictxt = 'L'.
        wa_lv_fieldcat-ddic_outputlen = 13.
        MODIFY lv_fieldcat FROM wa_lv_fieldcat.
      WHEN 'GROSS'.
        wa_lv_fieldcat-seltext_l = 'Expected Bonus Payout'.
        wa_lv_fieldcat-ddictxt = 'L'.
        wa_lv_fieldcat-ddic_outputlen = 13.
        MODIFY lv_fieldcat FROM wa_lv_fieldcat.
    ENDCASE.
  ENDLOOP.
ENDFORM.                    " INIT_FIELDCAT
*&      Form  ALV_LISTDISPLAY
      Use the function to display the alv list
FORM alv_listdisplay.
  CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
       EXPORTING
            i_program_name         = driver
            i_internal_tabname     = 'IT_OVERSEAS'
            i_client_never_display = 'X'
            i_inclname             = driver
       CHANGING
            ct_fieldcat            = lv_fieldcat[]
       EXCEPTIONS
            inconsistent_interface = 1
            program_error          = 2
            OTHERS                 = 3.
  IF sy-subrc <> 0.
  ENDIF.
*Add correct column names..
  PERFORM init_fieldcat.
*Display the list.
  CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
       EXPORTING
            i_callback_program      = driver
            it_fieldcat             = lv_fieldcat[]
            i_default               = 'X'
            i_save                  = 'A'
            is_variant              = lv_tmplt
            is_layout               = lv_ls_layout
            i_callback_user_command = 'USER_COMMAND'
       TABLES
            t_outtab                = it_overseas
       EXCEPTIONS
            program_error           = 1
            OTHERS                  = 2.
  IF sy-subrc <> 0.
  ENDIF.
ENDFORM.                    " ALV_LISTDISPLAY
*&      Form  DATA_SELECTION
      Select the data from various tables and logical database
FORM data_selection.
  CONCATENATE  p_pabrj p_pabrp '01' INTO lc_dt.
*Get the last date of the month
  CALL FUNCTION 'RP_LAST_DAY_OF_MONTHS'
       EXPORTING
            day_in            = lc_dt
       IMPORTING
            last_day_of_month = gc_enddate
       EXCEPTIONS
            day_in_no_date    = 1.
  IF sy-subrc <> 0.
    WRITE : / 'Error in date entry'.
  ENDIF.
  CONCATENATE p_pabrj p_pabrp '01' INTO gc_startdate. "startdate
  SELECT * FROM pa0008
    WHERE (
            ( begda BETWEEN gc_startdate and gc_enddate )
            OR ( endda BETWEEN gc_startdate AND gc_enddate )
            OR ( begda >= gc_startdate AND endda >= gc_enddate )
            OR ( begda <= gc_startdate AND endda = '99991231' )
      AND subty NE '0'
      AND subty NE '11'.
    it_overseas-empno = pa0008-pernr.
    IF sy-subrc = 0.
*Check whether employee has left.
      CALL FUNCTION 'HR_LEAVING_DATE'
           EXPORTING
                persnr                 = pa0008-pernr
           IMPORTING
                leavingdate            = gc_chkdate
           TABLES
                leaving_dates          = it_leavedate
           EXCEPTIONS
                leaving_date_not_found = 1
                pernr_not_assigned     = 2
                OTHERS                 = 3.
      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.
        IF gc_chkdate BETWEEN gc_startdate AND gc_enddate
            OR gc_chkdate >= gc_startdate.
        ELSE.
          CONTINUE.
        ENDIF.
      ENDIF.
*Check whether the start date is less than the enddate of the month
*If it is less than the enddate of the month then only take that record.
      IF pa0008-begda <= gc_enddate.
Getting the name of the employees
        CALL FUNCTION 'CATS_GET_EMPLOYEE_NAME'
             EXPORTING
                  pernr           = it_overseas-empno
             IMPORTING
                  name            = it_overseas-name
             EXCEPTIONS
                  pernr_not_found = 1.
        IF sy-subrc <> 0.
        ENDIF.
*Get the joining date of the employees
        CALL FUNCTION 'RP_GET_HIRE_DATE'
             EXPORTING
                  persnr          = it_overseas-empno
                  check_infotypes = '0000'
             IMPORTING
                  hiredate        = it_overseas-doj.
*Get the role information for the employee
       rp-read-infotype pa0008-pernr 9001 p9001 gc_startdate gc_enddate.
        PROVIDE * FROM p9001 BETWEEN gc_startdate AND gc_enddate.
*Get the role description for that particular period.
          SELECT SINGLE zrole_desc INTO (it_overseas-c_role_desc)
          FROM zhrrole WHERE zrole_cd = p9001-zrole_cd.
*Get the job Band for that employee
      SELECT SINGLE * FROM zhrrole_assg WHERE zrole_cd = p9001-zrole_cd.
          SELECT SINGLE zband_desc INTO it_overseas-band
                FROM zhrband
               WHERE zband_cd = zhrrole_assg-zband_cd.
        ENDPROVIDE.
*Get Personal Sub Band
        it_overseas-perband = pa0008-trfgr.
*Get pay data
        CALL FUNCTION 'RP_FILL_WAGE_TYPE_TABLE'
             EXPORTING
                  appli                        = 'E'
                  begda                        = pa0008-begda
                  endda                        = pa0008-endda
                  infty                        = '0008'
                  pernr                        = pa0008-pernr
                  subty                        = pa0008-subty
             TABLES
                  ppbwla                       = ppbwla  "output
             EXCEPTIONS
                  error_at_indirect_evaluation = 1.
        IF sy-subrc <>  0.
          REFRESH ppbwla.
          CLEAR ppbwla.
        ELSE.
          LOOP AT ppbwla.
            it_overseas-currency = ppbwla-waers.
            IF ppbwla-lgart = '8101'
              OR ppbwla-lgart = '6001' OR ppbwla-lgart = '6002'
              OR ppbwla-lgart = '6003' OR ppbwla-lgart = '6004'
              OR ppbwla-lgart = '7151' OR ppbwla-lgart = '6005'
              OR ppbwla-lgart = '6006' OR ppbwla-lgart = '6007'
              OR ppbwla-lgart = '6008' OR ppbwla-lgart = '6009'
              OR ppbwla-lgart = '6010' OR ppbwla-lgart = '6011'
              OR ppbwla-lgart = '6012' OR ppbwla-lgart = '6013'
              OR ppbwla-lgart = '6014' OR ppbwla-lgart = '6015'.
              it_overseas-basic = ppbwla-betrg.
            ELSEIF ppbwla-lgart = '8301'.
              it_overseas-hra  = ppbwla-betrg.
            ELSEIF ppbwla-lgart = '7801'.
              it_overseas-insurance  = ppbwla-betrg.
            ELSEIF ppbwla-lgart = '8302' OR ppbwla-lgart = '7802'
              OR ppbwla-lgart = '6301' OR ppbwla-lgart = '6303'
              OR ppbwla-lgart = '6302' OR ppbwla-lgart = '6304'
              OR ppbwla-lgart = '6305' OR ppbwla-lgart = '6306'
              OR ppbwla-lgart = '6307' OR ppbwla-lgart = '6308'
              OR ppbwla-lgart = '6309' OR ppbwla-lgart = '6310'
              OR ppbwla-lgart = '6311' OR ppbwla-lgart = '6312'
              OR ppbwla-lgart = '6313' OR ppbwla-lgart = '6314'.
              it_overseas-oda = ppbwla-betrg.
            ELSEIF ppbwla-lgart = '6409'
              OR ppbwla-lgart = '6410' OR ppbwla-lgart = '6411'
              OR ppbwla-lgart = '6412' OR ppbwla-lgart = '6413'
              OR ppbwla-lgart = '6414' OR ppbwla-lgart = '8303'
              OR ppbwla-lgart = '6401' OR ppbwla-lgart = '6402'
              OR ppbwla-lgart = '6403' OR ppbwla-lgart = '6404'
              OR ppbwla-lgart = '6405' OR ppbwla-lgart = '6406'
              OR ppbwla-lgart = '6407' OR ppbwla-lgart = '6408'
              OR ppbwla-lgart = '7803' OR ppbwla-lgart = '6415'.
              it_overseas-car_all = ppbwla-betrg.
            ELSEIF ppbwla-lgart = '8945'
              OR ppbwla-lgart = '6101' OR ppbwla-lgart = '6102'
              OR ppbwla-lgart = '6103' OR ppbwla-lgart = '6104'
              OR ppbwla-lgart = '7945' OR ppbwla-lgart = '6105'
              OR ppbwla-lgart = '6106' OR ppbwla-lgart = '6107'
              OR ppbwla-lgart = '6108' OR ppbwla-lgart = '6109'
              OR ppbwla-lgart = '6110' OR ppbwla-lgart = '6111'
              OR ppbwla-lgart = '6112' OR ppbwla-lgart = '6113'
              OR ppbwla-lgart = '6114' OR ppbwla-lgart = '6115'.
              it_overseas-bonus = ppbwla-betrg.
            ELSEIF ppbwla-lgart = '8975'
              OR ppbwla-lgart = '6201' OR ppbwla-lgart = '6202'
              OR ppbwla-lgart = '6203' OR ppbwla-lgart = '6204'
              OR ppbwla-lgart = '7975' OR ppbwla-lgart = '6205'
              OR ppbwla-lgart = '6206' OR ppbwla-lgart = '6207'
              OR ppbwla-lgart = '6208' OR ppbwla-lgart = '6209'
              OR ppbwla-lgart = '6210' OR ppbwla-lgart = '6211'
              OR ppbwla-lgart = '6212' OR ppbwla-lgart = '6213'
              OR ppbwla-lgart = '6214' OR ppbwla-lgart = '6215'.
              it_overseas-cpi = ppbwla-betrg.
            ENDIF.
          ENDLOOP.
          REFRESH ppbwla.
        ENDIF.
*Add which country according to the subtype of the record
        SELECT SINGLE stext INTO it_overseas-country
                  FROM t591s WHERE subty = pa0008-subty
                   AND infty = '0008'
                   AND sprsl = sy-langu.
*Addition to gross components
        it_overseas-gross_1 = it_overseas-basic  + it_overseas-hra
                             + it_overseas-insurance + it_overseas-oda
                             + it_overseas-car_all.
        it_overseas-gross_2 =  it_overseas-bonus + it_overseas-cpi
                                + it_overseas-gross_1.
*Get PU DU Location and Region for the employee
       rp-read-infotype pa0008-pernr 0001 p0001 gc_startdate gc_enddate.
        PROVIDE * FROM p0001 BETWEEN gc_startdate AND gc_enddate.
          SELECT SINGLE * FROM t001p WHERE btrtl = p0001-btrtl.
          SELECT SINGLE * FROM t503t WHERE persk = p0001-persk.
          SELECT SINGLE * FROM t500p WHERE persa = p0001-werks.
          SELECT SINGLE * FROM t005h WHERE land1 = t500p-land1 AND
          regio = t500p-regio AND cityc = t500p-cityc.
          it_overseas-pu = t001p-btext.
          it_overseas-location = t500p-name1.               "dev903953
          it_overseas-region = t005h-bezei.
        ENDPROVIDE.
*Get the DU Details from infotype 9009
<b>      rp-read-infotype pa0008-pernr 9009 p9009 gc_startdate gc_enddate.
        PROVIDE * FROM p9009 BETWEEN gc_startdate AND gc_enddate.
          it_overseas-du = p9009-du_cd.
        ENDPROVIDE.</b>*Decide the category
        PERFORM get_category.
*Calculate the Provision
*Start and enddate of the period
        IF pa0008-begda <= gc_startdate.
          it_overseas-start_period = gc_startdate.
        ELSE.
          it_overseas-start_period = pa0008-begda.
        ENDIF.
        IF gc_enddate <= pa0008-endda.
          it_overseas-end_period = gc_enddate.
        ELSE.
          it_overseas-end_period = pa0008-endda.
        ENDIF.
*The monthly bonus is bonus / 12
        lf_mon_bonus = it_overseas-bonus / 12.
*Working days onsite. Add 1 to days to consider todays day.
If employee has resigned.
        li_tdt = it_overseas-end_period - it_overseas-start_period  + 1.
        li_days = gc_enddate - gc_startdate + 1.
        it_overseas-provision = ( lf_mon_bonus * li_tdt ) / li_days.
*Tax Calculation.
        it_overseas-tax = it_overseas-provision * p_prcnt / 100.
*Total Provision
        it_overseas-total = it_overseas-provision + it_overseas-tax.
*Gross Provision
        it_overseas-gross = it_overseas-total * p_bprcnt / 100.
        APPEND it_overseas.
        CLEAR it_overseas.
        CLEAR gc_chkdate.
        CLEAR : zhrrole, zhrband, zhrrole_assg,t001p,t503t,t500p.
        CLEAR : p0001,p9001,p9009.
      ENDIF.
    ENDIF.
  ENDSELECT.
ENDFORM.                    " DATA_SELECTION
      FORM USER_COMMAND                                SK           *
      USER COMMAND FOR DYNAMIC REPORTING      -SHEKHAR KULKARNI     *
-->  UCOMM                                                         *
-->  SELFIELD                                                      *
FORM user_command USING ucomm LIKE sy-ucomm
                       selfield TYPE slis_selfield.
  READ TABLE it_overseas INDEX selfield-tabindex.
  CHECK sy-subrc = 0.
  CASE ucomm.
    WHEN '&IC1'.
      CASE selfield-sel_tab_field.
*If clicked on BAND.
        WHEN 'IT_OVERSEAS-EMPNO' OR 'IT_OVERSEAS-NAME'.
          PERFORM display_details USING it_overseas-empno.
*If clicked on Purchase order.
      ENDCASE.
  ENDCASE.
ENDFORM.
*&      Form  DISPLAY_DETAILS
     Display the selected employee details.
     -->P_IT_OVERSEAS_EMPNO  text
FORM display_details USING    p_it_overseas_empno.
READ TABLE IT_OVERSEAS WITH KEY EMPNO = P_IT_OVERSEAS_EMPNO
              BINARY SEARCH.
*transporting empno total.
  IF sy-subrc = 0.
    LOOP AT it_overseas.
      it_empoverseas-empno = it_overseas-empno.
      it_empoverseas-country = it_overseas-country.
      it_empoverseas-currency = it_overseas-currency.
      it_empoverseas-category = it_overseas-category.
      it_empoverseas-name = it_overseas-name.
      it_empoverseas-gross = it_overseas-gross.
      APPEND it_empoverseas.
    ENDLOOP.
    SORT it_empoverseas BY category currency empno.
    REFRESH lv_fieldcat[].
    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
         EXPORTING
              i_program_name         = driver
              i_internal_tabname     = 'IT_EMPOVERSEAS'
              i_client_never_display = 'X'
              i_inclname             = driver
         CHANGING
              ct_fieldcat            = lv_fieldcat[]
         EXCEPTIONS
              inconsistent_interface = 1
              program_error          = 2
              OTHERS                 = 3.
    IF sy-subrc <> 0.
    ENDIF.
    PERFORM init_fieldcat.
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
         EXPORTING
              i_callback_program = driver
              it_fieldcat        = lv_fieldcat[]
              i_default          = 'X'
              i_save             = 'A'
              is_variant         = lv_tmplt
              is_layout          = lv_ls_layout
         TABLES
              t_outtab           = it_empoverseas
         EXCEPTIONS
              program_error      = 1
              OTHERS             = 2.
    IF sy-subrc <> 0.
    ENDIF.
  ENDIF.
  REFRESH it_empoverseas.
ENDFORM.                    " DISPLAY_DETAILS
*&      Form  GET_CATEGORY
     Find out the category of the person.
FORM get_category.
  CASE p0001-btrtl.
    WHEN '30' OR '31' OR '35' OR '36' OR '39' OR '45' OR '47' OR '48'
    OR '49' OR '65' OR '71' OR '74'.
      it_overseas-category = 'Sales'.
    WHEN '63'.
      it_overseas-category = 'IBCS'.
    WHEN '54' OR '18' OR '19' OR '20'.
      it_overseas-category = 'Banking Bonus'.
    WHEN OTHERS.
      it_overseas-category = 'Others'.
  ENDCASE.
  IF (     p9001-zrole_cd = 'BM'
        OR p9001-zrole_cd = 'GEM'
        OR p9001-zrole_cd = 'KEYACMGR'
        OR p9001-zrole_cd = 'AM'
        OR p9001-zrole_cd = 'BSM'
        OR p9001-zrole_cd = 'ENGMGR' ).
    it_overseas-category = 'AM/BM/EM'.
  ENDIF.
  IF ( p9001-zrole_cd = 'PRINCIPAL'
      OR p9001-zrole_cd = 'SRPRIN' ).
    it_overseas-category = 'IBCS'.
  ENDIF.
ENDFORM.                    " GET_CATEGORY
<b></b>

Similar Messages

  • HR ABAP Macro include files?

    Hi all ABAPers,
    I am trying to develope a BAPI using HR ABAP Macro. (Eg RP-EXP-C1-TX ,RP-EXP-C3-TY)
    obviously, ABAP Macro is pretty new to me....
    I have a feeling HR ABAP macro requires me to "Include" some file beforeI can use it.
    Can anyone please let me know what include file I should put it on.
    Any help appreciated!!!!

    Hi,
    before you can use it ABAP macro requires you to define it
    in the program ( or one of its includes) or in table TRMAC.
    In the macro definition you can use tables, files etc.
    e. g. for macro
    AA-BB-DD-XX
    you should code in the program ( or one of its includes):
    DEFINE AA-BB-DD-XX.
    LOOP AT ITAB.
    MOVE-CORRESPONDING ITAB TO ITAB2.
    ITAB2-FIELD1 = 8.
    APPEND ITAB2. " or write or upload etc.
    ENDLOOP.
    END-OF-DEFINITION.

  • How to debug abap macros?

    Hi,
    Can anyone tell me How to debug abap macros?
    Thanks in advance.
    -Selva

    Hi Rigel,
    Understand it is a very old thread, but still could you please help me out with this? I tried to search for the option which you mentioned, but to no avail. I have SAP ECC 7.0.
    Thanks in advance.

  • HR-ABAP macros avoid

    I am new  to HR-ABAP
    i want to avoid this macro
      rp-provide-from-last p0000 space pn-begda pn-endda.
    plz send how to write code , with this place.
    2. i want to move one internal table fileds to another table
       but i do not use move-corresponding ? how plz send code

    1. to avoid the macro, here is exact code which works behind that macro.
    SORT P0000.
    PNP-SW-FOUND = '0'.
    CLEAR PNP-SY-TABIX.
    LOOP AT P0000.
      IF P0000-BEGDA LE PN-ENDDA AND P0000-ENDDA GE PN-ENDDA.
        PNP-SW-FOUND = '1'.
        EXIT.
      ENDIF.
      IF P0000-BEGDA LE PN-ENDDA AND P0000-ENDDA GE PN-BEGDA.
        PNP-SY-TABIX = SY-TABIX.
      ENDIF.
    ENDLOOP.
    IF PNP-SW-FOUND EQ '0'.
      IF PNP-SY-TABIX NE 0.
        PNP-SW-FOUND = '1'.
        READ TABLE P0000 INDEX PNP-SY-TABIX.
      ELSE.
        CLEAR P0000.
      ENDIF.
    ENDIF.
    2. To assign an internal table to another without move coresponding, just copy like this:
    it_new[] = it_old[].

  • Regarding abap Macros

    Hi Experts,
    I am wring the programming in Abap-Hr usnig Macros.
    But my clients requirement is, don't use macros when using LDB's. Is it possible for payroll results.
    By using the macro
    RP_PROVIDE_FROM_LAST P0002 SPACE LOW-DATE HIGH-DATE
    what is the alternative of this macro by retrieving the data from infotype based on PERNR.
    thanks in advance.
    Sai
    Edited by: Sai Babu on Nov 21, 2008 8:19 AM

    Hi
    You can use HR_READ_INFOTYPE function module to read latest record of an employee.
    pass system date (sy-datum) in importing parameters validbegin and validend.
    Thanks
    Vishal Kapoor

  • Abap macro parameter number limit?

    Is there any number of macro parameter restriction?
    I am using "set_column" to populate field-category for ALV report. Every is fine until I add ls_fcat-no_out    = &10.  I wonder the max parameter no. is 9? Then what can I do for this case?
      DEFINE set_column.
        clear ls_fcat.
        ls_fcat-fieldname = &1.
        ls_fcat-scrtext_l = &2.
        ls_fcat-edit      = &3.
        ls_fcat-do_sum    = &4.
        ls_fcat-no_zero   = &5.
        ls_fcat-just      = &6.
        ls_fcat-datatype  = &7.
        ls_fcat-outputlen = &8.
        ls_fcat-emphasize = &9.
        ls_fcat-no_out    = &10.
        append ls_fcat to pt_fcat.
      END-OF-DEFINITION.

    Only up to 9 parameters !!.
    Thanks
    Venkat.

  • Javascript in abap

    hi,
    I'm trying to dynamically build a condition and then do an IF cond.
    Unfortunately, dynamics are not supported very well in ABAP. Therefore, it was suggested to me by a gentleman named Christian to use javascript to do this.
    ex.
    //dynamically constructed cond
    if (cond).
      write:/ 'success'.
    else.
      write:/ 'F'.
    endif.
    I have already built the condition dynamically in ABAP, so I do not need to construct it in JAVA.
    I tried several ABAP macros and variations of syntax- unsuccessfully.
    Now I plan on creating a javascript within my ABAP. I'm using the following as documentation to lead me in the right direction. (https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/documents/a1-8-4/abap faqs.faq#q-17).
    It seems like the  <b>CL_JAVA_SCRIPT </b> javascript class is not available on 46. is this true?
    Is there another javascript class on the 46 system I can refer to?
    Also, that link refers me to the program DEMO_JAVA_SCRIPT_MINI_EDITOR. How do I access this?
    Please help if you can,
    Natasha

    Hi  Marcin,
    Thankyou for your quick reply.
    It is server side scripting only. but i have already chekced the link which u sent me. i did not find anything realted ... we are not able to debug the issue?
                This is the place where it is throwing the error:
           var lv_pct=`FREM-TBR_PCT[j]`
                       if (parseInt("`lv_pct`") == `i`)
    is the syntax of the code is correct?
    Do you want me to send the whole code to you?
    Also please tell me if there any way to debug the javascripts  for this IAC applications.
    Thanks & Regards,
    Kavitha.

  • Macro syntax for non-negativity

    Hi,
    Could some one copy past the syntax for non-negativity like this
    If KF1 < 0, then KF1 = 0 else KF1
    This condition needs to be applied on top of existing macro for KF1 that does some arithmatic whose result could be < 0.
    would appreciate if you copy paste the steps.. that you may already have in any of your macro books.
    I also take this opportunity to request the macro experts to compile a wiki document on macro syntax.. A piecemeal approach would also do without relating to WHERE such a macro could be used. I find this learning the macro syntax by trial and error a rather unproductive and painful experience.
    If some of you could volunteer lets build a fantastic reference document on the macros where everyone can contribute and come with with something really useful.
    The final list can then be classified into artithmatical, conditional, control, abap macros. A brief description alongside each macro and some expert comments on possible application can be later expanded. newer and alternate ways of realzing the same macro creatively and in lesser steps could be regularly appended. I could moderate if such a thing is correct and agreeable
    Regards,
    Loknath

    I cant have more than 10 questions open. so closing this though there arent any responses

  • Macro and Field Symbol

    Hi Experts,
    I want to assign the fields of a field symbol using a macro because the field names come from a table
    the code look like this
        DEFINE ASSIGN_VALUE.
          &1-&2 = &3.
        END-OF-DEFINITION.
        ASSIGN_VALUE <RESULT_FIELDS> FIELDNAME FIELDVALUE.
    Where FIELDNAME is a CHAR variable containing the name of the field
    I get the following error:
    E:The data object "<RESULT_FIELDS>" does not have a component called
    "FIELDNAME".
    The macro and the call to it are located in a method of a class ( end routine of a transformation in BW)
    Thanks for your help
    Thibault

    Hi
    Welcome to SDN forum
    See the doc of MACROS and do accordingly
    Macros
    If you want to reuse the same set of statements more than once in a program, you can include them in a macro. For example, this can be useful for long calculations or complex WRITE statements. You can only use a macro within the program in which it is defined, and it can only be called in lines of the program following its definition.
    The following statement block defines a macro macro:
    DEFINE makro.
       statements
    END-OF-DEFINITION.
    You must specify complete statements between DEFINE and END-OF-DEFINITION. These statements can contain up to nine placeholders &1, &2,...., &9). You must define the macro before the point in the program at which you want to use it.
    Macros do not belong to the definition part of the program. This means that the DEFINE statement block is not interpreted before the processing blocks in the program. At the same time, however, macros are not operational statements that are executed within a processing block at runtime. When the program is generated, macro definitions are not taken into account at the point at which they are defined. For this reason, they do not appear in the overview of the structure of processing logic.
    A macro definition inserts a form of shortcut at any point in a program and can be used at any subsequent point in the program. As the programmer, you must ensure that the macro definition occurs in the program before the macro itself is used. Particular care is required if you use both macros and include programs, since not all include programs are included in the syntax check (exception: TOP include).
    To use a macro, use the following form:
    makro [p1 p2... p9].
    When the program is generated, the system replaces the macro by the appropriate statements and the placeholders &1, &2, …, &9 by the parameter p1, p2, …, p9. You can use macros within macros. However, a macro cannot call itself.
    REPORT demo_mod_tech_macros.
    DATA: result TYPE i,
          n1     TYPE i VALUE 5,
          n2     TYPE i VALUE 6.
    DEFINE operation.
      result = &1 &2 &3.
      output   &1 &2 &3 result.
    END-OF-DEFINITION.
    DEFINE output.
      write: / 'The result of &1 &2 &3 is', &4.
    END-OF-DEFINITION.
    operation 4 + 3.
    operation 2 ** 7.
    operation n2 - n1.
    This produces the following output:
    The result of 4 + 3 is          7
    The result of 2 ** 7 is        128
    The result of N2 - N1 is          1
    In this example, the two macros operation and output are defined. output is nested in operation. operation is called three times with different parameters. Note how the placeholders &1, &2,... are replaced in the macros.
    The following example shows that a macro definition only works in the program lines following its definition. Do not copy it!
    Let us have a look at a program with a subroutine test:
    PROGRAM macro_test.
    FORM test.
      WRITE '...'.
    ENDFORM.
    We can rewrite the program by introducing a macro macro:
    PROGRAM macro_test.
    FORM test.
    DEFINE macro.
        WRITE '...'.
      ENDFORM.
    END-OF-DEFINITION.
    MACRO.
    Inserting the macro changes nothing in the generated form of the program. Processing blocks - here a subroutine - are always indivisible. We could also write the program as follows:
    PROGRAM macro_test.
    DEFINE macro.
        WRITE '...'.
      ENDFORM.
    END-OF-DEFINITION.
    FORM test.
    MACRO.
    The most essential feature of a macro definition is that it should occur before the macro is used.
    Macro in ABAP
    Macro in ABAP
    Submitted by : SAP Basis, ABAP Programming and Other IMG Stuff
                   http://www.sap-img.com
    REPORT ZMACRO.
    DATA: RESULT TYPE I,
          N1     TYPE I VALUE 5,
          N2     TYPE I VALUE 6.
    DEFINE OPERATION.
       RESULT = &1 &2 &3.
       OUTPUT   &1 &2 &3 RESULT.
    END-OF-DEFINITION.
    DEFINE OUTPUT.
       WRITE: / 'The result of &1 &2 &3 is', &4.
    END-OF-DEFINITION.
    OPERATION 4 + 3.
    OPERATION 2 ** 7.
    OPERATION N2 - N1.
    *-- End of Program
    Regards
    Anji

  • Web Dynpro OfficeObject with VB Macros

    Hi all,
      I'm trying to employ an MS Word Template using the OfficeControl. The word template has macros in it, tied to buttons. When this is previewed in the Mime repository, the buttons are there and the macro runs. When the document is called in the WD, the Word document doesn't appear, just a big white box with SAP IOS instead of the place where the document would normally be previewed.
    Anyone know why this is and how to fix it?
    Thanks in advance.

    Hi, Patrick,
    I know this is a very old post, but I have got similar issues, so maybe you would be able to help. I have the same scenario + we would like to execute the macros directly from ABAP (macro is digitally signed by the customer). This looks impossible once you use setfields( ) method to do the mail-merge (I believe the macro's digital signature is lost then - the ACF protocol shows up the message - not signed).
    I tried opening two documents in the view at once (which looks impossible). When running the macro name ".macroname", it seems to look for .dot template in the default location C:\Users\"USERNAME"\AppData\Roaming\Microsoft\Templates\. We've got Office 2010, so .dotm template should be used. But ACF trace protocol shows a message that word cannot open this template:
    "(c:\users\"USERNAME"\appdata\...\.dot)". In fact, I only suppose the whole path is appdata\roaming..., because the protocol shows only this wrapper. It does not state the name of the file, but I suppose that Normal.dot is what it looks for.
    The office control itselft has a property "DocumentName". I would expect that this property has some meaning, but it seems it does not (if I try to run a macro "RealDocumentName.MacroName" - it states that there is no open document RealDocumentName.
    Now how to force the ACF to look for .dotm instead of .dot? Or did you find any other suitable solution? If I created a .dot template (in an older version of office - which I do not have right now), I suppose I would be able to let the customer to digitally sign the document. But how to distribute this kind of stuff to all the target PCs, that is very confusing (not all the users will have the same version of Office).
    Any push is greatelly appreciates.

  • Itu00B4s possible use a bapi inside a macro?

    Hello APO experts!!
    We need to create a macro that will have to get the values of the independent demand of some sku´s and check the capacity of the productive resources...if the demand is less than the capacity, more demand (independent necessities) will have to be created to fullfill it.
    There will be a lot of calculations besides the use of a bapi.
    It´s possible to use a bapi inside a macro?
    If you have any suggestions, please tell me.
    Thanks a lot!!
    Regards
    Angela

    yes, you would do it via an ABAP macro.
    be careful with how this interacts with default macro logic in the sense that a BAPI reads data that is in the database (LC) so you may end needing to hit the save key after the macro call if you want to re-run the macro.

  • Error in PT60 realted to period

    When we run PT60 , we are getting an error - "Check entries in T549Q". When I look at this table with period parameter '01', the entries exists only up to 06/2011 which is the reason for the error. However, we only use period parameter '04' (T549A). Why is PT60 looking at period parameter '01'?
    I have also checked the ABAP macro RP-DEF-TIME-PERIOD in table TRMAC
    value there is  DATA RPTIME_PERIOD(2) VALUE '01

    I am not able to generate periods for parameter 01 as there is no entry in T549A. For our payroll area 04 period parameter is assigned.
    If I create a new payroll area in T549A and assign 01 as period parameter,I am able to generate periods for 01. Then i can run PT60 with no errors but is this a right way to do?
    Edited by: vasehgal on Jan 4, 2011 8:16 AM

  • Product view in DP session

    Hello
    In the SNP94 I use the characteristic locationproduct in the shuffler. With a right click I can show me the product view (via Shuffler).
    I want to use this function in a DP session, but how I define ja characteristi combination locationproduct for the shuffler?
    Thanks, sven

    Dear Sven,
             As far as I know there is no direct answer for it.
    But still you can view the SNP transaction data from the DP planning book.
    This may require lot of vaildations and Coding (ABAP/Macro).
    Thanks,
    Siva.

  • How to call HR Macros in ABAP-Webdynpro

    HI all,
    I want to extract HR data in webdynpro view.
    Where should I give Logical Database PNP?
    The ifnotypes key word is not accepting in Webdynpro coding?
    Where should I give GET PERNR event in Webdynpro?
    When I use RP_PROVIDE_FROM_LAST .... says error message
    Statement "RP_PROVIDE_FROM_LAST" is not defined. Check your spelling .
    How to use the Macros in Webdynpro (VIEW) methods.
    First time I'm working in ABAP-HR Webynpro.
    Please help me out..
    Thanks,
    Prasad

    Hi,
    How did u  solve this? pls provide the solution.
    Regards,
    Lakshmi.

  • Calling HR Macros in ABAP-Webdynpro

    HI all,
    I want to extract HR data in webdynpro view.
    Where should I give Logical Database PNP?
    The ifnotypes key word is not accepting in Webdynpro coding?
    Where should I give GET PERNR event in Webdynpro?
    When I use RP_PROVIDE_FROM_LAST .... says error message 
    Statement "RP_PROVIDE_FROM_LAST" is not defined. Check your spelling .
    How to use the Macros in Webdynpro (VIEW) methods.
    First time I'm working in ABAP-HR Webynpro.
    Please help me out..
    Thanks,
    Prasad

    Hi,
    I suspect that you are in a right forum. Please post it to appropriate forum.

Maybe you are looking for