How to populate field catalogue fields in ALV using  dynamic internal table

Hi All,
Please let me know how to populate field catalogue fields in ALV using  dynamic internal table.
I have created <dyn_table> using code below.
CALL METHOD cl_alv_table_create=>create_dynamic_table
                 EXPORTING
                   it_fieldcatalog = g_t_ifc
                    it_fieldcatalog = g_t_fieldcat
                 IMPORTING
                    ep_table        = dy_table.
  ASSIGN dy_table->* TO <dyn_table>.
Create dynamic work area and assign to FS
  CREATE DATA dy_line LIKE LINE OF <dyn_table>.
  ASSIGN dy_line->* TO <dyn_wa>.
Now this  <dyn_table>  has fields like idoc no.,creation date ,
segment field 1, segment field 2 etc..Now idoc no.,creation date  are static fields from table EDIDC. And segment field 1, segment field 2 etc are dynamic fields from table EDSAPPL.
In my  ALV report I am getting the final layout properly but I am unable to move values to corresponding fields in the final layout shown.Please let me know how to populate these fields from different tables.
I tried this way but its not working.
SORT g_t_edid4 BY docnum.
  LOOP AT g_t_edidc INTO g_r_edidc.
    READ TABLE g_t_edid4 into g_r_edid4
                     WITH KEY docnum = g_r_edidc-docnum
                                    BINARY SEARCH.
    IF sy-subrc = 0.
      <dyn_wa> =  g_r_edid4-sdata.
     MOVE-CORRESPONDING g_r_edid4 to <dyn_wa>.
   CLEAR g_r_edid4.
    ENDIF.
MOVE-CORRESPONDING g_r_edidc to <dyn_wa>.
APPEND <dyn_wa> TO <dyn_table>.

You have to assign each field to field symbol and then assign the value to that field symbol and asssign that field symbol to workarea field symbol.
LOOP AT g_t_edidc INTO g_r_edidc.
READ TABLE g_t_edid4 into g_r_edid4
WITH KEY docnum = g_r_edidc-docnum
BINARY SEARCH.
IF sy-subrc = 0.
ASSIGN COMPONENT 'SDATA' OF STRUCTURE <DYN_WA> TO <DYN_FLD>.
<DYN_FLD> = g_r_edid4-sdata.
" <dyn_wa> = g_r_edid4-sdata.
" Assign each fields like this.
" MOVE-CORRESPONDING g_r_edid4 to <dyn_wa>.
CLEAR g_r_edid4.
ENDIF.
" MOVE-CORRESPONDING g_r_edidc to <dyn_wa>.
APPEND <dyn_wa> TO <dyn_table>.
Regards,
Naimesh Patel

