Nested table in ALV grid

Hi all
i have the following types:
<begin of type1,
fieldA type i ,
fieldB type i,
<end of type1,
<begin of type2,
fieldC type i
fieldA type i,
<end of type2,
<begin of type3,
fieldA type i,
fieldB type i,
fieldC type i,
<end of type3,
<begin of type4,
fieldA type i
fields1 type type1 occurs 4,
fields2 type type2 occurs 5,
fields3 type type3 occurs 7,
fieldD type i,
<end of type4.
I would like to set a internal table of type4 in an ALV grid. How do you do this? because i thought it could
like to hear from you! And off course << Moderator message - Please do not offer points >>
kind regards
Anton
Edited by: Rob Burbank on Nov 9, 2010 2:03 PM

I have found another solution. I make one internal table with all the fields in it. It is not what i like, but it works...
thanks all for your replies!
kind regards
Anton Pierhagen

Similar Messages

  • Modifying database table in ALV Grid

    Hi all.
    I need to be able to modify the database table in ALV Grid. Here's the code. The database table, that is displayed is 'zng_so_head', it's internal table is 'res_tab'. In the program i tried to create a button 'CHANGE' on the ALV-toolbar, but when executing the program there's no such button (why?). What code, screens, screen elements, etc. should be added to this program to provide a possibility of changing data of the database table 'zng_so_head' (i mean changing existing data, adding new lines and saving changes)?
    CODE:
    & Report  ZNG_ALV_TC_EDIT_SIMP&
    REPORT  ZNG_ALV_TC_EDIT_SIMP.
    *-- GLOBAL DATA DECLARATIONS FOR ALV
    DATA gr_alvgrid TYPE REF TO cl_gui_alv_grid.
    DATA gc_custom_control_name TYPE scrfname VALUE 'CC_ALV'.
    DATA gr_ccontainer TYPE REF TO cl_gui_custom_container.
    DATA gt_fieldcat TYPE lvc_t_fcat.
    DATA gs_layout TYPE lvc_s_layo.
    TABLES: zng_so_head, zng_cust, zng_vendors.
    *-- STRUCTURE OF INTERNAL TABLE
    TYPES: BEGIN OF in_tab,
            so_num TYPE zng_so_head-so_num,          "type numc
            vend_num TYPE zng_so_head-vend_num,      "type numc
            cust_num TYPE zng_so_head-cust_num,      "type numc
            so_date TYPE zng_so_head-so_date,        "type dats
           END OF in_tab.
    *-- INTERNAL TABLE HOLDING LIST DATA
    DATA res_tab TYPE TABLE OF in_tab WITH HEADER LINE.
    *-- FILLING IN INTERNAL TABLE
    SELECT hso_num hvend_num hcust_num hso_date
    INTO TABLE res_tab FROM zng_so_head AS h.
    *&      Form  prepare_field_catalog
    FORM prepare_field_catalog CHANGING pt_fieldcat TYPE lvc_t_fcat.
      DATA ls_fcat TYPE lvc_s_fcat.
      ls_fcat-fieldname = 'SO_NUM'.
      ls_fcat-inttype = 'N'.
      ls_fcat-ref_table = 'zng_so_head'.
      ls_fcat-outputlen = '12'.
      ls_fcat-coltext = 'SO_NUM'.
      ls_fcat-seltext = 'SO_NUM'.
      APPEND ls_fcat TO pt_fieldcat.
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'VEND_NUM'.
      ls_fcat-inttype = 'N'.
      ls_fcat-ref_table = 'zng_so_head'.
      ls_fcat-outputlen = '12'.
      ls_fcat-coltext = 'VEND_NUM'.
      ls_fcat-seltext = 'VEND_NUM'.
      APPEND ls_fcat TO pt_fieldcat.
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'CUST_NUM'.
      ls_fcat-inttype = 'N'.
      ls_fcat-ref_table = 'zng_so_head'.
      ls_fcat-outputlen = '12'.
      ls_fcat-coltext = 'CUST_NUM'.
      ls_fcat-seltext = 'CUST_NUM'.
      APPEND ls_fcat TO pt_fieldcat.
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'SO_DATE'.
      ls_fcat-inttype = 'D'.
      ls_fcat-ref_table = 'zng_so_head'.
      ls_fcat-outputlen = '12'.
      ls_fcat-coltext = 'SO_DATE'.
      ls_fcat-seltext = 'SO_DATE'.
      APPEND ls_fcat TO pt_fieldcat.
    ENDFORM.                    "prepare_field_catalog
    *&      Form  display_alv
    FORM display_alv.
      IF gr_alvgrid IS INITIAL.
        CREATE OBJECT gr_ccontainer
        EXPORTING container_name = gc_custom_control_name.
        CREATE OBJECT gr_alvgrid
        EXPORTING i_parent = gr_ccontainer.
        PERFORM prepare_field_catalog CHANGING gt_fieldcat.
        CALL METHOD gr_alvgrid->set_table_for_first_display
          EXPORTING
            is_layout       = gs_layout
          CHANGING
            it_outtab       = res_tab[]
            it_fieldcatalog = gt_fieldcat.
      ELSE.
        CALL METHOD gr_alvgrid->refresh_table_display.
      ENDIF.
    ENDFORM.                    "display_alv
          CLASS lcl_event_handler DEFINITION
    CLASS lcl_event_handler DEFINITION.
      PUBLIC SECTION.
        METHODS:
        handle_toolbar
          FOR EVENT toolbar OF cl_gui_alv_grid
            IMPORTING e_object
                      e_interactive.
    ENDCLASS.             "lcl_event_handler DEFINITION
          CLASS lcl_event_handler IMPLEMENTATION
    CLASS lcl_event_handler IMPLEMENTATION.
      METHOD handle_toolbar.
        DATA: ls_toolbar TYPE stb_button.
        MOVE 3 TO ls_toolbar-butn_type.
        APPEND ls_toolbar TO e_object->mt_toolbar.
        CLEAR ls_toolbar.
        MOVE 'CHANGE' TO ls_toolbar-function.
        MOVE icon_change TO ls_toolbar-icon.
        MOVE 'change' TO ls_toolbar-quickinfo.
        MOVE 'change' TO ls_toolbar-text.
        APPEND ls_toolbar TO e_object->mt_toolbar.
      ENDMETHOD.                    "handle_toolbar
    ENDCLASS.                    "lcl_event_handler IMPLEMENTATION
    DATA object_ref TYPE REF TO lcl_event_handler.
    START-OF-SELECTION.
      CALL SCREEN 100.
    MODULE STATUS_0100 OUTPUT
    MODULE display_alv OUTPUT.
      SET PF-STATUS 'SCREEN_100'.
      PERFORM display_alv.
      CREATE OBJECT object_ref.
      SET HANDLER object_ref->handle_toolbar FOR gr_alvgrid.
    ENDMODULE.                    "display_alv OUTPUT
    MODULE USER_COMMAND_0100 INPUT
    MODULE user_command_0100 INPUT.
      IF sy-ucomm = 'BACK' OR
         sy-ucomm = 'EXIT' OR
         sy-ucomm = 'CANCEL'.
        LEAVE PROGRAM.
      ELSE.
        CALL METHOD object_ref->handle_toolbar.
      ENDIF.
    ENDMODULE.                    "status_0100 INPUT
    END OF CODE
    Thanks all.

    Hi,
    For the button on the toolbar,here is the code:
    CLASS lcl_eh IMPLEMENTATION.
    *METHOD:      HANDLE_TOOLBAR
    *DESCRIPTION: This method provides the necessary detail required to
                 create an extra button in the toolbar.
      METHOD handle_toolbar.
        CLEAR ls_toolbar.
        MOVE 'CHANGE' TO ls_toolbar-function.
        MOVE 0 TO ls_toolbar-butn_type.
        MOVE CHANGETO ls_toolbar-text.
        MOVE 'ICON_DETAIL' TO ls_toolbar-icon.
        MOVE 'CHANGE' TO ls_toolbar-quickinfo.
        APPEND ls_toolbar TO e_object->mt_toolbar.
      ENDMETHOD.                    "handle_toolbar
    Also,if you are using the CHANGE button to record changes in the DB,then in the local class that you have defined,you should use the following method and then write the logic:
    *METHOD:      HANDLE_USER_COMMAND
      METHOD handle_user_command.
        CASE e_ucomm.
          WHEN 'CHANGE'.
    CHECK_CHANGED_DATA
    REFRESH_TABLE_DISPLAY
    Now call the methods that i have given in my previous post.This function code will be checked at the event you click the button 'CHANGE'.I think you have done this in an ELSE condition in the PAI of the screen.Not too sure if it works in the PAI.
    Regards,
    Beejal
    **Reward if this helps

  • Show dynamic table in ALV grid

    Hi !
    how do I show a dynamic table in ALV GRID ?
    I used the following commands:
    call method cl_alv_table_create=>create_dynamic_table
      exporting
        it_fieldcatalog = it_fieldcat[]
      importing
        ep_table        = gt_new_table.
      assign gt_new_table->* to <l_table>.
      create data gs_new_line like line of <l_table>.
      assign gs_new_line->* to <l_line>.
    I added records into the table
    Now I got a dynamic table.
    How do I show it in ALV GRID ?
    thanks
      Adi

    Hi,
    Check these links
    Re: Dynamic table
    http://sap.ittoolbox.com/code/d.asp?a=s&d=3038
    http://www.sap4.com/codigo-138.html
    http://www.sapassist.com/code/d.asp?a=s&d=3365
    There is an example in the report BCALV_TABLE_CREATE
    report BCALV_TABLE_CREATE.
    data: ok_code like sy-ucomm,
         g_container type scrfname value 'BCALV_GRID_DEMO_0100_CONT1',
         grid1  type ref to cl_gui_alv_grid,
         g_custom_container type ref to cl_gui_custom_container.
    data: gt_fieldcat type lvc_t_fcat.
    data: gp_table type ref to data.
    field-symbols: <gt_table> type table.
    parameters: n type i.
    if n > 100.
    message a000(0k) with 'N <= 100'.
    endif.
    perform fieldcat_build.
    call method cl_alv_table_create=>create_dynamic_table
                            exporting it_fieldcatalog = gt_fieldcat
                            importing ep_table = gp_table.
    assign gp_table->* to <gt_table>.
    perform fill_table.
    call screen 100.

  • How to print to tables in ALV grid

    hi all
    I have 2 internal tables with some values
    i want to display the 2 internal tables in the grid one after another with some title
    can anyone tell me how to do it
    Thank you.

    i think in grid you can not do like this (By using function module). But you can do it in OO approach for that just check the se38 with alvgrid* and search. you can findout lot of example there. And one more option is there by using alv block but it is a list display.
    Just check this sample program of alv block
    TYPE-POOLS : SLIS.
    TABLES : EKKO,EKPO.
    DATA : BEGIN OF IEKKO OCCURS 0,
           EBELN LIKE EKKO-EBELN,
           AEDAT LIKE EKKO-AEDAT,
           END OF IEKKO.
    DATA : BEGIN OF IEKPO OCCURS 0,
           EBELN LIKE EKPO-EBELN,
           EBELP LIKE EKPO-EBELP,
           MATNR LIKE EKPO-MATNR,
           MENGE LIKE EKPO-MENGE,
           MEINS LIKE EKPO-MEINS,
           END OF IEKPO.
    DATA : IFIELDCATEKKO TYPE SLIS_T_FIELDCAT_ALV,
           IFIELDCATEKPO TYPE SLIS_T_FIELDCAT_ALV,
           WFIELDCAT     TYPE SLIS_FIELDCAT_ALV,
           ILAYOUT       TYPE SLIS_LAYOUT_ALV,
           IEVENTHEAD    TYPE SLIS_T_EVENT,
           IEVENTITEM    TYPE SLIS_T_EVENT,
           WEVENT        TYPE SLIS_ALV_EVENT,
           ISORT         TYPE SLIS_T_SORTINFO_ALV,
           WSORT         TYPE SLIS_SORTINFO_ALV.
    PARAMETERS : P_NUM(3) TYPE N DEFAULT 10.
    PERFORM GET_DATA_EKKO.
    PERFORM GET_DATA_EKPO.
    PERFORM BUILD_FCAT_HEAD.
    PERFORM BUILD_FCAT_ITEM.
    PERFORM BUILD_LAYOUT.
    PERFORM BUILD_EVENT_TAB.
    PERFORM DISPLAY_BLOCK.
    *&      Form  GET_DATA_EKKO
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM GET_DATA_EKKO .
    SELECT EBELN AEDAT INTO TABLE IEKKO FROM EKKO UP TO P_NUM ROWS WHERE EBELN LIKE '45000057%'.
    ENDFORM.                    " GET_DATA_EKKO
    *&      Form  GET_DATA_EKPO
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM GET_DATA_EKPO .
    IF NOT IEKKO[] IS INITIAL.
      SELECT EBELN EBELP MATNR MENGE MEINS INTO TABLE IEKPO FROM EKPO FOR ALL ENTRIES IN IEKKO
                                                      WHERE EBELN = IEKKO-EBELN.
    ENDIF.
    ENDFORM.                    " GET_DATA_EKPO
    *&      Form  DISPLAY_BLOCK
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM DISPLAY_BLOCK .
    CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
      EXPORTING
        I_CALLBACK_PROGRAM             = SY-REPID
    *   I_CALLBACK_PF_STATUS_SET       = ' '
    *   I_CALLBACK_USER_COMMAND        = ' '
    *   IT_EXCLUDING                   =
              CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
                EXPORTING
                  IS_LAYOUT                        = ILAYOUT
                  IT_FIELDCAT                      = IFIELDCATEKKO
                  I_TABNAME                        = 'IEKKO'
                  IT_EVENTS                        = IEVENTHEAD[]
    *             IT_SORT                          =
    *             I_TEXT                           = ' '
                TABLES
                  T_OUTTAB                         = IEKKO
               EXCEPTIONS
                 PROGRAM_ERROR                    = 1
                 MAXIMUM_OF_APPENDS_REACHED       = 2
                 OTHERS                           = 3
              IF SY-SUBRC <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
              ENDIF.
    CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
      EXPORTING
        IS_LAYOUT                        = ILAYOUT
        IT_FIELDCAT                      = IFIELDCATEKPO
        I_TABNAME                        = 'IEKPO'
        IT_EVENTS                        = IEVENTITEM
    *   IT_SORT                          =
    *   I_TEXT                           = ' '
      TABLES
        T_OUTTAB                         = IEKPO
    * EXCEPTIONS
    *   PROGRAM_ERROR                    = 1
    *   MAXIMUM_OF_APPENDS_REACHED       = 2
    *   OTHERS                           = 3
    IF SY-SUBRC <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'
    * EXPORTING
    *   I_INTERFACE_CHECK             = ' '
    *   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       =
    *   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.                    " DISPLAY_BLOCK
    *&      Form  BUILD_FCAT_HEAD
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM BUILD_FCAT_HEAD .
    WFIELDCAT-FIELDNAME = 'EBELN'.
    WFIELDCAT-TABNAME   = 'IEKKO'.
    WFIELDCAT-SELTEXT_L = 'Pur. Doc no'.
    WFIELDCAT-OUTPUTLEN = 15.
    APPEND WFIELDCAT TO IFIELDCATEKKO.
    CLEAR WFIELDCAT.
    WFIELDCAT-FIELDNAME = 'AEDAT'.
    WFIELDCAT-TABNAME   = 'IEKKO'.
    WFIELDCAT-SELTEXT_L = 'Pur. doc date'.
    WFIELDCAT-OUTPUTLEN = 15.
    APPEND WFIELDCAT TO IFIELDCATEKKO.
    CLEAR WFIELDCAT.
    ENDFORM.                    " BUILD_FCAT_HEAD
    *&      Form  BUILD_FCAT_ITEM
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM BUILD_FCAT_ITEM .
    WFIELDCAT-FIELDNAME = 'EBELN'.
    WFIELDCAT-TABNAME   = 'IEKPO'.
    WFIELDCAT-SELTEXT_L = 'Pur. Doc no'.
    WFIELDCAT-OUTPUTLEN = 15.
    APPEND WFIELDCAT TO IFIELDCATEKPO.
    CLEAR WFIELDCAT.
    WFIELDCAT-FIELDNAME = 'EBELP'.
    WFIELDCAT-TABNAME   = 'IEKPO'.
    WFIELDCAT-SELTEXT_L = 'Pur. Doc item'.
    *wfieldcat-do_sum = 'X'.
    WFIELDCAT-OUTPUTLEN = 15.
    APPEND WFIELDCAT TO IFIELDCATEKPO.
    CLEAR WFIELDCAT.
    WFIELDCAT-FIELDNAME = 'MATNR'.
    WFIELDCAT-TABNAME   = 'IEKPO'.
    WFIELDCAT-SELTEXT_L = 'Material no'.
    WFIELDCAT-OUTPUTLEN = 18.
    APPEND WFIELDCAT TO IFIELDCATEKPO.
    CLEAR WFIELDCAT.
    WFIELDCAT-FIELDNAME = 'MENGE'.
    WFIELDCAT-TABNAME   = 'IEKPO'.
    WFIELDCAT-SELTEXT_L = 'P.O. Qty'.
    wfieldcat-do_sum = 'X'.
    *WFIELDCAT-DATATYPE = 'QUAN'.
    WFIELDCAT-OUTPUTLEN = 15.
    APPEND WFIELDCAT TO IFIELDCATEKPO.
    CLEAR WFIELDCAT.
    WFIELDCAT-FIELDNAME = 'MEINS'.
    WFIELDCAT-TABNAME   = 'IEKPO'.
    WFIELDCAT-SELTEXT_L = 'UOM'.
    WFIELDCAT-OUTPUTLEN = 3.
    APPEND WFIELDCAT TO IFIELDCATEKPO.
    CLEAR WFIELDCAT.
    ENDFORM.                    " BUILD_FCAT_ITEM
    *&      Form  BUILD_LAYOUT
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM BUILD_LAYOUT .
    ILAYOUT-COLWIDTH_OPTIMIZE = 'X'.
    ENDFORM.                    " BUILD_LAYOUT
    *&      Form  BUILD_EVENT_TAB
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM BUILD_EVENT_TAB .
    CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
    EXPORTING
       I_LIST_TYPE           = 0
    IMPORTING
       ET_EVENTS             = IEVENTHEAD
    * 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.
    IEVENTITEM = IEVENTHEAD.
    READ TABLE IEVENTHEAD INTO WEVENT WITH KEY NAME = 'TOP_OF_PAGE'.
    IF SY-SUBRC = 0.
    WEVENT-FORM = 'TOPOFPAGEHEAD'.
    MODIFY IEVENTHEAD FROM WEVENT INDEX SY-TABIX.
    ENDIF.
    READ TABLE IEVENTHEAD INTO WEVENT WITH KEY NAME = 'USER_COMMAND'.
    IF SY-SUBRC = 0.
    WEVENT-FORM = 'USERCOMMAND'.
    MODIFY IEVENTHEAD FROM WEVENT INDEX SY-TABIX.
    ENDIF.
    READ TABLE IEVENTITEM INTO WEVENT WITH KEY NAME = 'TOP_OF_PAGE'.
    IF SY-SUBRC = 0.
    WEVENT-FORM = 'TOPOFPAGEITEM'.
    MODIFY IEVENTITEM FROM WEVENT INDEX SY-TABIX.
    ENDIF.
    ENDFORM.                    " BUILD_EVENT_TAB
    FORM USERCOMMAND USING PUCOMM LIKE SY-UCOMM SELFIELD TYPE SLIS_SELFIELD.
    CASE PUCOMM.
    WHEN '&IC1'.
    WHEN 'OTHERS'.
    ENDCASE.
    ENDFORM.
    FORM TOPOFPAGEHEAD.
    DATA : ILIST TYPE SLIS_T_LISTHEADER,
           WLIST TYPE SLIS_LISTHEADER.
    WLIST-INFO = 'Header data with P.O. no and creating date'.
    WLIST-TYP  = 'H'.
    APPEND WLIST TO ILIST.
    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
      EXPORTING
        IT_LIST_COMMENTARY       = ILIST
    *   I_LOGO                   =
    *   I_END_OF_LIST_GRID       =
    ENDFORM.
    FORM TOPOFPAGEITEM.
    DATA : ILIST TYPE SLIS_T_LISTHEADER,
           WLIST TYPE SLIS_LISTHEADER.
    WLIST-INFO = 'Item data with P.O.item material no and qty'.
    WLIST-TYP  = 'H'.
    APPEND WLIST TO ILIST.
    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
      EXPORTING
        IT_LIST_COMMENTARY       = ILIST
    *   I_LOGO                   =
    *   I_END_OF_LIST_GRID       =
    ENDFORM.
    regards
    shiba dutta

  • Two Internal Tables for ALV Grid

    Hi Gurus,
    I have a little problem here. I have a report to display cost of production. The rows is about 50 displaying amount in dollars (currency fields). I have this in ALV Grid. But my problem is that the last 4 lines of the report are not currency fields like the others, they are quantity fields.
    How can i go about to display this last 4 lines in this ALV Grid. They are from different internal tables off course because of the data type.
    In short. I just want to display these 2 internal tables in an ALV Grid.
    Thanks in Advance.

    Hi,
    u can use ALV Block list to display 2 ALV.
    Reffer to the below code.
    DATA: v_layout TYPE slis_layout_alv.
      DATA: ls_print TYPE slis_print_alv.
      PERFORM build_fieldcatalog.
      CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
        EXPORTING
          i_callback_program             = sy-repid
    *     I_CALLBACK_PF_STATUS_SET       = ' '
    *     I_CALLBACK_USER_COMMAND        = ' '
    *     IT_EXCLUDING                   =
      CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
        EXPORTING
          is_layout                        = v_layout
          it_fieldcat                      = it_fcat_nlei
          i_tabname                        = 'IT_NLEI_ALV'
          it_events                        = it_event_nlei
    *     IT_SORT                          =
    *     I_TEXT                           = ' '
        TABLES
          t_outtab                         = it_nlei_alv
        EXCEPTIONS
          program_error                    = 1
          maximum_of_appends_reached       = 2
          OTHERS                           = 3.
      CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
        EXPORTING
          is_layout                        = v_layout
          it_fieldcat                      = it_fcat_vbrp
          i_tabname                        = 'IT_VBRP_ALV'
          it_events                        = it_event_vbrp
    *     IT_SORT                          =
    *     I_TEXT                           = ' '
        TABLES
          t_outtab                         = it_vbrp_alv
       EXCEPTIONS
         program_error                    = 1
         maximum_of_appends_reached       = 2
         OTHERS                           = 3.
      ls_print-no_print_selinfos  = 'X'.   " Display no selection infos
      ls_print-no_print_listinfos = 'X'.   " Display no listinfos
      ls_print-reserve_lines      = 2.     " Lines reserved for end of page
      CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'
        EXPORTING
    *     I_INTERFACE_CHECK             = ' '
          is_print                      = ls_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       =
    *     ES_EXIT_CAUSED_BY_USER        =
       EXCEPTIONS
         program_error                 = 1
         OTHERS                        = 2

  • Updating database table using ALV Grid class CL_ALV_CHANGED_DATA_PROTOCOL

    Hi,
    I am trying to use class CL_ALV_CHANGED_DATA_PROTOCOL to update a database table from an ALV grid.
    I have used program BCALV_EDIT_04 as an example.
    I am able to successfully processed inserted or deleted lines using the attributes
    MT_DELETED_ROWS
    MT_INSERTED_ROWS
    but I also want to process modified lines.
    I was just wondering whether anyone out there has some example code for this.
    I can see that there are the following attributes available
    MT_MOD_CELLS
    MP_MOD_ROWS.
    I would ideally like to use MP_MOD_ROWS rather than  MT_MOD_CELLS but it is not clear to me what type MP_MOD_ROWS is.
    If anyone has any example code for this sort of thing, please let me know.
    Thanks,
    Ruby

    hi Ruby,
    Yes we can use that *data reference variable *.
    It is a variable( something comparable to a pointer ) that points to a int table( table with changed contents )
    which ll be created at run-time based on the data type ot the internal table that we pass to the parameter it_outtab of method set_table_for_first_display ...
    assign er_data_changed->mp_mod_rows->* to a field-symbol and use it...
    Check the below code for example -> method refresh_changed_data
    screen flow logic.
    PROCESS BEFORE OUTPUT.
      MODULE pbo.
    PROCESS AFTER INPUT.
      MODULE pai.
    main program.
    *       CLASS lcl_event_responder DEFINITION                           *
    CLASS lcl_event_responder DEFINITION.
      PUBLIC SECTION.
        DATA  : ls_changed_cell TYPE  lvc_s_modi,
                lv_language     TYPE  spras..
        METHODS refresh_changed_data  FOR EVENT data_changed
                                      OF cl_gui_alv_grid
                                      IMPORTING er_data_changed
                                                e_ucomm.
    ENDCLASS.                    "event_responder DEFINITION
    TYPES tt_makt TYPE STANDARD TABLE OF makt.
    DATA: go_handler         TYPE REF TO lcl_event_responder,
          go_grid            TYPE REF TO cl_gui_alv_grid,
          gt_fieldcat        TYPE lvc_t_fcat,
          gv_language        TYPE spras VALUE 'E',
          gt_outtab          TYPE tt_makt,
          gs_tableline       TYPE LINE OF tt_makt.
    FIELD-SYMBOLS : <changed_rows> TYPE tt_makt.
    CALL SCREEN 100.
    *       MODULE PBO OUTPUT                                             *
    MODULE pbo OUTPUT.
      SET PF-STATUS 'BASIC'.
      PERFORM create_and_init_alv CHANGING gt_outtab[]
                                           gt_fieldcat.
    ENDMODULE.                    "pbo OUTPUT
    *       MODULE PAI INPUT                                              *
    MODULE pai INPUT.
      LEAVE PROGRAM.
    ENDMODULE.                    "pai INPUT
    FORM create_and_init_alv CHANGING pt_outtab LIKE gt_outtab[]
                                      pt_fieldcat TYPE lvc_t_fcat.
      CHECK go_grid IS NOT BOUND.
      CREATE OBJECT go_grid
        EXPORTING
          i_parent = cl_gui_container=>default_screen.
      PERFORM build_display_table.
      PERFORM build_fieldcat CHANGING pt_fieldcat.
      go_grid->set_table_for_first_display( CHANGING  it_fieldcatalog      = pt_fieldcat
                                                      it_outtab            = pt_outtab ).
      go_grid->set_ready_for_input( 1 ).
    * raises the 'data_changed' event when we select another cell/any action after changing the data
      go_grid->register_edit_event( EXPORTING i_event_id = cl_gui_alv_grid=>mc_evt_enter ).
      CREATE OBJECT go_handler.
      SET HANDLER go_handler->refresh_changed_data FOR go_grid.
    ENDFORM.                               "CREATE_AND_INIT_ALV
    FORM build_display_table.
      FREE gt_outtab.
      SELECT * FROM makt UP TO 20 ROWS INTO TABLE gt_outtab WHERE spras EQ gv_language.
    ENDFORM.                               "build_display_table
    FORM build_fieldcat CHANGING pt_fieldcat TYPE lvc_t_fcat.
      DATA ls_fcat TYPE lvc_s_fcat.
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
        EXPORTING
          i_structure_name = 'MAKT'
        CHANGING
          ct_fieldcat      = pt_fieldcat.
      LOOP AT pt_fieldcat INTO ls_fcat.
        ls_fcat-edit       = abap_true.
        MODIFY pt_fieldcat FROM ls_fcat.
      ENDLOOP.
    ENDFORM.                               "build_fieldcat
    *       CLASS event_responder IMPLEMENTATION                          *
    CLASS lcl_event_responder IMPLEMENTATION.
      METHOD refresh_changed_data.
        ASSIGN er_data_changed->mp_mod_rows->* TO <changed_rows>.
        LOOP AT <changed_rows> INTO gs_tableline.
          BREAK-POINT.
        ENDLOOP.
      ENDMETHOD.                    "click
    ENDCLASS.                    "event_responder IMPLEMENTATION
    Cheers,
    Jose.

  • Modifying database table through ALV-Grid

    Hi all.
    I need to modify a database table (ZNG_SO_HEAD) by entering data in ALV-Grid, which displays its internal table (exact  copy of ZNG_SO_HEAD), and clicking the button ('CHANGE') on the ALV-toolbar. The ALV is already editable, the button already exists. Here is the code. After changing data in ALV and clicking 'CHANGE' on the toolbar the database table ZNG_SO_HEAD remains unchangeable, but i need to change data in it somehow.
    Thanks all.
    REPORT  zng_alv_tc_edit_simp.
    *-- GLOBAL DATA DECLARATIONS FOR ALV
    DATA gr_alvgrid TYPE REF TO cl_gui_alv_grid.
    DATA gc_custom_control_name TYPE scrfname VALUE 'CC_ALV'.
    DATA gr_ccontainer TYPE REF TO cl_gui_custom_container.
    DATA gt_fieldcat TYPE lvc_t_fcat.
    DATA gs_layout TYPE lvc_s_layo.
    TABLES: zng_so_head, zng_cust, zng_vendors.
    *-- STRUCTURE OF INTERNAL TABLE
    TYPES: BEGIN OF in_tab,
            mandt TYPE zng_so_head-mandt,
            so_num TYPE zng_so_head-so_num,          "type numc
            vend_num TYPE zng_so_head-vend_num,      "type numc
            cust_num TYPE zng_so_head-cust_num,      "type numc
            so_date TYPE zng_so_head-so_date,        "type dats
           END OF in_tab.
    *-- INTERNAL TABLE HOLDING LIST DATA
    DATA res_tab TYPE TABLE OF in_tab WITH HEADER LINE.
    *DATA wa_res_tab LIKE LINE OF res_tab.
    *-- FILLING IN INTERNAL TABLE
    SELECT h~mandt h~so_num h~vend_num h~cust_num h~so_date
    INTO TABLE res_tab FROM zng_so_head AS h.
    *       CLASS lcl_event_handler DEFINITION
    CLASS lcl_event_handler DEFINITION.
      PUBLIC SECTION.
        METHODS:
    *   to add new functional buttons to the alv toolbar
        handle_toolbar
          FOR EVENT toolbar OF cl_gui_alv_grid
            IMPORTING e_object
                      e_interactive,
    *   to implement user commands
        handle_user_command
          FOR EVENT user_command OF cl_gui_alv_grid
            IMPORTING e_ucomm.
    ENDCLASS.             "lcl_event_handler DEFINITION
    *       CLASS lcl_event_handler IMPLEMENTATION
    CLASS lcl_event_handler IMPLEMENTATION.
      METHOD handle_toolbar.
        DATA: ls_toolbar TYPE stb_button.
        MOVE 3 TO ls_toolbar-butn_type.
        CLEAR ls_toolbar.
        MOVE 'CHANGE' TO ls_toolbar-function.
        MOVE icon_change TO ls_toolbar-icon.
        MOVE 'change' TO ls_toolbar-quickinfo.
        MOVE 'change' TO ls_toolbar-text.
        APPEND ls_toolbar TO e_object->mt_toolbar.
      ENDMETHOD.                    "handle_toolbar>
      METHOD handle_user_command.
        DATA:l_valid TYPE c.
        CASE e_ucomm.
          WHEN 'CHANGE'.
            CALL METHOD gr_alvgrid->check_changed_data
              IMPORTING
                e_valid = l_valid.
            IF l_valid = 'X'.
              MODIFY zng_so_head FROM res_tab.
            ENDIF.
        ENDCASE.
      ENDMETHOD. "handle_user_command
    ENDCLASS.                    "lcl_event_handler IMPLEMENTATION
    DATA object_ref TYPE REF TO lcl_event_handler.
    FORM prepare_field_catalog CHANGING pt_fieldcat TYPE lvc_t_fcat.
    >>>>>>done correctly>>>>>>>>>
    FORM display_alv.
    >>>>>>done correctly>>>>>>>>>
    START-OF-SELECTION.
      CALL SCREEN 100.
    *  MODULE STATUS_0100 OUTPUT
    MODULE display_alv OUTPUT.
      SET PF-STATUS 'SCREEN_100'.
      PERFORM display_alv.
      CREATE OBJECT object_ref.
      SET HANDLER object_ref->handle_toolbar FOR gr_alvgrid.
      SET HANDLER object_ref->handle_user_command FOR gr_alvgrid.
    ENDMODULE.                    "display_alv OUTPUT
    *  MODULE USER_COMMAND_0100 INPUT
    MODULE user_command_0100 INPUT.
    IF sy-ucomm = 'BACK' OR
         sy-ucomm = 'EXIT' OR
         sy-ucomm = 'CANCEL'.
        LEAVE PROGRAM.
      ELSE.
        CALL METHOD object_ref->handle_toolbar.
        CALL METHOD object_ref->handle_user_command.
      ENDIF.
    ENDMODULE.

    Hello Nikolai,
    I have written a sample code taking care of all the requirements(button in the toolbar and changes saved in database).I have used SPFLI table and the internal table i_spfli.This code works and the change is also made in the database table.
    REPORT  SAMPLE.
    *-- GLOBAL DATA DECLARATIONS FOR ALV
    DATA gr_alvgrid TYPE REF TO cl_gui_alv_grid.
    DATA gc_custom_control_name TYPE scrfname VALUE 'CC_ALV'.
    DATA gr_ccontainer TYPE REF TO cl_gui_custom_container.
    DATA gt_fieldcat TYPE lvc_t_fcat.
    DATA gs_layout TYPE lvc_s_layo.
    Data:i_spfli type table of spfli.
          CLASS lcl_event_handler DEFINITION
    CLASS lcl_event_handler DEFINITION.
      PUBLIC SECTION.
        DATA:l_valid TYPE c.
         DATA: ls_toolbar TYPE stb_button.
        METHODS:
      to add new functional buttons to the alv toolbar
        handle_toolbar
          FOR EVENT toolbar OF cl_gui_alv_grid
            IMPORTING e_object
                      e_interactive,
      to implement user commands
        handle_user_command
          FOR EVENT user_command OF cl_gui_alv_grid
            IMPORTING e_ucomm.
    ENDCLASS.             "lcl_event_handler DEFINITION
          CLASS lcl_event_handler IMPLEMENTATION
    CLASS lcl_event_handler IMPLEMENTATION.
      METHOD handle_toolbar.
      CLEAR ls_toolbar.
        MOVE 0 TO ls_toolbar-butn_type.
        MOVE 'CHANGE' TO ls_toolbar-function.
        MOVE 'ICON_CHANGE' TO ls_toolbar-icon.
        MOVE 'change' TO ls_toolbar-quickinfo.
        MOVE 'change' TO ls_toolbar-text.
        APPEND ls_toolbar TO e_object->mt_toolbar.
      ENDMETHOD.                    "handle_toolbar>
      METHOD handle_user_command.
        CASE e_ucomm.
          WHEN 'CHANGE'.
            CALL METHOD gr_alvgrid->check_changed_data
              IMPORTING
                e_valid = l_valid.
            IF l_valid = 'X'.
              MODIFY spfli FROM table i_spfli.
            ENDIF.
        ENDCASE.
      ENDMETHOD. "handle_user_command
    ENDCLASS.                    "lcl_event_handler IMPLEMENTATION
    START-OF-SELECTION.
    DATA object_ref TYPE REF TO lcl_event_handler.
    select * from spfli into table i_spfli.
    Call screen 100.
    MODULE STATUS_0100 OUTPUT
    MODULE STATUS_0100 OUTPUT.
      SET PF-STATUS 'SCREEN_100'.
      PERFORM display_alv.
    ENDMODULE.                    "display_alv OUTPUT
    MODULE USER_COMMAND_0100 INPUT
    MODULE user_command_0100 INPUT.
    IF sy-ucomm = 'BACK' OR
         sy-ucomm = 'EXIT' OR
         sy-ucomm = 'CANCEL'.
        LEAVE PROGRAM.
      ENDIF.
    ENDMODULE.
    *& Form display_alv
    FORM display_alv.
    *IF gr_alvgrid IS INITIAL.
    CREATE OBJECT gr_ccontainer
    EXPORTING container_name = gc_custom_control_name.
    CREATE OBJECT gr_alvgrid
    EXPORTING i_parent = gr_ccontainer.
    PERFORM prepare_field_catalog CHANGING gt_fieldcat.
    CREATE OBJECT object_ref.
      SET HANDLER object_ref->handle_toolbar FOR gr_alvgrid.
      SET HANDLER object_ref->handle_user_command FOR gr_alvgrid.
    CALL METHOD gr_alvgrid->set_table_for_first_display
    EXPORTING
    is_layout = gs_layout
    CHANGING
    it_outtab = i_spfli[]
    it_fieldcatalog = gt_fieldcat.
    ENDFORM. "display_alv
    *& Form prepare_field_catalog
    FORM prepare_field_catalog CHANGING pt_fieldcat TYPE lvc_t_fcat.
    DATA ls_fcat TYPE lvc_s_fcat.
    ls_fcat-fieldname = 'CARRID'.
    ls_fcat-ref_table = 'SPFLI'.
    ls_fcat-edit = 'X'.
    APPEND ls_fcat TO pt_fieldcat.
    CLEAR ls_fcat.
    ls_fcat-fieldname = 'CONNID'.
    ls_fcat-ref_table = 'SPFLI'.
    ls_fcat-edit = 'X'.
    APPEND ls_fcat TO pt_fieldcat.
    CLEAR ls_fcat.
    ls_fcat-fieldname = 'DEPTIME'.
    ls_fcat-ref_table = 'SPFLI'.
    ls_fcat-edit = 'X'.
    APPEND ls_fcat TO pt_fieldcat.
    CLEAR ls_fcat.
    ls_fcat-fieldname = 'ARRTIME'.
    ls_fcat-ref_table = 'SPFLI'.
    ls_fcat-edit = 'X'.
    APPEND ls_fcat TO pt_fieldcat.
    CLEAR ls_fcat.
    endform.
    Hope this helps.
    Regards,
    Beejal

  • Subtotals in dynamic internal table using alv grid

    hi experts i have created one dynamic table.  The requirement is to display the subtotals in the output using reuse_alv_grid.
    Dynamic itab (field-symbols) and ALV event BEFORE_LINE_OUTPUT
    the above is the thread related and could any one please provide the sample code for this task.
    can any one post the solution for that.
    rewards points will be awarded.
    khazi

    * ASSINING STRUCTURE FOR FILD CATLOGS
    DATA: DYN_TABLE    TYPE REF TO DATA,
          DYN_LINE     TYPE REF TO DATA,
          LS_FIELDCAT TYPE LVC_S_FCAT,
          LT_FIELDCAT TYPE LVC_T_FCAT.
      LOOP AT LT_DMTAB INTO LS_DMTAB.
        CLEAR LS_FIELDCAT.
        LS_FIELDCAT-FIELDNAME = LS_DMTAB-SDATE .
        LS_FIELDCAT-DATATYPE  = 'DEC'.
        LS_FIELDCAT-INTTYPE   = 'P'.
        LS_FIELDCAT-INTLEN    = '16' .
        LS_FIELDCAT-DECIMALS  = '03'.
        LS_FIELDCAT-JUST      = 'C'.
        APPEND LS_FIELDCAT TO LT_FIELDCAT.
      ENDLOOP.
    *& For grouping the table rows for Under Line
      LS_FIELDCAT-FIELDNAME = 'ULFIELD' .
      LS_FIELDCAT-DATATYPE  = 'INT'.
      LS_FIELDCAT-INTTYPE   = 'P'.
      LS_FIELDCAT-INTLEN    = '2' .
      LS_FIELDCAT-DECIMALS  = ''.
      APPEND LS_FIELDCAT TO LT_FIELDCAT.
      "* Create dynamic internal table and assign to Field-Symbol
      CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
        EXPORTING
          IT_FIELDCATALOG = LT_FIELDCAT
        IMPORTING
          EP_TABLE        = DYN_TABLE.
      IF SY-SUBRC <> 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                  WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      ASSIGN DYN_TABLE->* TO <LT_AREA_F>.
      "* Create dynamic work area and assign to Field Symbol
      CREATE DATA DYN_LINE LIKE LINE OF <LT_AREA_F>.
      ASSIGN DYN_LINE->* TO <LS_AREA_F>.
    You check in Field cat level you will get  Check Sub total field will exist
    Thanks and regards
    Jogu

  • Table Maintenance via ALV GRID

    Hi Experts,
    I have a requirement to do table maintenance for multiple tables using ALV GRID, with options to change, delete, add records and upload multiple records via copy/paste functionality.
    Thanks.

    Your welcome.
    Rob

  • For all users having probs with OO ALV Grid

    I wanted to put this in the WIKI but it keeps bombing out when I try and save so I've put this here -- Maybe a MOD can move it for me.
    This generic class should give you far more insite into using an EDITABLE ALV table than the standard documentation.
    If you follow the steps you should be able to code very quickly a decent useable ALV OO program which can retrieve and manipulate data very easily.  The events are (hopefully) well documented as are all the steps.
    Once you understand the basics you can add more functionality like colouring Cells, adding hyperlinks etc etc.
    I've always found that stupid SEAT / AIRLINE application SAP uses for its examples far too overblown and in reality who would ever use a SAP system for Airline reservations anyway.
    The class here describes a much simpler application which CLEARLY (I hope) explains how the whole thing works.
    Jimbo's generic class for using the OO ALV GRID Class CL_GUI_ALV_GRID
    from an application program to display and manipulate ANY table
    with minimal coding needed in the Calling application program.
    Handles the following EVENTS
    1) TOOLBAR BUTTONS
    (you can add more to the toolbar method
      if you need even more functionality).
    2) DOUBLE CLICK
    3) ENTER KEY PRESSED
    4) DATA CHANGED
    5) DATA CHANGED FINISHED
    Methods available
    PUBLIC METHODS  ( Can be called directly from the application program).
    1) display_grid  displays grid with toolbar
       Table and FCAT are built dynamically - user only needs to
       define the table structure (can be DDIC or User fields)
    2) change_title  - changes title at the top of the Grid
    3) refresh_grid   - refreshes grid after table updated etc.
    4) build_dynamic_structures - this method creates a dynamic table and a dynamic FCAT
       using the structure defined in the calling application program
    PRIVATE METHODS (Internal Methods used within the class)
    1) verwerk - returns to FORM VERWERK in calling application program
       (Via Toolbar). The application program can then do any special processing
       at this point e.g update SAP tables etc.
    2) download_to_excel (via Toolbar). This creates an EXCEL spreadsheet
       directly which can be downloaded / saved to a file if required,
    3) return_structure - internal method returns the structure
       of the table defined in the calling application program. This is needed in order
       to build the dynamic table and Field Catalog.
    4) create_dynamic_table  - creates a dynamic table from the structure defined in
       the calling application program
    5) create_dynamic_fcat  - creates the dynamic field catalog from the structure
       defined in the application program.
    6) dubbleklik entered when user double clicks a cell
    activated by EVENT DOUBLE_CLICK.
    returns to FORM DUBBELKLIK  in the
    calling application program
       COOKBOOK STEP BY STEP instructions on how to use this class
       in your application program.
       In the application program :
    1) define a blank screen 100  - SE51 with a custom container
       on it called CCONTAINER1.
       you need the following logic in the screen
       The PAI is only used if you have defined a STATUS with SE41 and you exit the
       application program via the standard SAP buttons on the
       top of the Screen (NOT the GRID toolbar).
         PROCESS BEFORE OUTPUT.
          MODULE STATUS_0100.
         PROCESS AFTER INPUT.
         MODULE USER_COMMAND_0100.
    2) (optional) define a STATUS with a titlebar - SE41
       you only need this if you want the standard EXIT and menu buttons on the
       top line of the screen
    3) If you want to have your OWN colum names on the grid
       add the following macro to the start of your program
         DEFINE col_name.
         read  table it_fldcat into  wa_it_fldcat index &1.
         wa_it_fldcat-coltext = &2.
         modify it_fldcat from wa_it_fldcat index &1.
         END-OF-DEFINITION.
    4) Define the following Field symbols
       <fs1>           TYPE  ANY,
       <fs2>           TYPE  STANDARD TABLE,
       <fs3>           TYPE ANY,
       <field_catalog> TYPE STANDARD TABLE,
       <dyn_table>    TYPE  STANDARD TABLE,
       <orig_table>   TYPE  STANDARD TABLE,
       <dyn_field>,
       <dyn_wa>.
    5) After the field-symbols add the code in this class
        as an INCLUDE
        e.g INCLUDE ZZJIMBOXX_INCL.
    6) define your Internal table as follows
        TYPES:  BEGIN OF s_elements,
                  Your structure
                your structure etc.
                END OF  s_elements.
    For example
    INCLUDE  <icon>.
    TABLES: VAPMA.
    *TYPES:  BEGIN OF s_elements,
    vbeln   TYPE vapma-vbeln,
    posnr   TYPE vapma-posnr,
    matnr   TYPE vapma-matnr,
    kunnr   TYPE vapma-kunnr,
    werks   TYPE vapma-werks,
    vkorg   TYPE vapma-vkorg,
    vkbur   TYPE vapma-vkbur,
    status  TYPE c,
    *END OF  s_elements.
    7) Define the following data  IN YOUR APPLICATION PROGRAM
       (note here only data is described
       that relates to using THIS CLASS. Data purely used internally
       in the application program is NOT shown here).
    DATA: z_object          TYPE REF TO zcl_dog,  "Instantiate our class
          grid_container1    TYPE REF TO cl_gui_custom_container,
          t_elements         TYPE TABLE OF s_elements, "refers to our ITAB
          wa_elements        TYPE s_elements,
          wa_dyn_table_line  TYPE REF TO DATA,
          it_fldcat          TYPE lvc_t_fcat,
          i_gridtitle        TYPE lvc_title,
          wa_it_fldcat       TYPE lvc_s_fcat,
          new_table          TYPE REF TO DATA,
          dy_table           TYPE REF TO data,
          dy_line            TYPE REF TO data,
          row_id             TYPE sy-index.
    8) insert the following code at the start of the application program.
    *START-OF-SELECTION.
    *CALL SCREEN 100.
    *END-OF-SELECTION.
    *MODULE status_0100 OUTPUT.
    *ASSIGN  wa_elements TO <fs1>.
    *CREATE OBJECT z_object EXPORTING z_object = z_object. "Instantiate the class
    *CALL METHOD z_object->build_dynamic_structures
           CHANGING it_fldcat = it_fldcat.
    9) if you inserted the macro in step 3) then
       define your own column names as follws
      col_name 1 'Name1'.
      col_name 2 'Name2'.
      etc. The number is the colum number you want and the name is
      the name you want to assign to the column.
    for example using the table shown above
      col_name 1 'Order Nr'.
      col_name 2 'Item'.
      col_name 3 'Material'.
      col_name 4 'Customer'.
      col_name 5 'Plant'.
      col_name 6 'Sales Org'.
      col_name 7 'Sales Office'.
      col_name 8 'Status'.
    10)  perform a routine that fills your dynamic table and
         display the GRID. If you created a status with SE41 you can set
         a title etc. Further processing is dependent on the users action
         after the GRID is displayed for example if a Cell is double clicked,
         dat is entered, a toolbar button is pressed or a SAP ICON on top of the screen is pressed.
    PERFORM populate_dynamic_itab.
    CALL METHOD z_object->display_grid
          CHANGING it_fldcat = it_fldcat.
    SET PF-STATUS '0001'.
    SET TITLEBAR '000'.
    ENDMODULE.
    11) If you added a STATUS via SE41 you can exit the program via the
    standard SAP buttons at the top of the screen
    otherwise exit via the exit button on the toolbar.
    You only need this piece of code if you defined a STATUS in the application program
    MODULE user_command_0100 INPUT.
    CASE sy-ucomm.
       WHEN 'BACK'.
         LEAVE PROGRAM.
       WHEN 'EXIT'.
         LEAVE PROGRAM.
       WHEN 'RETURN'.
         LEAVE PROGRAM.
       WHEN OTHERS.
    ENDCASE.
    12)  to populate the dynamic table you only need to code something like this
    remember the class has already created and structured the field-symbol <dyn_table>
    so you don't have to do anything other than just select the fields you want
    filled and from what data source(es).
    *FORM populate_dynamic_itab.
    *SELECT vbeln posnr matnr kunnr werks vkorg vkbur
          UP TO 200 rows
          FROM vapma
          INTO  CORRESPONDING FIELDS OF TABLE <dyn_table>.
    if you want to keep the original table before making any changes etc code
    the following
    create 2nd Dyn table to hold original data. We can use
    the same field catalog as for the original table
    as we are just creating an identical copy here.
    *CALL METHOD cl_alv_table_create=>create_dynamic_table
       EXPORTING
            it_fieldcatalog = it_fldcat
         IMPORTING
            ep_table = dy_table.
      ASSIGN dy_table->* TO <orig_table>.
    CREATE DATA dy_line LIKE LINE OF <orig_table>.
    ASSIGN dy_line->* TO <dyn_wa>.
    <orig_table> = <dyn_table>.
    ENDFORM.
    13) you need these 2 processing routines in your application program.
    FORM VERWERK.  "Entered from VERW on toolbar
    *break-point 1.
    Orig table is in dynamic table <orig_table>
    ALV GRID changed table is in <dyn_table>.
    *Loop at <orig_table>  into <dyn_wa>.
      Do what you want here
    end
    endloop.
    ENDFORM.
    *form dubbleklik using     "Entered when a cell is double clicked
           e_row   type LVC_S_ROW
           e_column type LVC_S_col
           es_row_no type lvc_s_roid.
           break-point 1.
    Get Row id into a variable for this program.
           row_id =  e_row.
            SET TITLEBAR '001'.      "If you defined a status in SE41
           i_gridtitle = 'Grid Title Changed'.
           CALL METHOD  z_object->change_title
             EXPORTING i_gridtitle = i_gridtitle.
           PERFORM refresh.
    endform.
    The REFRESH routine is optional but after a double click I assume
    you want to do some processing
    and re-display the data
    so as a sample code something like
    *FORM refresh.
    data: ord_nr  TYPE vapma-vbeln.  "Your data
    *READ TABLE  <dyn_table> index row_id into wa_elements.
       ord_nr = wa_elements-vbeln.
    You've now got the Row double clicked so pick out the data element(s)
    you wnat to process and do your processing
    *set parameter id 'AUN'  field ord_nr.
    *CALL TRANSACTION  'VA02' AND SKIP FIRST SCREEN.
    You can update the dynamic table for example
    *wa_elements-status = 'C'.
    *modify <dyn_table> from wa_elements index row_id.
    now redisplay the updated grid.
    *CALL METHOD z_object->refresh_grid.
    *ENDFORM.
    *************Class ZCL_DOG*************
    CLASS zcl_dog DEFINITION.
    PUBLIC SECTION.
    METHODS:
      constructor
         IMPORTING
                      z_object TYPE REF TO zcl_dog,
       display_grid
         CHANGING
                      it_fldcat TYPE lvc_t_fcat,
           build_dynamic_structures
         CHANGING        it_fldcat TYPE lvc_t_fcat,
        change_title
         IMPORTING
                i_gridtitle  TYPE lvc_title,
         refresh_grid.
      PRIVATE SECTION.
       METHODS:
        on_user_command FOR EVENT before_user_command OF cl_gui_alv_grid
          IMPORTING       e_ucomm
                          sender,
        on_toolbar FOR EVENT toolbar OF cl_gui_alv_grid
          IMPORTING      e_object
                         e_interactive,
         on_dubbelklik FOR EVENT double_click OF cl_gui_alv_grid
          IMPORTING e_row
                    e_column
                    es_row_no,
        handle_data_changed
                 FOR EVENT data_changed OF cl_gui_alv_grid
                 IMPORTING er_data_changed,
        handle_data_changed_finished
                 FOR EVENT data_changed_finished OF cl_gui_alv_grid
                 IMPORTING e_modified
                           et_good_cells,
        verwerk
                IMPORTING program TYPE sy-repid,
        download_to_excel,
        dubbleklik
                IMPORTING
                     e_row  type  LVC_S_ROW
                     e_column   TYPE LVC_S_COL
                     es_row_no  type lvc_s_ROID
                     program type sy-repid,
         return_structure,
         create_dynamic_fcat
          EXPORTING       it_fldcat TYPE lvc_t_fcat,
          create_dynamic_table
          IMPORTING       it_fldcat TYPE lvc_t_fcat
          EXPORTING       dy_table  TYPE REF TO DATA.
    DATA:
        lr_rtti_struc    TYPE REF TO cl_abap_structdescr,        "RTTI
        zog              LIKE LINE OF lr_rtti_struc->components, "RTTI
        wa_it_fldcat     TYPE lvc_s_fcat,
        it_fldcat        TYPE lvc_t_fcat,
        dy_table         TYPE REF TO data,
        dy_line          TYPE REF TO data,
        struct_grid_lset TYPE lvc_s_layo,
        e_row            TYPE LVC_S_ROW,
        e_column         TYPE lvc_s_col,
        es_rowid         TYPE lvc_s_roid,
        grid_container1  TYPE REF TO cl_gui_custom_container,
        grid1            TYPE REF TO cl_gui_alv_grid,
        ls_layout        TYPE kkblo_layout,
        lt_fieldcat_wa   TYPE kkblo_fieldcat,
        l_mode           TYPE raw4,
        celltab          TYPE LVC_T_STYL,
        wa_celltab       TYPE lvc_s_styl,
        lt_fieldcat      TYPE kkblo_t_fieldcat,
       l_tabname         TYPE slis_tabname.
    TYPES:
       struc            LIKE  zog.
    DATA:
        zogt           TYPE TABLE OF struc.
       ENDCLASS.
    CLASS zcl_dog IMPLEMENTATION.
    METHOD constructor.
       CREATE OBJECT grid_container1
           EXPORTING
                   container_name = 'CCONTAINER1'.
        CREATE OBJECT  grid1
            EXPORTING
                  i_parent = grid_container1.
        SET HANDLER z_object->on_user_command for grid1.
        SET HANDLER z_object->on_toolbar for grid1.
        SET HANDLER Z_OBJECT->handle_data_changed_finished FOR grid1.
        SET HANDLER Z_OBJECT->on_dubbelklik FOR grid1.
        CALL METHOD grid1->register_edit_event
            EXPORTING
                    i_event_id = cl_gui_alv_grid=>mc_evt_enter.
    ENDMETHOD.
    METHOD refresh_grid.
      CALL METHOD cl_gui_cfw=>flush.
      CALL METHOD grid1->refresh_table_display.
    ENDMETHOD.
    METHOD on_dubbelklik.
    CALL METHOD me->dubbleklik
             EXPORTING
                     e_row  = e_row
                     e_column =  e_column
                     es_row_no = es_row_no
                     program  = sy-repid.
    break-point 1.
    ENDMETHOD.
    METHOD  handle_data_changed.
    Insert user code here if required
    this method is entered if user ENTERS DATA.
    ENDMETHOD.
    METHOD handle_data_changed_finished.
    Insert user code here if required
    Method entered here after data entry has finished.
    ENDMETHOD.
    METHOD return_structure.
      lr_rtti_struc ?= cl_abap_structdescr=>DESCRIBE_BY_DATA( <fs1> ).
      zogt[]  = lr_rtti_struc->components.
      ASSIGN zogt[] TO <fs2>.
      ENDMETHOD.
    METHOD create_dynamic_fcat.
        LOOP AT <fs2>  INTO zog.
          CLEAR wa_it_fldcat.
          wa_it_fldcat-fieldname = zog-name .
          wa_it_fldcat-datatype = zog-type_kind.
          wa_it_fldcat-inttype = zog-type_kind.
          wa_it_fldcat-intlen = zog-length.
          wa_it_fldcat-decimals = zog-decimals.
          wa_it_fldcat-coltext = zog-name.
          wa_it_fldcat-lowercase = 'X'.
          APPEND wa_it_fldcat TO it_fldcat .
          ASSIGN it_fldcat[] TO <field_catalog>.
          ENDLOOP.
           ASSIGN  it_fldcat[] TO <field_catalog>.
        ENDMETHOD.
    METHOD  download_to_excel.
    break-point 5.
    CALL FUNCTION  'LVC_TRANSFER_TO_KKBLO'
        EXPORTING
          it_fieldcat_lvc   = <field_catalog>
         is_layout_lvc     = m_cl_variant->ms_layout
           is_tech_complete  = ' '
        IMPORTING
          es_layout_kkblo   = ls_layout
          et_fieldcat_kkblo = lt_fieldcat.
    LOOP AT lt_fieldcat INTO lt_fieldcat_wa.
       CLEAR lt_fieldcat_wa-tech_complete.
        IF lt_fieldcat_wa-tabname IS initial.
           lt_fieldcat_wa-tabname = '1'.
           MODIFY lt_fieldcat FROM lt_fieldcat_wa.
        ENDIF.
        l_tabname = lt_fieldcat_wa-tabname.
    ENDLOOP.
    CALL FUNCTION 'ALV_XXL_CALL'
        EXPORTING
          i_tabname           = l_tabname
          is_layout           = ls_layout
          it_fieldcat         = lt_fieldcat
          i_title             = sy-title
        TABLES
          it_outtab           = <dyn_table>
        EXCEPTIONS
          fatal_error         = 1
          no_display_possible = 2
          others              = 3.
      IF  sy-subrc <> 0.
         message id sy-msgid type 'S' number sy-msgno
                with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        ENDIF.
    ENDMETHOD.
    METHOD create_dynamic_table.
    CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
             it_fieldcatalog = it_fldcat
          IMPORTING
             ep_table = dy_table.
    ENDMETHOD.
    METHOD build_dynamic_structures.
    CALL METHOD me->return_structure.
    CALL METHOD me->create_dynamic_fcat
       IMPORTING
         it_fldcat = it_fldcat.
    CALL METHOD me->create_dynamic_table
        EXPORTING
          it_fldcat = it_fldcat
        IMPORTING
          dy_table        = dy_table.
         ASSIGN dy_table->* TO <dyn_table>.
    CREATE DATA dy_line LIKE LINE OF <dyn_table>.
    ASSIGN dy_line->* TO <dyn_wa>.
    ENDMETHOD.
    METHOD display_grid.
      struct_grid_lset-edit = 'X'. "To enable editing in ALV
      struct_grid_lset-grid_title = 'Bulkwijzigingen inkoopprijzen'.
      struct_grid_lset-ctab_fname = 'T_CELLCOLORS'.
      struct_grid_lset-stylefname = 'CELLTAB'.
      CALL METHOD grid1->set_ready_for_input
          EXPORTING
               i_ready_for_input = '1'.
      CALL METHOD grid1->set_table_for_first_display
          EXPORTING
               is_layout       = struct_grid_lset
        CHANGING
               it_outtab       = <dyn_table>
               it_fieldcatalog = it_fldcat.
    ENDMETHOD.
    METHOD change_title.
      CALL METHOD grid1->set_gridtitle
       EXPORTING
       i_gridtitle =  i_gridtitle.
      ENDMETHOD.
    METHOD on_user_command.
      CASE e_ucomm.
          WHEN 'EXIT'.
            LEAVE PROGRAM.
         WHEN 'EXCEL'.
         CALL METHOD me->download_to_excel.
          WHEN 'SAVE'.
          WHEN 'VERW'.
          CALL METHOD me->verwerk
               EXPORTING
                  PROGRAM = SY-REPID.
      ENDCASE.
    ENDMETHOD.                    "on_user_command
    METHOD on_toolbar.
    User can add extra functionality by adding extra
    buttons if required. Functionality can also be simplified by removing buttons.
    DATA: ls_toolbar TYPE stb_button.
         CLEAR ls_toolbar.
         MOVE 0 TO ls_toolbar-butn_type.
         MOVE 'EXIT' TO ls_toolbar-function.
         MOVE SPACE TO ls_toolbar-disabled.
         MOVE icon_system_end TO ls_toolbar-icon.
         MOVE 'Click2Exit' TO ls_toolbar-quickinfo.
         APPEND ls_toolbar TO e_object->mt_toolbar.
         CLEAR ls_toolbar.
         MOVE  0 TO ls_toolbar-butn_type.
         MOVE 'SAVE' TO ls_toolbar-function.
         MOVE SPACE TO ls_toolbar-disabled.
         MOVE  icon_system_save TO ls_toolbar-icon.
         MOVE 'Save data' TO ls_toolbar-quickinfo.
         APPEND ls_toolbar TO e_object->mt_toolbar.
         CLEAR ls_toolbar.
         MOVE  0 TO ls_toolbar-butn_type.
         MOVE 'EDIT' TO ls_toolbar-function.
         MOVE  SPACE TO ls_toolbar-disabled.
         MOVE  icon_toggle_display_change TO ls_toolbar-icon.
         MOVE 'Edit data' TO ls_toolbar-quickinfo.
         MOVE  'EDIT' TO ls_toolbar-text.
         APPEND ls_toolbar TO e_object->mt_toolbar.
         CLEAR ls_toolbar.
         MOVE  0 TO ls_toolbar-butn_type.
         MOVE 'VERW' TO ls_toolbar-function.
         MOVE  SPACE TO ls_toolbar-disabled.
         MOVE   icon_businav_process to ls_toolbar-icon.
         MOVE 'Verw.' TO ls_toolbar-quickinfo.
         MOVE  'VERW' TO ls_toolbar-text.
         APPEND ls_toolbar TO e_object->mt_toolbar.
          CLEAR ls_toolbar.
         MOVE  0 TO ls_toolbar-butn_type.
         MOVE 'EXCEL' TO ls_toolbar-function.
         MOVE  SPACE TO ls_toolbar-disabled.
         MOVE  icon_xxl TO ls_toolbar-icon.
         MOVE 'Excel' TO ls_toolbar-quickinfo.
         MOVE  'EXCEL' TO ls_toolbar-text.
         APPEND ls_toolbar TO e_object->mt_toolbar.
       ENDMETHOD.
       METHOD verwerk.
          PERFORM verwerk IN PROGRAM (program).
          LEAVE PROGRAM.
      ENDMETHOD.
      METHOD dubbleklik.
      PERFORM dubbleklik IN PROGRAM (program)
        USING
            e_row
            e_column
            es_row_no.
      ENDMETHOD.
    ENDCLASS.
    Cheers
    Jimbo

    Hi Dinu,
    Before analysing ALV, please cross check the behaviour of the calling program.
    Is the control really going to the application server when you do all the above process?
    If so, when user makes some changes are they saved in the data base / affected the internal table which you are using for ALV?
    Regards
    Surya.

  • Position button at the end of ALV grid

    Hi,
    I have a requirement to place position button (like in OB52 or any table/view maintenance ) to search and position the record on the top of list. I have placed the position pushbutton with function code and have called TABLE_GET_KEY_TO_SET_CUR_ROW for the input . My alv grid doesn't show the toolbar till the records cross one page. can you please suggest 1- how to make the scrollbar visible always ? 2- How to make the position button work as in tables for ALV grid?
    Regards,
    Garima

    I have created the pushbutton in the same screen as container and assigned a function code. I have put this logic in user-command for this button and refreshed display. But it doesn't work, moreover the scrollbar is not visible if the records are less than one page.
    MODULE USER_COMMAND_0100 INPUT.
      CASE SY-UCOMM.
        WHEN '&BACK&'.
          LEAVE TO SCREEN 0.
        WHEN '&EXIT&'.
          LEAVE PROGRAM.
        WHEN '&POSI&'.
          DATA: LV_EBELN(15) TYPE C,
                IT_EXCL TYPE VIMEXCLFLD OCCURS 0,
          WA_EXCL TYPE VIMEXCLFLD,
          LV_PO TYPE EKKO-EBELN.
          DATA: LT_CELL1 TYPE TABLE OF LVC_S_ROID,
           LS_ROW_ID TYPE LVC_S_ROID,
           LS_COL_ID TYPE LVC_S_COL.
          DATA: LWA_CELL1 LIKE LINE OF LT_CELL1.
          WA_EXCL-FIELDNAME = 'MANDT'.
          APPEND WA_EXCL TO IT_EXCL.
          CALL FUNCTION 'TABLE_GET_KEY_TO_SET_CUR_ROW'
            EXPORTING
              TABLE             = 'EKKO'
            IMPORTING
              TABLE_KEY         = LV_EBELN
            TABLES
              EXCLUDE_FIELDS    = IT_EXCL
            EXCEPTIONS
              CANCELLED_BY_USER = 1
              TABLE_NOT_FOUND   = 2
              OTHERS            = 3.
          IF SY-SUBRC EQ 0.
            SHIFT LV_EBELN LEFT DELETING LEADING SPACE.
            MOVE LV_EBELN+0(10) TO LV_PO.
            READ TABLE GT_FINAL INTO WA_FINAL WITH KEY EBELN = LV_PO.
            CALL METHOD R_GRID->GET_SCROLL_INFO_VIA_ID
             iMPORTING
                ES_ROW_NO   = LS_ROW_ID
                ES_COL_INFO = LS_COL_ID.
            LS_ROW_ID-ROW_ID = sy-tabix.
            LS_COL_ID-FIELDNAME = 'EKGRP'.
            data: ls_row type LVC_S_ROW,
           ls_col type LVC_S_COL.
    ls_row-index = 2.
    CALL METHOD r_grid->set_scroll_info_via_id
       EXPORTING
         IS_ROW_INFO = ls_row
         is_col_info = ls_col.
          ENDIF.
        **Row and column of the alv are refreshed after changing values
      STABLE-ROW = 'X'.
      STABLE-COL = 'X'.
    *REfreshed ALV display with the changed values
    *This ALV is non editable and contains new values
      CALL METHOD R_GRID->REFRESH_TABLE_DISPLAY
        EXPORTING
          IS_STABLE = STABLE
        EXCEPTIONS
          FINISHED  = 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.
    Please help!!

  • Display the material details in alv grid based on material(in mara)

    hi,
    display the material details when get input of material from user in mara table using alv-grid display.
    give some examples.
    Thanks of advance.

    Hi
    For your help i am just giving you few hints.
    1. Create a selection screen.
    2. Select matnr from mara into an internal table.
    3. use fm Reuse_Alv_grid_display to display your entries from the internal table
    Please read about all of this step by step in the forum.

  • ALV GRID  and Integrated ITS 7 (SAP GUI for HTML) - dissapears on reload

    Hi All,
    We have a custom report that uses an ALV grid to display information to the user. Within this grid, there are fields that are display only and fields that are editable. Also, the grid is wider than the screen's width. It works fine in ECC. It also worked fine when we were using ITS 6.4.
    We have recently upgraded to ITS 7. Now when we run the report using a Transaction iView (in EP 7) or the Webgui service (SAP GUI for HTML), if a field that is editable has focus when an event is triggered that reloads the grid, the screen becomes blank. So, you can click the Save button and the screen goes blank, also, there are date fields in the grid and if you choose a new date, the grid reloads and the screen becomes blank.
    We have found that when the screen is blank, you can use the "Page Up" button on your keyboard and the last few columns of the grid will appear. As if the entire grid has moved off-screen to the left.
    If you click onto a non-editable field and refresh or save, the grid returns to its normal state.
    We are on Basis Patch level 15.
    Does anyone have any ideas on how to fix this?
    Also, does anyone know of a standard SAP transaction we can call from the Webgui that would have a similar setup...with an ALV grid containing editable and non-editable fields? We would like to rule out any errors in the report itself. Since it worked before we upgraded and it works fine in ECC. This would be a really big help too.
    Thank you so much!
    -Kevin

    Hi,
    Thanks Raymond, I have seen Note 314568. I could not get the second link to work but I have looked at just about every Note in reference to Integrated ITS 7 and Tables or ALV Grids and there are very many, so it would appear that SAP has had a hard time with implementing this control, but I have not seen any instance that matches the problem we are having.
    Unfortunately, SAP will not investigate this unless we can provide a standard Transaction that exhibits the same behavior.
    If anyone knows of a standard SAP Transaction that displays an ALV Grid that is wider than the screen (requiring a horizontal scroll bar) and with editable and non-editable fields, that would be fantastic. If we can test against that, then we would know for sure if this is a problem with ITS / SAP GUI for HTML, or if there is an issue with this specific report.
    Thanks!
    -Kevin

  • Dynamic table with alv rows & colums

    Hey,
    How to create dynamic internal table with alv grid rows & columns with data .

    TYPE-POOLS : abap.
    FIELD-SYMBOLS: <f_dyn_table> TYPE STANDARD TABLE,
                 <f_dyn_wa>.
    DATA: t_dy_table TYPE REF TO data,
          dy_line  TYPE REF TO data,
          wa_xfc TYPE lvc_s_fcat,
          t_ifc TYPE lvc_t_fcat.
    *get the structure
      DATA: $field        TYPE lvc_fname,
            $counter(2)   TYPE n.
      DATA: $output_field(25) TYPE c,
            $fld_len      TYPE i.
      FIELD-SYMBOLS: <f_out_field> TYPE ANY.
      DATA : $t_idetails  TYPE abap_compdescr_tab,
             $wa_xdetails TYPE abap_compdescr.
      DATA : $ref_table_des TYPE REF TO cl_abap_structdescr.
    get the structure of the table.*
      $ref_table_des ?=
          cl_abap_typedescr=>describe_by_name( c_struc ).
      $t_idetails[] = $ref_table_des->components[].
      LOOP AT $t_idetails INTO $wa_xdetails.
        CLEAR: wa_xfc, $output_field, $fld_len.
        wa_xfc-fieldname = $wa_xdetails-name .
        wa_xfc-datatype  = $wa_xdetails-type_kind.
        wa_xfc-inttype   = $wa_xdetails-type_kind.
        IF $wa_xdetails-type_kind EQ 'C'
           OR $wa_xdetails-type_kind EQ 'N'.
          CONCATENATE 'WA_OUTTAB' '-' $wa_xdetails-name
                                         INTO $output_field.
          ASSIGN ($output_field) TO <f_out_field>.
          IF <f_out_field> IS ASSIGNED.
            DESCRIBE FIELD <f_out_field> LENGTH $fld_len
                                           IN CHARACTER MODE.
            wa_xfc-intlen    = $fld_len.
          ENDIF.
        ELSE.
          wa_xfc-intlen    = $wa_xdetails-length.
        ENDIF.
        wa_xfc-decimals  = $wa_xdetails-decimals.
        APPEND wa_xfc TO t_ifc.
        CLEAR $wa_xdetails.
      ENDLOOP.
    here if you have any other fields to be added to the dynamic structure based on your requirement, you can add then and apped them to t_ifc. There is a special handling for unicode conversion- so for the numc and char fields the length is passed in a different mothed.
    create dynamic internal table and assign to fs*
      CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog           = t_ifc
          i_length_in_byte          = 'X'
        IMPORTING
          ep_table                  = t_dy_table
        EXCEPTIONS
          generate_subpool_dir_full = 1
          OTHERS                    = 2.
      IF sy-subrc <> 0.
      ELSE.
        ASSIGN t_dy_table->* TO <f_dyn_table>.
    create dynamic work area and assign to fs
        CREATE DATA dy_line LIKE LINE OF <f_dyn_table>.
        ASSIGN dy_line->* TO <f_dyn_wa>.
      ENDIF.
    *move the data into <f_dyn_wa> and then append this to output table <f_dyn_table>.
    example:-
        IF <f_dyn_wa> IS ASSIGNED AND <f_dyn_table> IS ASSIGNED.
          MOVE-CORRESPONDING wa_outtab TO <f_dyn_wa>.
    APPEND <f_dyn_wa> TO <f_dyn_table>.
    endif.
    Edited by: Krishna Adabala on Dec 2, 2008 7:57 AM

  • ALV Grid Display in Loop.

    Hello experts,
    I need your help to resolve the issue.
    I have made a report:
    On selection screen, Release group and release strategy is taken in select options:
    SELECT-OPTIONS : S_FRGGR FOR T16FS-FRGGR,
                                   S_FRGSX FOR T16FS-FRGSX.
    if s_frgsx is not initial.
    select frggr frgsx from t16fs into table i_t16fs where frggr in s_frggr and frgsx in s_frgsx.
    else.
    select frggr frgsx from t16fs into table i_t16fs where frggr in s_frggr.
    endif.
    loop at i_t16fs into wa_t16fs.
    Inside this all code is written.
    endloop.
    I have to display the output (from table CDHDR and CDPOS) same as the output of transaction CL24N but in ALV GRID DISPLAY.
    I have written all the code to fetch the values and passed final internal table to ALV GRID DISPLAY.
    The problem is :
    We can select a range of values for release group and release strategy as it is in select-options.
    For every release group, more than 10 strategies are present.
    For example :
    For release group 62, 710 release strategies are present.
    In output, I can see output of 1st strategy. When I press the back button, I can see the output of 1st strategy (but values from only CDPOS not from CDHDR) and second strategy (Both values from CDHDR and CDPOS). When I press the back button, I can see the output of 1st (but values from only CDPOS not from CDHDR), second strategy (but values from only CDPOS not from CDHDR)) and third strategy (Both values from CDHDR and CDPOS). Like this…. So on… upto 710th entry.
    I want the output of all 710 entries in single ALV GRID DISPLAY.
    What can be done?
    Regards,
    Titiksha

    Hello Manish,
    Following is some code for final internal table.
       LOOP AT I1_CDPOS ASSIGNING <FS_GT_OUTPUT_ITEM>.
        WA_FINAL-CHANGENO    = <FS_GT_OUTPUT_ITEM>-CHANGENR.
        WA_FINAL-FRGGR       = S_FRGGR.
        WA_FINAL-FRGSX       = S_FRGSX.
        WA_FINAL-CLASS       =  V_CLASS. "<FS_GT_OUTPUT_ITEM>-CLASS.  "    LIKE KLAH-CLASS,
        WA_FINAL-VALUE_OLD   = <FS_GT_OUTPUT_ITEM>-VALUE_OLD.      " LIKE AUSP-ATWRT,
        WA_FINAL-VALUE_NEW   = <FS_GT_OUTPUT_ITEM>-VALUE_NEW.
        IF WA_FINAL-VALUE_OLD IS NOT INITIAL.
          WA_FINAL-ACTION    =  'DELETED'.  "<FS_GT_OUTPUT_ITEM>-ACTION."    TYPE C,
        ELSE.
          WA_FINAL-ACTION    =  'CREATED'.
        ENDIF.
        IF WA_FINAL-VALUE_OLD IS NOT INITIAL.
          WA_FINAL-VALUE     = <FS_GT_OUTPUT_ITEM>-VALUE_OLD.
        ELSE.
          WA_FINAL-VALUE     = <FS_GT_OUTPUT_ITEM>-VALUE_NEW.
        ENDIF.
        READ TABLE I_GT_OUTPUT_HEADER ASSIGNING  <FS_GT_OUTPUT_HEADER> WITH KEY CHANGENO = <FS_GT_OUTPUT_ITEM>-CHANGENR.
        IF SY-SUBRC = 0.
          WA_FINAL-DATE  =  <FS_GT_OUTPUT_HEADER>-DATE."        LIKE CDHDR-UDATE,
          WA_FINAL-TIME  = <FS_GT_OUTPUT_HEADER>-TIME."          LIKE CDHDR-UTIME,
          WA_FINAL-USER  = <FS_GT_OUTPUT_HEADER>-USER."         LIKE CDHDR-USERNAME,
          WA_FINAL-TCODE = <FS_GT_OUTPUT_HEADER>-TCODE."          LIKE CDHDR-TCODE,
        ENDIF.
        APPEND WA_FINAL TO I_FINAL.
        UNASSIGN <FS_WA_FINAL>.
        READ TABLE I_FINAL ASSIGNING <FS_WA_FINAL> WITH KEY CHANGENO  = <FS_GT_OUTPUT_ITEM>-CHANGENR
                                                            VALUE_OLD = <FS_GT_OUTPUT_ITEM>-VALUE_OLD
                                                            VALUE_NEW = <FS_GT_OUTPUT_ITEM>-VALUE_NEW.
        IF SY-SUBRC EQ 0.
          UNASSIGN <FS_WA_CABNT>.
          READ TABLE I_CABNT ASSIGNING <FS_WA_CABNT> WITH KEY ATINN = <FS_GT_OUTPUT_ITEM>-TABKEY+18(10).
          IF SY-SUBRC EQ 0.
            <FS_WA_FINAL>-ATBEZ = <FS_WA_CABNT>-ATBEZ.
          ENDIF.
        ENDIF.
      ENDLOOP.
    And I_FINAL is passed to ALV.
    Here the line which is in BOLD and UNDERLINED, data after that is getting displayed only for the last value of Realese strategy and release group, not for others.
    Please help.
    Regards,
    Titiksha

Maybe you are looking for