Average function in ALV Report

Hi ,
I am doing Subtotal in ALV by Grouping the Fields. Instead of Using Subtotal i want to Use Average of
(Total / Quantity) in AlV. Is there any function availabile for doing Average in ALV Reports.
Point will be definately awarded .\
Kamal

>  I am doing Subtotal in ALV by Grouping the Fields. Instead of Using Subtotal i want to Use Average of
> (Total / Quantity) in AlV. Is there any function availabile for doing Average in ALV Reports.
>
It is possible to show the Average using the FIELDCATALOG-DO_SUM = 'C'. for the column/field which you want the Average.
FIELDCATALOG-DO_SUM = 'C'. "<-----Avergage
Read the Rules , Don't use Forbidden words...

Similar Messages

  • How to add the dril down functionality in alv report.

    Hi All,
    I have a ALV report and now i want to add drill down functionality in this ALV report.
    See my code below:
    FORM f0002_build_field_catalog.
    Build the field catalog
    CLEAR ws_layout.
    ws_layout-colwidth_optimize = 'X'.
    ws_layout-edit = ' '.
      ws_field_catalog-col_pos = '1'.
      ws_field_catalog-fieldname = 'BUKRS'.
      ws_field_catalog-tabname = 'I_OUTPUT'.
      ws_field_catalog-seltext_l = 'Company Code'.
      ws_field_catalog-seltext_m = 'CCode'.
      ws_field_catalog-seltext_s = 'CCode'.
    ws_field_catalog-fix_column = 'X'.
    ws_field_catalog = 'X'.
    ws_fieldcat-ref_tabname  = 'VBKPF'.
      APPEND ws_field_catalog TO lt_fieldcat.
      CLEAR: ws_field_catalog.
      ws_field_catalog-col_pos = '2'.
      ws_field_catalog-fieldname = 'BELNR'.
      ws_field_catalog-tabname = 'I_OUTPUT'.
      ws_field_catalog-seltext_l    = 'Document no.'.
      ws_field_catalog-hotspot = 'V'.
      ws_field_catalog-seltext_m    = 'Doc.no.'.
      ws_field_catalog-seltext_s    = 'Doc.no.'.
      APPEND ws_field_catalog TO lt_fieldcat.
      CLEAR: ws_field_catalog.
      ws_field_catalog-col_pos = '3'.
      ws_field_catalog-fieldname = 'GJAHR'.
      ws_field_catalog-tabname = 'I_OUTPUT'.
      ws_field_catalog-seltext_l    = 'Year'.
      ws_field_catalog-seltext_m    = 'Year'.
      ws_field_catalog-seltext_s    = 'Year'.
      APPEND ws_field_catalog TO lt_fieldcat.
      CLEAR: ws_field_catalog.
      ws_field_catalog-col_pos = '4'.
      ws_field_catalog-fieldname = 'BSTAT'.
      ws_field_catalog-tabname = 'I_OUTPUT'.
      ws_field_catalog-seltext_l    = 'Status'.
      ws_field_catalog-seltext_m    = 'Status'.
      ws_field_catalog-seltext_s    = 'Status'.
      APPEND ws_field_catalog TO lt_fieldcat.
      CLEAR: ws_field_catalog.
      ws_field_catalog-col_pos = '5'.
      ws_field_catalog-fieldname = 'FLAG'.
      ws_field_catalog-tabname = 'I_OUTPUT'.
      ws_field_catalog-seltext_l    = 'Open/Cleared'.
      ws_field_catalog-seltext_m    = 'Open/Cleared'.
      ws_field_catalog-seltext_s    = 'Open/Cleared'.
      APPEND ws_field_catalog TO lt_fieldcat.
      CLEAR: ws_field_catalog.
      ws_field_catalog-col_pos = '6'.
      ws_field_catalog-fieldname = 'BLART'.
      ws_field_catalog-tabname = 'I_OUTPUT'.
      ws_field_catalog-seltext_l    = 'Doc.Type.'.
      ws_field_catalog-seltext_m    = 'Doc.Type'.
      ws_field_catalog-seltext_s    = 'Doc.Type'.
      APPEND ws_field_catalog TO lt_fieldcat.
      CLEAR: ws_field_catalog.
      ws_field_catalog-col_pos = '7'.
      ws_field_catalog-fieldname = 'WRBTR'.
      ws_field_catalog-tabname = 'I_OUTPUT'.
      ws_field_catalog-seltext_l    = 'Total Amount'.
      ws_field_catalog-seltext_m    = 'Total Amount'.
      ws_field_catalog-seltext_s    = 'Total Amount'.
      APPEND ws_field_catalog TO lt_fieldcat.
      CLEAR: ws_field_catalog.
      ws_field_catalog-col_pos = '8'.
      ws_field_catalog-fieldname = 'WAERS'.
      ws_field_catalog-tabname = 'I_OUTPUT'.
      ws_field_catalog-seltext_l    = 'Currency.'.
      ws_field_catalog-seltext_m    = 'Currency'.
      ws_field_catalog-seltext_s    = 'Currency'.
      APPEND ws_field_catalog TO lt_fieldcat.
      CLEAR: ws_field_catalog.
      ws_field_catalog-col_pos = '9'.
      ws_field_catalog-fieldname = 'LIFNR'.
      ws_field_catalog-tabname = 'I_OUTPUT'.
      ws_field_catalog-seltext_l    = 'Vendor'.
      ws_field_catalog-seltext_m    = 'Vendor'.
      ws_field_catalog-seltext_s    = 'Vendor'.
      APPEND ws_field_catalog TO lt_fieldcat.
      CLEAR: ws_field_catalog.
      ws_field_catalog-col_pos = '10'.
      ws_field_catalog-fieldname = 'NAME1'.
      ws_field_catalog-tabname = 'I_OUTPUT'.
      ws_field_catalog-seltext_l    = 'Vendor Name'.
      ws_field_catalog-seltext_m    = 'Name 1'.
      ws_field_catalog-seltext_s    = 'Name 1'.
      APPEND ws_field_catalog TO lt_fieldcat.
      CLEAR: ws_field_catalog.
      ws_field_catalog-col_pos = '11'.
      ws_field_catalog-fieldname = 'UZAWE'.
      ws_field_catalog-tabname = 'I_OUTPUT'.
      ws_field_catalog-seltext_l    = 'Payment Method Supplement'.
      ws_field_catalog-seltext_m    = 'PmtMthSuppl'.
      ws_field_catalog-seltext_s    = 'PmtMthSuppl'.
      APPEND ws_field_catalog TO lt_fieldcat.
      CLEAR: ws_field_catalog.
      ws_field_catalog-col_pos = '12'.
      ws_field_catalog-fieldname = 'XBLNR'.
      ws_field_catalog-tabname = 'I_OUTPUT'.
      ws_field_catalog-seltext_l    = 'Reference'.
      ws_field_catalog-seltext_m    = 'Ref. No.'.
      ws_field_catalog-seltext_s    = 'Ref. No.'.
      APPEND ws_field_catalog TO lt_fieldcat.
      CLEAR: ws_field_catalog.
    g_variant-report  = sy-repid.
       CLEAR struct_extab.
      MOVE '&XPA' TO struct_extab-fcode.
      APPEND struct_extab TO i_extab.
      MOVE '&OMP' TO struct_extab-fcode.
      APPEND struct_extab TO i_extab.
    Display the list
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
          i_callback_program      = ws_repid
          i_callback_user_command = 'HANDLE_USER_COMMAND'
         is_layout               = ws_layout
          it_fieldcat             = lt_fieldcat[]
          it_excluding            = i_extab[]
         i_default                = 'X'
         i_save                  =  'U'  "For user variants
         is_variant              = g_variant
        TABLES
          t_outtab                = i_output.
    ENDFORM.                    "f0002_build_field_catalog
    *&      Form  f0038_pf_status
          text
         -->I_EXTAB    text
    FORM f0038_pf_status USING i_extab TYPE slis_t_extab.       "#EC CALLED
      CLEAR struct_extab.
      MOVE '&XPA' TO struct_extab-fcode.
      APPEND struct_extab TO i_extab.
      MOVE '&OMP' TO struct_extab-fcode.
      APPEND struct_extab TO i_extab.
      SET PF-STATUS 'Z_PFSTATUS2' EXCLUDING i_extab.
    ENDFORM.                     "f0038_pf_status
    Pls tell me how i use this below dril down ability functionality in my code.
    See the requirement below.
    The Document Number, aka Accounting Document Number (BELNR) of each row will take the user to the appropriate document to edit as follows:
    For Parked documents:-
    If VBKPF-AWTYP (Reference Procedure) = “RMRP”, then the drilldown functionality should be to MIR4 using the Object ID in VBKPF- AWKEY. In this scenario the Object ID represents a Invoice Document Number, not an Accounting Document Number. Not the Object ID is a combination of Invoice Document Number and Fiscal Year
    If VBKPF-AWTYP = Any other value, then the drilldown functionality should be to FBV2 using the Object ID in VBKPF-AWKEY. In this scenario the Object ID represents a true Accounting Document Number. Note the Object ID is a combination of Company Code (VBKPF-BUKRS), Accounting Document Number (VBKPF-BELNR) and Fiscal Year (VBKPF-GJAHR)
    For Posted, not Cleared documents:-
    Drilldown ability should be to FB02. The combination of Company Code (BSIK-BUKRS), Accounting Document Number (BSIK-BELNR) and Fiscal Year (BSIK-GJAHR) will be used to open/drilldown to the correct document in FB02.
    For Cleared documents:-
    Drilldown ability should be to FB03. The combination of Company Code (BSIK-BUKRS), Accounting Document Number (BSIK-BELNR) and Fiscal Year (BSIK-GJAHR) will be used to open/drilldown to the correct document in FB03.
    Its very urgent, pls help on this.
    Thanks!
    Vipin

    Pls refer :
    https://wiki.sdn.sap.com/wiki/display/Snippets/ABAPInteractiveALVwithCallTransaction%28usingParameterID%29
    https://wiki.sdn.sap.com/wiki/display/Snippets/ABAPInteractiveALV+Program
    Regards,
    Anish Thomas
    Pls reward all useful answers

  • Handle back functionality in ALV report

    Hi,
    I have created the alv report which has 2 button on the report display, if you select any of them it will display other 2 reports.
    here i am facing problem in handling the BACK functionality.
    i.e after the navigations between the 2nd and 3rd reports, at which ever screen, if i press BACK then it has to come to 1st report.
    kindly guide.

    what have you used for the BACK button
    when 'BACK'.
      SET SCREEN 0.

  • Subtotal  function in ALV report

    Hi, experts,
    I got a problem when creating an ALV report about billing document.
    This ALV report include following info&#65306;
    Billing date
    Billing doc no.
    Customer no.
    Customer name
    Material no.
    Material name
    Condition name
    Qty
    Unit price
    Amount
    Tax amount
    Invoice total
    The logic of subtotal for this report is:
    In same billing document no.
    1. If condition name=A, then subtotal Qty, Amount, Invoice total by material no.
    2. If condition name &#8800;A, then subtotal Qty, Amount , Invoice total by condition name
    Is it possible? How can I achieve it?

    Hi,
    Please find details on how to modify ALV report below:
    /people/ravikumar.allampallam/blog/2005/12/05/need-a-way-to-change-appearance-of-a-standard-existing-alv-report
    <b>Reward if helpful.</b>

  • Drill Down functionality in ALV Report

    Hi Experts,
    Gud Afternoon..!!!
    My Requirement: I have to display a report in ALV and if user click on vbeln the screen should go to transaction code VA43 for that particular contract.
    I used the below code,
    FORM user_command  USING r_ucomm LIKE sy-ucomm
                            rs_selfield TYPE slis_selfield.
    data:  w_vbeln type vbak-vbeln.
      IF r_ucomm EQ '&IC1' .   " Click value of hot spot
        CASE rs_selfield-fieldname.
          WHEN 'VBELN'.
            w_vbeln =  rs_selfield-value.
            SET PARAMETER ID 'AUN' FIELD w_vbeln.
            CALL TRANSACTION 'VA43' AND SKIP FIRST SCREEN.
        ENDCASE.
      ELSEIF r_ucomm EQ 'CANC'
            OR r_ucomm EQ 'BACK'
            OR r_ucomm EQ 'EXIT'.
        LEAVE PROGRAM.
      ENDIF.
    ENDFORM.                    " user_command
    I am getting error message in VA43 initial screen as "Enter the doc. no"
    Plz help me in this. Thanks in Advance..!!!
    Regards,
    Vadhu...

    Hi,
    Thanks Aakash Banga, Rimpa Abhishek..!!!
    I got the solution with help of SDN. The Solution as follows,
    FORM user_command  USING r_ucomm LIKE sy-ucomm
                            rs_selfield TYPE slis_selfield.
      DATA:  w_vbeln TYPE vbak-vbeln.
      IF r_ucomm EQ '&IC1' .   " Click value of hot spot
        CASE rs_selfield-fieldname.
          WHEN 'VBELN'.
            w_vbeln =  rs_selfield-value.
            REFRESH t_bdcdata.
            CLEAR t_bdcdata.
            t_bdcdata-program  = 'SAPMV45A'.
            t_bdcdata-dynpro   = '102'.
            t_bdcdata-dynbegin = 'X'.
            APPEND t_bdcdata TO t_bdcdata.
            CLEAR t_bdcdata.
            t_bdcdata-fnam = 'BDC_CURSOR'.
            t_bdcdata-fval = 'VBAK-VBELN'.
            APPEND t_bdcdata TO t_bdcdata.
            CLEAR t_bdcdata.
            t_bdcdata-fnam = 'BDC_OKCODE'.
            t_bdcdata-fval = '=SUCH'.
            APPEND t_bdcdata TO t_bdcdata.
            CLEAR t_bdcdata.
            t_bdcdata-fnam = 'VBAK-VBELN'.
            t_bdcdata-fval = w_vbeln.
            APPEND t_bdcdata TO t_bdcdata.
            CLEAR t_bdcdata.
            t_bdcdata-program  = 'SAPMV45A'.
            t_bdcdata-dynpro   = '4001'.
            t_bdcdata-dynbegin = 'X'.
            APPEND t_bdcdata TO t_bdcdata.
            CALL TRANSACTION 'VA43' USING t_bdcdata MODE 'P' .
            CALL TRANSACTION 'VA43' AND SKIP FIRST SCREEN.
        ENDCASE.
      ELSEIF r_ucomm EQ 'CANC'
            OR r_ucomm EQ 'BACK'
            OR r_ucomm EQ 'EXIT'.
        LEAVE PROGRAM.
      ENDIF.
    ENDFORM.                    " user_command
    Thanks & Regards,
    Vadhu Duraisami

  • Enhancing print functionality for ALV report

    Our client requires a special Print at click button in few reports and screens in such a way that there is no effort in setting page sizes etc. 
    For one particular report, there are many columns.  When I try to use List -> Print, only first few columns are printed.  I want that all the columns are printed in landscape manner in different pages and the first column is repeated in both pages (it is frozen in report). 
    How to make these happen?

    HI,
    You can try following steps,
    1) Goto transaction SPAD and create Page formate according to your requirement.
    2) Create format and copy action from standard format.
    3) create device type
    4) assign that device type to custamize output type.
    When ever you take print out of that ALV use your custamize Output Type

  • Subtracting in ALV report

    i have a FI report where i am showing Assets and liabilities value in ALV format, i m using ALV grid layout. there i can easily add those values, but my problem is i have to subtract liabilities value from Assets value, but in ALV i do not find any option to Subtract values between those criteria. so my question is: Is there any option or function in ALV report where we can Subtract, multiply, division between the values in the table?

    hiiiiiiiiiiiiiii
    try to do this
    multiply any one of field by -1
    for ex: 
    loop at itab.
          multiply  itab_field  by -1.
        endloop
    and then add in alv report may this subtracted
    or
    initialize substraction field in itab
    do substracion of these tow fields append the result to itab and display it
    if u want substraction at last
    write in loop
    at last of itab
    do substraction
    i think ,
    may this solve ur problenm

  • ALV Report Toolbar

    Hey All,
    in my ALV report I am not able to see standard toolbar. I have copied the same using SE80 and when I check my program in SE80 it shows the Standard Toolbar to be there. Can someone help me how to add the same.
    Also I am using standard function based ALV report and in that I need to add additional button once my report is visible. I know this question may have been asked upteen time. But I am not able to resolve the above two problems so if someone can help me it will be great help.
    Siddhartha

    Hi All,
    My first problem of toolbar not visible has been solved. Now In the toolbar copied in my code I added a button and labeled it as inactive" I would like to call a function on click of it which will do the further processing. The code snippets which I have used are as follows:
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          I_CALLBACK_PROGRAM       = LW_REPID
         I_CALLBACK_PF_STATUS_SET = G_STATUS
          I_CALLBACK_html_top_of_page = L_C_html_top
          I_CALLBACK_USER_COMMAND  = G_USER_COMMAND
         IT_EVENTS                = I_EVENTS[]
          IT_FIELDCAT              = I_FLD_CAT
          IS_LAYOUT                = PRT_LAYOUT
          IT_SORT                  = IT_SORT
        TABLES
          T_OUTTAB                 = T_OUTPUT[].
    Now the button which I have created in my standard toolbar is not visible in the report. So can someone tell me what I am missing.
    Also while creating button what are the required things to be provided and how this button will be linked so that on click of it a required Form will be called.
    Thanks once again to Max_Bianchi and Sum_it2.
    Siddhartha

  • What is alv report?

    hi guys, i would like to know the functionality of ALV reports.Please help me in this regard.
    reward points if answered.
    thanks in advance.

    Hi,
      ALV is ABAP LIST VIEWER.
    To have more functionalities like totals, subtotals,logos,etc we choose ALVs compared to reports.
    Check this:
    Documentation on alv:
    you can check out:
    http://www.****************/Tutorials/ALV/ALVMainPage.htm
    http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCSRVALV/BCSRVALV.pdf
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/e8a1d690-0201-0010-b7ad-d9719a415907
    http://help.sap.com/saphelp_nw2004s/helpdata/en/43/41341147041806e10000000a1553f6/frameset.htm
    ABAP List Viewer
    The common features of report are column alignment, sorting, filtering, subtotals, totals etc. To implement these, a lot of coding and logic is to be put. To avoid that we can use a concept called ABAP List Viewer (ALV).
    This helps us to implement all the features mentioned very effectively.
    Using ALV, We can have three types of reports:
    1. Simple Report
    2. Block Report
    3. Hierarchical Sequential Report
    There are some function modules which will enable to produce the above reports without much effort.
    All the definitions of internal tables, structures and constants are declared in a type-pool called SLIS.
    1. SIMPLE REPORT.
    The important function modules are
    a. Reuse_alv_list_display
    b. Reuse_alv_fieldcatalog_merge
    c. Reuse_alv_events_get
    d. Reuse_alv_commentary_write
    e. Reuse_alv_grid_display
    A. REUSE_ALV_LIST_DISPLAY : This is the function module which prints the data.
    The important parameters are :
    I. Export :
    i. I_callback_program : report id
    ii. I_callback_pf_status_set : routine where a user can set his own pf status or change the functionality of the existing pf status
    iii. I_callback_user_command : routine where the function codes are handled
    iv. I_structure name : name of the dictionary table
    v. Is_layout : structure to set the layout of the report
    vi. It_fieldcat : internal table with the list of all fields and their attributes which are to be printed (this table can be populated automatically by the function module REUSE_ALV_FIELDCATALOG_MERGE
    vii. It_events : internal table with a list of all possible events of ALV and their corresponding form names.
    II. Tables :
    i. t_outtab : internal table with the data to be output
    B. REUSE_ALV_FIELDCATALOG_MERGE : This function module is used to
    populate a fieldcatalog which is essential to display the data in ALV.
    If the output data is from a single dictionary table and all the
    columns are selected, then we need not exclusively create the field cat
    alog. Its enough to mention the table name as a parameter
    (I_structure name) in the REUSE_ALV_LIST_DISPLAY. But in other cases
    we need to create it.
    The Important Parameters are :
    I. Export :
    i. I_program_name : report id
    ii. I_internal_tabname : the internal output table
    iii. I_inclname : include or the report name where all the dynamic forms are handled.
    II Changing
    ct_fieldcat : an internal table with the type SLIS_T_FIELDCAT_ALV which is
    declared in the type pool SLIS.
    C. REUSE_ALV_EVENTS_GET : Returns table of possible events for a list type
    Parameters :
    I. Import :
    Et_Events : The event table is returned with all possible CALLBACK events
    for the specified list type (column 'NAME'). For events to be processed by Callback, their 'FORM' field must be filled. If the field is initialized, the event is ignored. The entry can be read from the event table, the field 'FORM' filled and the entry modified using constants from the type pool SALV.
    II. Export :
    I_List_type :
    0 = simple list REUSE_ALV_LIST_DISPLAY
    1 = hierarchcal-sequential list REUSE_ALV_HIERSEQ_LIST_DISPLAY
    2 = simple block list REUSE_ALV_BLOCK_LIST_APPEND
    3 = hierarchical-sequential block list
    REUSE_ALV_BLOCK_LIST_HS_APPEND
    D. REUSE_ALV_COMMENTARY_WRITE : This is used in the Top-of-page event to print the headings and other comments for the list.
    Parameters :
    I. it_list_commentary : internal table with the headings of the type slis_t_listheader.
    This internal table has three fields :
    Typ : ‘H’ – header, ‘S’ – selection , ‘A’ - action
    Key : only when typ is ‘S’.
    Info : the text to be printed
    E. REUSE_ALV_GRID_DISPLAY : A new function in 4.6 version, to display the results in grid rather than as a preview.
    Parameters : same as reuse_alv_list_display
    This is an example for simple list.
    2. BLOCK REPORT
    This is used to have multiple lists continuously.
    The important functions used in this report are:
    A. REUSE_ALV_BLOCK_LIST_INIT
    B. REUSE_ALV_BLOCK_LIST_APPEND
    C. REUSE_ALV_BLOCK_LIST_HS_APPEND
    D. REUSE_ALV_BLOCK_LIST_DISPLAY
    A. REUSE_ALV_BLOCK_LIST_INIT
    Parameters:
    I. I_CALLBACK_PROGRAM
    II. I_CALLBACK_PF_STATUS_SET
    III. I_CALLBACK_USER_COMMAND
    This function module is used to set the default gui status etc.
    B. REUSE_ALV_BLOCK_LIST_APPEND
    Parameters :
    Export :
    I. is_layout : layout settings for block
    II. it_fieldcat : field catalog
    III. i_tabname : internal table name with output data
    IV. it_events : internal table with all possible events
    Tables :
    i. t_outtab : internal table with output data.
    This function module adds the data to the block.
    Repeat this function for all the different blocks to be displayed one after the other.
    C. REUSE_ALV_BLOCK_LIST_HS_APPEND
    This function module is used for hierarchical sequential blocks.
    D. REUSE_ALV_BLOCK_LIST_DISPLAY
    Parameters : All the parameters are optional.
    This function module display the list with data appended by the above function.
    Here the functions REUSE_ALV_FIELDCATALOG_MERGE, REUSE_ALV_EVENTS_GET, REUSE_ALV_COMMENTARY_WRITE can be used.
    3. Hierarchical reports :
    Hierarchical sequential list output.
    The function module is
    A. REUSE_ALV_HIERSEQ_LIST_DISPLAY
    Parameters:
    I. Export:
    i. I_CALLBACK_PROGRAM
    ii. I_CALLBACK_PF_STATUS_SET
    iii. I_CALLBACK_USER_COMMAND
    iv. IS_LAYOUT
    v. IT_FIELDCAT
    vi. IT_EVENTS
    vii. i_tabname_header : Name of the internal table in the program containing the
    output data of the highest hierarchy level.
    viii. i_tabname_item : Name of the internal table in the program containing the
    output data of the lowest hierarchy level.
    ix. is_keyinfo : This structure contains the header and item table field
    names which link the two tables (shared key).
    II. Tables
    i. t_outtab_header : Header table with data to be output
    ii. t_outtab_item : Name of the internal table in the program containing the
    output data of the lowest hierarchy level.
    slis_t_fieldcat_alv : This internal table contains the field attributes. This internal table can be populated automatically by using ‘REUSE_ALV_FIELDCATALOG_MERGE’.
    Important Attributes :
    A. col_pos : position of the column
    B. fieldname : internal fieldname
    C. tabname : internal table name
    D. ref_fieldname : fieldname (dictionary)
    E. ref_tabname : table (dictionary)
    F. key(1) : column with key-color
    G. icon(1) : icon
    H. symbol(1) : symbol
    I. checkbox(1) : checkbox
    J. just(1) : (R)ight (L)eft (C)ent.
    K. do_sum(1) : sum up
    L. no_out(1) : (O)blig.(X)no out
    M. outputlen : output length
    N. seltext_l : long key word
    O. seltext_m : middle key word
    P. seltext_s : short key word
    Q. reptext_ddic : heading (ddic)
    R. ddictxt(1) : (S)hort (M)iddle (L)ong
    S. datatype : datatype
    T. hotspot(1) : hotspot
    some theory regarding alv:
    This table tells ALV which events are processed by the caller by CALLBACK.
    The table of possible events per list type can be initialized using the module REUSE_ALV_EVENTS_GET.
    You can display the names of the constants in the type pools SLIS which represent the individual events using the individual test function in the function module
    REUSE_ALV_EVENT_NAMES_GET. Only events with a form routine name are processed.
    The table structure contains the fields:
    • IT_EVENTS-NAME
    Name of the Callback event.
    Possible Callback events:
    • Action
    USER_COMMAND USING R_UCOMM LIKE SY-UCOMM RS_SELFIELD TYPE SLIS_SELFIELD
    Process actions on the list
    As this is a frequently-used Callback event, the form routine can also be passed directly in the interface in the IMPORTING parameter I_CALLBACK_USER_COMMAND.
    PF_STATUS_SET USING RT_EXTAB TYPE SLIS_T_EXTAB
    If a user list status is to be set, it must be done in the form routine assigned to this event. The ALV function codes, which must not be active, are in the Parameter RT_EXTAB. This table must be passed with the SET PF-STATUS command (with inactive user function codes as well, if necessary).
    The STANDARD status of the function group SALV should be used as a template for a user-specific status.
    As this is a frequently-used Callback event, its form routine can also be passed directly in the interface in the IMPORTING parameter I_CALLBACK_PF_STATUS_SET.
    ITEM_DATA_EXPAND USING RS_SELFIELD TYPE SLIS_SELFIELD RFLG_ALL TYPE C
    Only relevant for hierarchical-sequential lists using the layout parameter IS_LAYOUT-EXPAND_FIELDNAME of the structure IS_LAYOUT.
    Exit for passing item entries (ITEM table) for a header record which was expanded interactively by the user.
    RS_SELFIELD-TABINDEX contains the header table index for which the item entries are to be put in the global item output table (T_OUTTAB_SLAVE). The Callback is only called if ALV has no items for a header which is to be expanded.
    RFLG_ALL is passed with 'X' if the user shows all items. The application must ensure that entries are not repeated in the item table. RS_SELFIELD is initial in this case.
    CALLER_EXIT USING RS_DATA Is called at the beginning of the function module to make special settings. It is not usually used.
    • List processing events
    IMPORTANT: The application Callback routine must not manipulate the internal output table and/or its header record. This restriction applies to all Callbacks which are called in the list output and run under the 'List processing events'.
    TOP_OF_LIST no USING parameter. Information output at the start of the list
    END_OF_LIST no USING parameter. Information output at the end of the list
    TOP_OF_PAGE no USING parameter
    Equivalent to the list processing TOP-OF-PAGE event
    END_OF_PAGE no USING parameter. Not available for hierarchical-sequential lists.
    Information output at the end of a page. This is only called for printing.
    TOP_OF_COVERPAGE no USING parameter
    The selection information and list status are output together (if they exist) on a separate page by default. See also the documentation of the parameters:
    IS_PRINT-NO_COVERPAGE
    IS_PRINT-NO_PRINT_SELINFOS
    IS_PRINT-NO_PRINT_LISTINFOS
    IS_LAYOUT-GET_SELINFOS
    The user can format the header area of the 'cover page' himself or herself by specifying a Callback routine for this event.
    END_OF_COVERPAGE no USING parameter
    Analogously to TOP_OF_COVERPAGE the user can add other information to the information output by ALV (selection information, list status) at this event.
    FOREIGN_TOP_OF_PAGE no USING parameter
    The Top-of-page event is always processed in ALV and is only passed to the caller via the Callback mechanism. This is still the case if the caller, e.g. by a user action, processes a branch list which was not formatted by ALV (e.g. a popup with additional information about the list record selected and displayed by ALV).
    In this case, top-of-page cannot be formatted by ALV analogously to the basic list, it must be handled completely by the caller. The event top-of-page still occurs in ALV. When ALV notices a top-of-page which was not caused by an ALV output, the form routine in FOREIGN_TOP_OF_PAGE is called.
    FOREIGN_END_OF_PAGE no USING parameter
    The event end-of-page is always processed in ALV and only passed to the caller via callback. This is still the case, e.g. when the caller processes a details list which was not formatted by ALV (e.g. a popup with further information about selected list records which were displayed by ALV).
    In this case, end-of-page cannot be formatted by ALV analogously to the basic list, it must be handled completely by the caller. The event end-of-page still occurs in ALV. When ALV notices an end-of-page that was not caused by an ALV output, the form routine in FOREIGN_END_OF_PAGE is called.
    BEFORE_LINE_OUTPUT USING RS_LINEINFO TYPE SLIS_LINEINFO
    Output information before each output line. Should only be used in justified cases because it costs a lot of performance.
    AFTER_LINE_OUTPUT USING RS_LINEINFO TYPE SLIS_LINEINFO
    Output information after each output line. Should only be used in justified cases because it costs a lot of performance.
    • Internal use only
    LIST_MODIFY USING R_TABNAME TYPE SLIS_TABNAME
    R_INDEX LIKE SY-TABIX
    R_INDEX_ITEM LIKE SY-TABIX
    R_INDEX_SUM LIKE SY-TABIX
    • IT_EVENTS-FORM
    Name of the form routine which should be called in the calling program at the event.
    Field_catalog:
    Field catalog with field descriptions
    2.7.1. Description
    Field catalog containing descriptions of the list output fields (usually a subset of the internal output table fields). A field catalog is required for every ALV list output.
    The field catalog for the output table is built-up in the caller's coding. The build-up can be completely or partially automated by calling the REUSE_ALV_FIELDCATALOG_MERGE module
    See also the documentation of the function module REUSE_ALV_FIELDCATALOG_MERGE.
    The minimal field catalog is documented under 'default'. The caller can use the other optional parameters to assign output attributes to a field which differ from the default.
    A field catalog need not be built-up and passed explicitly only under the following conditions:
    • The internal table to be output has the same structure as a Data Dictionary structure which is referred to in the internal table declaration using LIKE or INCLUDE STRUCTURE.
    • all fields in this structure are to be output
    • the structure name is passed to ALV in the parameter I_STRUCTURE_NAME.
    See also the documentation of the IMPORTING paramter I_STRUCTURE_NAME.
    Positioning
    • row_pos (row position)
    value set: 0, 1 - 3
    Only relevant if the list output is to be multi-line (two or three lines) by default.
    A multi-line list can also be defined by the user interactively if the default list is one-line.
    The parameter specifies the relative output line of the column in a multi-line list.
    • col_pos (column position)
    value set: 0, 1 - 60
    only relevant when the default relative column positions differ from the field catalog field sequence. The parameter specifies the relative column position of the field in the list output. The column order can be changed interactively by the user. If this parameter is initial for all field catalog entries, columns appear in the field catalog field sequence.
    Identification
    • fieldname (field name)
    value set: internal output table field name (required parameter)
    Name of the internal output table field which is described by this field catalog entry
    • tabname (internal output table)
    value set: SPACE, internal output table name
    This parameter is used in 'manual' field catalog build-up only for hierarchical-sequential lists.
    Name of the internal output table which contains the field FIELDCAT-FIELDNAME.
    Data Dictionary reference
    • ref_fieldname (reference field name)
    value set: SPACE, Data Dictionary field name
    Name of the Data Dictionary field referred to.
    This parameter is only used when the internal output table field described by the current field catalog entry has a reference to the Data Dictionary (not a program field), and the field name in the internal output table is different from the name of the field in the Data Dictionary. If the field names are identical, naming the Data Dictionary structure or table in the FIELDCAT-REF_TABNAME parameter is sufficient.
    • ref_tabname (reference table/structure field name)
    value set: SPACE, name of a Data Dictionary structure or table
    Structure or table name of the referred Data Dictionary field.
    This parameter is only used when the internal output table field described by the current field catalog entry has a Data Dictionary reference (not a program field).
    Reference to fields with currency/measurement unit
    Each internal output table sum or quantity field whose decimal places are to be formatted appropriately for the unit in the list must follow the convention:
    • the field is of data type QUAN or CURR (internal type P) (the field must really have this physical data type. Overwriting the physical data type with the parameter FIELDCAT-DATATYPE has no effect)
    • There is a field in the internal output table which contains the associated unit.
    • There is also an entry in the field catalog for the unit field.
    (If the unit is not to appear as a column in the list, and cannot be interactively displayed as a column, e.g. because it is always unambiguous and is therefore explicitly output by the caller in the list header, the field catalog units field entry can take the parameter FIELDCAT-TECH = 'X'.
    The association of a value field to a unit affects the output as follows:
    • appropriate decimal places display for the unit
    • an initialized field with a link to a non-initial unit is output as '0' for the unit (if FIELDCAT-NO_ZERO is initial). When this field is summed, this unit affects whether the units are homogeneous.
    • an initialized field with a link to an initial unit is output as SPACE. When this field is summed, the unit SPACE does not affect the homogeneity of the units.
    • When non-initial fields with an initial unit are summed, the unit SPACE is considered to be a unit.
    Link to currency unit
    • cfieldname (currency unit field name)
    value set: SPACE, output table field name
    Only relevant for amount columns with associated unit.
    Name of the internal output table field containing the currency unit associated with the amount field FIELDCAT-FIELDNAME. The field in FIELDCAT-CFIELDNAME must have its own field catalog entry.
    • ctabname (internal currency unit field output table)
    value set: SPACE, output table field name
    only relevant for hierarchical-sequential lists
    Name of the internal output table containing the FIELDCAT-CFIELDNAME field.
    Link to measurement unit
    • qfieldname (measurement unit field name)
    value set: SPACE, output table field name
    only relevant for quantity columns with unit link.
    Name of the internal output table field containing the measurement unit associated with the quantity field FIELDCAT-FIELDNAME.
    The field in FIELDCAT-QFIELDNAME must have its own field catalog entry.
    • qtabname (internal measurement unit field output table)
    value set: SPACE, output table field name
    only relevant for hierarchical-sequential lists
    Name of the internal output table containing the FIELDCAT-QFIELDNAME field.
    Column output options
    • outputlen (column width)
    value set: 0 (initial), n
    For fields with a Data Dictionary link this parameter can be left initial.
    For fields without a Data Dictionary link (program field) the parameter must be given the value of the desired field list output length (column width).
    initial = column width is the output length of the referred Data Dictionary field (domain).
    n = column width is n characters
    • key (key column)
    value set: SPACE, 'X' 'X' = kex field (key field output in color)
    Key fields can not be interactively hidden. Parameter FIELDCAT-NO_OUT must be left initial.
    For exceptions see the documentation of the FIELDCAT-KEY_SEL parameter.
    • key_sel (hideable key column)
    value set: SPACE, 'X'
    only relevant when FIELDCAT-KEY = 'X'
    Key field which can be hidden interactively.
    The key column sequence cannot be changed interactively by the user.
    The output is controlled by the FIELDCAT-NO_OUT parameter analogously to non-key fields.
    • no_out (field in field list)
    value set: SPACE, 'X' 'X' = field is not displayed in the current list.
    The user can interactively choose the field for output from the field list.
    The user can display the contents of these fields at line level using the 'Detail' function.
    See also the 'Detail screen' documentation of the parameter IS_LAYOUT.
    • tech (technical field)
    value set: SPACE, 'X' 'X' = technical field
    Field cannot be output in the list and cannot be displayed interactively.
    Field can only be used in the field catalog (not in IT_SORT, ...).
    • emphasize (highlight columns in color)
    value set: SPACE, 'X' or 'Cxyz' (x:'1'-'9'; y,z: '0'=off '1'=on)
    'X' = column is colored with the default column highlight color.
    'Cxyz' = column is colored with a coded color:
    • C: Color (coding must begin with C)
    • x: color number
    • y: bold
    • z: inverse
    • hotspot (column as hotspot)
    value set: SPACE, 'X'
    'X' = column cells are output as hotspots
    • fix_column (fix column)
    value set: SPACE, 'X'
    Not relevant for block lists (output of several lists consecutively)
    'X' = column fixed (does not scroll horizontally)
    All columns to be fixed must have this flag, starting from the left. If a column without this flag is output, only the columns to the left of this column are fixed. The user can change the column fixing interactively. See also the documentation of the Layout parameter
    IS_LAYOUT-NO_KEYFIX of the IMPORTING paramter IS_LAYOUT.
    • do_sum (sum over column)
    value set: SPACE, 'X' 'X' = a sum is to be calculated over this internal output table field.
    This function can also be called by the user interactively.
    • no_sum (sums forbidden)
    value set: SPACE, 'X' 'X' = no sum can be calculated over this field, although the data type of the field would allow summing.
    • input (column ready for input)
    Function not available
    Format column contents
    • icon
    value set: SPACE, 'X' 'X' = column contents to be output as an icon.
    The caller must consider the printability of icons.
    • symbol
    value set: SPACE, 'X' 'X' = column contents are to be output as a symbol.
    The internal output table column must be a valid symbol character.
    The caller must consider the printability of symbols.
    Symbols can usually be printed, but may not always be output correctly, depending on the printer configuration.
    • just (justification)
    value set: SPACE, 'R', 'L', 'C'
    Only relevant for fields of data type CHAR or NUMC
    ' ' = default justification for this data type
    'R' = right-justified output
    'L' = left-justified output
    'C' = centered output
    The justification of the column header always follows the justification of the columns. Independent justification of the column neader is not possible.
    • lzero (leading zeros)
    value set: SPACE, 'X'
    Only relevant for fields of data type NUMC
    ALV outputs NUMC fields right-justified without leading zeros by default.
    'X' = output with leading zeros
    Note: If a NUMC field is output left-justified or centered by FIELDCAT-JUST, leading zeros are output. If the output of leading zeros is suppressed by a Data Dictionary reference ALPHA conversion exit, the output is always left-justified.
    • no_sign (no +/- sign) Only relevant for value fields
    value set: SPACE, 'X' 'X' = value output without +/ sign
    • no_zero (suppress zeros) Only relevant for value fields
    value set: SPACE, 'X' 'X' = suppress zeros
    • edit_mask (field formatting)
    value set: SPACE, template
    template = see documentation of WRITE formatting option USING EDIT MASK template
    The output conversion conv can be made by template = '== conv'.
    Texts
    The following text parameters should be specified for program fields without a Data Dictionary reference. The texts are taken from the Data Dictionary for fields with a Data Dictionary reference. If this is not desired, the text parameters can also be specified. The Data Dictionary texts are then ignored. If the user changes the column width interactively, the column header text with the appropriate length is always used. The interactive function 'Optimize column width' takes account of both the field contents and the column headers: if all field contents are shorter than the shortest column header, the column width depends on the column header.
    The 'long field label' is also used in display variant definition, sort, etc. popups.
    • seltext_l (long field label)
    • seltext_m (medium field label)
    • seltext_s (short field label)
    • reptext_ddic (header)
    analogous to the Data element maintenance 'Header'
    The specified text is not necessarily output in the list, an optimum among all texts is sought.
    • ddictxt (specify text)
    value set: SPACE, 'L', 'M', 'S'
    You can specify with values 'L', 'M', and 'S', the keyword that should always be used as column header. If the column width changes, no attempt is made in this case to find an appropriate header for the new output width.
    Parameters for program fields without Data Dictionary reference
    see also 'Text' parameters
    • datatype (data type)
    value set: SPACE, Data Dictionary data type (CHAR, NUMC,...)
    Only relevant for fields without Data Dictionary reference
    Program field data type
    • ddic_outputlen (external output length)
    value set: 0 (initial), n
    Only relevant for fields without Data Dictionary reference whose output is nevertheless to be modified by a conversion exit.
    Prerequisites:
    • FIELDCAT-EDIT_MASK = '==conv'
    see also the documentation of the parameter FIELDCAT-EDIT_MASK
    • FIELDCAT-INTLEN = n
    see also the documentation of the parameter FIELDCAT-INTLEN
    n = external format field output length
    The column width FIELDCAT-OUTPUTLEN need not be the same as the external format output length (FIELDCAT-DDIC_OUTPUTLEN).
    • intlen (internal output length)
    value set: 0 (initial), n
    Only relevant for fields without Data Dictionary reference whose output is nevertheless to be modified by a conversion exit.
    Prerequisites:
    • FIELDCAT-EDIT_MASK = '==conv'
    see also the documentation of the parameter FIELDCAT-EDIT_MASK
    • FIELDCAT-DDIC_OUTPUTLEN = n
    see also the documentation of the parameter FIELDCAT-DDIC_OUTPUTLEN
    n = internal format field output length
    • rollname (data element)
    value set: SPACE, Data Dictionary data element name
    F1 help can be provided for a program field without a Data Dictionary reference, or F1 help which differs from the Data Dictionary help can be provided for a field with a Data Dictionary reference, using this parameter.
    When F1 help is called for this field, the documentation of the specified data element is displayed.
    If the FIELDCAT-ROLLNAME is initial for fields with a Data Dictionary reference, the documentation of the data element of the referred Data Dictionary field is output.
    Others
    • sp_group (field group key)
    value set: SPACE, CHAR(1)
    Field group key.
    Keys are assigned to group names in the IT_SPECIAL_GROUPS parameter (see also the documentation of the parameter IT_SPECIAL_GROUPS).
    When such an assignment is made in the field catalog and in IT_SPECIAL_GROUPS, the fields are grouped correspondingly in the display variant popup.
    • reprep (Report/Report interface selection criterion)
    value set: SPACE, 'X'
    Prerequisites:
    • The system contains the Report/Report interface (function group RSTI, table TRSTI)
    • Parameter LAYOUT-REPREP = 'X'
    (see also the documentation of the parameter LAYOUT-REPREP of the IMPORTING parameter IS_LAYOUT )
    'X' = When the Report/Report interface is called, the value of this field is passed in the selected interface start record as a selection criterion.
    2.7.2. Default
    • The following entries are usually sufficient for internal table fields with a reference to a field defined in the Data Dictionary :
    • fieldname
    • ref_tabname
    Notes:
    ALV gets the remaining information from the Data Dictionary.
    If no relative column position (COL_POS) is specified, the fields are output in the list in the order in which they were added to the field catalog.
    REF_FIELDNAME need only be specifid when the name of the internal table field differs from the name of the referred Data Dictionary field.
    Information which is explicitly entered in the field catalog is not overwritten by information from the Data Dictionary.
    Priority rule:
    Entries in the field catalog have priority over differing entries in the Data Dictionary.
    • The following entries are usually sufficient for internal table fields without a reference to the Data Dictionary (program fields):
    • fieldname
    • outputlen
    • datatype
    • seltext_s
    • seltext_m
    • seltext_l
    Notes:
    F1 help can be provided for program fields by assigning a data element to the parameter ROLLNAME.
    If the parameters SELTEXT_S, SELTEXT_M, SELTEXT_L, and REPTEXT_DDIC contain appropriate field labels, the program field column headers are also adjusted appropriately when the column width changes
    sites :
    http://www.sapdevelopment.co.uk/reporting/alv/alv_variousfcat.htm
    Check out these links : top one is on slis specifcally,
    How to know about these SLIS types?
    Re: sap alv examples
    ALV reporting - Step by step
    http://help.sap.com/saphelp_nw04/helpdata/en/8d/e994374c9cd355e10000009b38f8cf/frameset.htm
    Go through with these links :
    ALV
    http://www.geocities.com/mpioud/Abap_programs.html
    ALV Group Heading
    http://www.sap-img.com/fu037.htm
    ALVGRID with refresh
    http://www.geocities.com/mpioud/Z_DEMO_ALV_REFRESH_BUTTON.htm
    Editable ALV
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/abap/abap%20code%20samples/alv%20grid/abap%20code%20sample%20to%20edit%20alv%20grid.doc
    -->download the PDF from following link.
    www.abap4.it/download/ALV.pdf
    http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCSRVALV/BCSRVALV.pdf
    OOPS ALV tutorial.
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e8a1d690-0201-0010-b7ad-d9719a415907
    Sample programs:
    http://www.geocities.com/victorav15/sapr3/abap_ood.html#d_grid
    http://www.sapdevelopment.co.uk/reporting/alv/alvgrid_color.htm
    http://www.sapdevelopment.co.uk/reporting/alvhome.htm
    You can get all demo programs for ALV:
    Go to se38 and type BCALV* and press F4 for all demo porgrams.
    Check out these links
    http://www.sap-img.com/abap/what-is-alv-programming.htm
    https://www.sdn.sap.com/irj/sdn/wiki?path=/display/home/alv&
    http://www.sap-img.com/abap/an-interactive-alv-report.htm
    https://www.sdn.sap.com/irj/sdn/weblogs?blog=/cs/user/view/cs_msg/18628
    Regards

  • Reg : Dynamic Drown list in ALV Report

    Hi Guru's,
    Please help on showing Dynamic drop down list in ALV Report.
    My requirement is to show sales partner function in ALV report for each and every line.Every line item may have different partner function.
    Regards
    P.Senthil Kumar

    ok

  • Average of the column in ALV report

    Hi,
      I am working on an ALV report and for one of the column, i am calculating the average with fieldcatalog property do_sum = 'C'.
    I am sorting the output table for 2 fields and whenever I am expanding/compressing the sorted fields the average of the column is changing. Please let me know how do I get this average calculated constant. It should not change when the user collapses/expands on the sorted field.
    Regards
    Rashmi

    The same question has been asked in this thread:
    Compute average of a report column
    I have offered a solution but as I've said it's not great but it may meet your needs.
    Or another forum user may review and be able to suggest a better solution.
    Does the average need to be part of the report?
    Could you calculate it and display it within a page item below the report instead?

  • Filter Function problems on ALV report. [Resolved]

    Hi,
    I developed an ALV report by using function as below:
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
             EXPORTING
                  I_CALLBACK_PROGRAM = G_REPID
    *            I_CALLBACK_PF_STATUS_SET = status_set
    *            I_CALLBACK_USER_COMMAND  = USER_COMMAND
                  I_STRUCTURE_NAME = 'T_BSIK'
                  IS_LAYOUT        = GS_LAYOUT
                  IT_FIELDCAT      = GT_FIELDCAT[]
             TABLES
                  T_OUTTAB    = TAB_BSIK.
    And this ALV custom report is referenced from standard function FBL5N.
    After i completed this report, i made an comparision of FBL5N and my custom report.
    When I apply the filter function, for example, on the document type, I cannot input 2 characters in the document type field under the filter function. The field length is only 1 character. Similar case results on the field document date.
    While the standard function FBL5N works very nice.
    What should i do to make the filter function of my own ALV report as the same as the standard function FBL5N do?
    Thanks in advance.
    Lala
    Message was edited by:
            Hoo lala

    Oh, i found where the problem is...
    add below 2 statements, then the question is resolved.
      LS_FIELDCAT-ref_fieldname = ****
      LS_FIELDCAT-ref_tabname = ***
    FORM FIELDCAT_INIT tables RT_FIELDCAT.
    CLEAR LS_FIELDCAT.
      LS_FIELDCAT-COL_POS   =  3.
      LS_FIELDCAT-FIELDNAME = 'BLART'.
      LS_FIELDCAT-TABNAME   = 'TAB_BSIK'.
      LS_FIELDCAT-SELTEXT_L = 'Document Type'.
      LS_FIELDCAT-ref_fieldname = 'BLART'.
      LS_FIELDCAT-ref_tabname = 'BSIK'.
      APPEND LS_FIELDCAT TO  RT_FIELDCAT.
    endform.
    Fine now.
    Lala

  • Example of  a Simple ALV Report using Function Modules (not OO)

    Hi,
    I am new to ABAP. Where can I get a proper Example of  a Simple ALV Report using Function Modules?  I searched the forum but did not find a proper solution. Kindly help.
    Smruthi.
    Edited by: Smruthi Acharya on Jan 29, 2009 7:13 PM

    Hi,
    Use this demo code:-
    REPORT  z_alv01 MESSAGE-ID zmsg.
    *          TABLES
    TABLES : ekpo.
    *          TYPE POOLS
    TYPE-POOLS : slis.
    *          TYPE DECLARATION
    TYPES : BEGIN OF t_ekpo,
              ebeln TYPE ekpo-ebeln,
              ebelp TYPE ekpo-ebelp,
              matnr TYPE ekpo-matnr,
              werks TYPE ekpo-werks,
              menge TYPE ekpo-menge,
            END OF t_ekpo.
    *          PARAMETERS
    PARAMETERS : s_var TYPE disvariant-variant.
    *          DATA DECLARATION
    *VARIABLES
    DATA : check(1),
           rep_id TYPE sy-repid.
    *INTERNAL TABLE TYPE OF ZEKPO
    DATA : it_ekpo TYPE STANDARD TABLE OF t_ekpo WITH HEADER LINE.
    *FIELD CATALOG
    DATA : it_field TYPE slis_t_fieldcat_alv,
           wa_field TYPE slis_fieldcat_alv.
    *SORTING
    DATA : it_sort TYPE slis_t_sortinfo_alv,
           wa_sort TYPE slis_sortinfo_alv.
    *FOR TOP OF THE PAGE
    DATA : it_top TYPE slis_t_listheader,
           wa_top TYPE slis_listheader.
    *FOR END OF THE PAGE
    DATA : it_end TYPE slis_t_listheader,
           wa_end TYPE slis_listheader.
    *TO CAPTURE EVENTS AND HANDLE
    DATA : it_event TYPE slis_t_event,
           wa_event TYPE slis_alv_event.
    *FOR GRID TITLE
    DATA : wa_title TYPE lvc_title.
    *FOR LAYOUT
    DATA : wa_layout TYPE slis_layout_alv.
    *FOR EXCLUDING STANDARD BUTTON FROM ALV TOOLBAR
    DATA : it_exclude TYPE slis_t_extab,
           wa_exclude TYPE slis_extab.
    *FOR VARIANT
    DATA : wa_variant TYPE disvariant.
    *          INITIALIZATION
    INITIALIZATION.
      check = 'X'.
      rep_id = sy-repid.
      wa_variant-report = sy-repid.
    *GET DEFUALT ON THE SELECTION SCREEN FOR DEFAULT DISPLAY
      CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
        EXPORTING
          i_save        = 'A'
        CHANGING
          cs_variant    = wa_variant
        EXCEPTIONS
          wrong_input   = 1
          not_found     = 2
          program_error = 3
          OTHERS        = 4.
      IF sy-subrc = 0.               " IF DEFAULT VARIANT FOUND
        s_var = wa_variant-variant.  " PASS THE DEFAULT VARIANT TO THE SELECTION SCREEN FIELD
      ENDIF.
    *          AT-SELECTION SCREEN ON VALUE REQUEST
    *          TO GET THE F4 HELP FOR VARIANT
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_var.
      CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
        EXPORTING
          is_variant                = wa_variant
    *   I_TABNAME_HEADER          =
    *   I_TABNAME_ITEM            =
    *   IT_DEFAULT_FIELDCAT       =
         i_save                    = 'A'
    *   I_DISPLAY_VIA_GRID        = ' '
       IMPORTING
    *   E_EXIT                    =
         es_variant                = wa_variant
       EXCEPTIONS
         not_found                 = 1
         program_error             = 2
         OTHERS                    = 3.
      IF sy-subrc = 0.
        s_var = wa_variant-variant. " PASS THE SELECTED VARIANT TO THE SELECTION SCREEN FIELD
      ENDIF.
    *          AT-SELECTION SCREEN
    *          TO CHECK THE EXISTENCE FOR VARIANT
    AT SELECTION-SCREEN.
      wa_variant-variant = s_var.
      CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'
        EXPORTING
          i_save        = 'A'
        CHANGING
          cs_variant    = wa_variant
        EXCEPTIONS
          wrong_input   = 1
          not_found     = 2
          program_error = 3
          OTHERS        = 4.
      IF sy-subrc <> 0.
        MESSAGE w001.
      ENDIF.
    *          START OF SELECTION
    START-OF-SELECTION.
      SELECT ebeln
             ebelp
             matnr
             werks
             menge
             FROM ekpo
             INTO TABLE it_ekpo.
    *          FIELD CATALOG
      wa_field-fieldname = 'EBELN'.
      wa_field-tabname = 'IT_TAB'.
      wa_field-outputlen = 10.
      wa_field-seltext_l = 'PO #'.
      APPEND wa_field TO it_field.
      CLEAR wa_field.
      wa_field-fieldname = 'EBELP'.
      wa_field-tabname = 'IT_TAB'.
      wa_field-outputlen = 10.
      wa_field-seltext_l = 'Line Item'.
      APPEND wa_field TO it_field.
      CLEAR wa_field.
      wa_field-fieldname = 'MATNR'.
      wa_field-tabname = 'IT_TAB'.
      wa_field-outputlen = 15.
      wa_field-seltext_l = 'Material'.
    *  wa_field-input = check.
    *  wa_field-edit = check.
      APPEND wa_field TO it_field.
      CLEAR wa_field.
      wa_field-fieldname = 'WERKS'.
      wa_field-tabname = 'IT_TAB'.
      wa_field-outputlen = 6.
      wa_field-seltext_l = 'Plant'.
    *  wa_field-input = check.
    *  wa_field-edit = check.
      APPEND wa_field TO it_field.
      CLEAR wa_field.
      wa_field-fieldname = 'MENGE'.
      wa_field-tabname = 'IT_TAB'.
      wa_field-outputlen = 10.
      wa_field-seltext_l = 'Qty.'.
    *  wa_field-input = check.
    *  wa_field-edit = check.
      wa_field-do_sum = check.
      APPEND wa_field TO it_field.
      CLEAR wa_field.
    *          SORT W.R.T. PURCHASE ORDER NUMBER
      wa_sort-spos = 1.
      wa_sort-fieldname = 'EBELN'.
      wa_sort-tabname = 'IT_EKPO'.
      wa_sort-up = check.
      wa_sort-subtot = check.
      APPEND wa_sort TO it_sort.
      CLEAR wa_sort.
    *          FOR GRID TITLE
      wa_title = 'Hello'.
    *          FOR LAYOUT
      wa_layout-zebra = check.
    *          FOR EXCLUDING STANDARD BUTTONS FROM ALV TOOLBAR
      wa_exclude-fcode = '&OUP'.
      APPEND wa_exclude TO it_exclude.
      CLEAR wa_exclude.
      wa_exclude-fcode = '&ODN'.
      APPEND wa_exclude TO it_exclude.
      CLEAR wa_exclude.
      wa_exclude-fcode = '&OAD'.
      APPEND wa_exclude TO it_exclude.
      CLEAR wa_exclude.
    *  wa_exclude-fcode = '&AVE'.
    *  APPEND wa_exclude TO it_exclude.
    *  CLEAR wa_exclude.
      wa_exclude-fcode = '&INFO'.
      APPEND wa_exclude TO it_exclude.
      CLEAR wa_exclude.
    *          POPULATE ALL EVENTS INTO INTERNAL TABLE
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          i_list_type     = 0
        IMPORTING
          et_events       = it_event
        EXCEPTIONS
          list_type_wrong = 1
          OTHERS          = 2.
      IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      READ TABLE it_event INTO wa_event WITH KEY name = 'END_OF_LIST'.
      wa_event-form = 'END'.
      MODIFY it_event FROM wa_event INDEX sy-tabix.
      CLEAR wa_event.
    *          DISPLAY RECORDS IN ALV GRID
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
    *   I_INTERFACE_CHECK                 = ' '
    *   I_BYPASSING_BUFFER                = ' '
    *   I_BUFFER_ACTIVE                   = ' '
       i_callback_program                = rep_id
    *   i_callback_pf_status_set          = 'PF'
       i_callback_user_command           = 'COMMAND'
       i_callback_top_of_page            = 'TOP'
    *   I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
    *   I_CALLBACK_HTML_END_OF_LIST       = ' '
    *   I_STRUCTURE_NAME                  =
    *   I_BACKGROUND_ID                   = ' '
       i_grid_title                      = wa_title
    *   I_GRID_SETTINGS                   =
       is_layout                         = wa_layout
       it_fieldcat                       = it_field
       it_excluding                      = it_exclude
    *   IT_SPECIAL_GROUPS                 =
       it_sort                           = it_sort
    *   IT_FILTER                         =
    *   IS_SEL_HIDE                       =
    *   I_DEFAULT                         = 'X'
       i_save                            = 'A'
       is_variant                        = wa_variant
       it_events                         = it_event
    *   IT_EVENT_EXIT                     =
    *   IS_PRINT                          =
    *   IS_REPREP_ID                      =
    *   I_SCREEN_START_COLUMN             = 0
    *   I_SCREEN_START_LINE               = 0
    *   I_SCREEN_END_COLUMN               = 0
    *   I_SCREEN_END_LINE                 = 0
    *   I_HTML_HEIGHT_TOP                 = 0
    *   I_HTML_HEIGHT_END                 = 0
    *   IT_ALV_GRAPHICS                   =
    *   IT_HYPERLINK                      =
    *   IT_ADD_FIELDCAT                   =
    *   IT_EXCEPT_QINFO                   =
    *   IR_SALV_FULLSCREEN_ADAPTER        =
    * IMPORTING
    *   E_EXIT_CAUSED_BY_CALLER           =
    *   ES_EXIT_CAUSED_BY_USER            =
        TABLES
          t_outtab                          = it_ekpo
    EXCEPTIONS
       program_error                     = 1
       OTHERS                            = 2.
      IF sy-subrc <> 0.
      ENDIF.
    *&      Form  top
    *       TO WRITE THE HEADER
    FORM top.
      REFRESH it_top.
      wa_top-typ = 'S'.
      wa_top-key = text-001.
      wa_top-info = rep_id.
      APPEND wa_top TO it_top.
      CLEAR wa_top.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          it_list_commentary       = it_top
    *   I_LOGO                   =
    *   I_END_OF_LIST_GRID       =
    *   I_ALV_FORM               =
    ENDFORM.                    "top
    *&      Form  end
    *       TO WRITE THE FOOTER
    FORM end.
      REFRESH it_end.
      wa_end-typ = 'S'.
      wa_end-key = text-001.
      wa_end-info = rep_id.
      APPEND wa_end TO it_end.
      CLEAR wa_end.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          it_list_commentary       = it_end
    *   I_LOGO                   =
    *   I_END_OF_LIST_GRID       =
    *   I_ALV_FORM               =
    ENDFORM.                    "end
    *&      Form  pf
    *       FOR PF-STATUS WITH USER DEFINED BUTTONS
    *      -->RT_EXTAB   text
    FORM pf USING rt_extab TYPE slis_t_extab.
      SET PF-STATUS 'ZTG_PF_ALV'.
    ENDFORM.                    "pf
    *&      Form  command
    *       TO HANDLE USER ACTIONS AGAINST PF-STATUS
    *      -->UCOMM      text
    *      -->SELFIELD   text
    FORM command USING ucomm LIKE sy-ucomm selfield TYPE slis_selfield.
      DATA : ok_code TYPE sy-ucomm.
      ok_code = ucomm.
      CASE ok_code.
        WHEN 'T_DOWN'.
          CALL FUNCTION 'POPUP_TO_INFORM'
            EXPORTING
              titel = 'HELLO'
              txt1  = 'USER COMMAND'
              txt2  = 'TOTAL DOWN'.
        WHEN 'DOWN'.
          CALL FUNCTION 'POPUP_TO_INFORM'
            EXPORTING
              titel = 'HELLO'
              txt1  = 'USER COMMAND'
              txt2  = 'DOWN'.
        WHEN 'UP'.
          CALL FUNCTION 'POPUP_TO_INFORM'
            EXPORTING
              titel = 'HELLO'
              txt1  = 'USER COMMAND'
              txt2  = 'UP'.
        WHEN 'T_UP'.
          CALL FUNCTION 'POPUP_TO_INFORM'
            EXPORTING
              titel = 'HELLO'
              txt1  = 'USER COMMAND'
              txt2  = 'TOTAL UP'.
      ENDCASE.
    ENDFORM.                    "command
    Hope this helps you.
    Thanks & Regards,
    Tarun Gambhir

  • Reg. Alv report using function modules

    I have a ALV report in which i am displaying a report in main screen1. i have a pushbutton on the main screen.
    when i click the pushbutton it has to display the interactive report below, in the main screen1 itself.
    like it has to display first the main report and then when i click the pushbutton, it has to display the corresponding report on the same screen below it.
    points will be rewarded..

    hi use this ,
    *& Report  ZPR_02
    REPORT  ZPR_02.
    TYPE-POOLS: SLIS.
    Tables Declaration.
    TABLES: MARA.
    *Internal tables and data declaration.
    DATA: BEGIN OF IT_MARA OCCURS 0,
            MATNR LIKE MARA-MATNR,
            MTART LIKE MARA-MTART,
            MBRSH LIKE MARA-MBRSH,
          END OF IT_MARA,
          BEGIN OF IT_MARC OCCURS 0,
            MATNR LIKE MARC-MATNR,
            WERKS LIKE MARC-WERKS,
            EKGRP LIKE MARC-EKGRP,
          END OF IT_MARC,
          BEGIN OF IT_MARD OCCURS 0,
            MATNR LIKE MARD-MATNR,
            WERKS LIKE MARD-WERKS,
            LGORT LIKE MARD-LGORT,
            LABST LIKE MARD-LABST,
          END OF IT_MARD.
    DATA: WA_FIELD_CAT TYPE SLIS_FIELDCAT_ALV,
          IT_FIELD_CAT1 TYPE SLIS_T_FIELDCAT_ALV,
          IT_FIELD_CAT2 TYPE SLIS_T_FIELDCAT_ALV,
          IT_FIELD_CAT3 TYPE SLIS_T_FIELDCAT_ALV,
          WA_KEYINFO TYPE SLIS_KEYINFO_ALV,
          IT_LAYOUT TYPE SLIS_LAYOUT_ALV,
          IT_EVENTS1    TYPE SLIS_T_EVENT WITH HEADER LINE,
          IT_EVENTS2    TYPE SLIS_T_EVENT WITH HEADER LINE,
          IT_EVENTS3    TYPE SLIS_T_EVENT WITH HEADER LINE.
    *Selection Screen.
    SELECT-OPTIONS: S_MATNR FOR MARA-MATNR.
    *Start Of selection.
    START-OF-SELECTION.
    *Selecting the data.
      PERFORM SELECT_DATA.
    *Populating the field catelogue.
      PERFORM BUILD_FIELD_CAT.
    *Displaying the final output.
      PERFORM DISPLY_OUTPUT.
    *&      Form  Select_data
          Selecting the data.
    FORM SELECT_DATA .
      SELECT MATNR
             MTART
             MBRSH FROM MARA
           INTO TABLE IT_MARA
           WHERE MATNR IN S_MATNR.
      IF NOT IT_MARA[] IS INITIAL.
        SELECT MATNR
               WERKS
               EKGRP FROM MARC
             INTO TABLE IT_MARC
             FOR ALL ENTRIES IN IT_MARA
             WHERE MATNR EQ IT_MARA-MATNR.
      ENDIF.
      IF NOT IT_MARC[] IS INITIAL.
        SELECT MATNR
               WERKS
               LGORT
               LABST FROM MARD
             INTO TABLE IT_MARD
             FOR ALL ENTRIES IN IT_MARC
             WHERE MATNR = IT_MARC-MATNR
             AND   WERKS = IT_MARC-WERKS.
      ENDIF.
    ENDFORM.                    " Select_data
    *&      Form  Build_field_cat
         Populating the field catelogue.
    FORM BUILD_FIELD_CAT .
      DEFINE M_FIELDCAT1.
        WA_FIELD_CAT-TABNAME = &1.
        WA_FIELD_CAT-FIELDNAME = &2.
        WA_FIELD_CAT-SELTEXT_L = &3.
        APPEND WA_FIELD_CAT TO IT_FIELD_CAT1.
      END-OF-DEFINITION.
      DEFINE M_FIELDCAT2.
        WA_FIELD_CAT-TABNAME = &1.
        WA_FIELD_CAT-FIELDNAME = &2.
        WA_FIELD_CAT-SELTEXT_L = &3.
        APPEND WA_FIELD_CAT TO IT_FIELD_CAT2.
      END-OF-DEFINITION.
      DEFINE M_FIELDCAT3.
        WA_FIELD_CAT-TABNAME = &1.
        WA_FIELD_CAT-FIELDNAME = &2.
        WA_FIELD_CAT-SELTEXT_L = &3.
        APPEND WA_FIELD_CAT TO IT_FIELD_CAT3.
      END-OF-DEFINITION.
      M_FIELDCAT1 'MARA' 'MATNR' 'Material No'.
      M_FIELDCAT1 'MARA' 'MTART' 'Material type'.
      M_FIELDCAT1 'MARA' 'MBRSH' 'Industry Sector'.
      M_FIELDCAT2 'MARC' 'MATNR' 'Material No'.
      M_FIELDCAT2 'MARC' 'WERKS' 'Plant'.
      M_FIELDCAT2 'MARC' 'EKGRP' 'Purchasing Group'.
      M_FIELDCAT3 'MARD' 'MATNR' 'Material No'.
      M_FIELDCAT3 'MARD' 'WERKS' 'Plant'.
      M_FIELDCAT3 'MARD' 'LGORT' 'Storage Loc'.
      M_FIELDCAT3 'MARD' 'LABST' 'Valued Stock'.
      IT_EVENTS1-NAME  =  'TOP_OF_PAGE'.
      IT_EVENTS1-FORM  =  'F_TOP_OF_PAGE_ONE'.
      APPEND IT_EVENTS1.
      CLEAR IT_EVENTS1.
      IT_EVENTS2-NAME  =  'TOP_OF_PAGE'.
      IT_EVENTS2-FORM  =  'F_TOP_OF_PAGE_TWO'.
      APPEND IT_EVENTS2.
      CLEAR IT_EVENTS2.
      IT_EVENTS3-NAME  =  'TOP_OF_PAGE'.
      IT_EVENTS3-FORM  =  'F_TOP_OF_PAGE_THREE'.
      APPEND IT_EVENTS3.
      CLEAR IT_EVENTS3.
    ENDFORM.                    " Build_field_cat
    *&      Form  disply_output
         Displaying the final output.
    FORM DISPLY_OUTPUT .
      CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
        EXPORTING
          I_CALLBACK_PROGRAM = SY-REPID.
      CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
        EXPORTING
          IS_LAYOUT                        = IT_LAYOUT
          IT_FIELDCAT                      = IT_FIELD_CAT1[]
          I_TABNAME                        = 'IT_MARA'
          IT_EVENTS                        = IT_EVENTS1[]
      IT_SORT                          = IT_SORT
      I_TEXT                           = ' '
        TABLES
          T_OUTTAB                         = IT_MARA     .
      CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
        EXPORTING
          IS_LAYOUT                        = IT_LAYOUT
          IT_FIELDCAT                      = IT_FIELD_CAT2[]
          I_TABNAME                        = 'IT_MARC'
          IT_EVENTS                        = IT_EVENTS2[]
      IT_SORT                          = IT_SORT
      I_TEXT                           = ' '
        TABLES
          T_OUTTAB                         = IT_MARC    .
      CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
        EXPORTING
          IS_LAYOUT                        = IT_LAYOUT
          IT_FIELDCAT                      = IT_FIELD_CAT3[]
          I_TABNAME                        = 'IT_MARD'
          IT_EVENTS                        = IT_EVENTS3[]
      IT_SORT                          = IT_SORT
      I_TEXT                           = ' '
        TABLES
          T_OUTTAB                         = IT_MARD    .
      CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'
    EXPORTING
      I_INTERFACE_CHECK             = ' '
      IS_PRINT                      = IS_PRINT
      I_SCREEN_START_COLUMN         = 0
      I_SCREEN_START_LINE           = 0
      I_SCREEN_END_COLUMN           = 0
      I_SCREEN_END_LINE             = 0
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER       = E_EXIT_CAUSED_BY_CALLER
      ES_EXIT_CAUSED_BY_USER        = ES_EXIT_CAUSED_BY_USER
    EXCEPTIONS
      PROGRAM_ERROR                 = 1
      OTHERS                        = 2
      IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    " disply_output
    *&      Form  top_of_page_one
          text
    FORM F_TOP_OF_PAGE_ONE.
      WRITE: / 'Header details (MARA)'.
    ENDFORM.                    "top_of_page_one
    *&      Form  top_of_page_one
          text
    FORM F_TOP_OF_PAGE_TWO.
      WRITE: / 'Item details (MARC)'.
    ENDFORM.                    "top_of_page_one
    *&      Form  top_of_page_one
          text
    FORM F_TOP_OF_PAGE_THREE.
      WRITE: / 'Item details (MARD)'.
    ENDFORM.                    "top_of_page_one
    reward points if useful,
    venkat.

  • How to edit ALV report using function modules

    I have a ALV report , i want to edit the report
    using function modules.
    how can i do that...
    Edited by: ms kumar on Mar 6, 2008 3:24 PM

    hi i had used this report with the check box,
    using the fm of alvs.....
    *& Report  ZZZ00
    REPORT  ZPR_02.
    TYPE-POOLS: SLIS.
    TABLES:pa0002,pa0008.
    data:begin of it_pa0002 occurs 0,
         checkbox,
         pernr like pa0002-pernr,
         begda like pa0002-begda,
         endda like pa0002-endda,
         vorna like pa0002-vorna,
         nachn like pa0002-nachn,
         end of it_pa0002.
    data:begin of it_pa00021 occurs 0,
         pernr like pa0002-pernr,
         begda like pa0002-begda,
         endda like pa0002-endda,
         vorna like pa0002-vorna,
         nachn like pa0002-nachn,
         expand TYPE xfeld value 'X',
         end of it_pa00021.
    data:begin of it_pa0008 occurs 0,
         pernr like pa0008-pernr,
         begda like pa0008-begda,
         endda like pa0008-endda,
         ANSAL like pa0008-ANSAL,
         LGA01 like pa0008-LGA01,
         BET01 LIKE PA0008-BET01,
         end of it_pa0008.
    DATA: IT_FIELD_CAT TYPE SLIS_T_FIELDCAT_ALV,
          IT_FIELD_CAT1 TYPE SLIS_T_FIELDCAT_ALV,
          IT_LAYOUT1 TYPE SLIS_LAYOUT_ALV,
          WA_FIELD_CAT TYPE SLIS_FIELDCAT_ALV,
          WA_FIELD_CAT1 TYPE SLIS_FIELDCAT_ALV,
          IT_LAYOUT TYPE SLIS_LAYOUT_ALV,
          IT_EVENTS TYPE SLIS_T_EVENT,
          WA_EVENTS TYPE SLIS_ALV_EVENT,
          IT_HEADER TYPE SLIS_T_LISTHEADER,
          WA_HEADER TYPE SLIS_LISTHEADER,
          wa_keyinfo TYPE slis_keyinfo_alv.
    CONSTANTS:c VALUE 'X'.
    SELECT-OPTIONS: S_pernr FOR pa0002-pernr.
    START-OF-SELECTION.
      SET PF-STATUS 'DATA' .
      PERFORM GET_DATA.
      PERFORM BUILD_FIELD_CAT.
      PERFORM GET_EVENTS.
      PERFORM DISPLAY_DATA.
    *&      Form  get_data
          text
    FORM GET_DATA .
      SELECT pernr
             begda
             endda
             vorna
             nachn
             FROM pa0002
             INTO CORRESPONDING FIELDS OF TABLE IT_pa0002
             WHERE pernr IN S_pernr.
    ENDFORM.                    " get_data
    *&      Form  build_field_cat
          text
    FORM BUILD_FIELD_CAT .
        wa_field_cat-tabname = 'PA0002'.
      WA_FIELD_CAT-FIELDNAME = 'CHECKBOX'.
      wa_field_cat-ref_tabname = 'IT_PA0002'.
      WA_FIELD_CAT-REPTEXT_DDIC = 'Check Box'.
      APPEND WA_FIELD_CAT TO IT_FIELD_CAT.
      CLEAR WA_FIELD_CAT.
        wa_field_cat-tabname = 'PA0002'.
      WA_FIELD_CAT-FIELDNAME = 'PERNR'.
        wa_field_cat-ref_tabname = 'IT_PA0002'.
      WA_FIELD_CAT-REPTEXT_DDIC = 'Personnel no'.
      APPEND WA_FIELD_CAT TO IT_FIELD_CAT.
      CLEAR WA_FIELD_CAT.
        wa_field_cat-tabname = 'PA0002'.
      WA_FIELD_CAT-FIELDNAME = 'BEGDA'.
      wa_field_cat-ref_tabname = 'IT_PA0002'.
      WA_FIELD_CAT-REPTEXT_DDIC = 'Start date'.
      APPEND WA_FIELD_CAT TO IT_FIELD_CAT.
      CLEAR WA_FIELD_CAT.
        wa_field_cat-tabname = 'PA0002'.
      WA_FIELD_CAT-FIELDNAME = 'ENDDA'.
      wa_field_cat-ref_tabname = 'IT_PA0002'.
      WA_FIELD_CAT-REPTEXT_DDIC = 'End date'.
      APPEND WA_FIELD_CAT TO IT_FIELD_CAT.
      CLEAR WA_FIELD_CAT.
        wa_field_cat-tabname = 'PA0002'.
      WA_FIELD_CAT-FIELDNAME = 'VORNA'.
      wa_field_cat-ref_tabname = 'IT_PA0002'.
      WA_FIELD_CAT-REPTEXT_DDIC = 'First name'.
      APPEND WA_FIELD_CAT TO IT_FIELD_CAT.
      CLEAR WA_FIELD_CAT.
        wa_field_cat-tabname = 'PA0002'.
      WA_FIELD_CAT-FIELDNAME = 'NACHN'.
        wa_field_cat-ref_tabname = 'IT_PA0002'.
      WA_FIELD_CAT-REPTEXT_DDIC = 'Last name'.
      APPEND WA_FIELD_CAT TO IT_FIELD_CAT.
      CLEAR WA_FIELD_CAT.
        wa_field_cat1-tabname = 'PA0002'.
      WA_FIELD_CAT1-FIELDNAME = 'PERNR'.
        wa_field_cat1-ref_tabname = 'IT_PA00021'.
      WA_FIELD_CAT1-REPTEXT_DDIC = 'Personnel no'.
      APPEND WA_FIELD_CAT1 TO IT_FIELD_CAT1.
      CLEAR WA_FIELD_CAT1.
        wa_field_cat1-tabname = 'PA0002'.
      WA_FIELD_CAT1-FIELDNAME = 'BEGDA'.
        wa_field_cat1-ref_tabname = 'IT_PA00021'.
      WA_FIELD_CAT1-REPTEXT_DDIC = 'Start date'.
      APPEND WA_FIELD_CAT1 TO IT_FIELD_CAT1.
      CLEAR WA_FIELD_CAT1.
        wa_field_cat1-tabname = 'PA0002'.
      WA_FIELD_CAT1-FIELDNAME = 'ENDDA'.
        wa_field_cat1-ref_tabname = 'IT_PA00021'.
      WA_FIELD_CAT1-REPTEXT_DDIC = 'End date'.
      APPEND WA_FIELD_CAT1 TO IT_FIELD_CAT1.
      CLEAR WA_FIELD_CAT1.
        wa_field_cat1-tabname = 'PA0002'.
      WA_FIELD_CAT1-FIELDNAME = 'VORNA'.
        wa_field_cat1-ref_tabname = 'IT_PA00021'.
      WA_FIELD_CAT1-REPTEXT_DDIC = 'First name'.
      APPEND WA_FIELD_CAT1 TO IT_FIELD_CAT1.
      CLEAR WA_FIELD_CAT.
        wa_field_cat1-tabname = 'PA0002'.
      WA_FIELD_CAT1-FIELDNAME = 'NACHN'.
        wa_field_cat1-ref_tabname = 'IT_PA00021'.
      WA_FIELD_CAT1-REPTEXT_DDIC = 'Last name'.
      APPEND WA_FIELD_CAT1 TO IT_FIELD_CAT1.
      CLEAR WA_FIELD_CAT1.
        wa_field_cat1-tabname = 'PA0008'.
        wa_field_cat1-fieldname = 'PERNR'.
          wa_field_cat-ref_tabname = 'IT_PA0008'.
        wa_field_cat1-REPTEXT_DDIC = 'personnelno'.
        APPEND wa_field_cat1 TO it_field_cat1.
       CLEAR WA_FIELD_CAT1.
        wa_field_cat1-tabname = 'PA0008'.
        wa_field_cat1-fieldname = 'BEGDA'.
          wa_field_cat-ref_tabname = 'IT_PA0008'.
        wa_field_cat1-REPTEXT_DDIC = 'begindate'.
        APPEND wa_field_cat1 TO it_field_cat1.
        CLEAR WA_FIELD_CAT1.
        wa_field_cat1-tabname = 'PA0008'.
        wa_field_cat1-fieldname = 'ENDDA'.
          wa_field_cat-ref_tabname = 'IT_PA0008'.
        wa_field_cat1-REPTEXT_DDIC = 'enddate'.
        APPEND wa_field_cat1 TO it_field_cat1.
        CLEAR WA_FIELD_CAT1.
        wa_field_cat1-tabname = 'PA0008'.
        wa_field_cat1-fieldname = 'ANSAL'.
          wa_field_cat-ref_tabname = 'IT_PA0008'.
        wa_field_cat1-REPTEXT_DDIC = 'annualsalary'.
        APPEND wa_field_cat1 TO it_field_cat1.
        CLEAR WA_FIELD_CAT1.
        wa_field_cat1-tabname = 'PA0008'.
        wa_field_cat1-fieldname = 'LGA01'.
          wa_field_cat-ref_tabname = 'IT_PA0008'.
        wa_field_cat1-REPTEXT_DDIC = 'wagetype'.
        APPEND wa_field_cat1 TO it_field_cat1.
        CLEAR WA_FIELD_CAT1.
        wa_field_cat1-tabname = 'PA0008'.
        wa_field_cat1-fieldname = 'BET01'.
          wa_field_cat-ref_tabname = 'IT_PA0008'.
        wa_field_cat1-REPTEXT_DDIC = 'Amount'.
        APPEND wa_field_cat1 TO it_field_cat1.
        CLEAR WA_FIELD_CAT1.
    ENDFORM.                    " build_field_cat
    *&      Form  display_data
          text
    FORM DISPLAY_DATA .
    it_layout-box_fieldname = 'CHECKBOX'.
    it_layout-EDIT = 'X'.
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
        EXPORTING
          I_CALLBACK_PROGRAM             = SY-REPID
          I_CALLBACK_PF_STATUS_SET       = 'PF_STATUS'
          I_CALLBACK_USER_COMMAND        = 'USER_COMMAND'
          IT_FIELDCAT                    = IT_FIELD_CAT
          IS_LAYOUT                      = IT_LAYOUT
          IT_EVENTS                      = IT_EVENTS
        TABLES
          T_OUTTAB           = IT_pa0002.
    ENDFORM.                    " display_data
    *&      Form  get_events
          text
    FORM GET_EVENTS .
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
       IMPORTING
         ET_EVENTS             = IT_EVENTS .
      READ TABLE IT_EVENTS INTO WA_EVENTS
                           WITH KEY NAME = SLIS_EV_TOP_OF_PAGE.
      IF SY-SUBRC = 0.
        WA_EVENTS-FORM = 'TOP_OF_PAGE'.
        MODIFY IT_EVENTS FROM WA_EVENTS INDEX SY-TABIX.
      ENDIF.
    ENDFORM.                    " get_events
    *&      Form  top_of_page
          text
    FORM TOP_OF_PAGE.
      WA_HEADER-TYP = 'H'.
      WA_HEADER-INFO = 'EMPLOYEE DATA'.
      APPEND WA_HEADER TO IT_HEADER.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          IT_LIST_COMMENTARY       = IT_HEADER
    ENDFORM. "top_of_page
    *&      Form  GUI_SET
    FORM GUI_SET USING RT_EXTAB TYPE SLIS_T_EXTAB .
      SET PF-STATUS 'DATA' .
    ENDFORM.                    "GUI_SET
    *&      Form  USER_COMMAND
    FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
                            R_SELFIELD TYPE SLIS_SELFIELD.
    DATA:V_PERNR LIKE PA0002-PERNR.
      CASE R_UCOMM.
        WHEN 'DET'.
    DATA: V_FLAG.
      clear : v_flag.
    LOOP AT IT_PA0002.
         if it_PA0002-checkbox =  'X'.
                   v_flag = 'X'.
              v_pernr = IT_PA0002-PERNR.
    SELECT  PERNR
            BEGDA
            ENDDA
            VORNA
            NACHN
            FROM PA0002
            INTO CORRESPONDING FIELDS OF TABLE IT_PA00021
            WHERE PERNR = V_PERNR.
    SORT IT_PA00021 BY PERNR.
    DELETE ADJACENT DUPLICATES FROM IT_PA00021 COMPARING PERNR.
    READ TABLE IT_PA00021 INDEX 1.
    SELECT PERNR
           BEGDA
           ENDDA
           ANSAL
           LGA01
           BET01
           FROM PA0008
           INTO TABLE IT_PA0008
           FOR ALL ENTRIES IN IT_PA00021
           WHERE PERNR = IT_PA00021-PERNR.
              if not it_PA0008[] Is initial.
              SORT IT_PA0008 BY PERNR.
             delete adjacent duplicates from  it_PA0008 comparing pernr.
              READ TABLE IT_PA0008 INDEX 1.
              endif.
            endif.
         enddo.
      it_layout1-group_change_edit = c.
      it_layout1-colwidth_optimize = c.
      it_layout1-zebra             = c.
      it_layout1-detail_popup      = c.
      it_layout1-get_selinfos      = c.
      it_layout-expand_fieldname  = 'EXPAND'.
      wa_keyinfo-header01 = 'PERNR'.
      wa_keyinfo-item01 = 'PERNR'.
    IF NOT V_FLAG IS INITIAL.
    CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
      EXPORTING
       I_CALLBACK_PROGRAM             = SY-REPID
        IS_LAYOUT                      = IT_LAYOUT1
       IT_FIELDCAT                    =  IT_FIELD_CAT1
        I_TABNAME_HEADER               = 'PA0002'
        I_TABNAME_ITEM                 = 'PA0008'
        IS_KEYINFO                     = wa_keyinfo
        TABLES
        T_OUTTAB_HEADER                = IT_PA00021
        T_OUTTAB_ITEM                  = IT_PA0008.
    ENDIF.
    CLEAR: IT_PA00021,IT_PA0002,IT_PA0008.
    ENDLOOP.
    WHEN 'BACK'.
    EXIT.
    ENDCASE.
    ENDFORM.                    "USER_COMMAND
    reward points if useful,
    venkat.

Maybe you are looking for

  • Spool file of a background job

    Hello Friends, In an SAP system, there is a background job which creates a spool file. If there is no printer configuration done on the SAP server, how to find the location of this file in the filesystem? Thanks & Regards, Kunal Patel.

  • Nokia Lumia 900 Crack in the LCD!

    Hi there, I got a crack in the lcd glass, is there any way i can just change the glass instead of the whole lcd? and where do i get the original lcd?

  • Why the empty form is showing?

    Friends, OAS - 10gR2 in RHEL AS 4.8 Client PC - winxp sp2 I have set the userid in the formsweb.cfg like below for my configuration part. userid=username/password@db why this "userid=username/password@db" in formsweb.cfg is not working in oracle appl

  • Engineering simulations and quadtree

    Hi all, i want to make an engineering simulation about heat transfer and i need to learn how to realize this king of applications. I stuid about computer graphics, game development, bsp tree but this is not enough to make solid shapes so i can implem

  • SHA-256 on ISE 3315 ?

    Is it possible to possible to use SHA2-256 certificates with an installed ISE 3315 ? I have no experience with those systems. Version information of installed applications Cisco Identity Services Engine Version     : 1.1.2.145 Build Date   : Fri Oct