Add a row after Total row in ALV report

Hi Experts,
I have a report is displayed by  ALV format(not use function module to display it but use Class cl_gui_custom_container),I want to add a row after the total row. for example,
Customer   amount1    amount2    amount3 
10000         1,234        1,000         2,000
10001         4,000        2,000         1,000
10002         1,300        1,000         3,000
11000         1,200        4,000         3,000
     Total:     7,734        8,000         9,000
Ratio%        31.27       32.34          36.39
the row of 'Total' is calculated by fieldcat-do_sum = 'X' But after the Total row we need a Ratio row to display the ratio. Yes we can calculate the total amout and ratio and then append it into the output itab, but we don't like this solution.We want to keep the total function in the ALV report.Any experts can poit me a direction. Thanks in advance.
Joe

Djoe,
First you need to handle the user command,in order to capture the button action. For this you need to implment a class, i  am attaching sample codes here
In top include write the following code
CLASS lcl_event_handler DEFINITION .
  PUBLIC SECTION .
    METHODS:
     handle_toolbar  FOR EVENT toolbar                   " To add new functional buttons to the ALV toolbar
                     OF        cl_gui_alv_grid
                     IMPORTING e_object,
     handle_user_command FOR EVENT user_command          " To implement user commands
                        OF cl_gui_alv_grid
                        IMPORTING e_ucomm .
  PRIVATE SECTION.
ENDCLASS.                                               " Lcl_event_handler DEFINITION
Now   <b>Class implementation</b>
CLASS lcl_event_handler IMPLEMENTATION .
  METHOD handle_toolbar.                                " Handle Toolbar
    PERFORM f9500_handle_toolbar USING e_object.
ENDMETHOD .                                            " Handle_toolbar
  METHOD handle_user_command .                          " Handle User Command
    PERFORM f9600_handle_user_command USING e_ucomm .
  ENDMETHOD.
ENDCLASS .                                              " lcl_event_handler IMPLEMENTATION
FORM f9600_handle_user_command USING p_e_ucomm TYPE sy-ucomm.
  CONSTANTS:c_newl(4) TYPE c
                      VALUE 'NEWL',               " New line
            c_copy(4) TYPE c
                      VALUE 'COPY',               " Copy
            c_corr(4) TYPE c
                      VALUE 'CORR'.               " Correction
  CASE p_e_ucomm .
    WHEN c_newl.
Create a new line
      PERFORM f9610_insert_new_line.
ENDFORM.                                          " f9600_handle_user_command
FORM f9610_insert_new_line .
*Data Declarations
  DATA: lt_rows     TYPE lvc_t_row,                 " Itab for row property
        ls_rows     TYPE lvc_s_row,                 " Work area for row
        lv_cntid    TYPE i.                         " Counter
  DATA: gv_index TYPE sy-index.
  CLEAR gs_last.
  CALL METHOD gr_alvgrid->get_selected_rows
    IMPORTING
      et_index_rows = lt_rows.
  READ TABLE lt_rows INTO ls_rows INDEX 1.
  IF sy-subrc EQ 0.
    gv_index = ls_rows-index + 1.
  ELSE.
    gv_index = 1.
  ENDIF.
  DESCRIBE TABLE gt_last LINES lv_cntid.
  lv_cntid = lv_cntid + 1.
  gs_last-cntid = lv_cntid.
  INSERT gs_last INTO gt_last INDEX gv_index.
  LOOP AT gt_last INTO gs_last FROM gv_index TO gv_index.
Make the new line editable
    PERFORM f9611_style.
  ENDLOOP.
  CALL METHOD gr_alvgrid->refresh_table_display
    EXCEPTIONS
      finished = 1
      OTHERS   = 2.
ENDFORM.                    " f9610_insert_new_line
You can ask questions doubts if any!
regards
Antony Thomas