Similar Messages

  • Problem disalying alv using dynamic internal table

    Hi All,
        I have 4 radiobutton for each radiobutton there is one internaltable to be displayed in alv.
    My requirement is intead of calling the function module reuse_alv_grid_display everytime for
    each of the internal table I want to create a dynamic internal tble for the function module.
       My question is how to create a dynamic internal table which will hold the fields & data of
    different interna table when diffrent radiobuttons are checked.
       Areciate your time to help.
       Thank you very much.

    Hi follow following logic:
    field-symbols: <i_table> type standard table.
    when rb1 is checked.
    assign itab1 to <i_table>.
    perform alv_disp using <i_table>
    when rb2 is checked.
    assign itab2 to <i_table>.
    perform alv_disp using <i_table>
    when rb3 is checked.
    assign itab3 to <i_table>.
    perform alv_disp using <i_table>
    when rb4 is checked.
    assign itab4 to <i_table>.
    perform alv_disp using <i_table>
    <<<<<<<<<<form alv_disp
    form alv_disp  using p_i_table type standard table.
    perform create fieldcatelog changing i_fc
    call the fm and pass the table p_i_table and i_fc
    <<<<<<<<<< form create fieldcaelog
    here create field catelog ..either by fm reuse_alv_fieldcatelog_merge ...in this just pass the structure name based on the radiobutton
    hope its useful

  • No column text displayed in alv when i use dynamic internal table

    Hi friends,
    when I use dynamic internal table to display the fields in ALV formant, field column text was not displaying ,
    total row of column text was blank.
    can u sujjest me in this...
    with regards,
    prasad.

    Hi
    That depends on how you've filled the catalog table, here u need to insert the description for the labels (short, medium and long) and the description for the layout variant management.
    So u make sure to fill the fields like
    SCRTEXT_L
    SCRTEXT_M
    SCRTEXT_S
    REPTEXT
    Max

  • Problem with grid display in ALV for dynamic internal tables

    Hi,
    I am using dynamic internal tables in my program. To display it in grid format after populating it, I have used the following class and method. Here Im getting sy-subrc = 0 but, the grid is not getting displayed. Can some one pls help me with this.,
    DATA: W_GRID TYPE REF TO CL_GUI_ALV_GRID.
    DATA: w_tabname TYPE w_tabname.
    CREATE OBJECT W_GRID
    EXPORTING I_PARENT = CL_GUI_CONTAINER=>SCREEN0.
    CALL METHOD W_GRID->SET_TABLE_FOR_FIRST_DISPLAY
      EXPORTING
       I_BUFFER_ACTIVE               =
       I_BYPASSING_BUFFER            =
       I_CONSISTENCY_CHECK           =
        I_STRUCTURE_NAME              = W_TABNAME
       IS_VARIANT                    =
       I_SAVE                        =
       I_DEFAULT                     = 'X'
       IS_LAYOUT                     =
       IS_PRINT                      =
       IT_SPECIAL_GROUPS             =
       IT_TOOLBAR_EXCLUDING          =
       IT_HYPERLINK                  =
       IT_ALV_GRAPHICS               =
       IT_EXCEPT_QINFO               =
       IR_SALV_ADAPTER               =
      CHANGING
        IT_OUTTAB                     = <FS_1>
        IT_FIELDCATALOG               = LT_FIELDCATALOG2
       IT_SORT                       =
       IT_FILTER                     =
      EXCEPTIONS
        INVALID_PARAMETER_COMBINATION = 1
        PROGRAM_ERROR                 = 2
        TOO_MANY_LINES                = 3
        others                        = 4
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
               WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    Here, <FS_1> is the field symbol of table type and it holds all my data. and LT_FIELDCATALOG2  is the structure of my fieldcatalog
    Thanks and Regards,
    Avinash

    Hi Avinash,
    Either use parameter
    I_STRUCTURE_NAME = W_TABNAME
    or
    IT_FIELDCATALOG = LT_FIELDCATALOG2
    Both are not required.
    At the end of ur program simply use a write statement like below. Your program will work.
    IF SY-SUBRC 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    Write /.      <----
    Thanks,
    Edited by: Sap Fan on Oct 6, 2009 7:17 AM

  • Display ALV GRID Using Dynamic Internal Table

    Hi all,
    I try to display ALV Grid using Dynamic Internal Table, but when i activate my program, i get an error message "DYN_TABLE" is not type-compatible with formal parameter "IT_OUTTAB". ( DYN_TABLE is my Dynamic Itab).
    Anybody can help me how to passing Dynamic Itab into ALV Grid ?? Of ALV Grid only accept static Itab ??
    Thanks,

    Hi Vijay,
    It's doesn't work, and make new error "Formal parameter "IT_OUTTAB[]" does not exist. However, the parameter "IT_OUTTAB" has a similar name."
    Because the method is:
    CALL METHOD <ref. var. to CL_GUI_ALV_GRID>->set_table_for_first_display
    EXPORTING
    I_BUFFER_ACTIVE = <any type (ANY)>
    I_STRUCTURE_NAME = <string of type DD02L-TABNAME>
    IS_VARIANT = <structure of type DISVARIANT>
    I_SAVE = <var. of type CHAR01>
    I_DEFAULT = <var. of type CHAR01>
    IS_LAYOUT = <structure of type LVC_S_LAYO>
    IS_PRINT = <structure of type LVC_S_PRNT>
    IT_SPECIAL_GROUPS = <internal table of type LVC_T_SGRP>
    IT_TOOLBAR_EXCLUDING = <internal table of type UI_FUNCTIONS>
    IT_HYPERLINK = <internal table of type LVC_T_HYPE>
    IT_ALV_GRAPHICS = <internal table of type DTC_T_TC>
    CHANGING
    IT_OUTTAB = <internal table>
    IT_FIELDCATALOG = <internal table of type LVC_T_FCAT>
    IT_SORT = <internal table of type LVC_T_SORT>
    IT_FILTER = <internal table of type LVC_T_FILT>
    Thanks,

  • Alv grid using dynamic internal table

    hi i have an internal table
    begin of itab
    equipno like equi-equnr,
    reading like imrg-readg
    uom like imrg-uom
    date like imrg-date
    end of itab.
    and many more fields  in this table the reading, date, uom are dynamic its not fixed there can be five readings and 6 reading etc
    if i get all the data populated into final table  itab. how to display it throgh the alv grid
    i can use fieldsymbols i have seen some documents i want to know how to populate the fieldname s of the dynamic internal table to the field catalog and the values of the dynamic internal table .its a alv grid display pls guide

    Hi,
    Before displaying the records in ALV, you integrate all the fields (Fixed fields as well as variable fields) into one table. To do so you need create one dynamic table. If you already created this dynamic table then in the same way (same sequence) you need to populate the field catalog and use normal FM REUSE_ALV_GRID_DISPLAY to display it.
    If you not aware of how to create this dynamic internal table, please check the below way.
    1. Populate the fixed field into one field catalog(NB. this to create dyn table not ALV).
    *--- Cons Unit
      wa_lvc_cat-fieldname = c_cons.       
      wa_lvc_cat-ref_field = c_rbunit.      
      wa_lvc_cat-ref_table = c_ecmca.   
      append wa_lvc_cat to it_lvc_cat.    
    *--- account description
      wa_lvc_cat-fieldname = c_acctd.
      wa_lvc_cat-ref_field = c_txtmi.
      wa_lvc_cat-ref_table = c_tf101.
      append wa_lvc_cat to it_lvc_cat.
    2. For variable fields you have your own logic based on which you need to display the output. (like loop at one table and make each field as one column). Here one thing need to make sure every time field name should be different. You know in one structure there are 2 fields with same name is not allowed.
    3. next use the below method to create the internal table
    Create a new Table
      call method cl_alv_table_create=>create_dynamic_table
        exporting
          it_fieldcatalog = it_lvc_cat
        importing
          ep_table        = it_new_table.
    Create a new Line with the same structure of the table.
      assign it_new_table->* to <l_table>. " internal table
      create data wa_new_line like line of <l_table>.
      assign wa_new_line->* to <l_line>.  " Work area
    4. To populate the field catalog for ALV use the same sequence. Better while you populated it_lvc_cat for dynamic table also create one lookup table with three fields. (fieldname, Text, col_pos). Here loop into this look up table and populate the ALV field catalog.
    5. Display it using REUSE_ALV_GRID_DISPLAY
    call function 'REUSE_ALV_GRID_DISPLAY'
        exporting
          i_callback_program      = c_rep_name
          i_callback_user_command = 'F_USER_DOUBLE_CLICK'       "SD0K963313
          is_layout               = l_wa_layout
          it_fieldcat             = it_fieldcat
          it_sort                 = it_sort
          i_save                  = l_save
          is_variant              = wa_variant1
          it_events               = it_events
        tables
          t_outtab                = <l_table>
        exceptions
          program_error           = 1
          others                  = 2.
    Thanks
    Subhankar

  • How to use dynamic internal table when using gui_upload?

    Hi Experts,
    my scenario is like i have header data, item data and serial numbers.
    so with respect to the  quantity in unit of measure ,there will be number of serial numbers..
    i have declared the dynamic internal table,but i am not getting the logic to change the structure accordingly with respect to the flat file entries..
    is it possible to do or its not possible....any suggestion!!!!i have declared like this....
    TYPES: BEGIN OF ty_final,
          bldat TYPE string,      "Document Date
          budat TYPE string,      "Psting Date
          bktxt TYPE string,      "Document Header Text
          werks TYPE string,      "Plant
          lgort TYPE string,      "Storage Location
          matnr TYPE string,      "Material Number
          erfmg TYPE string,      "Quantity in Unit Of Entry
          anln1 TYPE string,      "Asset Number
          anln2 TYPE string,      "Asset Subnumber
          sernr TYPE string,      "serial Number
    END OF ty_final.
    DATA : it_final TYPE TABLE OF ty_final,
           wa_final TYPE ty_final.
    FIELD-SYMBOLS : <fs_final> TYPE table.
    ASSIGN it_final TO <fs_final>.
    after this i called gui upload and passed internal table it_final..
    but i have to change the internal table structure dynamically before the upload function.so that it will match with the flat file...
    Regards
    Karthick

    There are at least two approaches you can use to change/generate new dynamic-structured table. Either with [RTTI + RTTS|https://wiki.sdn.sap.com/wiki/display/Snippets/CreatingFlatandComplexInternalTablesDynamicallyusingRTTI] or using [CL_ALV_TABLE_CREATE|http://www.sdn.sap.com/irj/scn/advancedsearch?query=cl_alv_table_create] . In this one just determine fieldcatalog of current table and change it accordingly, then regenarate table.
    There are plenty of examples in SCN for this. You should not face difficulties applying this.
    Regards
    Marcin

  • How to use dynamic internal table with FOR ALL ENTRIES

    Hello SDNers,
    I am having a dynamic internal table & want to use FOR ALL ENTRIES(FAE) using this dyn. table.
    This works fine for me:
    IF <lt_tmp> IS NOT INITIAL. "<lt_tmp> is my dyn. internal table
            SELECT field1 field2
              FROM TABLE ztable
              INTO TABLE itab "Itab is a static table
              FOR ALL ENTRIES IN <lt_tmp>
              WHERE (lv_dynwhere). "lv_dynwhere -> dynamic where clause
          ENDIF.
    SAP documentation says:
    "The logical expression sql_cond of the WHERE condition can be comprised of several logical expressions using AND and OR. However, if FOR ALL ENTRIES is specified, there must be at least one comparison with a column of the internal table itab that can be specified statically or dynamically. "
    How do we specify the column of the internal table dynamically ? Can we do something like this:
    IF <lt_tmp> IS NOT INITIAL. "<lt_tmp> is my dyn. internal table
            SELECT field1 field2
              FROM TABLE
              INTO TABLE itab "Itab is a static table
              FOR ALL ENTRIES IN <lt_tmp>
              WHERE key_field1 = (dynamic token for column1 of <lt_tmp>)
                           key_field2 = (dynamic token for column2 of <lt_tmp>)
          ENDIF.
          ENDIF.
    Let me know if i am not clear about my requirement.
    BR,
    Suhas

    Hello Thomas,
    What i meant was something like this:
    WHERE key_field1 = ('<LT_TMP-COL1>') AND
          key_field2 = ('<LT_TMP-COL2>')
    I am confused by what SAP means with "dynamic representation of internal table columns" in FAE ?
    @Rob: I was referring to SAPNW 7.0 documentation & the phrase (release 6.40 & higher) is missing. Anyways fyi i am on ECC5.0 ABAP release 6.40.
    @Subhankar: This is what Marcin had proposed in For all entries and dynamic table.
    Thanks,
    Suhas
    Edited by: Suhas Saha on Apr 6, 2010 11:53 AM

  • How to use Dynamic Internal table

    Hello,
    I have a requirement where I need to pick a field from final internal table and display that field as ALV columns and I have to pick another field in the same INternal table to display it as a corresponding value for each header DYNAMICALLY.
    lw_fieldcat-col_pos = 1.
      lw_fieldcat-tabname = 'T_FINAL'.
      lw_fieldcat-fieldname = 'ATTR20A'.
      lw_fieldcat-seltext_m = 'SUBSTANCE ID'.
      lw_fieldcat-outputlen = '21'.
      lw_fieldcat-fix_column = 'X'.
      lw_fieldcat-key = 'X'.
      APPEND lw_fieldcat TO lt_fieldcat.
      CLEAR LW_FIELDCAT.
      lw_fieldcat-col_pos = 2.
      lw_fieldcat-tabname = 'T_FINAL'.
      lw_fieldcat-fieldname = 'PRVSY'.
      lw_fieldcat-seltext_m = 'R3 MAT NBR'.
      lw_fieldcat-outputlen = '14'.
      lw_fieldcat-FIX_COLUMN = 'X'.
      lw_fieldcat-key = 'X'.
      APPEND lw_fieldcat TO lt_fieldcat.
      CLEAR LW_FIELDCAT.
    These 2 fields are constant, now i need to display fields dynamically from the field STCTS (for dynamic header) CCNGN (for the value in each header)
    In the below code the logic is working to pick appropriate value for each header.
    DATA : Y_I_FCAT  TYPE LVC_T_FCAT,
          Y_WA_FCAT LIKE LINE OF Y_I_FCAT.
    DATA : T_NEWFINAL TYPE STANDARD TABLE OF TY_FINAL,
           WA_NEWFINAL TYPE TY_FINAL.
    LOOP AT T_FINAL INTO WA_FINAL
                  WHERE STCTS IS NOT INITIAL
    CONCATENATE 'SUBID CLASSIFICATION-' WA_FINAL-STCTS
                       INTO Y_WA_FCAT-FIELDNAME.
                       INTO Y_WA_FCAT-SCRTEXT_M.
      APPEND Y_WA_FCAT TO Y_I_FCAT. "Header of column appear as
                                    'SUBID SUBID CLASSIFICATION-AR-HTS'
      CLEAR Y_WA_FCAT.
    MOVE WA_FINAL-CCNGN TO WA_NEWFINAL-CCNGN.  "HERE IT WILL PICK THE VALUE FOR THE ABOVE                                             " HEADER EX : '2345'
    *&THIS STATEMENT WILL MOVE THE KEY FIELD TO
    *&WA_NEWFINAL.
    MOVE WA_FINAL-GUID_PR TO WA_NEWFINAL-GUID_PR.
      APPEND WA_NEWFINAL TO T_NEWFINAL.
      CLEAR : WA_FINAL,
              WA_NEWFINAL.
    ENDLOOP.
    How should i pass it to the dynamic interanl table and then to the ALV grid filed catlog.
    Below is my code for refernce :
    **DATA : Y_I_FCAT  TYPE LVC_T_FCAT,
          Y_WA_FCAT LIKE LINE OF Y_I_FCAT.
          Y_WA_FCAT TYPE LVC_S_FCAT.
    **DATA : T_NEWFINAL TYPE STANDARD TABLE OF TY_FINAL,
          WA_NEWFINAL TYPE TY_FINAL.
    *DATA : W_STRING TYPE STRING.
    DATA : WA_FLNAME(32) TYPE C.
    *LOOP AT T_FINAL INTO WA_FINAL
                 WHERE STCTS IS NOT INITIAL
                   AND CCNGN IS NOT INITIAL.
    *ADD 1 TO COUNTER.
    *ENDLOOP.
    *DO COUNTER TIMES.
    LOOP AT T_FINAL INTO WA_FINAL
                  WHERE STCTS IS NOT INITIAL
                    AND CCNGN IS NOT INITIAL.
    CONCATENATE 'SUBID CLASSIFICATION-' WA_FINAL-STCTS
                      INTO Y_WA_FCAT-FIELDNAME.
                       INTO Y_WA_FCAT-SCRTEXT_M.
                        INTO WA_FLNAME.
       Y_WA_FCAT-FIELDNAME = WA_FLNAME.
       Y_WA_FCAT-SELTEXT = WA_FLNAME.
      APPEND Y_WA_FCAT TO Y_I_FCAT.
      CLEAR Y_WA_FCAT.
    MOVE WA_FINAL-CCNGN TO W_STRING.
    MOVE WA_FINAL-CCNGN TO WA_NEWFINAL-CCNGN.
    *&THIS STATEMENT WILL MOVE THE KEY FIELD TO
    *&WA_NEWFINAL.
    MOVE WA_FINAL-GUID_PR TO WA_NEWFINAL-GUID_PR.
      APPEND WA_NEWFINAL TO T_NEWFINAL.
      CLEAR : WA_FINAL,
              WA_NEWFINAL.
    ENDIF.
    *ENDDO.
    ENDLOOP.
    PERFORM CREATE_DYNAMIC_ITAB.
    LOOP AT Y_I_FCAT INTO Y_WA_FCAT. "IT_FIELDCAT INTO LW_FIELDCAT.
    MOVE :  Y_WA_FCAT-SCRTEXT_M TO LW_FIELDCAT-SELTEXT_M,
            Y_WA_FCAT-FIELDNAME TO LW_FIELDCAT-FIELDNAME,
           Y_WA_FCAT-TABNAME   TO LW_FIELDCAT-TABNAME,
           Y_WA_FCAT-COL_POS   TO LW_FIELDCAT-COL_POS,
            Y_WA_FCAT-SCRTEXT_M TO LW_FIELDCAT-SELTEXT_M.
           Y_WA_FCAT-DATATYPE  TO LW_FIELDCAT-DATATYPE,
           Y_WA_FCAT-INTLEN    TO LW_FIELDCAT-INTLEN.
    APPEND LW_FIELDCAT TO LT_FIELDCAT.
    ENDLOOP.
    ENDFORM.                    " DYNAMIC
    *&      Form  CREATE_DYNAMIC_ITAB
          text
    -->  p1        text
    <--  p2        text
    FORM CREATE_DYNAMIC_ITAB .
    *DATA : DY_TABLE TYPE REF TO DATA,
          DY_LINE TYPE REF TO DATA.
    DATA : Y_LV_COMP TYPE STRING.
    *FIELD-SYMBOLS: <DYN_TABLE> TYPE STANDARD TABLE,
                  <DYN_WA>,
                  <DYN_FIELD>.
    *FIELD-SYMBOLS : <y_fld> TYPE ANY.
    CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
      EXPORTING
        IT_FIELDCATALOG           = Y_I_FCAT
      IMPORTING
        EP_TABLE                  = DY_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 DY_TABLE->* TO <DYN_TABLE>.
    *CREATE DYNAMIC WORK AREA AND ASSIGN TO FS.
    CREATE DATA DY_LINE LIKE LINE OF <DYN_TABLE>.
    ASSIGN DY_LINE->* TO <DYN_WA>.
    LOOP AT T_FINAL INTO WA_FINAL.
      Y_LV_COMP = 'ATTR20A'.
      ASSIGN COMPONENT Y_LV_COMP OF STRUCTURE <DYN_WA> TO <Y_FLD>.
       <Y_FLD> = WA_FINAL-ATTR20A.
       Y_LV_COMP = 'PRVSY'.
       ASSIGN COMPONENT Y_LV_COMP OF STRUCTURE <DYN_WA> TO <Y_FLD>.
       <Y_FLD> = WA_FINAL-PRVSY.
       Y_LV_COMP = 'PRTXT'.
       ASSIGN COMPONENT Y_LV_COMP OF STRUCTURE <DYN_WA> TO <Y_FLD>.
       <Y_FLD> = WA_FINAL-PRVSY.
       Y_LV_COMP = 'GRVSY'.
       ASSIGN COMPONENT Y_LV_COMP OF STRUCTURE <DYN_WA> TO <Y_FLD>.
       <Y_FLD> = WA_FINAL-GRVSY.
    LOOP AT T_NEWFINAL INTO WA_NEWFINAL
          WHERE GUID_PR = WA_FINAL-GUID_PR.
    CONCATENATE 'SUBID Classification-'
                  WA_FINAL-STCTS
                   INTO Y_LV_COMP.
      ASSIGN COMPONENT Y_LV_COMP OF STRUCTURE <DYN_WA> TO <Y_FLD>.
          <Y_FLD> = WA_NEWFINAL-CCNGN.
    ENDLOOP.
    APPEND <DYN_WA> TO <DYN_TABLE>.
    FREE : <DYN_WA>, <Y_FLD>.
    ENDLOOP.
    ENDFORM.                    " CREATE_DYNAMIC_ITA
    ANy suggestion would be apprecaited.
    Regards,
    Kittu

    I think I need to put it in more descriptive way...
    I am closing this thread

  • How to use dynamic internal table in interactive report syntax

    pls let me know

    Hi Aarif,
    Go through the below code for better understanding:
    *& Report  ZDYN_INT_TABLE_02                                           *
    REPORT  ZDYN_INT_TABLE_02.
    TYPE-POOLS: slis.                      " ALV Global types
    SELECTION-SCREEN BEGIN OF BLOCK b1.
    PARAMETERS : p_max(3) TYPE n OBLIGATORY.
    SELECTION-SCREEN END OF BLOCK b1.
    TYPES: BEGIN OF wa_gt_data,
              matnr TYPE mara-matnr,
           END OF wa_gt_data.
    DATA gt_data TYPE STANDARD TABLE OF wa_gt_data WITH HEADER LINE.
    *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 matnr INTO TABLE gt_data
               FROM mara
                 UP TO p_max ROWS.
    ENDFORM.                               " F_READ_DATA
         Form  F_DISPLAY_DATA
    FORM f_display_data.
      DATA:
        l_column    TYPE sy-tabix,
        lp_struct   TYPE REF TO data,
        lp_table    TYPE REF TO data,      " Pointer to dynamic table
        ls_lvc_cat  TYPE lvc_s_fcat,
        lt_lvc_cat  TYPE lvc_t_fcat,       " Field catalog
        lt_fcat     TYPE slis_t_fieldcat_alv,  " Field catalog
        ls_fieldcat TYPE slis_fieldcat_alv,
        lt_fieldcat TYPE slis_t_fieldcat_alv,  " Field catalog
        ls_layout   TYPE slis_layout_alv.
      FIELD-SYMBOLS :
        <header>       TYPE ANY,
        <field_header> TYPE ANY,
        <field_mara>  TYPE ANY,
        <lt_data>      TYPE table.         " Data to display
      ls_lvc_cat-fieldname = 'COLUMNTEXT'.
      ls_lvc_cat-ref_table = 'LVC_S_DETA'.
      APPEND ls_lvc_cat TO lt_lvc_cat.
      ls_fieldcat-fieldname = 'COLUMNTEXT'.
      ls_fieldcat-ref_tabname = 'LVC_S_DETA'.
      ls_fieldcat-key  = 'X'.
      APPEND ls_fieldcat TO lt_fieldcat.
      DO p_max TIMES.
      For each line, a column 'VALUEx' is created in the fieldcatalog
      Build Fieldcatalog
       WRITE sy-index TO ls_lvc_cat-fieldname LEFT-JUSTIFIED.
        CONCATENATE 'VALUE' ls_lvc_cat-fieldname
               INTO ls_lvc_cat-fieldname.
        ls_lvc_cat-ref_field = 'VALUE'.
        ls_lvc_cat-ref_table = 'LVC_S_DETA'.
        APPEND ls_lvc_cat TO lt_lvc_cat.
      Build Fieldcatalog
        CLEAR ls_fieldcat.
        ls_fieldcat-fieldname = ls_lvc_cat-fieldname.
        ls_fieldcat-ref_fieldname = 'VALUE'.
        ls_fieldcat-ref_tabname = 'LVC_S_DETA'.
        APPEND ls_fieldcat TO lt_fieldcat.
      ENDDO.
    Create internal table
      CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog = lt_lvc_cat
        IMPORTING
          ep_table        = lp_table.
      ASSIGN lp_table->* TO <lt_data>.
    Create structure = structure of the internal table
      CREATE DATA lp_struct LIKE LINE OF <lt_data>.
      ASSIGN lp_struct->* TO <header>.
    Create field catalog from dictionary structure
      CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
        EXPORTING
          i_structure_name       = 'MARA'
        CHANGING
          ct_fieldcat            = lt_fcat
        EXCEPTIONS
          inconsistent_interface = 1
          program_error          = 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.
      LOOP AT lt_fcat INTO ls_fieldcat WHERE fieldname = 'MATNR'.
        ASSIGN COMPONENT 1 OF STRUCTURE <header> TO <field_header>.
        IF sy-subrc NE 0. EXIT .ENDIF.
        READ TABLE lt_fcat INTO ls_fieldcat INDEX sy-index.
        <field_header> = ls_fieldcat-seltext_m.
        IF <field_header> IS INITIAL.
          <field_header> = ls_fieldcat-fieldname.
        ENDIF.
        LOOP AT gt_data.
          l_column = sy-tabix + 1.
          ASSIGN COMPONENT 1 OF STRUCTURE gt_data TO <field_mara>.
          IF sy-subrc NE 0. EXIT .ENDIF.
          ASSIGN COMPONENT l_column OF STRUCTURE <header> TO <field_header>.
          IF sy-subrc NE 0. EXIT .ENDIF.
          WRITE <field_mara> TO <field_header> LEFT-JUSTIFIED.
        ENDLOOP.
        APPEND <header> TO <lt_data>.
      ENDLOOP.
      ls_layout-colwidth_optimize = 'X'.
      ls_layout-no_colhead = 'X'.
      ls_layout-zebra = 'X'.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          is_layout   = ls_layout
          it_fieldcat = lt_fieldcat
        TABLES
          t_outtab    = <lt_data>.
    ENDFORM.                               " F_DISPLAY_DATA
    END OF PROGRAM Z_ALV_LIST_TRANSPOSED *********************
    *Always reward point for helpful answers
    Regards,
    Amit

  • How to append contents of a local object to dynamic internal table ?

    Dear ABAP-Specialists,
    i am trying to append contents of a local object to a dynamic table. The most relevant lines are the ones written in bold
    I guess the append is the problem due to the reason that a unknown format has to be assigned to a fixed format somehow.
    +METHOD wddomodifyview .+
      +DATA lo_ui_root                TYPE REF TO  if_wd_view_element.+
      +DATA lo_container              TYPE REF TO  cl_wd_uielement_container.+
      +DATA lo_table                  TYPE REF TO  cl_wd_table.+
      +DATA lo_table_column           TYPE REF TO  cl_wd_table_column.+
      +DATA lv_tabname                TYPE         tabname.+
      +DATA lt_output                 TYPE TABLE OF sychar512.+
      +DATA lo_data TYPE REF TO data.+
      +DATA:+
        +lo_node_output_data                    TYPE REF TO if_wd_context_node,+
        +lo_node_table_list                     TYPE REF TO if_wd_context_node,+
        +lo_node_differences                    TYPE REF TO if_wd_context_node,+
        +lo_node_output                         TYPE REF TO if_wd_context_node,+
        +lt_all_elem_differences                TYPE        wdr_context_element_set,+
        +lo_elem_table_list                     TYPE REF TO if_wd_context_element,+
        +lo_elem_differences                    TYPE REF TO if_wd_context_element,+
        +ls_differences                         TYPE        if_table_differences=>element_differences,+
        +lt_differences                         TYPE STANDARD TABLE OF if_table_differences=>element_differences.+
      +FIELD-SYMBOLS:+
                     +<ls_output> TYPE ANY,+
                     +<lt_output> TYPE ANY TABLE.+
    +     ....+
        +*CREATE DATA lo_data TYPE TABLE OF (lv_tabname).*+
        +*ASSIGN lo_data->* TO <lt_output>.*+
        +*LOOP AT lt_differences INTO ls_differences.*+
    +**      APPEND ls_differences-ct_line TO lo_data->*.*+
        +*ENDLOOP.*     ....+
    +ENDMETHOD.+
    Thanks a lot in advance for your Ideas.
    Best regards
    Carsten Klatt
    Please post in the correct forum and use code tags to format your code
    Edited by: Rob Burbank on Oct 1, 2010 1:27 PM

    This might help - you should not reference the data reference directly:
    DATA: lt_t001 TYPE TABLE OF t001,
          ls_t001 TYPE t001.
    DATA: lr_dref    TYPE REF TO data.
    DATA: lv_tabname TYPE tabname.
    FIELD-SYMBOLS: <lfs>      TYPE table,
                   <lfs_line> TYPE ANY.
    lv_tabname = 'T001'.
    TRY.
        CREATE DATA lr_dref TYPE TABLE OF (lv_tabname).
        ASSIGN lr_dref->* TO <lfs>.
      CATCH cx_sy_create_data_error.
    *     Do something
    ENDTRY.
    SELECT * FROM t001 INTO TABLE lt_t001.
    LOOP AT lt_t001 INTO ls_t001.
      ASSIGN ls_t001 TO <lfs_line>.
      APPEND <lfs_line> TO <lfs>.
    ENDLOOP.

  • Dynamic Alv for Dynamic Internal Table

    Hi All,
    I am new for abap dynpro.
    How can i create a dynamic alv table in abap dynpro withoud ddic structure??
    My requirement is as follows:
    I have a table having some field e.g MATNR WERKS NETWR.
    I want to pivot data werks and to display in webdynpro alv.
    Thnx:
    N. N. Tiwari

    You can use the RTTI to build up a dynamic structure in memory:
    Something like this - where both the data and its structure and meta data all come from an external source (which happens to be MDM in this case):
    ****ALV
          data:
             rootnode_info type ref to if_wd_context_node_info,
             dyn_node type ref to if_wd_context_node,
             dyn_node_info type ref to if_wd_context_node_info,
             tabname_node type ref to if_wd_context_node,
             current_tablename type string,
             tablename type string,
             struct_type type ref to cl_abap_structdescr,
              table_type  type ref to cl_abap_tabledescr,
              comp_tab    type cl_abap_structdescr=>component_table,
              comp        like line of comp_tab,
              my_table    type ref to data,
              my_row      type ref to data.
          field-symbols: <table> type table,
                         <row> type data,
                         <f>   type any,
                         <wa_string>     type string,
                         <wa_date_time>  type mdm_cdt_date_time,
                         <wa_integer>    type mdm_gdt_integervalue.
          rootnode_info = wd_context->get_node_info( ).
    * create subnode_info
          try.
              rootnode_info->remove_child_node( 'MDM_DATA' ).
            catch cx_wd_context.
          endtry.
          field-symbols <wa_detail> like line of field_details.
          field-symbols <wa_result> like line of result_set.
          field-symbols <wa_pair>   type mdm_name_value_pair.
          read table result_set assigning <wa_result> index 1.
          loop at field_details assigning <wa_detail>.
    * build a structure description from the list of single fields
            if strlen( <wa_detail>-field_code ) > 30.
              comp-name = <wa_detail>-field_code+0(30).
            else.
              comp-name = <wa_detail>-field_code.
            endif.
            if <wa_result> is assigned.
              read table <wa_result>-name_value_pairs assigning <wa_pair>
                            with key code = <wa_detail>-field_code.
              if sy-subrc = 0.
                case <wa_pair>-type.
                  when `MDM_CDT_DATE_TIME`.
                    comp-type ?= cl_abap_datadescr=>describe_by_name( 'TZNTSTMPL' ).
                  when `MDM_GDT_INTEGERVALUE`.
                    if <wa_detail>-field_lookup_table is not initial.
                      comp-type ?= cl_abap_datadescr=>describe_by_name( 'STRING' ).
                    else.
                      comp-type ?= cl_abap_datadescr=>describe_by_name( 'INT4' ).
                    endif.
                  when others.
                    comp-type ?= cl_abap_datadescr=>describe_by_name( <wa_pair>-type ).
                endcase.
              else.
                comp-type ?= cl_abap_datadescr=>describe_by_name( 'STRING' ).
              endif.
            else.
              comp-type ?= cl_abap_datadescr=>describe_by_name( 'STRING' ).
            endif.
            append comp to comp_tab.
          endloop.
          struct_type = cl_abap_structdescr=>create( comp_tab ).
          dyn_node_info = rootnode_info->add_new_child_node(
             name                   = 'MDM_DATA'
             is_mandatory           = abap_false
             is_mandatory_selection = abap_false
             static_element_rtti    = struct_type
             is_multiple            = abap_true
             is_static              = abap_false ).
    *  get instance of new node
          dyn_node = wd_context->get_child_node( name = 'MDM_DATA' ).
    ****Process Table Data
          data content_string type string.
          data l_tabix type sytabix.
          table_type = cl_abap_tabledescr=>create( p_line_type = struct_type ).
          create data my_table type handle table_type.
          assign my_table->* to <table>.
          loop at result_set assigning <wa_result>.
            create data my_row type handle struct_type.
            assign my_row->* to <row>.
            loop at field_details assigning <wa_detail>.
              l_tabix = sy-tabix.
              read table <wa_result>-name_value_pairs assigning <wa_pair>
                                      with key code = <wa_detail>-field_code.
    *        loop at <wa_result>-name_value_pairs assigning <wa_pair>.
              if sy-subrc = 0 and <wa_pair>-value is not initial.
                assign component l_tabix of structure <row> to <f>.
    *            READ TABLE field_details ASSIGNING <wa_detail> INDEX sy-tabix.
                case <wa_pair>-type.
                  when 'STRING'.
                    assign <wa_pair>-value->* to <wa_string>.
                    if <wa_string> is assigned.
    *                DATA: int TYPE i VALUE 258.
    *                DATA: buffer TYPE xstring,
    *                      text_buffer TYPE string,
    *                      conv TYPE REF TO cl_abap_conv_out_ce.
    *                conv = cl_abap_conv_out_ce=>create(
    *                         encoding = 'UTF-8'
    *                         endian = 'L' ).
    *                CALL METHOD conv->write( data = <wa_string> ).
    *                buffer = conv->get_buffer( ).
    *                DATA: convin  TYPE REF TO cl_abap_conv_in_ce.
    *                CALL METHOD cl_abap_conv_in_ce=>create
    *                  EXPORTING
    *                    input = buffer
    *                  RECEIVING
    *                    conv  = convin.
    *                CALL METHOD convin->read
    *                  IMPORTING
    *                    data = text_buffer.
    *                MOVE text_buffer TO <f>.
                      move <wa_string> to <f>.
                    endif.
                  when 'MDM_CDT_DATE_TIME'.
                    assign <wa_pair>-value->* to <wa_date_time>.
                    if <wa_date_time> is assigned.
                      move <wa_date_time>-content to <f>.
                    endif.
                  when 'MDM_GDT_INTEGERVALUE'.
                    assign <wa_pair>-value->* to <wa_integer>.
                    if <wa_integer> is assigned.
                      if <wa_detail>-field_lookup_table is not initial.
                        content_string = wd_assist->perform_value_lookup(
                            i_lookup_table = <wa_detail>-field_lookup_table
                            i_lookup_key   = <wa_integer> ).
                        move content_string to <f>.
                      else.
                        move <wa_integer> to <f>.
                      endif.
                    endif.
                endcase.
              endif.
            endloop.
            append <row> to <table>.
          endloop.
          dyn_node->bind_table( <table> ).
    * Connect to the component Usage of the ALV
          data: l_ref_cmp_usage type ref to if_wd_component_usage.
          l_ref_cmp_usage =   wd_this->wd_cpuse_alv( ).
          if l_ref_cmp_usage->has_active_component( ) is initial.
            l_ref_cmp_usage->create_component( ).
          endif.
    * Through the interface controller of the ALV Component set the DATA node dynamically
          data: l_ref_interfacecontroller type ref to iwci_salv_wd_table .
          l_ref_interfacecontroller =   wd_this->wd_cpifc_alv( ).
          l_ref_interfacecontroller->set_data(
            r_node_data = dyn_node  ).
          data alv_model type ref to cl_salv_wd_config_table.
          alv_model = l_ref_interfacecontroller->get_model( ).
          data columns type salv_wd_t_column_ref.
          field-symbols <wa_column> like line of columns.
          columns = alv_model->if_salv_wd_column_settings~get_columns( ).
          data column_id type string.
          data header type ref to cl_salv_wd_column_header.
          data l_text type string.
          loop at field_details assigning <wa_detail>.
    * build a structure description from the list of single fields
            if strlen( <wa_detail>-field_code ) > 30.
              column_id = <wa_detail>-field_code+0(30).
            else.
              column_id = <wa_detail>-field_code.
            endif.
            translate column_id to upper case.
            read table columns assigning <wa_column> with table key id = column_id.
            if sy-subrc = 0.
              header = <wa_column>-r_column->get_header( ).
              header->set_ddic_binding_field( if_salv_wd_c_column_settings=>ddic_bind_none ).
    *      if <wa_detail>-field_lookup_table is initial.
              header->set_text( <wa_detail>-field_name1 ).
    *      else.
    *        l_text = wd_assist->read_table_desc_for_lookup( <wa_detail>-field_lookup_table ).
    *        header->set_text( l_text ).
    *      endif.
            endif.
          endloop.
        catch cx_root into o_except.
          data: l_current_controller type ref to if_wd_controller,
                l_message_manager    type ref to if_wd_message_manager.
          l_current_controller ?= wd_this->wd_get_api( ).
          l_message_manager = l_current_controller->get_message_manager( ).
          l_message_manager->report_exception(
              message_object           = o_except ).
      endtry.

  • How to do parallel processing with dynamic internal table

    Hi All,
    I need to implement parallel processing that involves dynamically created internal tables. I tried doing so using RFC function modules (using starting new task and other such methods) but didn't get success this requires RFC enabled function modules and at the same time RFC enabled function modules do not allow generic data type (STANDARD TABLE) which is needed for passing dynamic internal tables. My exact requirement is as follows:
    1. I've large chunk of data in two internal tables, one of them is formed dynamically and hence it's structure is not known at the time of coding.
    2. This data has to be processed together to generate another internal table, whose structure is pre-defined. But this data processing is taking very long time as the number of records are close to a million.
    3. I need to divide the dynamic internal table into (say) 1000 records each and pass to a function module and submit it to run in another task. Many such tasks will be executed in parallel.
    4. The function module running in parallel can insert the processed data into a database table and the main program can access it from there.
    Unfortunately, due to the limitation of not allowing generic data types in RFC, I'm unable to do this. Does anyone has any idea how to implement parallel processing using dynamic internal tables in these type of conditions.
    Any help will be highly appreciated.
    Thanks and regards,
    Ashin

    try the below code...
      DATA: w_subrc TYPE sy-subrc.
      DATA: w_infty(5) TYPE  c.
      data: w_string type string.
      FIELD-SYMBOLS: <f1> TYPE table.
      FIELD-SYMBOLS: <f1_wa> TYPE ANY.
      DATA: ref_tab TYPE REF TO data.
      CONCATENATE 'P' infty INTO w_infty.
      CREATE DATA ref_tab TYPE STANDARD TABLE OF (w_infty).
      ASSIGN ref_tab->* TO <f1>.
    * Create dynamic work area
      CREATE DATA ref_tab TYPE (w_infty).
      ASSIGN ref_tab->* TO <f1_wa>.
      IF begda IS INITIAL.
        begda = '18000101'.
      ENDIF.
      IF endda IS INITIAL.
        endda = '99991231'.
      ENDIF.
      CALL FUNCTION 'HR_READ_INFOTYPE'
        EXPORTING
          pernr           = pernr
          infty           = infty
          begda           = '18000101'
          endda           = '99991231'
        IMPORTING
          subrc           = w_subrc
        TABLES
          infty_tab       = <f1>
        EXCEPTIONS
          infty_not_found = 1
          OTHERS          = 2.
      IF sy-subrc <> 0.
        subrc = w_subrc.
      ELSE.
      ENDIF.

  • How to populate the TEXT field in MIGO

    Hi folks,
    While creating material document in MIGO or MB01, i am inserting some data in TEXT ( Field in line item level ). This text data is disappearing , once mat doc is created.
    how to populate the TEXT field in MIGO?Is there any cusomisation?it's urgent .
    Regards
    pabi

    Hello Pabitra,
    I had a similar issue in my Project.
    Please verify if the SMOD enhancement MBCF0002 (EXIT_SAPMM07M_001) is active in your system.
    If this is the case, verify from two angles:
    a) Whether the Enhancement was accidentally activated - If yes, then De-activate the same
    b) If there is some logic coded in the User Exit, but, the Text is somehow not determined...even the existing content in the text field (input to EXIT_SAPMM07M_001) will get vanished.
    Hope that your problem will be resolved by this.  Pls reward points.
    With Regards
    Vijay Gajavalli

  • How to populate dynamic internal table fields with data??

    Hi Folks,
    How to assign a particular internal table field to a dynamically assigned internal table?
    I have an excel sheet, and i upload the excel sheet data into an internal IT_EXLOAD table using FM ALSM_EXCEL_TO_INTERNAL_TABLE
    Now i created a dynamic internal table which has the same column as in my DB table.
    I have to fill the dynamically created Internal table with the IT_EXLOAD data dynamically.
    Suppose in future if i add some field in DB table and for that field if i add some column in excel sheet there is no need to change in the program.
    Looking for reply...
    Best Regards,
    Sayak

    hi,
    CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
           EXPORTING
                filename                = p_path
                i_begin_col             = '1'
                i_begin_row             = '2'
                i_end_col               = '2'
                i_end_row               = '1000'
           TABLES
                intern                  = intern
           EXCEPTIONS
                inconsistent_parameters = 1
                upload_ole              = 2
                OTHERS                  = 3.
    *declare intern_tmp as internal table tb_data in wich you want the data
    *and declare a field symbol <fs_123>
    LOOP AT intern.
        ASSIGN COMPONENT intern-col OF STRUCTURE
        intern_tmp TO <fs_123>.
        IF NOT <fs_123> IS ASSIGNED.
          CLEAR intern.
          CLEAR intern_tmp.
          CONTINUE.
        ENDIF.
        <fs_123> = intern-value.
        AT END OF row.
          CLEAR tb_data.
          MOVE-CORRESPONDING: intern_tmp TO tb_data.
          APPEND tb_data.
          CLEAR intern_tmp.
        ENDAT.
        CLEAR intern.
      ENDLOOP.
    **paste this code and you can see the data in ur tables dynamically.
    Thanks
    Nitin Sachdeva

Maybe you are looking for