Subtype in abap hr

Hi Friends,
I have to retrive data from more than one(10-20) subtype of infotype2001. But i am using Rp_provide_from_last statement in my program.
How can i retrive.

As long as you use macros to access infotype data (i.e rp_provide_from_last ) I believe you also have declaration like
infotypes 2001.
This means that corresponding table p2001 is filled with all the data for particular EE during GET PERNR event. So all you need is to restrict the records from internal table with the subtypes you want, like
loop at p2001 where subty = ...
                              or subty = ...
"here process only selected subtypes' records
endloop.
or use range table, append there all the subtypes you want and use it in the loop
loop at p2001 where subty in it_range_subty.
  "here process only selected subtypes' records
endloop.
Regards
Marcin

Similar Messages

  • Getting the data for the infotype 0006 and Subtype 4 in HR ABAP

    Hi All,
       I need to get the data from the info type 0006 and the subtype 4 , only i need to fetch the data in communications . Could you any one tell me best way to fetch that data.
    Thanks,
    SAP SAR.

    Write a select single on PA0006 for the given pernr begin and end dates and for subtype 4 ...
    select single * from PA0006
               where pernr = p_pernr
               and SUBTY = '0004'
               and ENDDA >= s_date-low
               and BEGDA <= s_date-high.

  • SAP: HR/ABAP Pan Card Validation check in PA 30 (Subtype : 185)

    Hi Gurus,
    I am trying to implement BADI : ZHRPAD00INFTY for a validation check over the screen field  p0185-icnum.
    Pan must be of 10 digits .
    First five digit and tenth digit must be alphabet(A_Z)
    Sixth to Ninth digit must be Number (0,1,2,3,4,5,6,7,8,9)
    Fourth digit of Pan represent Assessee status,and if a Partnership firm provides pan with forth digit as P or C then it means the pan is incorrect
    Fifth Digit of Pan represent Surname as per Data filled in the application in case of Individual assessees and in other case first name .
    I require an assistance with code.
    Regards.

    Thank you always learner. Here is my working code in BAPI.
    IF new_innnn-infty = '0185'.  " Pan Card Check
    * screen field: P0185-ICNUM
         DATA: v_icnum TYPE i.
         DATA: text TYPE string,
            moff TYPE i,
            mlen TYPE i.
         FIELD-SYMBOLS : <fs_pan> TYPE any .
         ASSIGN ('(MP018500)P0185-ICNUM') TO <fs_pan>.
         v_icnum = strlen( <fs_pan> ).
         IF <fs_pan> IS NOT INITIAL AND v_icnum = '10' .
           FIND REGEX `[A-Z]{5}\d{4}[A-Z]{1}`
           IN <fs_pan>
              IGNORING CASE
              MATCH OFFSET moff
              MATCH LENGTH mlen.
           IF sy-subrc NE 0.
             MESSAGE e398(00) WITH 'Please Enter Valid Pan No.'.
           ENDIF.
         ELSE.
           MESSAGE e398(00) WITH 'Please Enter Valid Pan No.'.
         ENDIF.
       ENDIF.

  • HR ABAP report

    Hello,
    I am writing a bespoke HR ABAP report. I am using logical database PNP for this.
    I also need to include the Scale Proficiency Text in my report.
    I have had a look at the SAP standard Qualifications Overview report and I can see that this uses the logical database PCH.
    As I can only link to a single logical data, I am looking for a way of including the Scale Proficiency Text in my report.
    Does anyone have any ideas on this?
    Thanks,
    Ruby

    Hi,
    "" rp_provide_from_last p0033 space pn-begda pn-endda""
    Here if u don't want subtype specific records then give space otherwise u have to specify Subtype instead of space.
    ""provide * from p0033 between pn-ebgda and pn-endda
    endprovide.""
    used as loop where all records for the employee would be selected
    But if u use
    ""rp_provide_from_last p0033 '9001' pn-begda pn-endda""
    It will fetch only latest record for particular employee whose subtype is 9001.
    Hope it will help u!!!
    Regards,
    Aparna

  • Splash screen ABAP (Was 6.20) SAPGui 6.20

    I love splash screens. A small pop-up window with a picture should come for say 5  to 10 seconds and disappear by a timer task.
    Giving such timer splash screens at START or END makes the application attractive. I do it in VB PB & Java.
    How to do Slash screen in ABAP SAP GUI 6.20 WAS 6.20?
    Should be thrown up as a "floating" popup.
    Regards & Hopeful
    -jnc

    With good tips from Thomas Jung
    I made 2 function modules to suit my whims.
    SAP being a serious Businesss Software you cannot have too many JPGs floating around! One or two is fun.
    In Function group uou need two screens 0806 & 2009 which are essentially blank.
    I put 2 title Bars - 0806 "SAP - JOB in Progress"; 2009 - "SAP - JOB OVER!!"
    Code listing for function: ZJNC_START_SPLASH
    Description: Show Splash at Start
    FUNCTION zjnc_start_splash.
    ""Local interface:
    *"  IMPORTING
    *"     REFERENCE(IMAGEFILE) TYPE  C DEFAULT 'THANKS.JPG'
    *"     REFERENCE(WIDTH) TYPE  I DEFAULT 415
    *"     REFERENCE(HEIGHT) TYPE  I DEFAULT 274
    *"     REFERENCE(TIMEOUT) TYPE  I DEFAULT 3
    *"     REFERENCE(CALLBACK) TYPE  C
          Global data declarations
      MOVE imagefile TO g_name.
      MOVE width TO picwidth.
      MOVE height TO picheight.
      MOVE timeout TO pictimeout.
      MOVE callback TO piccallback.
      TRANSLATE piccallback TO UPPER CASE.
      PERFORM getpicurl.
      CALL SCREEN 0806.
    ENDFUNCTION.
    Code listing for function: ZJNC_END_SPLASH
    Description: Show Splash at End
    FUNCTION ZJNC_END_SPLASH.
    ""Local interface:
    *"  IMPORTING
    *"     REFERENCE(IMAGEFILE) TYPE  C DEFAULT 'THANKS.JPG'
    *"     REFERENCE(WIDTH) TYPE  I DEFAULT 415
    *"     REFERENCE(HEIGHT) TYPE  I DEFAULT 274
    *"     REFERENCE(TIMEOUT) TYPE  I DEFAULT 3
          Global data declarations
      MOVE imagefile TO g_name.
      MOVE width TO picwidth.
      MOVE height TO picheight.
      MOVE timeout TO pictimeout.
      PERFORM getpicurl.
      CALL SCREEN 2009.
    ENDFUNCTION.
    Code listing for: LZUTILTOP
    TOP level Include of Function Group ZUTIL
    Author Jayanta Narayan Choudhuri
            Flat 302
            395 Jodhpur Park
            Kolkata 700 068
          Email [email protected]
          URL:  http://www.geocities.com/ojnc
    FUNCTION-POOL zutil.                        "MESSAGE-ID ..
    TYPE-POOLS: abap.
    DATA: graphic_url(255),
          g_result   TYPE i,
          g_linesz   TYPE i,
          g_filesz   TYPE i,
          g_name(100).
    TYPES: t_graphic_line(256) TYPE x.
    DATA: graphic_line TYPE t_graphic_line,
          graphic_table TYPE TABLE OF t_graphic_line.
    DATA: picwidth        TYPE i,
          picheight       TYPE i,
          pictimeout      TYPE i,
          piccallback(60) TYPE c,
          first           TYPE boolean.
          CLASS ZCL_ES_SPLASH_SCREEN  DEFINITION
    CLASS zcl_es_splash_screen DEFINITION.
      PUBLIC SECTION.
        EVENTS on_close.
        METHODS constructor
          IMPORTING
            !i_num_secs  TYPE i DEFAULT 5
            !i_url       TYPE c
            !i_width     TYPE i
            !i_height    TYPE i.
      PROTECTED SECTION.
        METHODS handle_end_of_timer
          FOR EVENT finished OF cl_gui_timer.
      PRIVATE SECTION.
        DATA container TYPE REF TO cl_gui_dialogbox_container.
        DATA image     TYPE REF TO cl_gui_picture.
        DATA timer     TYPE REF TO cl_gui_timer.
    ENDCLASS.                    "ZCL_ES_SPLASH_SCREEN  DEFINITION
    CLASS ZCL_ES_SPLASH_SCREEN IMPLEMENTATION
    CLASS zcl_es_splash_screen IMPLEMENTATION.
      METHOD constructor.
        DATA: image_width     TYPE i,
              image_height    TYPE i.
        COMPUTE image_width  = i_width + 30.
        COMPUTE image_height = i_height + 50.
        CREATE OBJECT container
           EXPORTING
             width                       = 10
             height                      = 10
             top                         = 10
             left                        = 10
             name                        = 'DialogSplash'.
        CALL METHOD container->set_caption
          EXPORTING
            caption = g_name.
        CREATE OBJECT image
          EXPORTING
            parent = container.
        CALL METHOD image->load_picture_from_url
          EXPORTING
            url = i_url.
        image->set_display_mode( image->display_mode_normal_center ).
        cl_gui_cfw=>flush( ).
        container->set_metric( EXPORTING metric = image->metric_pixel ).
        DATA: myleft TYPE i,
              mytop  TYPE i.
        COMPUTE myleft = ( 800 - image_width ) / 2.
        COMPUTE mytop  = ( 600 - image_height ) / 2.
        IF myleft < 0.
          MOVE 0 TO myleft.
        ENDIF.
        IF mytop < 0.
          MOVE 0 TO mytop.
        ENDIF.
        container->set_position(
          EXPORTING
            height            = image_height
            left              = myleft
            top               = mytop
            width             = image_width ).
        cl_gui_cfw=>update_view( ).
        CREATE OBJECT timer.
        timer->interval = i_num_secs.
        SET HANDLER me->handle_end_of_timer FOR timer.
        timer->run( ).
        cl_gui_cfw=>flush( ).
      ENDMETHOD.                    "constructor
      METHOD handle_end_of_timer.
    I wanted NAMASTE to remain until JOB was complete.
       IF container IS NOT INITIAL.
         container->free( ).
         CLEAR container.
         FREE  container.
       ENDIF.
       IF timer IS NOT INITIAL.
         timer->free( ).
         CLEAR timer.
         FREE  timer.
       ENDIF.
       cl_gui_cfw=>flush( ).
        RAISE EVENT on_close.
      ENDMETHOD.                    "handle_end_of_timer
    ENDCLASS.                    "ZCL_ES_SPLASH_SCREEN  IMPLEMENTATION
          CLASS lcl_event_handler DEFINITION
    CLASS lcl_event_handler DEFINITION.
      PUBLIC SECTION.
        CLASS-METHODS: on_close FOR EVENT on_close OF zcl_es_splash_screen.
    ENDCLASS. "lcl_event_handler DEFINITION
    CLASS lcl_event_handler IMPLEMENTATION
    CLASS lcl_event_handler IMPLEMENTATION.
      METHOD on_close.
        IF sy-dynnr = 2009.
          LEAVE PROGRAM.
        ELSE.
          MOVE abap_false TO first.
          PERFORM (piccallback) IN PROGRAM (sy-cprog).
        ENDIF.
      ENDMETHOD. "on_close
    ENDCLASS. "lcl_event_handler IMPLEMENTATION
    DATA: splash TYPE REF TO zcl_es_splash_screen.
    *&      Module  STATUS_0806  OUTPUT
    MODULE status_0806 OUTPUT.
      IF first IS INITIAL.
        first = abap_true.
        SET TITLEBAR 'TITLE0806'.
        CREATE OBJECT splash
            EXPORTING
              i_num_secs = pictimeout
              i_url      = graphic_url
              i_width    = picwidth
              i_height   = picheight.
        SET HANDLER lcl_event_handler=>on_close FOR splash.
      ENDIF.
    ENDMODULE.                " STATUS_0806  OUTPUT
    *&      Module  STATUS_2009  OUTPUT
    MODULE status_2009 OUTPUT.
      IF first IS INITIAL.
        first = abap_true.
        SET TITLEBAR 'TITLE2009'.
        CREATE OBJECT splash
            EXPORTING
              i_num_secs = pictimeout
              i_url      = graphic_url
              i_width    = picwidth
              i_height   = picheight.
        SET HANDLER lcl_event_handler=>on_close FOR splash.
      ENDIF.
    ENDMODULE.                " STATUS_2009  OUTPUT
    *&      Form  getpicurl
    FORM getpicurl.
      OPEN DATASET g_name FOR INPUT IN BINARY MODE.
      REFRESH graphic_table.
      CLEAR   g_filesz.
      DO.
        CLEAR graphic_line.
        READ DATASET g_name INTO graphic_line ACTUAL LENGTH g_linesz.
        ADD g_linesz TO g_filesz.
        APPEND graphic_line TO graphic_table.
        IF sy-subrc <> 0.
          EXIT.
        ENDIF.
      ENDDO.
      CLOSE DATASET g_name.
      CLEAR graphic_url.
      CALL FUNCTION 'DP_CREATE_URL'
        EXPORTING
          type                 = 'IMAGE'
          subtype              = 'GIF'
        TABLES
          data                 = graphic_table
        CHANGING
          url                  = graphic_url
        EXCEPTIONS
          dp_invalid_parameter = 1
          dp_error_put_table   = 2
          dp_error_general     = 3
          OTHERS               = 4.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        EXIT.
      ENDIF.
    ENDFORM.                    "getpicurl
    Extracted by Direct Download Enterprise version 1.2 - E.G.Mellodew. 1998-2004 UK.

  • How to define default subtypes for Infotype 0105 on entry

    Hello;
      I have spend an entire day trying to look into PA configuration to determin how to make specific Subtype of the 0105 Communication Infotype automatically appear when an HR person is entering in a new employee.
    Currently we have the 0001, 0010, and ADP subtypes automatically appear in the Communication Infotype screen when the person is entering in a new employee.  I was asked to create three new Subtypes for Infortype 0105 and have these new subtypes automatically appear on the data entry screen for Infotype 0105.
    I can not find anywhere in configuration how to do this.  I ahve burnt an entire day searching configuration and have about had it with this garbage.
    Can someone please point me to specific spot in configuration where these subtypes of and Infotype can be identified as default data entry screens.
    I would greatly appreciate any help ... since I am not a HR Configurator ... just a plain old ABAP'er who has lost our configurators.
    Scott.

    Hi Scott,
    To create subtypes follow:
    Tcode: SPRO
    Path: Personnel Management>Personnel Administration>Communication>Create Communication Types
    Half the job is done. Then include those subtypes in your hiring action. To do so:
    Tcode: SPRO
    Path: Personnel Management>Personnel Administration>Customizing Procedures>Actions>Define infogroups>Info group
    Select your hiring infogroup and create new entries with operation INS for 105 and the three subtypes.
    You are all set!
    Cheers,
    Donnie

  • 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>

  • Abap-hr real time questions

    hi friends
    kindly send me ABAP-HR REAL TIME QUESTION to my mail [email protected]
    Thanks&Regards
    babasish

    Hi
    Logical database
    A logical database is a special ABAP/4 program which combines the contents of certain database tables. Using logical databases facilitates the process of reading database tables.
    HR Logical Database is PNP
    Main Functions of the logical database PNP:
    Standard Selection screen
    Data Retrieval
    Authorization check 
    To use logical database PNP in your program, specify in your program attributes.
    Standard Selection Screen
    Date selection
    Date selection delimits the time period for which data is evaluated. GET PERNR retrieves all records of the relevant infotypes from the database.  When you enter a date selection period, the PROVIDE loop retrieves the infotype records whose validity period overlaps with at least one day of this period.
    Person selection
    Person selection is the 'true' selection of choosing a group of employees for whom the report is to run.
    Sorting Data
    · The standard sort sequence lists personnel numbers in ascending order.
    · SORT function allows you to sort the report data otherwise. All the sorting fields are from infotype 0001.
    Report Class
    · You can suppress input fields which are not used on the selection screen by assigning a report class to your program.
    · If SAP standard delivered report classes do not satisfy your requirements, you can create your own report class through the IMG.
    Data Retrieval from LDB
    1. Create data structures for infotypes.
        INFOTYPES: 0001, "ORG ASSIGNMENT
                            0002, "PERSONAL DATA
                            0008. "BASIC PAY
    2. Fill data structures with the infotype records.
        Start-of-selection.
             GET PERNR.
        End-0f-selection. 
        Read Master Data
    Infotype structures (after GET PERNR) are internal tables loaded with data.
    The infotype records (selected within the period) are processed sequentially by the PROVIDE - ENDPROVIDE loop.
              GET PERNR.
                 PROVIDE * FROM Pnnnn BETWEEN PN/BEGDA AND PN/ENDDA
                        If Pnnnn-XXXX = ' '. write:/ Pnnnn-XXXX. endif.
                 ENDPROVIDE.
    Period-Related Data
    All infotype records are time stamped.
    IT0006 (Address infotype)
    01/01/1990   12/31/9999  present
              Which record to be read depends on the date selection period specified on the
              selection screen. PN/BEGDA PN/ENDDA.
    Current Data
    IT0006 Address  -  01/01/1990 12/31/9999   present
    RP-PROVIDE-FROM-LAST retrieves the record which is valid in the data selection period.
    For example, pn/begda = '19990931'    pn/endda = '99991231'
    IT0006 subtype 1 is resident address
    RP-PROVIDE-FROM-LAST P0006 1 PN/BEGDA PN/ENDDA.
    Process Infotypes
    RMAC Modules - RMAC module as referred to Macro, is a special construct of ABAP/4 codes. Normally, the program code of these modules is stored in table 'TRMAC'. The table key combines the program code under a given name. It can also be defined in programs.The RMAC defined in the TRMAC can be used in all Reports. When an RMAC is changed, the report has to be regenerated manually to reflect the change.
    Reading Infotypes - by using RMAC (macro) RP-READ-INFOTYPE
              REPORT ZHR00001.
              INFOTYPE: 0002.
              PARAMETERS: PERNR LIKE P0002-PERNR.
              RP-READ-INFOTYPE PERNR 0002 P0002 .
              PROVIDE * FROM P0002
                  if ... then ...endif.
              ENDPROVIDE.
    Changing Infotypes - by using RMAC (macro) RP-READ-INFOTYPE. 
    · Three steps are involved in changing infotypes:
    1. Select the infotype records to be changed;
    2. Make the required changes and store the records in an alternative table;
    3. Save this table to the database;
    The RP-UPDATE macro updates the database. The parameters of this macro are the OLD internal table containing the unchanged records and the NEW internal table containing the changed records. You cannot create or delete data. Only modification is possible.
    INFOTYPES: Pnnnn NAME OLD,
    Pnnnn NAME NEW.
    GET PERNR.
        PROVIDE * FROM OLD
               WHERE .... = ... "Change old record
               *Save old record in alternate table
               NEW = OLD.
        ENDPROVIDE.
        RP-UPDATE OLD NEW. "Update changed record
    Infotype with repeat structures
    · How to identify repeat structures.
    a. On infotype entry screen, data is entered in table form.
        IT0005, IT0008, IT0041, etc.
    b. In the infotype structure, fields are grouped by the same name followed by sequence number.
        P0005-UARnn P0005-UANnn P0005-UBEnn
        P0005-UENnn P0005-UABnn
    Repeat Structures
    · Data is entered on the infotype screen in table format but stored on the database in a linear  
      structure.
    · Each row of the table is stored in the same record on the database.
    · When evaluating a repeat structure, you must define the starting point, the increment and the
      work area which contains the complete field group definition.
    Repeat Structures Evaluation (I)
    · To evaluate the repeat structures
       a. Define work area.
           The work area is a field string. Its structure is identical to that of the field group.
       b. Use a DO LOOP to divide the repeat structure into segments and make it available for  
           processing in the work area, one field group (block) at a time.
    Repeat Structures Evaluation(II)
    Define work area
    DATA: BEGIN OF VACATION,
                  UAR LIKE P0005-UAR01, "Leave type
                  UAN LIKE P0005-UAN01, "Leave entitlement
                  UBE LIKE P0005-UBE01, "Start date
                  UEN LIKE P0005-UEN01, "End date
                  UAB LIKE P0005-UAB01, "Leave accounted
               END OF VACATION.
    GET PERNR.
         RP-PROVIDE-FROM-LAST P0005 SPACE PN/BEGDA PN/ENDDA.
         DO 6 TIMES VARYING VACATION
                 FROM P0005-UAR01 "Starting point
                     NEXT P0005-UAR02. "Increment
                 If p0005-xyz then ... endif.
          ENDDO.
    Processing 'Time Data'.
    · Dependence of time data on validity period
    · Importing time data
    · Processing time data using internal tables
    Time Data and Validity Period
    · Time data always applies to a specific validity period.
    · The validity periods of different types of time data are not always the same as the date selection period specified in the selection screen.
    Date selection period |----
    |
    Leave |----
    |
    · PROVIDE in this case is therefore not used for time infotypes.
    Importing Time Data
    · GET PERNR reads all time infotypes from the lowest to highest system data, not only those within the date selection period.
    · To prevent memory overload, add MODE N to the infotype declaration. This prevents the logical database from importing all data into infotype tables at GET PERNR.
    · Use macro RP-READ-ALL-TIME-ITY to fill infotype table.
    INFOTYPES: 2001 MODE N.
    GET PERNR.
        RP-READ-ALL-TIME-ITY PN/BEGDA PN/ENDDA.
        LOOP AT P0021.
             If P0021-XYZ = ' '. A=B. Endif.
        ENDLOOP.
    Processing Time Data
    · Once data is imported into infotype tables, you can use an internal table to process the interested data.
    DATA: BEGIN OF ITAB OCCURS 0,
                  BUKRS LIKE P0001-BUKRS, "COMPANY
                  WERKS LIKE P0001-WERKS, "PERSONNEL AREA
                  AWART LIKE P2001-AWART, "ABS./ATTEND. TYPE
                  ASWTG LIKE P2001-ASWTG, "ABS./ATTEND. DAYS
               END OF ITAB.
    GET PERNR.
    RP-PROVIDE-FROM-LAST P0001 SAPCE PN/BEGDA PN/ENDDA.
    CLEAR ITAB.
    ITAB-BUKRS = P0001-BURKS. ITAB-WERKS = P0001-WERKS.
    RP-READ-ALL-TIME-ITY PN/BEGDA PN/ENDDA.
    LOOP AT P2001.
          ITAB-AWART = P2001-AWART. ITAB-ASWTG = P2001-ASWTG.
          COLLECT ITAB. (OR: APPEND ITAB.)
    ENDLOOP.
    Database Tables in HR
    ·  Personnel Administration (PA) - master and time data infotype tables (transparent tables).
       PAnnnn: e.g. PA0001 for infotype 0001
    ·  Personnel Development (PD) - Org Unit, Job, Position, etc. (transparent tables).
       HRPnnnn: e.g. HRP1000 for infotype 1000
    ·  Time/Travel expense/Payroll/Applicant Tracking data/HR work areas/Documents (cluster  
       PCLn: e.g. PCL2 for time/payroll results.
    Cluster Table
    · Cluster tables combine the data from several tables with identical (or almost identical) keys
      into one physical record on the database.
    . Data is written to a database in compressed form.
    · Retrieval of data is very fast if the primary key is known.
    · Cluster tables are defined in the data dictionary as transparent tables.
    · External programs can NOT interpret the data in a cluster table.
    · Special language elements EXPORT TO DATABASE, IMPORT TO DATABASE and DELETE
      FROM DATABASE are used to process data in the cluster tables.
    PCL1 - Database for HR work area;
    PCL2 - Accounting Results (time, travel expense and payroll);
    PCL3 - Applicant tracking data;
    PCL4 - Documents, Payroll year-end Tax data
    Database Tables PCLn
    · PCLn database tables are divided into subareas known as data clusters.
    · Data Clusters are identified by a two-character code. e.g RU for US payroll result, B2 for
      time evaluation result...
    · Each HR subarea has its own cluster.
    · Each subarea has its own key.
    Database Table PCL1
    · The database table PCL1 contains the following data areas:
      B1 time events/PDC
      G1 group incentive wages
      L1 individual incentive wages
      PC personal calendar
      TE travel expenses/payroll results
      TS travel expenses/master data
      TX infotype texts
      ZI PDC interface -> cost account
    Database Table PCL2
    · The database table PCL2 contains the following data areas:
      B2 time accounting results
      CD cluster directory of the CD manager
      PS generated schemas
      PT texts for generated schemas
      RX payroll accounting results/international
      Rn payroll accounting results/country-specific ( n = HR country indicator )
      ZL personal work schedule
    Database Table PCL3
    · The database table PCL3 contains the following data areas:
      AP action log / time schedule
      TY texts for applicant data infotypes
    Data Management of PCLn
    · The ABAP commands IMPORT and EXPORT are used for management of read/write to
      database tables PCLn.
    · A unique key has to be used when reading data from or writing data to the PCLn.
      Field Name KEY Length Text
      MANDT X 3 Client
      RELID X 2 Relation ID (RU,B2..)
      SRTFD X 40 Work Area Key
      SRTF2 X 4 Sort key for dup. key
    Cluster Definition
    · The data definition of a work area for PCLn is specified in separate programs which comply  
       with fixed naming conventions.
    · They are defined as INCLUDE programs (RPCnxxy0). The following naming convention applies:
       n = 1 or 2 (PCL1 or PCL2)
       xx = Relation ID (e.g. RX)
       y = 0 for international clusters or country indicator (T500L) for different country cluster
    Exporting Data (I)
    · The EXPORT command causes one or more 'xy' KEY data objects to be written to cluster xy.
    · The cluster definition is integrated with the INCLUDE statement.
    REPORT ZHREXPRT.
    TABLES: PCLn.
    INCLUDE: RPCnxxy0. "Cluster definition
    Fill cluster KEY
    xy-key-field = .
    Fill data object
    Export record
    EXPORT TABLE1 TO DATABASE PCLn(xy) ID xy-KEY.
       IF SY-SUBRC EQ 0.
           WRITE: / 'Update successful'.
       ENDIF.
    Exporting Data (II)
    . Export data using macro RP-EXP-Cn-xy.
    · When data records are exported using macro, they are not written to the database but to a  
      main memory buffer.
    · To save data, use the PREPARE_UPDATE routine with the USING parameter 'V'.
    REPORT ZHREXPRT.
    *Buffer definition
    INCLUDE RPPPXD00. INCLUDE RPPPXM00. "Buffer management
    DATA: BEGIN OF COMMON PART 'BUFFER'.
    INCLUDE RPPPXD10.
    DATA: END OF COMMON PART 'BUFFER'.
    RP-EXP-Cn-xy.
    IF SY-SUBRC EQ 0.
        PERFORM PREPARE_UPDATE USING 'V'..
    ENDIF.
    Importing Data (I)
    · The IMPORT command causes data objects with the specified key values to be read from
       PCLn.
    · If the import is successful, SY-SUBRC is 0; if not, it is 4.
    REPORT RPIMPORT.
    TABLES: PCLn.
    INCLUDE RPCnxxy0. "Cluster definition
    Fill cluster Key
    Import record
    IMPORT TABLE1 FROM DATABASE PCLn(xy) ID xy-KEY.
       IF SY-SUBRC EQ 0.
    Display data object
       ENDIF.
    Importing data (II)
    · Import data using macro RP-IMP-Cn-xy.
    · Check return code SY-SUBRC. If 0, it is successful. If 4, error.
    · Need include buffer management routines RPPPXM00
    REPORT RPIMPORT.
    *Buffer definition
    INCLUDE RPPPXD00.
    DATA: BEGIN OF COMMON PART 'BUFFER'.
    INCLUDE RPPPXD10.
    DATA: END OF COMMON PART 'BUFFER'.
    *import data to buffer
    RP-IMP-Cn-xy.
    *Buffer management routines
    INCLUDE RPPPXM00.
    Cluster Authorization
    · Simple EXPORT/IMPORT statement does not check for cluster authorization.
    · Use EXPORT/IMPORT via buffer, the buffer management routines check for cluster
      authorization.
    Payroll Results (I)
    · Payroll results are stored in cluster Rn of PCL2 as field string and internal tables.
      n - country identifier.
    · Standard reports read the results from cluster Rn. Report RPCLSTRn lists all payroll results;
      report RPCEDTn0 lists the results on a payroll form.
    Payroll Results (II)
    · The cluster definition of payroll results is stored in two INLCUDE reports:
      include: rpc2rx09. "Definition Cluster Ru (I)
      include: rpc2ruu0. "Definition Cluster Ru (II)
    The first INCLUDE defines the country-independent part; The second INCLUDE defines the country-specific part (US).
    · The cluster key is stored in the field string RX-KEY.
    Payroll Results (III)
    · All the field string and internal tables stored in PCL2 are defined in the ABAP/4 dictionary. This
      allows you to use the same structures in different definitions and nonetheless maintain data
      consistency.
    · The structures for cluster definition comply with the name convention PCnnn. Unfortunately, 
       'nnn' can be any set of alphanumeric characters.
    *Key definition
    DATA: BEGIN OF RX-KEY.
         INCLUDE STRUCTURE PC200.
    DATA: END OF RX-KEY.
    *Payroll directory
    DATA: BEGIN OF RGDIR OCCURS 100.
         INCLUDE STRUCTURE PC261.
    DATA: END OF RGDIR.
    Payroll Cluster Directory
    · To read payroll results, you need two keys: pernr and seqno
    . You can get SEQNO by importing the cluster directory (CD) first.
    REPORT ZHRIMPRT.
    TABLES: PERNR, PCL1, PCL2.
    INLCUDE: rpc2cd09. "definition cluster CD
    PARAMETERS: PERSON LIKE PERNR-PERNR.
    RP-INIT-BUFFER.
    *Import cluster Directory
       CD-KEY-PERNR = PERNR-PERNR.
    RP-IMP-C2-CU.
       CHECK SY-SUBRC = 0.
    LOOP AT RGDIR.
       RX-KEY-PERNR = PERSON.
       UNPACK RGDIR-SEQNR TO RX-KEY-SEQNO.
       *Import data from PCL2
       RP-IMP-C2-RU.
       INLCUDE: RPPPXM00. "PCL1/PCL2 BUFFER HANDLING
    Function Module (I)
      CD_EVALUATION_PERIODS
    · After importing the payroll directory, which record to read is up to the programmer.
    · Each payroll result has a status.
      'P' - previous result
      'A' - current (actual) result
      'O' - old result
    · Function module CD_EVALUATION_PERIODS will restore the payroll result status for a period
       when that payroll is initially run. It also will select all the relevant periods to be evaluated.
    Function Module (II)
    CD_EVALUATION_PERIODS
    call function 'CD_EVALUATION_PERIODS'
         exporting
              bonus_date = ref_periods-bondt
              inper_modif = pn-permo
              inper = ref_periods-inper
              pay_type = ref_periods-payty
              pay_ident = ref_periods-payid
         tables
              rgdir = rgdir
              evpdir = evp
              iabkrs = pnpabkrs
         exceptions
              no_record_found = 1.
    Authorization Check
       Authorization for Persons
    ·  In the authorization check for persons, the system determines whether the user has the 
       authorizations required for the organizational features of the employees selected with
       GET PERNR.
    ·  Employees for which the user has no authorization are skipped and appear in a list at the end
       of the report.
    ·  Authorization object: 'HR: Master data'
    Authorization for Data
    · In the authorization check for data, the system determines whether the user is authorized to
      read the infotypes specified in the report.
    · If the authorization for a particular infotype is missing, the evaluation is terminated and an error
      message is displayed.
    Deactivating the Authorization Check
    · In certain reports, it may be useful to deactivate the authorization check in order to improve
      performance. (e.g. when running payroll)
    · You can store this information in the object 'HR: Reporting'.
    these are the main areas they ask q?

  • How to create the sub type field in hr abap infotype

    hi ,
        how to create the sub type field in hr abap infotype.
    regards,
    venkat.

    Try like this also
    creating of infotype please follow these steps ...
    Step 1: Create Infotypes
    i. Goto Transaction PM01 – To create Infotypes:
    ii. Enter the Infotype Number and say create all.
    iii. The following message would display:
    i. PSnnnn Does not exist. How do you want to proceed?
    iv. Click
    v. A maintain Structure screen appears.
    Fill in the short text description and the PS structure of the Infotype.
    Since the fields Personnel No, Employee Begin Date, End Date, Sequential Number,Date of Last Change, Name of user who changed the object are available in the PAKEY and PSHD1 structure, define the PSnnnn structure with only the fields you required.
    vi. Once the PS Structure is created, save and activate the structure.
    vii. In the initial screen of PM01, now click on .
    Create a new entry for the infotype.
    Fill in the values as mentioned below and save.
    Infotype Characteristics:
    Infotype Name of the infotype_ Short Text: __Short Description________
    *General Attributes :
    Time constraint = 1
    Check Subtype Obligatory
    Display and Selection:
    Select w/ start = 3 “Valid record for entered data
    Select w/ end = 5 “Records with valid dates within the period entered
    Select w/o date = 6 “Read all records
    Screen header = 02 “Header ID
    Create w/o end = 1 “Default value is 31.12.9999
    Technical Data:
    Single screen = 2000
    List screen = 3000; List Entry Checked.
    viii. In the initial screen of PM01, now click on .
    Choose the infotype entry in the list.
    Fill in the values as mentioned below and save.
    Technical Attributes:
    In tab section,
    The following attribute values are given:
    Applicant DB Tab = PAnnnn “Infotype Name
    Subtype field = SUBTY
    Subtype table = T591A
    Subty.text tab. = T591S
    Time cnstr.tab. = T591A
    Prim. /Sec. = I Infotype
    Period/key date = I Interval
    and .
    ix. Infotype Screen Modification:
    Edit Screen 2000 from PM01 for the Infotype.
    ABAP Editor for the Infotype Program MPnnnn00 will be displayed.
    Click . Flow Logic will be displayed. There string coding of your own logic.
    Regards
    Pavan

  • HR ABAP: LOOP AT SCREEN: Multiple Fields Disabling.

    Experts,
    Am a new member in the world of SAP ABAP!
    Need ur advice regarding.
    Have coded following for disabling a field in PBO based on subtypes.
        IF p9235-subty = GC_AICTD.
          IF screen-name = 'P9235-ZZ_RC_MDE'.
            screen-active = 0.
            MODIFY SCREEN.
          ENDIF.
        ENDIF.
    This disables the particular field mentioned in the screen name.
    If i want more than on field names to be disabled under single validation, then what should i do?
    Your help to this fresher would be appreciated!
    Points will be definitely rewarded for your help and time...
    Thank you.
    Sundar.

    *&      Module  display  OUTPUT
          text
    MODULE display OUTPUT.
    *break-point.
    loop at screen.
    if create = 'X'.
      if screen-group1 = 'XXX'.
      screen-input = 1.
      modify screen.
      endif.
    endif.
    if display = 'X'.
      if screen-group2 = 'YYY'.
    screen-input = 0.
      modify screen.
      endif.
    endif.
      endloop.
    ENDMODULE.                 " display  OUTPUT
    but declare the group!

  • HR ABAP : Custom Infotype updations

    Hi All,
    I am new to HR ABAP. Actually, I want to update the custom infotype 3 fields as per my user inputs. I am fetching the data from the PA table acoording to sy-datum falling in the begda, enda limitations. now I am changing the field with new values in the work area. And pass with the following data to the FM.
    But I am getting the error 'No data stored for 9008 in the selected period'. I had seen prvious therads, but could not get how they solved the issue.
    Please provide the inpus for the following code. I had also passed the validity start and end.
    CALL FUNCTION 'HR_INFOTYPE_OPERATION'
    EXPORTING
    infty = '9008'
    number = pernr
    SUBTYPE =
    OBJECTID =
    LOCKINDICATOR =
    VALIDITYEND =
    VALIDITYBEGIN =
    RECORDNUMBER =
    record = wa_pa9008
    operation = 'MOD'
    TCLAS = 'A'
    DIALOG_MODE = '0'
    NOCOMMIT =
    VIEW_IDENTIFIER =
    SECONDARY_RECORD =
    IMPORTING
    return = l_bapireturn
    key = bapipakey_tab
    Regards,
    Brijesh Patel

    Hi Remi,
            I have done the same thing. Please see the code. data is also available in the database. But the output is the error message. Please give some inputs on this.
    ***Updation of the PA9003 Infoty pe with the LTA amount and Medical Amount
        SELECT SINGLE endda
                      begda
                      FROM pa0001
                      INTO (endda, begda)
                      WHERE pernr EQ pernr
                        AND endda GE sy-datum
                        AND begda LE sy-datum.
        SELECT SINGLE *
                      FROM pa9003
                      INTO lwa_pa9003
                      WHERE pernr EQ pernr
                        AND endda >= sy-datum
                        AND begda <= sy-datum.
        wa_pa9003 = lwa_pa9003.
        wa_pa9003-zzallw = zzallw.
        wa_pa9003-zzlta = zzlta.
        wa_pa9003-zzmed = zzmed.
        ADD 1 TO wa_pa9003-seqnr.
    ***Locking the object
        CALL FUNCTION 'ENQUEUE_EPPRELE'
          EXPORTING
            pernr          = pernr
          EXCEPTIONS
            foreign_lock   = 1
            system_failure = 2
            OTHERS         = 3.
        CALL FUNCTION 'HR_INFOTYPE_OPERATION'
          EXPORTING
            infty                  = '9003'
            number                 = pernr
       subtype                = wa_pa9003-subty
       objectid               = wa_pa9003-objps
       lockindicator          = wa_pa9003-sprps
       validityend            = wa_pa9003-endda
       validitybegin          = wa_pa9003-begda
       recordnumber           = wa_pa9003-seqnr
            record                 = wa_pa9003
            operation              = 'MOD'
      TCLAS                  = 'A'
      DIALOG_MODE            = '0'
      nocommit               = space
      VIEW_IDENTIFIER        =
      SECONDARY_RECORD       =
         IMPORTING
           return                 = l_bapireturn
           key                    = bapipakey_tab
    ***Unlocking the object
        CALL FUNCTION 'DEQUEUE_EPPRELE'
          EXPORTING
            pernr = pernr.
    Regards,
    Brijesh Patel

  • Re : Reports in ABAP-HR

    Hi All,
    What is  the best way of creating reports in ABAP-HR while retreiving data from  infotypes.
    I mean to ask u among the four ways that i know
    1. Using Macros
    2. Using Provide.. Endprovide statement
    3. Using Select statements
    4. Using Function Modules like HR_read_infotype, etc....
    which is the better option...
    Pls... explain me with an example scenario...
    Thanks
    Phani

    Hi,
    Try to follow these steps..
    First U should create the base structure PSXXXX. You just include the additional fields you want in this structure. The common header data will be created for the tables.
    e.g. PS9919 should just contain the field 'NUMBR' of some data element (e.g. CHAR15 or a new one you create) or just use the built-in definition.
    Use transaction PM01, enter infotype number XXXX, maintain infotype settings (time constraint, subtype strategy,etc...). I think you have some documentation for these settings.
    To have the infotype listed on PA30 screen you should deal with some customization.
    Thanks,
    Rajesh Kumar

  • How to Add data in HR infotype 2011 through ABAP

    Hi All,
    Can any one please give me an idea about how to insert time record in Infotype 2011 through ABAP. I cannot use the front end recording (SHDB) as it locks the person's master data. I need to Add the record through ABAP Query. I have inserted record in Table TEven and it works fine but then there is a conflict of sequence number field and system does not allow to change the data in infotype 2011 and gives error message.
    Thanks

    Hi amit
           even i have same requirement i tried with the same code but i'm getting error No data stored for infotype 2011 in the period.
    code:
       CALL FUNCTION 'BAPI_EMPLOYEE_ENQUEUE'
            EXPORTING
              number        = wa_modify-pernr
           IMPORTING
             RETURN        = return
          clear return.
          CALL FUNCTION 'HR_INFOTYPE_OPERATION'
            EXPORTING
              infty                  = p_infty
              number                 = wa_modify-pernr
    *         SUBTYPE                =
    *         OBJECTID               =
    *         LOCKINDICATOR          =
    *         VALIDITYEND            = wa_modify-ldate
    *         VALIDITYBEGIN          =
    *         RECORDNUMBER           =
              record                 = wa_modify
              operation              = 'MOD'
             TCLAS                   = 'A'
             DIALOG_MODE             = '0'
    *         NOCOMMIT               =
    *         VIEW_IDENTIFIER        =
    *         SECONDARY_RECORD       =
           IMPORTING
             RETURN                 = return
    *         KEY                    =
          CALL FUNCTION 'HR_EMPLOYEE_DEQUEUE'
            EXPORTING
              number        = wa_modify-pernr
    *       IMPORTING
    *         RETURN        =

  • How to  update Education Data in ABAP HR.

    I'm new to ABAP HR Module and have problem to update Education Data in ABAP HR.
    Helpful Advice will be appreciated.

    Hi Suniel  ,
    Education data in HR is held in infotype 22.
    Go to PA30, enter the employee number & maintain 22 infotype (with respective subtype i.e. high school, university, etc..)
    Regards,
    Dilek

  • Grahical reports in abap how to devlop

    hi all
    can u please tell me how to display reports in graphical form 2d or 3d using abap programming

    Hi ,
    Paste this code in se38,
    PERFORM create_chart is important for you.
    *& Report  ZMM_INV_TURNS_REPORT                                       *
    *& Author  Vijay Babu Dudla                                           *
    *& Date    25th April 2008                                            *
    Description :  Inventory Turns Report                               *
    Inputs:                                                             *
      Tables:                                                           *
        ECMT  -  COGS data                                              *
        GLTO  -  Inventory Data                                         *
    Parameters:                                                        *
    From Period                                                        *
          Year                                                          *
    To   Period                                                        *
          Year                                                          *
          Company Code
      Parameters:                                                       *
        N/A                                                             *
    Outputs: A ALV report is generated to display the Inventory Turns   *
    External Routines                                                   *
      Classes: CL_GUI_ALV_GRID                                          *
               CL_IGS_CHART                                             *
      Transactions    : No                                              *
      Programs        : No                                              *
    Return Codes: No                                                    *
    Ammendments:                                                        *
       Programmer        Date     Req. #            Action              *
    ================  ==========  ======  ==============================*
    Vijay Dudla     04/15/2008   RD4K900255  Initial Development       *
    RMANDAL         05/18/2008   RD4K900419  1) Getting COGS values    *
                                                  from ZSCOMMON         *
                                              2) Displying values in    *
                                                 Graph                  *
    REPORT  zmm_inv_turns_report MESSAGE-ID zi.
    *-TYPES Declaration
    *- Period Details
    TYPES: BEGIN OF ty_period,
            perid TYPE fc_perid,           " Period
           END OF ty_period.
    *-Year Details
    TYPES: BEGIN OF ty_year,
            gjahr TYPE gjahr,              " Year
           END OF ty_year.
    *-Final Display Table
    TYPES: BEGIN OF ty_data,
            texts(20),                     " Col Value
            per01(20),                                          " Period1
            per02(20),                                          " Period2
            per03(20),                                          " Period3
            per04(20),                                          " Period4
            per05(20),                                          " Period5
            per06(20),                                          " Period6
            per07(20),                                          " Period7
            per08(20),                                          " Period8
            per09(20),                                          " Period9
            per10(20),                                          " Period10
            per11(20),                                          " Period11
            per12(20),                                          " Period12
            year TYPE gjahr,
          END OF ty_data.
    *-Period Balance information
    TYPES: BEGIN OF ty_balance,
             period TYPE fc_perid,         " Period
             gjahr TYPE gjahr,             " Year
             tslvt TYPE tslxx,             " Balance
           END OF ty_balance.
    *- Period and Year info
    TYPES: BEGIN OF ty_per_year,
             period TYPE fc_perid,         " Period
             gjahr TYPE gjahr,             " Year
           END OF ty_per_year.
    *- Field Symbols
    FIELD-SYMBOLS: <fs> TYPE ANY.
    *- Data Declarations
    *- Internal Table Decleations
    DATA: it_fieldcat TYPE lvc_t_fcat,     " Fieldcatalog
          it_per      TYPE STANDARD TABLE OF zmm_year_period,
          it_year_per TYPE zmm_t_inv_period,
          it_final    TYPE STANDARD TABLE OF ty_data,
          it_year     TYPE STANDARD TABLE OF ty_year,
          it_period   TYPE STANDARD TABLE OF ty_period,
          it_common   TYPE STANDARD TABLE OF zscommon,
    BEGIN OF INSERT BY RMANDAL - 19/05/2008 - RD4K900419
          it_common1  TYPE STANDARD TABLE OF zscommon,
    END OF INSERT BY RMANDAL - 19/05/2008 - RD4K900419
          it_inv      TYPE STANDARD TABLE OF glt0,
          it_cogs     TYPE STANDARD TABLE OF ecmct,
         it_inv_data TYPE STANDARD TABLE OF zfi_year_period,
          it_balance  TYPE STANDARD TABLE OF ty_balance,
          it_peryear  TYPE STANDARD TABLE OF ty_per_year
                           WITH HEADER LINE.
    *- Work Area declarations
    DATA: wa_fieldcat TYPE lvc_s_fcat,
          w_per       TYPE zmm_year_period,
          w_period    TYPE zmm_inv_period,
          wa_final    TYPE ty_data,
         wa_inv      TYPE zfi_year_period,
          wa_per      TYPE ty_period,
          wa_balance  TYPE ty_balance.
    *- Range table Declations
    DATA: return  TYPE TABLE OF ddshretval WITH HEADER LINE,
          r_year  TYPE RANGE OF gjahr WITH HEADER LINE,
          r_yr    TYPE RANGE OF gjahr WITH HEADER LINE,
          r_per   TYPE RANGE OF fc_perid WITH HEADER LINE,
          r_saknr TYPE RANGE OF racct.
    *- Variable to Period and Year
    DATA: perid   TYPE fc_perid,
          year    TYPE gjahr,
          w_bukrs TYPE glt0-bukrs.
    *- Graph Display
    DATA:  g_html  TYPE w3htmltabtype,
           g_url   TYPE w3url.
    *-Controls for Displaying the Grpah and ALV Report
    DATA: grid    TYPE REF TO cl_gui_alv_grid,
          split   TYPE REF TO cl_gui_splitter_container,
          cont    TYPE REF TO cl_gui_custom_container,
          gridcon TYPE REF TO cl_gui_container,
          htmlcon TYPE REF TO cl_gui_container,
          html_control TYPE REF TO cl_gui_html_viewer.
    *&     Selection Screen                                               *
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-ttl.
    SELECT-OPTIONS:  s_per FOR perid NO-EXTENSION NO INTERVALS OBLIGATORY,
                                         " Period
                     s_year FOR year NO-EXTENSION NO INTERVALS OBLIGATORY.
                                         " Year
    SELECTION-SCREEN END OF BLOCK b1.
    SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-tt2.
    SELECT-OPTIONS:  s_per2 FOR perid NO-EXTENSION NO INTERVALS OBLIGATORY,
                                         " Period
                     s_year2 FOR year NO-EXTENSION NO INTERVALS OBLIGATORY.
                                         " Year
    SELECTION-SCREEN END OF BLOCK b2.
    SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE text-tt3 .
    PARAMETERS: p_rep RADIOBUTTON GROUP g1 DEFAULT 'X',
                p_grp RADIOBUTTON GROUP g1,
                p_bot RADIOBUTTON GROUP g1.
    SELECTION-SCREEN END OF BLOCK b3.
    PARAMETERS: p_bukrs LIKE glt0-bukrs DEFAULT '3000' OBLIGATORY.
    *&     AT SELECTION-SCREEN ON VALUE REQUEST                           *
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_year-low.
    *-Value help for year
      PERFORM get_hlp_for_year.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_per-low.
    *-Value help for Period
      PERFORM get_hlp_for_period.
    *&     AT SELECTION-SCREEN                                            *
    AT SELECTION-SCREEN .
    *-Validations
    *- Per Period should be 1 to 12
      LOOP AT s_per.
        IF s_per-low GT 12 OR s_per-low LT 1.
          MESSAGE e000(zi) WITH 'Enter Period between 1 and 12'.
        ENDIF.                             " IF s_per-low GT 12 OR s_per-low
        IF NOT s_per-high IS INITIAL.
          IF s_per-high GT 12 OR s_per-high LT 1.
            MESSAGE e000(zi) WITH 'Enter Period between 1 and 12'.
          ENDIF.                           " IF s_per-high GT 12 OR
        ENDIF.                             " IF NOT s_per-high IS INITIAL
      ENDLOOP.                             " LOOP AT s_per
      IF s_per-low GE sy-datum+4(2) AND
         s_year-low GE sy-datum+0(4).
        MESSAGE e000(zi) WITH text-002 text-003.
      ENDIF.                               " IF s_per-low GE sy-datum+4(2)
      LOOP AT s_per2.
        IF s_per2-low GT 12 OR s_per2-low LT 1.
          MESSAGE e000(zi) WITH 'Enter Period between 1 and 12'.
        ENDIF.                             " IF s_per2-low GT 12 OR
      ENDLOOP.                             " LOOP AT s_per2.
      IF s_per2-low GE sy-datum+4(2) AND
         s_year2-low GE sy-datum+0(4).
        MESSAGE e000(zi) WITH text-002 text-003.
      ENDIF.                               " IF s_per2-low GE sy-datum+4(2)
    Company Code Validation
      IF p_bukrs IS NOT INITIAL.
        SELECT
        SINGLE  bukrs                      " Company Code
          FROM  t001
          INTO  w_bukrs
         WHERE  bukrs = p_bukrs.
        IF sy-subrc NE 0.
          MESSAGE e000(zi) WITH 'Enter Valid Company code '.
        ENDIF.                             " IF sy-subrc NE 0.
        CLEAR w_bukrs.
      ENDIF.                               " IF p_bukrs IS NOT
    *&     START OF SELECTION                                             *
    START-OF-SELECTION.
    *-Get the GL Accounts from table ZSCOMMON
      PERFORM get_gl_information.
    *-Get the Inventory Details
      PERFORM get_inventory_data.
    *-Get the COGS details
      PERFORM get_cogs_data.
    *-Population of Period Table
      PERFORM populate_period_data.
    *-Populate the Final Data
      PERFORM populate_final_data.
    *&     END OF SELECTION                                               *
    END-OF-SELECTION.
    *-Display the Output
      PERFORM display_inv_turn_data.
    *&      Form  get_hlp_for_year
          Get the Value help for Year
    FORM  get_hlp_for_year.
    *-Populate the F4 Values for Year
      SELECT  pabrj
        FROM  t549q
        INTO
       TABLE  it_year.
      IF sy-subrc EQ 0.
        SORT it_year.
        DELETE it_year WHERE gjahr = ''.
        DELETE ADJACENT DUPLICATES FROM it_year
                                COMPARING gjahr.
    *-Attaching the F4 Help to The Selection parameter
        CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
          EXPORTING
            retfield        = 'GJAHR'
            dynpprog        = sy-repid
            dynpnr          = sy-dynnr
            value_org       = 'S'
          TABLES
            value_tab       = it_year
            return_tab      = return
          EXCEPTIONS
            parameter_error = 1
            no_values_found = 2
            OTHERS          = 3.
        IF sy-subrc EQ 0.
          READ TABLE return INDEX 1.
          s_year-low = return-fieldval.
        ENDIF.                             " IF sy-subrc EQ 0
      ENDIF.                               " IF sy-subrc EQ 0
    ENDFORM.                               " get_hlp_for_year
    *&      Form  get_hlp_for_period
          Get the Search help for Period
    FORM get_hlp_for_period.
    *-Population of Period to Display the F4 values
      CLEAR return[].
      wa_per-perid = '001'.
      DO 12 TIMES.
        APPEND wa_per TO it_period.
        wa_per-perid = wa_per-perid + 1.
      ENDDO.                               " DO 12 TIMES.
    *-Attaching the F4 values to the selection parameter
      CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
        EXPORTING
          retfield        = 'PERID'
          dynpprog        = sy-repid
          dynpnr          = sy-dynnr
          value_org       = 'S'
        TABLES
          value_tab       = it_period
          return_tab      = return
        EXCEPTIONS
          parameter_error = 1
          no_values_found = 2
          OTHERS          = 3.
      IF sy-subrc EQ 0.
        READ TABLE return INDEX 1.
        s_per-low = return-fieldval.
      ENDIF.                               " IF sy-subrc EQ 0
    ENDFORM.                               " get_hlp_for_period
    *&      Form  GET_GL_INFORMATION
          Get the GL account Information from ZSCOMMON table
    FORM get_gl_information .
      DATA: wa_common TYPE zscommon,
            wa_saknr  LIKE LINE OF r_saknr.
    *-GL Accounts from ZSCOMMON
      SELECT  *
        FROM  zscommon
        INTO
       TABLE  it_common
       WHERE  programm  =  sy-repid AND
              code      = 'GLAC'.
      IF sy-subrc EQ 0.
        wa_saknr-sign   = 'I'.
        wa_saknr-option = 'EQ'.
        LOOP AT it_common INTO wa_common.
          wa_saknr-low = wa_common-valuestrng.
          CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
            EXPORTING
              input  = wa_saknr-low
            IMPORTING
              output = wa_saknr-low.
          APPEND wa_saknr TO r_saknr.
        ENDLOOP.                           " LOOP AT it_common
      ENDIF.                               " IF sy-subrc EQ 0
    ENDFORM.                               " GET_GL_INFORMATION
    *&      Form  GET_INVENTORY_DATA
          Get the Inventory Data
    FORM get_inventory_data .
      REFRESH r_year.
      r_year-sign = 'I'.
      r_year-option = 'EQ'.
    *-Populate the Year from Selection Parameters
      LOOP AT s_year.
        r_year-low = s_year-low.
        APPEND r_year.
        r_year-low = r_year-low - 1.
        APPEND r_year.
        r_year-low  = s_year-low.
        IF s_year2-low IS NOT INITIAL.
          DO.
            r_year-low = r_year-low + 1.
            IF r_year-low GT s_year2-low.
              EXIT.
            ENDIF.                         " IF r_year-low GT
            APPEND r_year.
          ENDDO.                           " DO
        ENDIF.                             " IF s_year2-low IS NOT
      ENDLOOP.                             " LOOP AT s_year
      CLEAR r_year.
      SORT r_year BY low.
      DELETE ADJACENT DUPLICATES FROM r_year COMPARING low.
      r_yr-sign = 'I'.
      r_yr-option = 'EQ'.
      LOOP AT s_year.
        r_yr-low = s_year-low.
        APPEND r_yr.
        IF s_year2-low IS NOT INITIAL.
          DO.
            r_yr-low = r_yr-low + 1.
            IF r_yr-low GT s_year2-low.
              EXIT.
            ENDIF.                         " IF r_yr-low GT s_year2-low
            APPEND r_yr.
          ENDDO.                           " DO
        ENDIF.                             " IF s_year2-low IS NOT
      ENDLOOP.                             " LOOP AT s_year
    *-Get the Inventory Data
      SELECT *
        FROM glt0
        INTO TABLE it_inv
        WHERE bukrs = p_bukrs AND
              ryear IN r_year AND
              racct IN r_saknr.
    ENDFORM.                               " GET_INVENTORY_DATA
    *&      Form  GET_COGS_DATA
          Get the COGS data
    FORM get_cogs_data .
      DATA: s_item TYPE RANGE OF fc_item,
            wa_item LIKE LINE OF s_item.
    BEGIN OF INSERT BY RMANDAL ON - 05/19/2008- RD4K900419
      data: wa_common1 TYPE zscommon.
      SELECT  *
        FROM  zscommon
        INTO
       TABLE  it_common1
       WHERE  programm  =  sy-repid AND
              code      = 'CCOA'.
      IF sy-subrc EQ 0.
        wa_item-sign   = 'I'.
        wa_item-option = 'EQ'.
        LOOP AT it_common1 INTO wa_common1.
          wa_item-low = wa_common1-valuestrng.
          APPEND wa_item TO s_item.
        ENDLOOP.                           " LOOP AT it_common1
      ENDIF.                               " IF sy-subrc EQ 0
    wa_item-sign = 'I'.
    wa_item-option  = 'EQ'.
    wa_item-low = '0000005000'.
    APPEND wa_item TO s_item.
    wa_item-low = '0000006100'.
    APPEND wa_item TO s_item.
    wa_item-low = '0000007900'.
    APPEND wa_item TO s_item.
    END OF INSERT BY RMANDAL ON - 05/19/2008- RD4K900419
    *-Population of COGS information
      SELECT *
        FROM ecmct
        INTO TABLE it_cogs
        WHERE ryear IN r_year AND
              rbunit EQ '000000000000003000' AND
              ritem IN s_item  AND
          ( ( sityp EQ '2  ' AND
              subit EQ '0100      ')
              OR
            ( sityp EQ ' ' AND
              subit EQ ' ') ).
      IF sy-subrc EQ 0.
      ENDIF.                               " IF sy-subrc EQ 0
    ENDFORM.                               " GET_COGS_DATA
    *&      Form  POPULATE_FINAL_DATA
          Population of final Data
    FORM populate_final_data .
      DATA: inc(2) TYPE n,
            w_pert(15),
            col(5).
    *Field catalog population.
      wa_fieldcat-fieldname = 'TEXTS'.
      wa_fieldcat-outputlen = 20.
      wa_fieldcat-coltext = 'Info'.
      APPEND wa_fieldcat TO it_fieldcat.
      inc = 1.
      DO 12 TIMES.
        CONCATENATE 'PER' inc INTO wa_fieldcat-fieldname.
        CONCATENATE 'PER' inc INTO wa_fieldcat-coltext.
        wa_fieldcat-outputlen = 20.
        wa_fieldcat-just = 'R'.
        APPEND wa_fieldcat TO it_fieldcat.
        CLEAR wa_fieldcat .
        inc  = inc + 1.
      ENDDO.                               " DO 12 TIMES.
      SORT it_per BY year period.
      inc = 1.
    *-Final Internal table formation
      LOOP AT it_per INTO w_per.
        READ TABLE it_final WITH KEY year = w_per-year
                                  TRANSPORTING NO FIELDS.
        IF sy-subrc NE 0.
          wa_final-texts = w_per-year.
          wa_final-year = w_per-year.
          inc = 1.
          DO 12 TIMES.
            CONCATENATE 'WA_FINAL-PER' inc INTO w_pert.
            ASSIGN (w_pert) TO <fs>.
            <fs> = inc.
            inc = inc + 1.
          ENDDO.                           " DO 12 TIMES
          APPEND wa_final TO it_final.
          CLEAR wa_final.
          inc = w_per-period+1(2).
          wa_final-year = w_per-year.
          wa_final-texts = 'COGS Tot(12 months)'.
          CONCATENATE 'WA_FINAL-PER' inc INTO w_pert.
          ASSIGN (w_pert) TO <fs>.
          <fs> = w_per-cogs.
          APPEND wa_final TO it_final.
          wa_final-texts = 'Inv Total(12 months)'.
          wa_final-year = w_per-year.
          CONCATENATE 'WA_FINAL-PER' inc INTO w_pert.
          ASSIGN (w_pert) TO <fs>.
          <fs> = w_per-invtot.
          APPEND wa_final TO it_final.
          wa_final-texts = 'Inv Avg(monthly)'.
          wa_final-year = w_per-year.
          CONCATENATE 'WA_FINAL-PER' inc INTO w_pert.
          ASSIGN (w_pert) TO <fs>.
          <fs> = w_per-invavg.
          APPEND wa_final TO it_final.
          wa_final-texts = 'Turns(COGS/Inv.Avg)'.
          wa_final-year = w_per-year.
          CONCATENATE 'WA_FINAL-PER' inc INTO w_pert.
          ASSIGN (w_pert) TO <fs>.
          <fs> = w_per-invturn.
          APPEND wa_final TO it_final.
          CLEAR wa_final.
          APPEND wa_final TO it_final.
        ELSE.
          inc = w_per-period+1(2).
         wa_final-texts = 'COGS Total(12 months)'.
          CONCATENATE 'WA_FINAL-PER' inc INTO w_pert.
          CONCATENATE 'PER' inc INTO col.
          ASSIGN (w_pert) TO <fs>.
          <fs> = w_per-cogs.
          MODIFY it_final FROM  wa_final TRANSPORTING (col)
                         WHERE  texts = 'COGS Tot(12 months)'
                           AND  year = w_per-year.
          wa_final-texts = 'Inv Total(12 months)'.
          CONCATENATE 'WA_FINAL-PER' inc INTO w_pert.
          CONCATENATE 'PER' inc INTO col.
          ASSIGN (w_pert) TO <fs>.
          <fs> = w_per-invtot.
          MODIFY it_final FROM  wa_final TRANSPORTING (col)
                         WHERE  texts = 'Inv Total(12 months)'
                           AND  year  = w_per-year .
          wa_final-texts = 'Inv Avg(monthly)'.
          CONCATENATE 'WA_FINAL-PER' inc INTO w_pert.
          CONCATENATE 'PER' inc INTO col.
          ASSIGN (w_pert) TO <fs>.
          <fs> = w_per-invavg.
          MODIFY it_final FROM  wa_final TRANSPORTING (col)
                         WHERE  texts = 'Inv Avg(monthly)'
                           AND  year  =  w_per-year
          wa_final-texts = 'Turns(COGS/Inv.Avg)'.
          CONCATENATE 'WA_FINAL-PER' inc INTO w_pert.
          CONCATENATE 'PER' inc INTO col.
          ASSIGN (w_pert) TO <fs>.
          <fs> = w_per-invturn.
          MODIFY it_final FROM  wa_final TRANSPORTING (col)
                         WHERE  texts = 'Turns(COGS/Inv.Avg)'
                           AND  year = w_per-year .
          CLEAR wa_final.
        ENDIF.                             " IF sy-subrc NE 0
      ENDLOOP.                             " LOOP AT it_per INTO
    ENDFORM.                               " POPULATE_FINAL_DATA
    *&      Form  DISPLAY_INV_TURN_DATA
          Display Inventory Turns Report
    FORM display_inv_turn_data .
      IF NOT it_final IS INITIAL.
    *-Save the Data
       PERFORM save_data.
        CALL SCREEN 100.
      ELSE.
        MESSAGE s000(zi) WITH 'No data for selection'.
      ENDIF.                               " IF NOT it_final
    ENDFORM.                               " DISPLAY_INV_TURN_DATA
    *&      Form  POPULATE_PERIOD_DATA
          Populate the Period Data
    FORM populate_period_data .
    *- Work Variables
      DATA: wa_inv     TYPE glt0,
            wa_cog     TYPE ecmct,
            w_amt(12),
            w_debit    TYPE tslxx,
            w_credit   TYPE tslxx,
            w_invtot   TYPE tslxx,
            w_cogstot  TYPE tslxx,
            w_bal1     TYPE tslxx,
            w_bal2     TYPE tslxx,
            w_total    TYPE tslxx,
            w_inc(2)   TYPE n,
            w_perd     TYPE fc_perid,
            w_bal(12),
            lv_period  TYPE fc_perid,
            lv_year    TYPE gjahr,
            w_change.
    *- Field Symbols
      FIELD-SYMBOLS: <fs> TYPE ANY,
                     <fs_bal> TYPE ANY.
    *-Population of Balance for all Periods.
      SORT it_inv BY ryear.
      LOOP AT r_year.
        CLEAR: w_debit,w_credit,
               w_bal1,w_bal2,w_total.
        wa_balance-gjahr = r_year-low.
        LOOP AT it_inv INTO wa_inv WHERE ryear = r_year-low AND
                                         drcrk = 'S' .
          w_bal1 = w_bal1 + wa_inv-tslvt.
          CLEAR wa_inv-tslvt.
        ENDLOOP.                           " LOOP AT it_inv
        LOOP AT it_inv INTO wa_inv WHERE ryear = r_year-low AND
                                         drcrk = 'H' .
          wa_inv-tslvt = wa_inv-tslvt * -1.
          w_bal2 = w_bal2 + wa_inv-tslvt.
          CLEAR wa_inv-tslvt.
        ENDLOOP.                           " LOOP AT it_inv INTO wa_inv
        w_total = w_bal1 - w_bal2.
        w_inc = 1.
        DO 12 TIMES.
          LOOP AT it_inv INTO wa_inv WHERE ryear = r_year-low AND
                                           drcrk = 'S' .
            CLEAR: w_bal.
            CONCATENATE 'WA_INV-TSL' w_inc INTO w_bal.
            ASSIGN (w_bal) TO <fs_bal>.
            w_debit = w_debit + <fs_bal>.
            UNASSIGN <fs_bal>.
          ENDLOOP.                         " LOOP AT it_inv INTO wa_inv
          LOOP AT it_inv INTO wa_inv WHERE ryear = r_year-low AND
                                       drcrk = 'H' .
            CLEAR: w_bal.
            CONCATENATE 'WA_INV-TSL' w_inc INTO w_bal.
            ASSIGN (w_bal) TO <fs_bal>.
            <fs_bal> = <fs_bal> * -1.
            w_credit = w_credit + <fs_bal>.
            UNASSIGN <fs_bal>.
          ENDLOOP.                         "  LOOP AT it_inv INTO wa_inv
          wa_balance-tslvt = w_debit - w_credit + w_total.
          wa_balance-period = w_inc.
          APPEND wa_balance TO it_balance.
          w_inc = w_inc + 1.
        ENDDO.                             " DO 12 TIMES
      ENDLOOP.                             " LOOP AT r_year
      CLEAR: w_credit,w_debit.
      r_per-sign = 'I'.
      r_per-option = 'EQ'.
      CLEAR it_peryear[].
    *-Populate the periods
      r_per-low = s_per-low.
      lv_year = s_year-low.
      DO .
        it_peryear-period = r_per-low.
        it_peryear-gjahr = lv_year.
        APPEND it_peryear.
        IF r_per-low GE s_per2-low AND
           lv_year EQ s_year2-low.
          EXIT.
        ENDIF.                             " IF r_per-low GE s_per2
        IF r_per-low = 12.
          r_per-low = 1.
          lv_year = lv_year + 1.
        ELSE.
          r_per-low = r_per-low + 1.
        ENDIF.                             " IF r_per-low = 12
      ENDDO.                               " DO
      CLEAR: r_per,r_year,w_change.
    *-Population of the Turns information based on Period and year
      LOOP AT it_peryear.
        w_perd = it_peryear-period.
        LOOP AT r_yr WHERE low = it_peryear-gjahr.
          w_per-period = it_peryear-period.
          IF w_change = ''.
            w_per-year = r_yr-low.
          ENDIF.                           " IF w_change = ''
          IF w_per-period = 12.
            IF  s_per-low <> w_per-period.
            r_yr-low = r_yr-low - 1.
              w_change = 'X'.
            ENDIF.                         " IF  s_per-low <> w_per-period
            w_per-year = r_yr-low.
          ENDIF.                           " IF w_per-period = 1
          CLEAR: w_invtot,
                 w_cogstot.
    *-For each period populate the Credit and Debit info
          DO 12 TIMES.
            w_period-period = it_peryear-period.
            w_period-year = r_yr-low.
            CLEAR: w_amt,w_debit,w_bal1.
            CONCATENATE 'WA_INV-TSL' w_period-period+1(2) INTO w_amt.
            LOOP AT it_inv INTO wa_inv WHERE ryear = w_period-year AND
                                             drcrk = 'S' .
              ASSIGN (w_amt) TO <fs>.
              w_debit = w_debit + <fs>.
              UNASSIGN <fs>.
              CLEAR wa_inv-tslvt.
            ENDLOOP.                       "  LOOP AT it_inv INTO wa_inv
            CLEAR: w_credit,w_bal2.
            LOOP AT it_inv INTO wa_inv WHERE ryear = w_period-year AND
                                             drcrk = 'H' .
              ASSIGN (w_amt) TO <fs>.
              <fs> = <fs> * -1.
              w_credit = w_credit + <fs>.
              UNASSIGN <fs>.
              CLEAR wa_inv-tslvt.
            ENDLOOP.                       " LOOP AT it_inv INTO wa_inv
            w_period-tsl01 = w_debit - w_credit.
            CLEAR w_amt.
            CONCATENATE 'WA_COG-TSL' w_period-period+1(2) INTO w_amt.
            LOOP AT it_cogs INTO wa_cog WHERE ryear = w_period-year.
              ASSIGN (w_amt) TO <fs>.
              w_period-tsl02 = w_period-tsl02 + <fs>.
              UNASSIGN <fs>.
            ENDLOOP.                       " LOOP AT it_cogs INTO wa_cog
    *-Calculate the total amounts
            w_invtot  =  w_invtot + w_period-tsl01.
            w_cogstot =  w_cogstot + w_period-tsl02.
            APPEND w_period TO it_year_per.
            CLEAR: w_period-tsl02,w_period-tsl01.
            IF it_peryear-period EQ 1.
              it_peryear-period = 12.
              r_yr-low = r_yr-low - 1.
            ELSE.
              it_peryear-period = it_peryear-period - 1.
            ENDIF.                         " IF it_peryear-period
          ENDDO.                           " DO 12 TIMES.
          lv_period = w_per-period.
          lv_year =  w_per-year.
          DO 12 TIMES.
            READ TABLE it_balance INTO wa_balance
                                  WITH KEY period = lv_period
                                           gjahr  = lv_year.
         w_per-invtot = w_invtot .+ wa_balance-tslvt.
            w_per-invtot = w_per-invtot + wa_balance-tslvt.
            IF lv_period = 1.
              lv_period = 12.
              lv_year = lv_year - 1.
            ELSE.
              lv_period = lv_period - 1.
            ENDIF.                         " IF lv_period = 1
            CLEAR wa_balance-tslvt.
          ENDDO.                           " DO 12 TIMES
          w_per-cogs = w_cogstot.
          w_per-invavg = w_per-invtot / 12.
          IF w_per-invavg NE 0.
            w_per-invturn = w_per-cogs / w_per-invavg.
          ENDIF.                           " IF w_per-invavg NE 0
          w_per-year = it_peryear-gjahr.
          w_per-info = it_year_per.
          APPEND w_per TO it_per.
          CLEAR: w_per-period,
                 w_per-invtot,
                 w_per-invavg,
                 w_per-cogs,
                 w_per-invturn,
                 w_per-info,it_year_per.
        ENDLOOP.                           " LOOP AT r_yr WHERE
      ENDLOOP.                             " LOOP AT it_peryear
    ENDFORM.                               " POPULATE_PERIOD_DATA
    *&      Form  create_chart
          Display the Chart
    FORM create_chart USING p_html TYPE w3htmltabtype p_real.
      DATA:
        igs_chart       TYPE REF TO cl_igs_chart,
        line            TYPE igs_data,
        data            TYPE igs_data_tab,
        ext_line        TYPE igs_ext,
        extension       TYPE igs_ext_tab,
        mime            TYPE w3mimetabtype,
        html            TYPE w3htmltabtype,
        html_line       TYPE w3html,
        url             TYPE w3url,
        content_length  TYPE i,
        content_type    TYPE w3param-cont_type,
        content_subtype TYPE w3param-cont_type.
      DATA: val TYPE char30.
    empty result table
      REFRESH p_html.
    create chart object
      CREATE OBJECT igs_chart.
    set chart type
      igs_chart->type = cl_igs_chart=>co_type_lines.
    set picture size
      igs_chart->width = 640.
      igs_chart->height = 480.
    igs_chart->width = 1024.
    igs_chart->height = 680.
    data to be displayed in the form of Graph
      SORT it_per BY period.
      LOOP AT it_per INTO w_per.
        line-groupid = w_per-year.
        line-x = w_per-period.
        IF w_per-invturn < 0.
          w_per-invturn = w_per-invturn * -1.
          CLEAR val.
          val = w_per-invturn .
          CONCATENATE '-' val INTO line-y.
        ELSE.
          line-y = w_per-invturn.
        ENDIF.                             " IF w_per-invturn < 0
    BEGIN OF INSERT BY RMANDAL - 19/05/2008 - RD4K900419
    To dislay the values in Graph
        line-DATALABEL = line-y.
        condense line-datalabel.
    END OF INSERT BY RMANDAL - 19/05/2008 - RD4K900419
        APPEND line TO data.
        CLEAR line.
      ENDLOOP.                             " LOOP AT it_per INTO w_per
    *-Populate the IGS data
      igs_chart->data = data.
    set titles
      igs_chart->title = 'Inventory Turns'.
      igs_chart->title_values = 'No of Turns'.
      igs_chart->title_categories = 'Period'.
    create picture
      CALL METHOD igs_chart->send
        IMPORTING
          content_type            = content_type
          content_length          = content_length
          content                 = mime
          imagemap                = html
        EXCEPTIONS
          rfc_communication_error = 1
          rfc_system_error        = 2
          internal_error          = 3
          OTHERS                  = 4.
      IF sy-subrc IS INITIAL AND p_real NE space.
        SPLIT content_type AT '/' INTO content_type content_subtype.
        CALL METHOD html_control->load_data
          EXPORTING
            type         = content_type
            subtype      = content_subtype
            size         = content_length
          IMPORTING
            assigned_url = url
          CHANGING
            data_table   = mime.
        CONCATENATE
          '<HTML><HEAD><TITLE>SAP IGS Chart</TITLE></HEAD>'
          '<BODY BGCOLOR=#DEDEC8>'
          '<MAP NAME=chart>'
          INTO html_line-line.
        APPEND html_line TO p_html.
        APPEND LINES OF html TO p_html.
        CONCATENATE
          '</MAP>'
          '<IMG SRC="' url '" USEMAP=#chart BORDER=0>'
          '</BODY></HTML>'
          INTO html_line-line.
        APPEND html_line TO p_html.
      ENDIF.                               "  IF sy-subrc IS INITIAL AND..
    ENDFORM.                               " create_chart
    *&      Module  STATUS_0100  OUTPUT
          Status and Controls Initialzation
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'ZTURN'.
      SET TITLEBAR 'ZTURN'.
      DATA: layout TYPE lvc_s_layo.
    *-Create the Container
      CREATE OBJECT cont
         EXPORTING
           container_name              = 'CONT'
         EXCEPTIONS
           cntl_error                  = 1
           cntl_system_error           = 2
           create_error                = 3
           lifetime_error              = 4
           lifetime_dynpro_dynpro_link = 5
           OTHERS                      = 6
      IF sy-subrc NE 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                   WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.                               " IF sy-subrc NE 0
    *-If Report option
      IF p_rep EQ 'X'.
    *-Creation of Grid Object
        CREATE OBJECT grid
          EXPORTING
            i_parent          = cont
          EXCEPTIONS
            error_cntl_create = 1
            error_cntl_init   = 2
            error_cntl_link   = 3
            error_dp_create   = 4
            OTHERS            = 5
        IF sy-subrc NE 0.
          MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                     WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        ENDIF.                             " IF sy-subrc NE 0
        layout-zebra = 'X'.
        layout-no_headers = 'X'.
        layout-cwidth_opt = 'X'.
        layout-grid_title = 'Inventory Turns Report'.
    *-Display the ALV
        grid->set_table_for_first_display(
           EXPORTING
             is_layout                     =  layout
           CHANGING
             it_outtab                     = it_final
             it_fieldcatalog               = it_fieldcat
         EXCEPTIONS
           invalid_parameter_combination = 1
           program_error                 = 2
           too_many_lines                = 3
        IF sy-subrc  NE 0.
          MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                     WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        ENDIF.                             " IF sy-subrc  NE 0
    *-If Graph Option selected
      ELSEIF p_grp EQ 'X'.
      set rfc destination
        cl_gfw=>its_rfc_dest = 'IGS_RFC_DEST'.
      create hmtl control
        CREATE OBJECT html_control
          EXPORTING parent = cont.
        PERFORM create_chart USING g_html 'X'.
      get url of output data
        CALL METHOD html_control->load_data
          EXPORTING
            type         = 'text'
            subtype      = 'html'
          IMPORTING
            assigned_url = g_url
          CHANGING
            data_table   = g_html.
      Load the picture by using the url generated by the data .
        CALL METHOD html_control->show_url
          EXPORTING
            url = g_url.
    *-If Both Report and Graph Selected
      ELSE.
      set rfc destination
        cl_gfw=>its_rfc_dest = 'IGS_RFC_DEST'.
    Create Splitter for custom_container
        CREATE OBJECT split
           EXPORTING
              parent  = cont
              rows    = 2
              columns = 1.
        CALL METHOD split->get_container
          EXPORTING
            row       = 1
            column    = 1
          RECEIVING
            container = htmlcon.
        CALL METHOD split->get_container
          EXPORTING
            row       = 2
            column    = 1
          RECEIVING
            container = gridcon.
      create hmtl control
        CREATE OBJECT html_control
          EXPORTING parent = htmlcon.
        PERFORM create_chart USING g_html 'X'.
      get url of output data
        CALL METHOD html_control->load_data
          EXPORTING
            type         = 'text'
            subtype      = 'html'
          IMPORTING
            assigned_url = g_url
          CHANGING
            data_table   = g_html.
      Load the picture by using the url generated by the data .
        CALL METHOD html_control->show_url
          EXPORTING
            url = g_url.
        CREATE OBJECT grid
          EXPORTING
            i_parent          = gridcon
          EXCEPTIONS
            error_cntl_create = 1
            error_cntl_init   = 2
            error_cntl_link   = 3
            error_dp_create   = 4
            OTHERS            = 5
        IF sy-subrc NE 0.
          MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                     WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        ENDIF.                             " IF sy-subrc NE 0
        layout-zebra = 'X'.
        layout-no_headers = 'X'.
        layout-cwidth_opt = 'X'.
        layout-grid_title = 'Inventory Turns Report'.
        grid->set_table_for_first_display(
           EXPORTING
             is_layout                     =  layout
           CHANGING
             it_outtab                     = it_final
             it_fieldcatalog               = it_fieldcat
         EXCEPTIONS
           invalid_parameter_combination = 1
           program_error                 = 2
           too_many_lines                = 3
        IF sy-subrc  NE 0.
          MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                     WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        ENDIF.                             " IF sy-subrc  NE 0
      ENDIF.                               " IF p_rep EQ 'X'
    ENDMODULE.                             " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
          User Action Handling
    MODULE user_command_0100 INPUT.
      CASE sy-ucomm.
    *-Handling the User actions
        WHEN 'BACK' OR 'CANC' OR 'EXIT'.
          LEAVE TO SCREEN 0.

Maybe you are looking for

  • Server Errors

    We experienced an error in processing your request. Please try again later. I am getting this when I try to upgrade my phone. I've tried redoing it about 50 times now and same error. Anybody else getting this?

  • EXC_BAD_ACCESS (SIGSEGV) and  KERN_INVALID_ADDRESS

    Hi! I've been having a lot of crashing by the software Corel Painter 2015, after using it normally for months, Today I tried to open it and while it was loading halfway I got a Problem report dialog, I've deleted the software, installed again, ran th

  • JVM memory allocation

    Hello, I am writing a program that requires me to read large files into memory. Since the JVM has a heap limitation, I am setting the max memory with the -Xmx"number"m command line command. I then create an exe wuing JBuilder. For some reason, I can'

  • Purchase Order Workflow event trigered when i create the Schedule Agrrement using ME31l.

    Hi expert,      When i create Schedule agreement using me31l it will raise the PO workflow instead of SA  Workflows. ?  where is the configuration mismatch happen ?

  • How can i Use the symbols from the main html page?

    Hello! Im trying to find a solution for days!! i need to use my symbols from the html page, for example to hide the symbol i want to use: sym.$( "sym1" ).hide(); or to make it draggable (with jquery UI) i wanna use: sym.$( "sym1" ).draggable(); but i