Similar Messages

  • Insert  Blank row  After every Row  in alv report

    How to insert blank  row After every row  in Alv report

    what do you mean by a 'blank row'? ALV displays tabular data with 'any' number of columns. Now if you actually want a blank row (no columns at all, just a row), then that is just not possible. If I'm not mistaken, this question was posted before, so try to do a search on SCN. See what is says.

  • How to insert the new row after current row in RowIterator - Steve Muench

    Hi,
    Our client wants the new row to be added after current row on the front end instead of before current row.
    we were using "new JUActionBinding(this,iterBinding,JUActionBinding.ACTION_CREATE_INSERT_ROW);" this code inserts the new row after current row.
    I tried a lot to insert the new row after current row. Used new JUActionBinding(this,iterBinding,JUActionBinding.ACTION_LAST to move the cursor to last row in rowiterator and the used .ACTION_CREATE_INSERT_ROW but this thing inserts the new row as the second last row.
    Could somebody plesae help ?
    Message was edited by:
    user556161

    I am using JDeveloper 9.0.4.2.0 (Build 1459)

  • How to find out the total, subtotal in alv report

    hi dears,
    how to find out the total, subtotal in alv report?
    pls tell me logic ,
    i will be waiting for eply
    regards
    eswar

    Hi,
    <b>ALV Grid List with sub-totals</b>
    REPORT z_demo_alv_sort.
    * This program lists orders (VBAK) with sort and sub-total for        *
    * 'sold-to-party' (KUNNR) and 'Sales organization' (VKORG)            *
    TABLES : vbak.
    TYPE-POOLS: slis.                      " ALV Global types
    SELECT-OPTIONS :
      s_vkorg FOR vbak-vkorg,              " Sales organization
      s_kunnr FOR vbak-kunnr,              " Sold-to party
      s_vbeln FOR vbak-vbeln.              " Sales document
    SELECTION-SCREEN :
      SKIP, BEGIN OF LINE,COMMENT 5(27) v_1 FOR FIELD p_max.
    PARAMETERS p_max(2) TYPE n DEFAULT '20' OBLIGATORY.
    SELECTION-SCREEN END OF LINE.
    DATA:
      BEGIN OF gt_vbak OCCURS 0,
        vkorg LIKE vbak-vkorg,             " Sales organization
        kunnr LIKE vbak-kunnr,             " Sold-to party
        vbeln LIKE vbak-vbeln,             " Sales document
        netwr LIKE vbak-netwr,             " Net Value of the Sales Order
        waerk LIKE vbak-waerk,             " Document currency
      END OF gt_vbak.
    INITIALIZATION.
      v_1 = 'Maximum of records to read'.
    START-OF-SELECTION.
      PERFORM f_read_data.
      PERFORM f_display_data.
    *      Form  f_read_data
    FORM f_read_data.
      SELECT * INTO CORRESPONDING FIELDS OF TABLE gt_vbak
               FROM vbak
                 UP TO p_max ROWS
              WHERE kunnr IN s_kunnr
                AND vbeln IN s_vbeln
                AND vkorg IN s_vkorg.
    ENDFORM.                               " F_READ_DATA
    *      Form  f_display_data
    FORM f_display_data.
      DEFINE m_fieldcat.
        add 1 to ls_fieldcat-col_pos.
        ls_fieldcat-fieldname   = &1.
        ls_fieldcat-ref_tabname = 'VBAK'.
        ls_fieldcat-do_sum      = &2.
        ls_fieldcat-cfieldname  = &3.
        append ls_fieldcat to lt_fieldcat.
      END-OF-DEFINITION.
      DEFINE m_sort.
        add 1 to ls_sort-spos.
        ls_sort-fieldname = &1.
        ls_sort-up        = 'X'.
        ls_sort-subtot    = &2.
        append ls_sort to lt_sort.
      END-OF-DEFINITION.
      DATA:
        ls_fieldcat TYPE slis_fieldcat_alv,
        lt_fieldcat TYPE slis_t_fieldcat_alv,
        lt_sort     TYPE slis_t_sortinfo_alv,
        ls_sort     TYPE slis_sortinfo_alv,
        ls_layout   TYPE slis_layout_alv.
      m_fieldcat 'VKORG' ''  ''.
      m_fieldcat 'KUNNR' ''  ''.
      m_fieldcat 'VBELN' ''  ''.
      m_fieldcat 'NETWR' 'X' 'WAERK'.
      m_fieldcat 'WAERK' ''  ''.
      m_sort 'VKORG' 'X'.                  " Sort by vkorg and subtotal
      m_sort 'KUNNR' 'X'.                  " Sort by kunnr and subtotal
      m_sort 'VBELN' ''.                   " Sort by vbeln
      ls_layout-cell_merge = 'X'.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
           EXPORTING
                is_layout   = ls_layout
                it_fieldcat = lt_fieldcat
                it_sort     = lt_sort
           TABLES
                t_outtab    = gt_vbak.
    ENDFORM.                               " F_DISPLAY_DATA
    ***************** END OF PROGRAM Z_DEMO_ALV_SORT **********************
    Regards
    Sudheer

  • How to calculate totals in Blocked ALV Report

    Hi All,
    Can any body tell how to calculate totals & sub totals in
    Blocked ALV Report[Blocked List].
    Thanks in advance
    Thanks & Regards,
    Rayeezuddin.

    read this it might help
    Sums                                                       
    15. No_sumchoice(1) TYPE c : This parameter allows the choice for summing up
    Only by fieldcatalog.
    Value set: SPACE, 'X'
    'X' = fields which are to be summed, passed by the calling program (FIELDCAT-DO_SUM = 'X'). The user should not be able to change this value interactively.
    16. No_totalline(1) TYPE c : Removes the option of having totals after sub-totals.
    Value set: SPACE, 'X'
    'X' = no total record is to be output. Subtotals can still be calculated and output. The fields in the subtotals are flagged DO_SUM = 'X' in the field list.
    17. No_subchoice(1) TYPE c : Does not allow the user to interactively change the field chosen for subtotals.
    Value set: SPACE, 'X'
    'X' = value whose change triggers subtotals, provided by the calling program. The user should not be able to change this value interactively.
    18. No_subtotals(1) TYPE c : No subtotals possible          
    Value set: SPACE, 'X'
    'X' = no subtotals.
    19. Numc_sum(1)  TYPE c : Totals only possible for NUMC-Fields.
    20. No_unit_splitting TYPE c: No separate total lines by inh.units   
    21.totals_before_items TYPE c: Display totals before the items   
    22. Totals_only(1) TYPE c :  Show only totals      
    Value set: SPACE, 'X'
    'X' = only total records are output.
    23. Totals_text(60) TYPE c : Text for 1st col. in totals   
    Value set: SPACE, string (max.60)
    ' ' = The first column in the total record contains an appropriate number of '*'s to indicate the total by default. If the first column is wide enough, the string 'Total' is output after the asterisks.
    'String’ = The string passed is output after the total indicated by '*', if the column is wide enough.
    24. Subtotals_text(60) TYPE c : Texts for subtotals
    Value set: SPACE, string (max.60)
    ' ' = In the first column of subtotal records, the subtotal is indicated by an appropriate number of '*' by default. If the first column is not a subtotal criterion, the string 'Total' is output after the asterisks, if the column is wide enough.
    'String’ = the string passed is output after the subtotal indicated by '*', if the column is wide enough and the first column is not a subtotal criterion. If it is a subtotal criterion, its value is repeated after the total, if the column is wide enough.
    ELSE TELL ME I WILL PASTE COMPLETE HELP
    regards

  • Hide grand total field on ALV report, But keep the sub total fields

    Dear Experts,
    1) How to hide grand total field on ALV report, But keep the sub total fields.
    2) How to populate rate per ton & calculate total price according to the qty in delivering document.

    Dear Experts,
    1) How to hide grand total field on ALV report, But keep the sub total fields.
    2) How to populate rate per ton & calculate total price according to the qty in delivering document.

  • How to get the total pages in ALV report?

    Hi guys,
    Since I used page breaks can somebody please help me on how to get the total pages in ALV report?sincerely please...thanks guys.

    automatic display total page.
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/e8a1d690-0201-0010-b7ad-d9719a415907
    r

  • Row wise total in editable ALV

    hello all,
                I am workin on editable alv, the user need to enter the values in the editable fields and in the last column(non-editable) i need to populate the total row wise,as soon as user enters a value and goes to next editable cell or on entering a vale and press enter.how to accomplish this task...
    with regards,
    sandeep akella.
    Edited by: sandeep akella on Aug 20, 2009 1:58 PM

    You need to Implement the OnCellAction event.follow these steps;
    1. Goto WDDOMODIFYVIEW and place the following code
    IF first_time IS INITIAL.
        DATA lo_cmp_usage TYPE REF TO if_wd_component_usage.
        lo_cmp_usage =   wd_this->wd_cpuse_usg_alv( ).
        IF lo_cmp_usage->has_active_component( ) IS INITIAL.
          lo_cmp_usage->create_component( ).
        ENDIF.
        DATA lo_interfacecontroller TYPE REF TO iwci_salv_wd_table .
        lo_interfacecontroller =   wd_this->wd_cpifc_usg_alv( ).
        DATA lo_value TYPE REF TO cl_salv_wd_config_table.
        lo_value = lo_interfacecontroller->get_model(
        CALL METHOD lo_value->if_salv_wd_table_settings~set_cell_action_event_enabled
         EXPORTING
            value = abap_true.
      ENDIF.
    2. Implement the onCellAction event as follows;
        Goto Methods tab, create a new method. Method Type- Event Handler , Event - ON_CELL_ACTION
    3. Now in this  method retrive the contents of the row and calculate the value as follows.
    DATA: l_element TYPE REF TO if_wd_context_element.
      DATA:ls_stru TYPE wd_this->element_cn_alv.
      DATA: l_node TYPE REF TO if_wd_context_node.
      l_node  = wd_context->get_child_node( 'CN_ALV' ).
      l_element = l_node->get_element(  r_param->index ).
      l_element->get_static_attributes( IMPORTING static_attributes = ls_stru ).
      ls_stru-last_col = ls_stru-col1+ls_stru-col2....+ ls_stru-col5. " add all the cells data
      l_element->set_static_attributes( exporting static_attributes = ls_stru ).

  • Going back to same row after saving changes in classic report

    dear all,
    I have a long classic report .User is able to update different rows of this report using MR update process.Now user is asking for easier flow.What he wants is to be able to go back to same row after he saves the changes.How is it possible to do so
    Thank you so much,
    Zahra

    Hi,
    I have one sample
    https://apex.oracle.com/pls/apex/f?p=40323:40
    When you change Active column select list, page is submitted. After submit JavaScript scrolls report
    See this post about details
    HELP TABULAR FORM CURSOR FOCUS
    Regards,
    Jari

  • Short dump when I do total or sub total in the ALV report

    Hi,
    When I do total or sub-total on the currency field in the ALV report, it'll give a short dump like
    " The current application program detected a situation which really
    should not occur. Therefore, a termination with a short dump was
    triggered on purpose by the key word MESSAGE (type X)".
       Short text of error message:
       Technical information about the message:
       Message classe...... "0K"
       Number.............. 000
       Variable 1.......... " "
       Variable 2.......... " "
       Variable 3.......... " "
       Variable 4.......... " "
       Variable 3.......... " "
       Variable 4.......... " "
    Trigger Location of Runtime Error
        Program                                 SAPLSLVC
        Include                                 LSLVCF36
        Row                                     2,726
        Module type                             (FORM)
        Module Name                             FILL_DATA_TABLE
    sometime when I do the page down on the ALV report, the same short dump is coming.
    Can anyone help me out.
    Thanks
    Selva

    Hi,
    I'm getting this short dump in the standard program.
    I'm getting ALV report display perfectly. the problem is, when I do total or subtotal on the currency fields.
    2704
    2705 ************************************
    2706 * Column per Fieldcat Entry
    2707 ************************************
    2708         ls_lvc_data-value = space.
    2709         clear ls_lvc_data-style.
    2710         loop at it_fcat_local assigning <ls_fcat>
    2711                 where tech ne 'X' and no_out ne 'X'.
    2712           if l_invisible eq 'X'.
    2713             clear l_invisible.
    2714             if <ls_fcat>-do_sum is initial.
    2715               continue.
    2716             else.
    2717               clear ls_lvc_data-col_pos.
    2718             endif.
    2719           endif.
    2720
    2721           add 1 to ls_lvc_data-col_pos.
    2722
    2723           assign component <ls_fcat>-fieldname
    2724                            of structure <ls_data> to <l_field_value>.
    2725           if sy-subrc ne 0.
    >>>>>             message x000(0k).
    2727           endif.
    2728
    in this standard program, I'm getting the dump. the line is mentioned above in the code.

  • The filtering , sorting , totaling action on ALV report is lost

    Hi ,
    I have an Interactive ALV report which i sort it , filter it and total it before I enter into my Z customised screen, from my Z cusomised screen when I come back to the ALV report, the report is no more sorted, no more filtered and no more totaled.
    Please help me on this its a bit urgent.

    *& Report  ZALV_SUM
    REPORT  ZNNR_ALV_SUM.
    TABLES:     ekko.
    type-pools: slis.                                 "ALV Declarations
    *Data Declaration
    TYPES: BEGIN OF t_vbap,
      vbeln TYPE vbap-vbeln,
      matnr TYPE vbap-matnr,
      netwr TYPE vbap-netwr,
      waerk TYPE vbap-waerk,
    END OF t_vbap.
    DATA: it_vbap TYPE STANDARD TABLE OF t_vbap INITIAL SIZE 0,
          wa_vbap TYPE t_vbap.
    *ALV data declarations
    data: fieldcatalog type slis_t_fieldcat_alv with header line,
          gd_tab_group type slis_t_sp_group_alv,
          gd_layout    type slis_layout_alv,
          gd_repid     like sy-repid.
    *Start-of-selection.
    START-OF-SELECTION.
    perform data_retrieval.
    perform build_fieldcatalog.
    perform build_layout.
    perform display_alv_report.
    *&      Form  BUILD_FIELDCATALOG
          Build Fieldcatalog for ALV Report
    form build_fieldcatalog.
      fieldcatalog-fieldname   = 'VBELN'.
      fieldcatalog-seltext_m   = 'Sales Order'.
      fieldcatalog-col_pos     = 0.
      fieldcatalog-outputlen   = 10.
      fieldcatalog-emphasize   = 'X'.
      fieldcatalog-key         = 'X'.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'MATNR'.
      fieldcatalog-seltext_m   = 'Material Number'.
      fieldcatalog-col_pos     = 4.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'NETWR'.
      fieldcatalog-seltext_m   = 'Net Price'.
      fieldcatalog-col_pos     = 7.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-do_sum      = 'X'.        "Display column total
      fieldcatalog-cfieldname     = 'WAERK'.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'WAERK'.
      fieldcatalog-seltext_m   = 'Price Curr'.
      fieldcatalog-col_pos     = 8.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
    endform.                    " BUILD_FIELDCATALOG
    *&      Form  BUILD_LAYOUT
          Build layout for ALV grid report
    form build_layout.
      gd_layout-no_input          = 'X'.
      gd_layout-colwidth_optimize = 'X'.
      gd_layout-totals_text       = 'Totals'(201).
    gd_layout-totals_only        = 'X'.
    gd_layout-f2code            = 'DISP'.  "Sets fcode for when double
                                            "click(press f2)
    gd_layout-zebra             = 'X'.
    gd_layout-group_change_edit = 'X'.
    gd_layout-header_text       = 'helllllo'.
    endform.                    " BUILD_LAYOUT
    *&      Form  DISPLAY_ALV_REPORT
          Display report using ALV grid
    form display_alv_report.
      gd_repid = sy-repid.
      call function 'REUSE_ALV_GRID_DISPLAY'
           exporting
                i_callback_program      = gd_repid
               i_callback_top_of_page   = 'TOP-OF-PAGE'  "see FORM
               i_callback_user_command = 'USER_COMMAND'
               i_grid_title           = outtext
                is_layout               = gd_layout
                it_fieldcat             = fieldcatalog[]
               it_special_groups       = gd_tabgroup
               IT_EVENTS                = GT_XEVENTS
                i_save                  = 'X'
               is_variant              = z_template
           tables
                t_outtab                = it_vbap
           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.                    " DISPLAY_ALV_REPORT
    *&      Form  DATA_RETRIEVAL
          Retrieve data form EKPO table and populate itab it_ekko
    form data_retrieval.
    select vbeln matnr netwr waerk
    up to 50 rows
      from vbap
      into table it_vbap.
    endform.                    " DATA_RETRIEVAL

  • Regd: Calculation of TOTAL field in ALV report

    Hi All,
    We have a scenario that we are not getting the total value for numeric fields in ALV report.
    Below i have given the code used for it.
    G_KEY = 'X'.
      G_NOKEY = SPACE.
      G_SUM = 'X'.
      G_NOSUM = SPACE.
      PERFORM BUILD_FIELDCAT USING 'VBELN'  G_KEY G_NOSUM.
      PERFORM BUILD_FIELDCAT USING 'BLDAT'  G_NOKEY G_NOSUM.
      PERFORM BUILD_FIELDCAT USING 'VGBEL'  G_KEY G_NOSUM.
      PERFORM BUILD_FIELDCAT USING 'POSNR'  G_KEY G_NOSUM.
      PERFORM BUILD_FIELDCAT USING 'MATNR'  G_KEY G_NOSUM..
      PERFORM BUILD_FIELDCAT USING 'LFIMG'  G_NOKEY G_NOSUM.
      PERFORM BUILD_FIELDCAT USING 'VRKME'  G_NOKEY G_NOSUM.
      PERFORM BUILD_FIELDCAT USING 'NETPR'  G_NOKEY G_NOSUM.
      PERFORM BUILD_FIELDCAT USING 'BRTWR'  G_NOKEY G_NOSUM.
      PERFORM BUILD_FIELDCAT USING 'VALUE_INR'  G_NOKEY G_SUM.
      PERFORM BUILD_FIELDCAT USING 'B_DUTY'     G_NOKEY G_SUM.
      PERFORM BUILD_FIELDCAT USING 'S_TOTAL1'   G_NOKEY G_SUM.
      PERFORM BUILD_FIELDCAT USING 'CV_DUTY'    G_NOKEY G_SUM.
      PERFORM BUILD_FIELDCAT USING 'C_CVD'      G_NOKEY G_SUM.
      PERFORM BUILD_FIELDCAT USING 'S_TOTAL2'   G_NOKEY G_SUM.
      PERFORM BUILD_FIELDCAT USING 'C_DUTY'     G_NOKEY G_SUM.
      PERFORM BUILD_FIELDCAT USING 'S_TOTAL3'   G_NOKEY G_SUM.
      PERFORM BUILD_FIELDCAT USING 'A_DUTY'     G_NOKEY G_SUM.
      PERFORM BUILD_FIELDCAT USING 'T_DUTY'     G_NOKEY G_SUM.
    PERFORM BUILD_LAYOUT.
      PERFORM BUILD_DISPLAY.
    *&      Form  DISPLAY
          text
    FORM BUILD_DISPLAY.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
      I_INTERFACE_CHECK                 = ' '
      I_BYPASSING_BUFFER                = ' '
      I_BUFFER_ACTIVE                   = ' '
      I_CALLBACK_PROGRAM                = ' '
      I_CALLBACK_PF_STATUS_SET          = ' '
      I_CALLBACK_USER_COMMAND           = ' '
      I_CALLBACK_TOP_OF_PAGE            = ' '
      I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
      I_CALLBACK_HTML_END_OF_LIST       = ' '
      I_STRUCTURE_NAME                  =
      I_BACKGROUND_ID                   = ' '
         I_GRID_TITLE                      = TEXT-000
      I_GRID_SETTINGS                   =
       IS_LAYOUT                         = IG_LAYOUT
         IT_FIELDCAT                       = IG_FIELDCAT
      IT_EXCLUDING                      =
      IT_SPECIAL_GROUPS                 =
      IT_SORT                           =
      IT_FILTER                         =
      IS_SEL_HIDE                       =
      I_DEFAULT                         = 'X'
         I_SAVE                            = 'A'
      IS_VARIANT                        =
      IT_EVENTS                         =
      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                          = IG_INBOUND
       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.                    "DISPLAY
    *&      Form  BUILD_FIELDCAT
          text
         -->G_FIELDNAME  text
         -->L_KEY        text
         -->L_SUM        text
    FORM BUILD_FIELDCAT USING L_FIELDNAME LIKE DD03L-FIELDNAME L_KEY TYPE C L_SUM TYPE C.
      CLEAR WG_FIELDCAT_LN.
      ADD 1 TO G_COL_POS.
      WG_FIELDCAT_LN-REF_TABNAME = 'IG_INBOUND'.
      WG_FIELDCAT_LN-FIELDNAME = L_FIELDNAME.
      WG_FIELDCAT_LN-KEY = L_KEY.
      WG_FIELDCAT_LN-DO_SUM = L_SUM.
      WG_FIELDCAT_LN-COL_POS = G_COL_POS.
      WG_FIELDCAT_LN-NO_OUT = SPACE.
      WG_FIELDCAT_LN-QFIELDNAME = SPACE.
      WG_FIELDCAT_LN-HOTSPOT = SPACE.
      APPEND WG_FIELDCAT_LN TO IG_FIELDCAT.
    ENDFORM.                    "BUILD_FIELDCAT
    *&      Form  BUILD_LAYOUT
          text
    FORM BUILD_LAYOUT.
    IG_LAYOUT-TOTALS_TEXT = 'Total Amount'.
    *IG_LAYOUT-SUBTOTALS_TEXT = 'A'.
    IG_LAYOUT-ZEBRA = 'X'.
    ENDFORM.
    Help and Sugesstions will be much appreciated.
    Thanks & Regds.
    Ramesh.

    This is sample program for the same
    REPORT  Z_50657_ALV_EX2
            NO STANDARD PAGE HEADING
            LINE-COUNT 65(3)
            LINE-SIZE 220
            MESSAGE-ID ZZ.
    *                             Type Pools                               *
    TYPE-POOLS: SLIS, ICON.
    *                              Tables                                  *
    TABLES: VBAK. "Sales Document Data
    *                         Internal Tables                              *
    * TABLE TO HOLD DATA OF SALES DOCUMENT
    DATA: BEGIN OF IT_VBAK OCCURS 0,
          VBELN LIKE VBAK-VBELN, "Sales Document
          VBTYP LIKE VBAK-VBTYP, "SD document category
          AUDAT LIKE VBAK-AUDAT, "Document date (date received/sent)
          AUGRU LIKE VBAK-AUGRU, "Order reason (reason for the business)
          AUART LIKE VBAK-AUART, "Sales Document Type
          NETWR LIKE VBAK-NETWR, "Net Sales Order in Doc. Currency
          WAERK LIKE VBAK-WAERK, "SD document currency
          ICON TYPE ICON-ID,     "traffic lights
          END OF IT_VBAK.
    *                             Work Areas                               *
    *WORK AREAS DEFINED FOR ALV'S
    DATA: WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV,      "field catalog
          IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,     "field catalog ITAB
          WA_SORT TYPE SLIS_SORTINFO_ALV,           "SORT work area
          IT_SORT TYPE SLIS_T_SORTINFO_ALV,         "SORT ITAB
          LAYOUT TYPE SLIS_LAYOUT_ALV,              "LAYOUT
          WA_FCODE TYPE SLIS_EXTAB,                 "FUN CODE
          I_FCODE_EXTAB TYPE SLIS_T_EXTAB,
          WA_EVENTS TYPE SLIS_ALV_EVENT,
          IT_EVENTS TYPE SLIS_T_EVENT.
    *                       Selection-Screen                               *
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME.
    SELECT-OPTIONS: S_VBELN FOR VBAK-VBELN.
    PARAMETERS: P_VBTYP LIKE VBAK-VBTYP DEFAULT 'C'.
    SELECTION-SCREEN END OF BLOCK B1.
    SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME.
    PARAMETERS: LIST RADIOBUTTON GROUP G1,
                GRID RADIOBUTTON GROUP G1.
    SELECTION-SCREEN END OF BLOCK B2.
    *                     At  Selection-Screen                             *
    *VALIDATION
    *                       Start of Selection                             *
    START-OF-SELECTION.
    *POPULATION OF DATA INTO INTERNAL TABLE ITAB
      PERFORM GET_DATA.
    *DEFINE USER DEFINED FIELDCATALOG
      PERFORM DEFINE_FIELDCATALOG.
    *SUBTOTALS AND TOTALS DISPLAY USING SORT
      PERFORM SORT_LIST.
    *CHANGE FCODE OF STATUS
      PERFORM CHANGE_FCODE.
    *CHECK RADIOBUTTON OPTION AND ACCORDINGLY FINAL DISPLAY
      PERFORM CHECK_OPTION.
    *&      Form  GET_DATA
    *       text
    FORM GET_DATA.
      SELECT VBELN
             VBTYP
             AUDAT
             AUGRU
             AUART
             NETWR
             WAERK FROM VBAK INTO TABLE IT_VBAK
             WHERE VBELN IN S_VBELN AND VBTYP = P_VBTYP
             AND ERDAT > '01.01.2004' AND NETWR > 0.
      LOOP AT IT_VBAK.
        IF IT_VBAK-NETWR < 10000.
          IT_VBAK-ICON = '@08@'.
        ELSEIF IT_VBAK-NETWR > 100000.
          IT_VBAK-ICON = '@0A@'.
        ELSE.
          IT_VBAK-ICON = '@09@'.
        ENDIF.
        MODIFY IT_VBAK INDEX SY-TABIX.
      ENDLOOP.
    ENDFORM.                    "GET_DATA
    *&      Form  CHECK_OPTION
    *       text
    FORM CHECK_OPTION.
      WA_EVENTS-NAME = 'TOP_OF_PAGE'.
      WA_EVENTS-FORM = 'TOP'.
      APPEND WA_EVENTS TO IT_EVENTS.
      CLEAR WA_EVENTS.
      WA_EVENTS-NAME = 'END_OF_LIST'.
      WA_EVENTS-FORM = 'END_LIST'.
      APPEND WA_EVENTS TO IT_EVENTS.
      CLEAR WA_EVENTS.
      IF LIST = 'X'.
        PERFORM LIST_DISP.
      ENDIF.
      IF GRID = 'X'.
        PERFORM GRID_DISP.
      ENDIF.
    ENDFORM.                    "CHECK_OPTION
    *&      Form  DEFINE_FIELDCATALOG
    *       text
    FORM DEFINE_FIELDCATALOG.
      WA_FIELDCAT-COL_POS = 1.
      WA_FIELDCAT-FIELDNAME = 'ICON'.
      WA_FIELDCAT-SELTEXT_L = 'ICON'.
      WA_FIELDCAT-ICON = 'X'.
      WA_FIELDCAT-OUTPUTLEN = 8.
      WA_FIELDCAT-TABNAME = 'IT_VBAK'.
      APPEND WA_FIELDCAT TO IT_FIELDCAT.
      CLEAR WA_FIELDCAT.
      WA_FIELDCAT-COL_POS = 2.
      WA_FIELDCAT-FIELDNAME = 'VBELN'.
      WA_FIELDCAT-SELTEXT_L = 'SALES DOC NO.'.
      WA_FIELDCAT-OUTPUTLEN = 10.
      WA_FIELDCAT-TABNAME = 'IT_VBAK'.
      APPEND WA_FIELDCAT TO IT_FIELDCAT.
      CLEAR WA_FIELDCAT.
      WA_FIELDCAT-COL_POS = 3.
      WA_FIELDCAT-FIELDNAME = 'AUDAT'.
      WA_FIELDCAT-SELTEXT_L = 'CREATED ON'.
      WA_FIELDCAT-OUTPUTLEN = 10.
      WA_FIELDCAT-TABNAME = 'IT_VBAK'.
      APPEND WA_FIELDCAT TO IT_FIELDCAT.
      CLEAR WA_FIELDCAT.
      WA_FIELDCAT-COL_POS = 4.
      WA_FIELDCAT-FIELDNAME = 'VBTYP'.
      WA_FIELDCAT-SELTEXT_L = 'CATEGORY'.
      WA_FIELDCAT-OUTPUTLEN = 1.
      WA_FIELDCAT-TABNAME = 'IT_VBAK'.
      APPEND WA_FIELDCAT TO IT_FIELDCAT.
      CLEAR WA_FIELDCAT.
      WA_FIELDCAT-COL_POS = 6.
      WA_FIELDCAT-FIELDNAME = 'AUGRU'.
      WA_FIELDCAT-SELTEXT_L = 'REASON'.
      WA_FIELDCAT-OUTPUTLEN = 3.
      WA_FIELDCAT-TABNAME = 'IT_VBAK'.
      APPEND WA_FIELDCAT TO IT_FIELDCAT.
      CLEAR WA_FIELDCAT.
      WA_FIELDCAT-COL_POS = 5.
      WA_FIELDCAT-FIELDNAME = 'AUART'.
      WA_FIELDCAT-SELTEXT_L = 'DOC TYPE'.
      WA_FIELDCAT-OUTPUTLEN = 4.
      WA_FIELDCAT-TABNAME = 'IT_VBAK'.
      APPEND WA_FIELDCAT TO IT_FIELDCAT.
      CLEAR WA_FIELDCAT.
      WA_FIELDCAT-COL_POS = 7.
      WA_FIELDCAT-FIELDNAME = 'NETWR'.
      WA_FIELDCAT-SELTEXT_L = 'NET VALUE'.
      WA_FIELDCAT-OUTPUTLEN = 17.
      WA_FIELDCAT-DECIMALS_OUT = 2.
    *  WA_FIELDCAT-DO_SUM = 'X'.
      WA_FIELDCAT-TABNAME = 'IT_VBAK'.
      APPEND WA_FIELDCAT TO IT_FIELDCAT.
      CLEAR WA_FIELDCAT.
      WA_FIELDCAT-COL_POS = 8.
      WA_FIELDCAT-FIELDNAME = 'WAERK'.
      WA_FIELDCAT-SELTEXT_L = 'UNIT'.
      WA_FIELDCAT-OUTPUTLEN = 50.
      WA_FIELDCAT-TABNAME = 'IT_VBAK'.
      APPEND WA_FIELDCAT TO IT_FIELDCAT.
      CLEAR WA_FIELDCAT.
    ENDFORM.                    "DEFINE_FIELDCATALOG
    *&      Form  DEFINE_LAYOUT
    *       text
    FORM DEFINE_LAYOUT.
      LAYOUT-ZEBRA = 'X'.
      LAYOUT-SUBTOTALS_TEXT = 'SUBTOTAL SUM'.
      LAYOUT-WINDOW_TITLEBAR = 'EXERCISE 2'.
      LAYOUT-TOTALS_TEXT  = 'TOTAL'.
    ENDFORM.                    "DEFINE_LAYOUT
    *&      Form  SORT_LIST
    *       text
    FORM SORT_LIST.
      WA_SORT-FIELDNAME = 'VBELN'.
      WA_SORT-TABNAME = 'IT_VBAK'.
      WA_SORT-SPOS = 1.
      WA_SORT-UP = 'X'.
      WA_SORT-SUBTOT = 'X'.
      APPEND WA_SORT TO IT_SORT.
      CLEAR WA_SORT.
      WA_SORT-FIELDNAME = 'NETWR'.
      WA_SORT-TABNAME = 'IT_VBAK'.
      WA_SORT-UP = 'X'.
      WA_SORT-SPOS = 2.
      WA_SORT-SUBTOT = 'X'.
      APPEND WA_SORT TO IT_SORT.
      CLEAR WA_SORT.
    ENDFORM.                    "SORT_LIST
    *&      Form  LIST_DISP
    *       text
    FORM LIST_DISP.
      PERFORM DEFINE_LAYOUT.
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
       EXPORTING
         I_CALLBACK_PROGRAM             = SY-REPID
         IT_FIELDCAT                    = IT_FIELDCAT
         IS_LAYOUT                      = LAYOUT
         IT_SORT                        = IT_SORT
         I_CALLBACK_PF_STATUS_SET       = 'STATUS'
         IT_EXCLUDING                   = I_FCODE_EXTAB
         I_CALLBACK_USER_COMMAND        = 'USER_COMMAND'
         IT_EVENTS                      = IT_EVENTS[]
    *   IMPORTING
    *     E_EXIT_CAUSED_BY_CALLER        =
    *     ES_EXIT_CAUSED_BY_USER         =
        TABLES
         T_OUTTAB                       = IT_VBAK
    *   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.                    "LIST_DISP
    *&      Form  GRID_DISP
    *       text
    FORM GRID_DISP.
      PERFORM DEFINE_LAYOUT.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          I_CALLBACK_PROGRAM       = SY-REPID
          IS_LAYOUT                = LAYOUT
          IT_FIELDCAT              = IT_FIELDCAT
          IT_SORT                  = IT_SORT
          I_CALLBACK_PF_STATUS_SET = 'STATUS'
          IT_EXCLUDING             = I_FCODE_EXTAB
          I_CALLBACK_USER_COMMAND  = 'USER_COMMAND'
          IT_EVENTS                = IT_EVENTS[]
        TABLES
          T_OUTTAB                 = IT_VBAK.
    * 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.                    "GRID_DISP
    *&      Form  STATUS
    *       text
    *      -->P_EXTAB    text
    FORM STATUS USING P_EXTAB TYPE SLIS_T_EXTAB.
      SET PF-STATUS 'STATUS' EXCLUDING P_EXTAB.
    ENDFORM.                    "STATUS
    *&      Form  USER_COMMAND
    *       text
    *      -->R_UCOMM      text
    *      -->RS_SELFIELD  text
    FORM USER_COMMAND USING R_UCOMM     LIKE SY-UCOMM
                                   RS_SELFIELD TYPE SLIS_SELFIELD.
      CASE R_UCOMM.
        WHEN 'BACK' OR 'CANC' OR 'EXIT'.
          LEAVE TO SCREEN 0.
        WHEN '&IC1'.
          SET PARAMETER ID 'AUN' FIELD RS_SELFIELD-VALUE.
          CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.
      ENDCASE.
    ENDFORM.                    "USER_COMMAND
    *&      Form  CHANGE_FCODE
    *       text
    FORM CHANGE_FCODE.
      WA_FCODE = 'PRNT'.
      APPEND WA_FCODE TO I_FCODE_EXTAB.
      WA_FCODE = '&OAD'.
      APPEND WA_FCODE TO I_FCODE_EXTAB.
      WA_FCODE = '&AVE'.
      APPEND WA_FCODE TO I_FCODE_EXTAB.
      WA_FCODE = '&EB9'.
      APPEND WA_FCODE TO I_FCODE_EXTAB.
      WA_FCODE = '&SUM'.
      APPEND WA_FCODE TO I_FCODE_EXTAB.
      WA_FCODE = '&UMC'.
      APPEND WA_FCODE TO I_FCODE_EXTAB.
      WA_FCODE = '&XPA'.
      APPEND WA_FCODE TO I_FCODE_EXTAB.
      WA_FCODE = '&OMP'.
      APPEND WA_FCODE TO I_FCODE_EXTAB.
    ENDFORM.                    "CHANGE_FCODE
    *&      Form  TOP
    *       text
    FORM TOP.
      IF LIST = 'X'.
        WRITE:/ SY-ULINE.
        WRITE:/ 'DATE:', SY-DATUM,55 'INTELLIGROUP ASIA PVT LTD'.
        WRITE:/ 'TIME:', SY-UZEIT.
        WRITE:/ 'USER NAME:', SY-UNAME,60 SY-TITLE.
        WRITE:/ 'PAGE', SY-PAGNO.
        WRITE:/ SY-ULINE.
      ENDIF.
      IF GRID = 'X'.
        DATA: LS_LINE TYPE SLIS_LISTHEADER,
              E04_LT_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER.
    *   Listenüberschrift: Typ H
        CLEAR LS_LINE.
        LS_LINE-TYP  = 'H'.
    *   LS_LINE-KEY:  not used for this type
        LS_LINE-INFO = 'Summary'.
        APPEND LS_LINE TO E04_LT_TOP_OF_PAGE.
    *   Kopfinfo: Typ S
        CLEAR LS_LINE.
        LS_LINE-TYP  = 'S'.
        LS_LINE-KEY  = 'Intelligroup'.
        LS_LINE-INFO = ''.
        APPEND LS_LINE TO E04_LT_TOP_OF_PAGE.
        LS_LINE-KEY  = 'ASIA'.
        LS_LINE-INFO = 'PVT LTD'.
        APPEND LS_LINE TO E04_LT_TOP_OF_PAGE.
    *   Aktionsinfo: Typ A
        CLEAR LS_LINE.
        LS_LINE-TYP  = 'A'.
    *   LS_LINE-KEY:  not used for this type
        LS_LINE-INFO = 'truman'.
        APPEND LS_LINE TO  E04_LT_TOP_OF_PAGE.
        CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
          EXPORTING
            IT_LIST_COMMENTARY = E04_LT_TOP_OF_PAGE
            I_LOGO             = 'ENJOY_SAP_LOGO'.
      ENDIF.
    ENDFORM.                    "TOP
    *&      Form  END_LIST
    *       text
    FORM END_LIST.
      IF LIST = 'X'.
        SKIP 2.
        WRITE:/60 'END OF PAGE'.
      ENDIF.
      IF GRID = 'X'.
          DATA: LS_LINE TYPE SLIS_LISTHEADER,
              E04_LT_END_OF_LIST TYPE SLIS_T_LISTHEADER.
    *   Listenüberschrift: Typ H
        CLEAR LS_LINE.
        LS_LINE-TYP  = 'H'.
    *   LS_LINE-KEY:  not used for this type
        LS_LINE-INFO = 'Summary'.
        APPEND LS_LINE TO E04_LT_END_OF_LIST.
    *   Kopfinfo: Typ S
        CLEAR LS_LINE.
        LS_LINE-TYP  = 'S'.
        LS_LINE-KEY  = 'Intelligroup'.
        LS_LINE-INFO = ''.
        APPEND LS_LINE TO E04_LT_END_OF_LIST.
        LS_LINE-KEY  = 'ASIA'.
        LS_LINE-INFO = 'PVT LTD'.
        APPEND LS_LINE TO E04_LT_END_OF_LIST.
    *   Aktionsinfo: Typ A
        CLEAR LS_LINE.
        LS_LINE-TYP  = 'A'.
    *   LS_LINE-KEY:  not used for this type
        LS_LINE-INFO = TEXT-105.
        APPEND LS_LINE TO  E04_LT_END_OF_LIST.
        CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
          EXPORTING
            IT_LIST_COMMENTARY = E04_LT_END_OF_LIST.
      ENDIF.
    ENDFORM.                    "END_LIST

  • Totals text for ALV report

    In my ALV report I need to add descriptions for totals
                Col1        Col2          Col3
    Sum1       #Value      #Value      #Value
    Sum2       #Value      #Value      #Value
    Sum3       #Value      #Value      #Value
    How to add text Sum1, Sum2, Sum3 to the report?
    I tried to use subtotals_text and totals_text in slis_layout_alv for REUSE_ALV_GRID_DISPLAY but that did not work out. I also tried to look for methods using CL_SALV_TABLE class and have not been able to find a solution yet.
    Edited by: Megan Flores on Feb 25, 2008 8:28 PM

    it's a package in the systems above 6.4 with new ALV. There are nice examples. Main package is SALV.
    /wg

  • How to add field to the header for FBL5N ALV report

    Hi,
       I need to add fields to the customer line item display ALV report(FBL5N) header part.Right now there are four fields in the header like customer, company code, name and city, after that I need to add first name last name and phone no. Can any one tell me where exactly I need to add and populate there fields to be appear in ALV output list.
    Thanks in Advance
    Swapna

    Yes I have tried, I have place a break point in that perform but it does not stop. I think that is not the correct place to added and populate fields. That routine is for populate selection screen ranges single and multiple values and parameters only.
    Thanks
    Swapna

  • Add multilple PO's to already existing ALV report

    hello all,
    i have an ALV Report requirement like below...
    serno network no       activity no  service code service text   units purchase requisition num     PR item    PR qty   Agreement num Agrmt item Agremt qty
    1     410000001401     0020          SCL10051      ****          KM    19000000461                        1              20         56000000199      1                 200
    2     410000001401     0030          SCL10052      ****          EA    19000000461                         2              30         56000000199      1                 500
    now my question is i have Purchase Order and PO qty(which i ahve taken from EKPO)...
    for a given purchase requisition number there are multiple PO's (say 10 Po's)...
    how do i add these PO's to above ALV report....
    thanks in advance....

    Dear Vinay,
    Please use these piece of code...........
    These report contains sending Mail & As per your layout comment the sending mail codes and use for your requirement...........
    Paste in a test program and check these is sales order based report..........
    Built field catalog & and sort your PO number as per in the field output display and field catalog....................................
    * Type Group Declaration
    TYPE-POOLS: slis,vrm.
    *  Tables Declaration
    TABLES : vbak.
    *  Structure Declaration
    TYPES: BEGIN OF  ty_vbakvbap,
       vbeln  TYPE vbak-vbeln,
       kunnr  TYPE vbak-kunnr,
       netpr  TYPE vbap-netpr,
       posnr  TYPE vbap-posnr,
       matnr  TYPE vbap-matnr,
       kwmeng TYPE vbap-kwmeng,
       arktx  TYPE vbap-arktx,
    END OF ty_vbakvbap,
    gt_t_vbakvbap TYPE STANDARD TABLE OF ty_vbakvbap.
    TYPES : BEGIN OF ty_kna1,
       kunnr TYPE kna1-kunnr,
       name1 TYPE kna1-name1,
       pstlz TYPE kna1-pstlz,
       stras TYPE kna1-stras,
       ort01 TYPE kna1-ort01,
       land1 TYPE kna1-land1,
    END OF ty_kna1,
    gt_t_kna1 TYPE STANDARD TABLE OF ty_kna1.
    TYPES : BEGIN OF ty_mara,
       mbrsh TYPE mara-mbrsh,
       matnr TYPE mara-matnr,
       mtart TYPE mara-mtart,
       matkl TYPE mara-matkl,
    END OF ty_mara,
    gt_t_mara TYPE STANDARD TABLE OF ty_mara.
    TYPES : BEGIN OF ty_final,
       vbeln  TYPE vbak-vbeln,
       kunnr  TYPE vbak-kunnr,
       netpr  TYPE vbap-netpr,
       posnr  TYPE vbap-posnr,
       matnr  TYPE vbap-matnr,
       kwmeng TYPE vbap-kwmeng,
       arktx  TYPE vbap-arktx,
       name1 TYPE kna1-name1,
       pstlz TYPE kna1-pstlz,
       stras TYPE kna1-stras,
       ort01 TYPE kna1-ort01,
       land1 TYPE kna1-land1,
       mbrsh TYPE mara-mbrsh,
       mtart TYPE mara-mtart,
       matkl TYPE mara-matkl,
    END OF ty_final,
    gt_t_final TYPE STANDARD TABLE OF ty_final.
    * Internal Table Declaration
    DATA: gt_vbakvbap TYPE gt_t_vbakvbap,
           gw_vbakvbap  TYPE  ty_vbakvbap,
           gt_kna1      TYPE  gt_t_kna1,
           gw_kna1      TYPE  ty_kna1,
           gt_mara      TYPE  gt_t_mara,
           gw_mara      TYPE  ty_mara,
           gt_final     TYPE  gt_t_final,
           gw_final     TYPE  ty_final,
           gt_fcat      TYPE slis_t_fieldcat_alv,
           gw_fcat      TYPE slis_fieldcat_alv,
           v_kunnr      TYPE vbak-kunnr,
    * Sub total based on the header details Sales order no. vbeln = 5006.
           gt_sort TYPE slis_t_sortinfo_alv,
           gw_sort TYPE slis_sortinfo_alv,
          g_tab_lines TYPE i,
          e(10) TYPE c,
          gv_selected_value(10) TYPE c,
    * DOC AND VRM DETAILS.
           tab          TYPE TABLE OF ty_final.
    SELECTION-SCREEN  BEGIN OF BLOCK name WITH FRAME TITLE text-001.
    SELECT-OPTIONS : s_vbeln FOR vbak-vbeln DEFAULT '5006' TO '5009'.
    PARAMETERS     : p_kunnr TYPE kna1-kunnr.
    SELECTION-SCREEN  END OF BLOCK name.
    SELECTION-SCREEN  BEGIN OF BLOCK name1 WITH FRAME TITLE text-002.
    PARAMETERS     : r1 RADIOBUTTON GROUP gr1 USER-COMMAND c,
                      r2 RADIOBUTTON GROUP gr1.
    * Selection Screen for Radio button 2
    SELECTION-SCREEN
      BEGIN OF BLOCK name3 WITH FRAME TITLE text-004.
    SELECTION-SCREEN END OF BLOCK name3.
    SELECTION-SCREEN  END OF BLOCK name1.
    INITIALIZATION.
       LOOP AT SCREEN .
         IF screen-group1 = 'ONE' .
           screen-input   = 0.
           screen-invisible = 1.
           MODIFY SCREEN.
         ENDIF.
       ENDLOOP.
    AT SELECTION-SCREEN OUTPUT.
       CASE 'X'.
         WHEN r1.
           LOOP AT SCREEN.
             IF
               screen-group1 = 'ONE' .
               screen-input = 0.
               screen-invisible = 1.
               MODIFY SCREEN.
             ENDIF.
           ENDLOOP.
           ENDCASE.
    START-OF-SELECTION.
       PERFORM f_fetch_ty_vbakbvbap.
       PERFORM f_fetch_ty_kna1.
       PERFORM f_fetch_ty_mara.
       PERFORM f_fetch_ty_final.
       PERFORM top_of_page.
    * Body of the Email.
       PERFORM f_customer_validation.
       CASE 'X'.
         WHEN r1.
           IF gt_final IS NOT INITIAL.
             PERFORM f_field_catalog.
             PERFORM  f_output_display.
           ELSE.
             MESSAGE 'No Records Exist for the radio button' TYPE 'I'.
           ENDIF.
       ENDCASE.
    *&      Form  f_fetch_ty_vbakbvbap
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM f_fetch_ty_vbakbvbap .
       SELECT vbak~vbeln
       vbak~kunnr
       vbap~netpr
       vbap~posnr
       vbap~matnr
       vbap~kwmeng
       vbap~arktx
       INTO TABLE gt_vbakvbap
       FROM vbak
       INNER JOIN vbap
       ON vbak~vbeln = vbap~vbeln
        WHERE vbak~vbeln IN s_vbeln.
    ENDFORM.                    " f_fetch_ty_vbakbvbap
    *&      Form  f_fetch_ty_kna1
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM f_fetch_ty_kna1 .
       IF gt_vbakvbap[] IS NOT INITIAL.
         SELECT kunnr
         name1
         pstlz
         stras
         ort01
         land1
         INTO TABLE gt_kna1
         FROM kna1
         FOR ALL ENTRIES IN gt_vbakvbap
         WHERE kunnr = gt_vbakvbap-kunnr.
       ENDIF.
    ENDFORM.                    " f_fetch_ty_kna1
    *&      Form  f_fetch_ty_mara
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM f_fetch_ty_mara .
       IF gt_kna1[] IS NOT INITIAL.
         SELECT mbrsh
         matnr
         mtart
         matkl
         INTO TABLE gt_mara
         FROM mara
         FOR ALL ENTRIES IN gt_vbakvbap
         WHERE matnr = gt_vbakvbap-matnr.
       ENDIF.
    ENDFORM.                    " f_fetch_ty_mara
    *&      Form  f_fetch_ty_final
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM f_fetch_ty_final .
       SORT gt_kna1 BY kunnr.
       LOOP AT gt_vbakvbap INTO gw_vbakvbap.
         MOVE: gw_vbakvbap-vbeln  TO gw_final-vbeln,
         gw_vbakvbap-kunnr  TO gw_final-kunnr,
         gw_vbakvbap-netpr  TO gw_final-netpr,
         gw_vbakvbap-posnr  TO gw_final-posnr,
         gw_vbakvbap-matnr  TO gw_final-matnr,
         gw_vbakvbap-kwmeng TO gw_final-kwmeng,
         gw_vbakvbap-arktx  TO gw_final-arktx.
         READ TABLE gt_kna1 INTO gw_kna1 WITH KEY kunnr = gw_vbakvbap-kunnr BINARY SEARCH.
         IF sy-subrc = 0.
           MOVE:  gw_kna1-name1 TO gw_final-name1,
           gw_kna1-pstlz TO gw_final-pstlz,
           gw_kna1-stras TO gw_final-stras,
           gw_kna1-ort01 TO gw_final-ort01,
           gw_kna1-land1 TO gw_final-land1.
           READ TABLE gt_mara INTO gw_mara WITH KEY matnr = gw_vbakvbap-matnr.
           MOVE: gw_mara-mbrsh TO gw_final-mbrsh,
           gw_mara-mtart TO gw_final-mtart,
           gw_mara-matkl TO gw_final-matkl.
           APPEND gw_final TO gt_final.
           CLEAR gw_final.
         ENDIF.
       ENDLOOP.
    ENDFORM.                    " f_fetch_ty_final
    *&      Form  f_output_display
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM f_output_display .
       DATA:lv_repid TYPE sy-repid.
       lv_repid = sy-cprog.
       DATA:w_layout TYPE slis_layout_alv.
       w_layout-colwidth_optimize = 'X'.
       w_layout-zebra = 'X'.
       gw_sort-fieldname = 'VBELN'.
       gw_sort-tabname = 'GW_FINAL'.
       gw_sort-subtot = 'X'.
       APPEND gw_sort TO gt_sort.
       CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
    *   I_INTERFACE_CHECK                 = ' '
    *   I_BYPASSING_BUFFER                = ' '
    *   I_BUFFER_ACTIVE                   = ' '
          i_callback_program                = sy-cprog
    *   I_CALLBACK_PF_STATUS_SET          = ' '
          i_callback_user_command           = 'USER_COMMAND'
          i_callback_top_of_page            = 'TOP_OF_PAGE'
    *   I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
    *   I_CALLBACK_HTML_END_OF_LIST       = ' '
    *   I_STRUCTURE_NAME                  =
    *   I_BACKGROUND_ID                   = ' '
    *   I_GRID_TITLE                      =
    *   I_GRID_SETTINGS                   =
           is_layout                         = w_layout
          it_fieldcat                       = gt_fcat
    *   IT_EXCLUDING                      =
    *   IT_SPECIAL_GROUPS                 =
         it_sort                           = gt_sort
    *   IT_FILTER                         =
    *   IS_SEL_HIDE                       =
    *   I_DEFAULT                         = 'X'
    *   I_SAVE                            = ' '
    *   IS_VARIANT                        =
    *   IT_EVENTS                         =
    *   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                          = gt_final
    * 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.                    " f_output_display
    *&      Form  f_field_catalog
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM f_field_catalog .
       gw_fcat-fieldname = 'VBELN'.
       gw_fcat-tabname = 'GT_FINAL'.
       gw_fcat-seltext_m = 'Sales Order No'.
       APPEND gw_fcat TO gt_fcat.
       CLEAR gw_fcat.
       gw_fcat-fieldname = 'KUNNR'.
       gw_fcat-tabname = 'GT_FINAL'.
       gw_fcat-seltext_m = 'Customer Number'.
       APPEND gw_fcat TO gt_fcat.
       CLEAR gw_fcat.
       gw_fcat-fieldname = 'NETPR'.
       gw_fcat-tabname = 'GT_FINAL'.
       gw_fcat-seltext_m = 'Net Price'.
       gw_fcat-do_sum = 'X'.
       APPEND gw_fcat TO gt_fcat.
       CLEAR gw_fcat.
       gw_fcat-fieldname = 'POSNR'.
       gw_fcat-tabname = 'GT_FINAL'.
       gw_fcat-seltext_m = 'Item Number'.
       APPEND gw_fcat TO gt_fcat.
       CLEAR gw_fcat.
       gw_fcat-fieldname = 'MATNR'.
       gw_fcat-tabname = 'GT_FINAL'.
       gw_fcat-seltext_m = 'Material Number'.
       APPEND gw_fcat TO gt_fcat.
       CLEAR gw_fcat.
       gw_fcat-fieldname = 'KWMENG'.
       gw_fcat-tabname = 'GT_FINAL'.
       gw_fcat-seltext_m = 'Cumulative Order Quantity'.
       APPEND gw_fcat TO gt_fcat.
       CLEAR gw_fcat.
       gw_fcat-fieldname = 'ARKTX'.
       gw_fcat-tabname = 'GT_FINAL'.
       gw_fcat-seltext_m = 'Short text for sales '.
       APPEND gw_fcat TO gt_fcat.
       CLEAR gw_fcat.
       gw_fcat-fieldname = 'NAME1'.
       gw_fcat-tabname = 'GT_FINAL'.
       gw_fcat-seltext_m = 'Customer Name'.
       APPEND gw_fcat TO gt_fcat.
       CLEAR gw_fcat.
       gw_fcat-fieldname = 'PSTLZ'.
       gw_fcat-tabname = 'GT_FINAL'.
       gw_fcat-seltext_m = 'Postal Code'.
       APPEND gw_fcat TO gt_fcat.
       CLEAR gw_fcat.
       gw_fcat-fieldname = 'STRAS'.
       gw_fcat-tabname = 'GT_FINAL'.
       gw_fcat-seltext_m = 'House number and street'.
       APPEND gw_fcat TO gt_fcat.
       CLEAR gw_fcat.
       gw_fcat-fieldname = 'ORT01'.
       gw_fcat-tabname = 'GT_FINAL'.
       gw_fcat-seltext_m = 'City'.
       APPEND gw_fcat TO gt_fcat.
       CLEAR gw_fcat.
       gw_fcat-fieldname = 'LAND1'.
       gw_fcat-tabname = 'GT_FINAL'.
       gw_fcat-seltext_m = 'Country Key'.
       APPEND gw_fcat TO gt_fcat.
       CLEAR gw_fcat.
       gw_fcat-fieldname = 'MBRSH'.
       gw_fcat-tabname = 'GT_FINAL'.
       gw_fcat-seltext_m = 'Industry sector'.
       APPEND gw_fcat TO gt_fcat.
       CLEAR gw_fcat.
       gw_fcat-fieldname = 'MTART'.
       gw_fcat-tabname = 'GT_FINAL'.
       gw_fcat-seltext_m = 'Material Type'.
       APPEND gw_fcat TO gt_fcat.
       CLEAR gw_fcat.
       gw_fcat-fieldname = 'MATKL'.
       gw_fcat-tabname = 'GT_FINAL'.
       gw_fcat-seltext_m = 'Material Group'.
       APPEND gw_fcat TO gt_fcat.
       CLEAR gw_fcat.
    ENDFORM.                    " f_field_catalog

Maybe you are looking for

  • CUPC 8.6 Desk phone control

    Currently running CUCM 8.6 along with CUPS 8.6.  Currently we are able to get the softphone to register and make calls, but we can not get deskphone control.  When we look at server health on the CUPC client, we just keep seeing "Connecting" and the

  • Reading/monitoring file on each update by using java code

    Hello, Thanks for help in advance.. I want to read a log file automatically on each time when log file get update . Actually i am reading that file one time but i have to read that file when log is added to that file. Thanks

  • Illustrator CS5 not working

    I have Master Collection CS5. After 5 years, Illustrator has stopped working and simply won't open. I have uninstalled it and tried to re-install, but the discs for CS5 aren't reading and eject within a few seconds. Is this problem familiar to anyone

  • Material Lock - Reg

    Hello Mates., how to find a material is locked or not that is material used by another user or any other transcation. This is because i am writing BDC for co11n where there is requirement of above mentioned case . while making entrying the manual pro

  • Music in slideshow

    When creating a slideshow, can you fade the song out at the end? I have a slideshow of about 20 images but only want them on the screen for a 5 sec duration and it doesnt fill a whole song. Thanks