Dynamic Internal table with field symbol

I made the report where the user enters two different tables and two fields that are to be compared.
Eg. If I enter (MARA & NAME1) and (MARC & NAME2) , I wish to compare all the entries of Mara-name1 against all entries in Marc-name2.
<u>The code I need to write is:</u>
DATA:
  gdo_data      TYPE REF TO data.
DATA:
  gdo_data1      TYPE REF TO data.
FIELD-SYMBOLS:
  <gt_itab>     TYPE table,
    <wa> LIKE <gt_itab>,                        "<gt_itab>,
  <gs_entry>    TYPE ANY.
FIELD-SYMBOLS:
  <gt_itab1>     TYPE table,
    <wa1> LIKE <gt_itab>,                        "<gt_itab>,
  <gs_entry1>    TYPE ANY.
PARAMETERS:
  p_table    TYPE tabname,            "    DEFAULT 'KNA1',
  p_fld      TYPE fieldname.          "  DEFAULT 'KUNNR'.
PARAMETERS:
  p_table1    TYPE tabname,            "    DEFAULT 'KNA1',
  p_fld1      TYPE fieldname.
DATA: var TYPE fieldname.
var = p_fld.
DATA: var1 TYPE fieldname.
var1 = p_fld1.
START-OF-SELECTION.
  CREATE DATA gdo_data TYPE TABLE OF (p_table).
  ASSIGN gdo_data->* TO <gt_itab>.
  CREATE DATA gdo_data1 TYPE TABLE OF (p_table1).
  ASSIGN gdo_data1->* TO <gt_itab1>.
  SELECT * FROM (p_table) INTO CORRESPONDING FIELDS OF TABLE <gt_itab>.
  SELECT * FROM (p_table1) INTO CORRESPONDING FIELDS OF TABLE <gt_itab1>.
<b>  LOOP AT <gt_itab> ASSIGNING <gs_entry>.
    READ TABLE <gt_itab1> ASSIGNING <gs_entry1>
         WITH KEY (var1) = <gt_itab>-(var).
    IF sy-subrc EQ 0.
      MESSAGE 'Success' TYPE 'S'.
    ENDIF.
  ENDLOOP.</b>
END-OF-SELECTION.
But the portion in bold is creating error: <b><gt_itab> is a table without a header lineand therefore has no component called "".</b>
please help.

Hi Amit
Try like this
LOOP AT <gt_itab> ASSIGNING <gs_entry>.
READ TABLE <gt_itab1> ASSIGNING <gs_entry1>
WITH KEY (var1) = <b><gs_entry></b>-(var).
IF sy-subrc EQ 0.
MESSAGE 'Success' TYPE 'S'.
ENDIF.
ENDLOOP.
Regards,
Atish

Similar Messages

  • Creating dynamic internal table(Not field symbol table)

    Hi Experts,
    I am facing problem creating Intarnal table
    I have fieldcatalog, I want create dynamic internal table(Not field symbol table).
    I have written----
      CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
       i_style_table             =
         it_fieldcatalog           = it_fldcat
          it_fieldcatalog           = me->gt_fieldcat
       i_length_in_byte          =
        IMPORTING
          ep_table                  = lt_new_table
       e_style_fname             =
        EXCEPTIONS
         generate_subpool_dir_full = 1
         OTHERS                    = 2.
        ASSIGN lt_new_table->* TO <gt_dyn_repdata>.
        CREATE DATA ls_new_line LIKE LINE OF <gt_dyn_repdata>.
        ASSIGN ls_new_line->* TO <gs_dyn_repdata>.
    above logic creating dynamic field symbol table.... But I want create normal internal table.
    Thanks,
    Rajasekhar

    Hi
    What do you mean?
    It needs to use the field-symbol, this is the price to pay if it wants a dynamic object
    Max

  • Dynamic internal  tables using field symbols

    Hello,
    Is it possible to create a dynamic table where the no of fields in the internal table can be created dynamically(using field symbols).
    Say sometimes internal tables with 10 fields and depending upon the requirement the fields can be dynamically increased or decreased in runtime.
    Thanks.

    Hi,
    Go through the following code....
    *Data definitions
    *** Tables
    data: lt_data type ref to data.
    data: lt_fieldcatalog type lvc_t_fcat.
    *** Structure
    data: ls_fieldcatalog type lvc_s_fcat.
    *** Data References
    data: new_line type ref to data,
          fs_data type ref to data.
    *** Field Symbols
    field-symbols: <fs_data> type ref to data,
                   <fs_1> type any table,
                   <fs_2>,
                   <fs_3>.
    *Populating the internal table with fieldnames required for our dynamic
    *internal table
    ls_fieldcatalog-fieldname = 'MANDT'.
    append ls_fieldcatalog to lt_fieldcatalog.
    ls_fieldcatalog-fieldname = 'CARRID'. "Fieldname
    ls_fieldcatalog-inttype = 'C'. "Internal Type C-> Character
    append ls_fieldcatalog to lt_fieldcatalog.
    ls_fieldcatalog-fieldname = 'CONNID'.
    ls_fieldcatalog-inttype = 'N'.
    append ls_fieldcatalog to lt_fieldcatalog.
    ls_fieldcatalog-fieldname = 'FLDATE'.
    ls_fieldcatalog-inttype = 'D'.
    append ls_fieldcatalog to lt_fieldcatalog.
    ls_fieldcatalog-fieldname = 'PRICE'.
    ls_fieldcatalog-inttype = 'P'.
    append ls_fieldcatalog to lt_fieldcatalog.
    ls_fieldcatalog-fieldname = 'CURRENCY'.
    ls_fieldcatalog-inttype = 'C'.
    append ls_fieldcatalog to lt_fieldcatalog.
    *Calling the method CREATE_DYNAMIC_TABLE
    call method cl_alv_table_create=>create_dynamic_table
         exporting
           it_fieldcatalog = lt_fieldcatalog
         importing
           ep_table = fs_data
         exceptions
           generate_subpool_dir_full = 1
           others = 2
    if sy-subrc <> 0.
    endif.
    *Assigning Field-Symbol to our dynamic internal table
    assign lt_data to <fs_data>.
    *Internal Table is ready, now to put data in that table
    *** So <FS_1> now points to our dynamic internal table.
    assign fs_data->* to <fs_1>.
    *** Next step is to create a work area for our dynamic internal table.
    create data new_line like line of <fs_1>.
    *** A field-symbol to access that work area
    assign new_line->*  to <fs_2>.
    *** And to put the data in the internal table
    select
          mandt
          carrid
          connid
          fldate
          price
          currency
                  from sflight
                  into corresponding fields of table <fs_1>.
    *** Access contents of internal table
    loop at <fs_1> assigning <fs_2>.
    do 5 times.
    assign component sy-index of structure <fs_2> to <fs_3>.
    write:  <fs_3>.
    enddo.
    skip 1.
    endloop.
    top-of-page.
    write:/5 'FUJITSU CONSULTING COMPANY' inverse color 6,
           50 sy-datum inverse color 6,
           70 sy-pagno inverse color 6.
    uline.
    <REMOVED BY MODERATOR>
    Vijay C
    Code Formatted by: Alvaro Tejada Galindo on Apr 14, 2008 1:47 PM

  • Some help needed on dynamic internal tables and field symbols

    Hi,
    I have a dyn internal table <dyn_table_r>.
    One of its fields is kna1-kunnr.
    I have another wa <fs>, with only one field alt_kunnr.
    now i want to modify  the data of <dyn_table_r>-kna1-kunnr from <fs>-alt_kunnr
    How should i do it?
    Regards ,
    Harshit Rungta

    Harshit Rungta:
    You have opened a number of related questions today. I'd like to see the other ones closed before you continue with this one.
    I'll lock this but will re-open it once the others are marked as solved.
    Rob

  • Delete row from internal table using field symbol.

    Hi friends,
      I created dynamic internal table using field symbol. I want to delete some data using where clause.
    for example. i want to use like,
        DELETE <FS> WHERE KUNNR = WA_KNA1-KUNNR.
    Like the above statment it won't work. How i can use delete with where clause in field symbols.
    Hope any one can help me.
    Thanks and regards
    Srikanth. S

    hi Srikanth,
    I think you have to LOOP through the whole internal table and check each line and decide to delete or not:
    LOOP at <itab> INTO <wa>.
    ASSIGN COMPONENT 'KUNNR' OF STRUCTURE <wa> TO <field>.
    CHECK <field> IS ASSIGNED.
    IF <field> EQ WA_KNA1-KUNNR.
    DELETE ...
    ENDIF.
    UNASSIGN <field>.
    ENDLOOP.
    hope this helps
    ec

  • Creating Dynamic Internal table with a dynamic name

    Hi,
    I want to create dynamic internal tables with dynamic names.
    For example:
    Suppose I have a table with three fields.
    1. Structure name
    2.Fields
    3.file
    And the structure of the internal table is as follows:
    TYPES:BEGIN OF table_type,
          struct                  TYPE char70,
          fields                   TYPE tt_type OCCURS 0,
          File                      TYPE ttab_type OCCURS 0,
          END OF table_type.
    Suppose I have one record inside my internal table with struct as "STRUCTURE", fields have an internal table content of set of fields and File has some set of records.
    Now I want to create dynamic internal table whose name will be "STRUCTURE" , the fields of the dynamic internal table structure[] will be as in fields, and the records will be as in File.
    Like this if i have 100 records in my internal table then I have to create 100 dynamic internal table dynamically.
    Can anyone suggest how to do this?
    Edited by: Jjammy on Jul 22, 2009 7:52 AM

    Hi,
    Check the sample program and develop your program accordingly.
    <font color=blue><pre>
    REPORT  ztest_notepad.
    *& Declarations
    *Type-pools
    TYPE-POOLS:
          slis.
    *Types
    TYPES:
          ty_fcat      TYPE lvc_s_fcat,
          ty_fcatalog  TYPE slis_fieldcat_alv.
    *Work areas
    DATA:
          wa_fcat      TYPE ty_fcat,
          wa_fcatalog  TYPE ty_fcatalog.
    *Internal tables
    DATA:
          it_fcat      TYPE STANDARD TABLE OF ty_fcat,
          it_fcatalog  TYPE STANDARD TABLE OF ty_fcatalog.
    *Type reference
    DATA:
          it_dyn_tab   TYPE REF TO data,
          wa_newline   TYPE REF TO data.
    *Filed symbols
    FIELD-SYMBOLS:
          <gt_table>   TYPE STANDARD TABLE,
          <fs_dyntable>,
          <fs_fldval>  TYPE ANY,
          <l_field>    TYPE ANY.
    *Variables
    DATA:
          l_fieldname  TYPE lvc_s_fcat-fieldname,
          l_tabname    TYPE lvc_s_fcat-tabname,
          l_fieldtext  TYPE lvc_s_fcat-seltext,
          l_index      TYPE char2.
    "Selection-screen
    PARAMETERS:
             p_colms   TYPE i.
    *& start-of-selection.
    START-OF-SELECTION.
      PERFORM build_fieldcat.
      PERFORM create_dynamic_table.
      DO 20 TIMES.
        DO p_colms TIMES.
          l_index = sy-index.
          CONCATENATE 'FIELD' l_index INTO l_fieldname.
          ASSIGN COMPONENT l_fieldname OF STRUCTURE <fs_dyntable> TO <l_field>.
          <l_field> = sy-index.
        ENDDO.
        INSERT <fs_dyntable> INTO TABLE <gt_table>.
      ENDDO.
      LOOP AT it_fcat INTO wa_fcat.
        PERFORM fieldcatalog1 USING: wa_fcat-fieldname
                                      wa_fcat-tabname
                                      wa_fcat-seltext.
      ENDLOOP.
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
        EXPORTING
          i_callback_program = 'ZTEST_NOTEPAD'
          it_fieldcat        = it_fcatalog
        TABLES
          t_outtab           = <gt_table>.
    *&      Form  BUILD_FIELDCAT
    FORM build_fieldcat .
      CLEAR: l_fieldname,
             l_tabname,
             l_fieldtext,
             l_index.
      DO  p_colms TIMES.
        CLEAR l_index.
        l_index = sy-index.
        CONCATENATE 'FIELD' l_index INTO l_fieldname.
        CONCATENATE 'Field' l_index INTO l_fieldtext.
        l_tabname = '<GT_TABLE>'.
        PERFORM fieldcatalog USING: l_fieldname
                                    l_tabname
                                    l_fieldtext.
      ENDDO.
    ENDFORM.                    " BUILD_FIELDCAT
    *&      Form  CREATE_DYNAMIC_TABLE
    FORM create_dynamic_table .
      CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog = it_fcat
        IMPORTING
          ep_table        = it_dyn_tab.
      ASSIGN it_dyn_tab->* TO <gt_table>.
    Create dynamic work area and assign to FS
      CREATE DATA wa_newline LIKE LINE OF <gt_table>.
      ASSIGN wa_newline->* TO <fs_dyntable>.
    ENDFORM.                    " CREATE_DYNAMIC_TABLE
    *&      Form  FIELDCATALOG
    FORM fieldcatalog USING field table f_txt.
      wa_fcat-fieldname = field.
      wa_fcat-tabname   = table.
      wa_fcat-seltext = f_txt.
      APPEND wa_fcat TO it_fcat.
      CLEAR  wa_fcat.
    ENDFORM.                    " FIELDCATALOG
    *&      Form  FIELDCATALOG1
    FORM fieldcatalog1 USING field table f_txt.
      wa_fcatalog-fieldname = field.
      wa_fcatalog-tabname   = table.
      wa_fcatalog-seltext_m = f_txt.
      APPEND wa_fcatalog TO it_fcatalog.
      CLEAR  wa_fcatalog.
    ENDFORM.                    " FIELDCATALOG1 </pre>
    </font>
    Thanks
    Venkat.O

  • Create dynamic internal table with dynamic structure

    I have an internal table itab1 that have 12 amount fields from period1 thru period12.  I need to create a dynamic table with dynamic structure for the  period column if the total amount of each column  is > 0.  Any idea on how to do that? 
    For example if my itab1 has 20 rows and the sum of period1 = 35, sum of period2 = 0, sum of period3 = 5, sum of period4 =0, sum of period5 = 2 then I need to create a dynamic structure for the field column that have the total > 0, i.e  structure struct1 have field period1, period3 and period5 only.  Then I will need to load the data to itab2 from itab1.  Can someone help.
    Thanks.  I am on 4.7 and will upgrade to ERP 6.0 soon.

    go throgh this....
    REPORT  yusmm_text1  NO STANDARD PAGE HEADING
                         LINE-SIZE 199.
    T A B L E S
    TABLES: MARA,
            MAKT,
            THEAD.
    GLOBAL TYPE-POOLS
    TYPE-POOLS : SLIS.
       GLOBAL TYPES
    TYPES : BEGIN OF TP_FINAL,
           MATNR TYPE MARA-MATNR,
           BEGRU TYPE MARA-BEGRU,
           MTART TYPE MARA-MTART,
           MAKTX TYPE MAKT-MAKTX,
           SPRAS TYPE MAKT-SPRAS,
           LTXT(2000)  TYPE C ,
           SRNO TYPE N ,
          END OF TP_FINAL.
    TYPES : BEGIN OF TP_T002,
            SPRAS TYPE T002-SPRAS,
            LAISO TYPE T002-LAISO,
            SRNO TYPE N ,
            END OF TP_T002.
    TYPES : BEGIN OF TP_MARA_MAKT,
            MATNR TYPE MARA-MATNR,
            BEGRU TYPE MARA-BEGRU,
            MTART TYPE MARA-MTART,
            SPRAS TYPE MAKT-SPRAS,
            MAKTX TYPE MAKT-MAKTX,
           END OF TP_MARA_MAKT.
    Types: BEGIN OF tp_matnr,
           matnr TYPE mara-matnr,
           END OF tp_matnr.
       GLOBAL ELEMENTARY VARIABLES
    DATA : gv_date TYPE sy-datum.
    DATA : gv_repid TYPE sy-repid.
    DATA : g_var1(10) TYPE C.
    DATA : gv_index TYPE sy-tabix.
    DATA: gv_strg TYPE string,
          gv_strg1(2000) TYPE C.
    DATA : gv_lang TYPE sy-langu.
    DATA : g_v(3) TYPE N .
    DATA : gv_lines(3) TYPE N .
    DATA : gv_var(3) TYPE N .
    DATA : gv_var1(3) TYPE N.
    DATA: gv_str TYPE STRING.
    DATA: gv_str1 TYPE STRING.
    DATA : gv_li TYPE I,
           gv_lit TYPE I,
           gv_lin TYPE I.
    DATA: g_var11(3) TYPE N,
          gv_li1(3) TYPE N,
          g_var2(3) TYPE N.
    DATA : gv_i1 TYPE I.
    DATA : gv_i TYPE I.
    DATA: gl_lenght TYPE I.
       GLOBAL STRUCTURES
    DATA:   T_NEWTABLE TYPE REF TO DATA,
            T_NEWLINE  TYPE REF TO DATA,
            T_FLDCAT1   TYPE SLIS_T_FIELDCAT_ALV,
            T_FLDCAT   TYPE LVC_T_FCAT,
            WA_IT_FLDCAT TYPE LVC_S_FCAT,
            WA_IT_FLDCAT1 TYPE SLIS_FIELDCAT_ALV,
            WA_COLNO(2) TYPE N,
            WA_FLNAME(5) TYPE C,
            L_LT TYPE SLIS_LAYOUT_ALV.
       GLOBAL INTERNAL TABLES (WITH INCLUDE STRUCTURE)
    DATA : IG_MARA_MAKT TYPE STANDARD TABLE OF TP_MARA_MAKT,
           WG_MARA_MAKT TYPE TP_MARA_MAKT.
    DATA : IG_T002 TYPE STANDARD TABLE OF TP_T002,
           WG_T002 TYPE TP_T002.
    DATA : IG_FINAL TYPE STANDARD TABLE OF TP_FINAL,
           WG_FINAL TYPE TP_FINAL.
    data : IG_MATNR TYPE STANDARD TABLE OF TP_MATNR WITH HEADER  LINE,
           WG_MATNR TYPE TP_MATNR.
    DATA:BEGIN OF IG_THEAD OCCURS 0.
            INCLUDE STRUCTURE THEAD .
    DATA: END OF IG_THEAD.
    DATA:BEGIN OF IG_TLINE OCCURS 0.
            INCLUDE STRUCTURE TLINE  .
    DATA:END OF IG_TLINE.
    FIELD-SYMBOLS
    FIELD-SYMBOLS: <T_DYNTABLE> TYPE STANDARD TABLE,"Dynamic internal
                                                            "tablename
                   <FS_DYNTABLE>,  "Field symbol to create work area
                  <FS_FLDVAL> TYPE ANY.   " Field symbol to assign values
    COMPULSORY
    FIELD-SYMBOLS: <FS_DATA> TYPE REF TO DATA,
                   <FS_DATA1> TYPE REF TO DATA,
                   <FS_2>    TYPE STANDARD TABLE,
                   <FS_22>   TYPE STANDARD TABLE,
                   <FS_1>,
                   <FS_11>,
                   <F>,
                   <FA>,
                   <LWA_LINE_WA>,
                   <LWA_LINE_WA1>.
    ------- Create Dyn Table From FC
    DATA: LT_DATA        TYPE   REF TO DATA,
          LT_DATA1        TYPE   REF TO DATA,
          LWA_LINE       TYPE   REF TO  DATA,
          LWA_LINE1       TYPE   REF TO  DATA,
          LI_FIELD_CAT   TYPE   LVC_T_FCAT,
          LWA_FIELD_CAT  TYPE   LVC_S_FCAT.
       PARAMETERS & SELECT-OPTIONS
    SELECTION-SCREEN : BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
    SELECT-OPTIONS : S_SPRAS FOR MAKT-SPRAS NO INTERVALS  DEFAULT 'EN'
                                                            OBLIGATORY ,
                     S_MATNR FOR MARA-MATNR,
                     S_MTART FOR MARA-MTART.
    PARAMETERS: GP_SIZE TYPE I DEFAULT '200'.
    SELECTION-SCREEN : END OF BLOCK B1.
       INITIALIZATION
    INITIALIZATION.
      gv_repid = sy-repid.
      gv_date = sy-datum.
    AT SELECTION-SCREEN
    AT SELECTION-SCREEN.
      IF GP_SIZE < 0.
       MESSAGE E002(00).
      ENDIF.
      IF GP_SIZE > 50000.
       MESSAGE W130(26) WITH TEXT-004.
        SET CURSOR FIELD 'gp_size'.
      ENDIF.
    START-OF-SELECTION
    START-OF-SELECTION.
      PERFORM FIELDCAT.
      PERFORM LAYOUT.
      PERFORM DATA_FETCH.
      PERFORM READ_DATA_TO_FINAL.
      SORT ig_final BY matnr spras.
      gv_lin = gv_li.
      gv_li = gv_li - 2.
      LOOP AT ig_final INTO wg_final.
        ASSIGN COMPONENT 1 OF STRUCTURE <LWA_LINE_WA1> TO <FA>.
        <FA> = 'Material Number'.
        ASSIGN COMPONENT 2 OF STRUCTURE <LWA_LINE_WA1> TO <FA>.
        <FA> = 'Authorization Group'.
        g_VAR11 = wg_final-srno + 2.
        gv_li1 = gv_li1 + 2.
        MOVE : g_var11 TO gv_i1.
        ASSIGN COMPONENT g_var11 OF STRUCTURE <LWA_LINE_WA1> TO <FA>.
        <FA> = 'MatDesc'.
        g_var2 = g_var11 + gv_lines.
        ASSIGN COMPONENT g_var2 OF STRUCTURE <LWA_LINE_WA1> TO <FA>.
        <FA> = 'BasicData'.
        APPEND <LWA_LINE_WA1> TO <FS_22>.
        EXIT.
       ENDLOOP.
      LOOP AT ig_final INTO wg_final.
        AT NEW matnr.
          gv_index = sy-tabix.
          ASSIGN COMPONENT 1 OF STRUCTURE <LWA_LINE_WA> TO <F>.
          <F> = wg_final-matnr.
          ENDAT.
        AT NEW MATNR.
        GV_INDEX = SY-TABIX.
        ASSIGN COMPONENT 1 OF STRUCTURE <LWA_LINE_WA1> TO <FA>.
        <FA> = wg_final-matnr.
         ENDAT.
        ASSIGN COMPONENT 2 OF STRUCTURE <LWA_LINE_WA> TO <F>.
        <F> = wg_final-begru.
        ASSIGN COMPONENT 2 OF STRUCTURE <LWA_LINE_WA1> TO <FA>.
        <FA> = wg_final-begru.
        gv_var = wg_final-srno + 2.
        gv_li = gv_li + 2.
        MOVE : gv_var TO gv_i.
        ASSIGN COMPONENT gv_var OF STRUCTURE <LWA_LINE_WA> TO <F>.
        <F> = wg_final-maktx.
        ASSIGN COMPONENT gv_var OF STRUCTURE <LWA_LINE_WA1> TO <FA>.
        <FA> = wg_final-maktx.
        gv_var1 = gv_var + gv_lines  .
        ASSIGN COMPONENT gv_var1 OF STRUCTURE <LWA_LINE_WA> TO <F>.
       <F> = wg_final-ltxt.
        ASSIGN COMPONENT gv_var1 OF STRUCTURE <LWA_LINE_WA1> TO <FA>.
        <FA> = wg_final-ltxt.
        AT END OF matnr.
          APPEND <LWA_LINE_WA> TO <FS_2>.
          CLEAR <LWA_LINE_WA>.
        ENDAT.
        AT END OF matnr.
         APPEND <LWA_LINE_WA1> TO <FS_22>.
         CLEAR <LWA_LINE_WA1>.
        ENDAT.
      ENDLOOP.
      PERFORM display..
    *&      Form  data_fetch
          text
    -->  p1        text
    <--  p2        text
    FORM DATA_FETCH .
      SELECT matnr
              from mara up to gp_size rows
             appending corresponding fields of table ig_matnr
             where matnr in s_matnr
             and mtart in s_mtart.
    loop at ig_matnr.
      SELECT  MARA~MATNR
              MARA~BEGRU
              MARA~MTART
              MAKT~SPRAS
              MAKT~MAKTX FROM MARA INNER JOIN MAKT
        ON MARAMATNR = MAKTMATNR
       appending corresponding fields of TABLE ig_mara_makt  UP TO GP_SIZE
    ROWS
        WHERE makt~spras IN s_spras
        AND   mara~matnr IN s_matnr
        AND   mara~mtart IN s_mtart
        AND   mara~matnr EQ ig_matnr-matnr.
        endloop.
      IF sy-subrc = 0.
        SORT ig_mara_makt.
      ENDIF.
    ENDFORM.                    " data_fetch
    *&      Form  read_data_to_final
          text
    -->  p1        text
    <--  p2        text
    FORM READ_DATA_TO_FINAL .
      LOOP AT ig_mara_makt INTO wg_mara_makt .
        wg_final-MATNR = wg_mara_makt-MATNR.
        wg_final-BEGRU = wg_mara_makt-BEGRU.
        wg_final-MTART = wg_mara_makt-MTART.
        wg_final-SPRAS = wg_mara_makt-SPRAS.
        wg_final-MAKTX = wg_mara_makt-MAKTX.
        READ TABLE ig_t002 INTO wg_t002 WITH KEY spras = wg_final-spras.
        IF sy-subrc = 0.
          wg_final-srno = wg_t002-srno.
        ENDIF.
        CLEAR ig_thead[].
        ig_thead-TDOBJECT = 'MATERIAL'.
        ig_thead-TDNAME   = wg_final-matnr.
        ig_thead-TDID     = 'GRUN'.
        ig_thead-TDSPRAS  = wg_final-spras.
        CALL FUNCTION 'TEXT_READ'
          EXPORTING
            I_HEADER   = IG_THEAD
            I_READONLY = 'X'
          IMPORTING
            E_HEADER   = IG_THEAD
          TABLES
            T_LINES    = IG_TLINE[]
          EXCEPTIONS
            NOTFOUND   = 1.
        IF sy-subrc  EQ 0.
          LOOP AT  ig_tline.
            gv_strg = ig_tline-tdline.
            IF gv_strg1 <> ' '.
              CONCATENATE gv_strg1 ';' gv_strg INTO gv_strg1.
            ELSE.
              gv_strg1 = gv_strg.
            ENDIF.
          ENDLOOP.
          wg_final-ltxt = gv_strg1.
          APPEND wg_final TO ig_final.
          CLEAR wg_final.
          gv_strg1 = ' '.
        ELSE.
          APPEND wg_final TO  ig_final.
        ENDIF.
      ENDLOOP.
    ENDFORM.                    " read_data_to_final
    " read_data_to_final
    *&      Form  layout
          text
    -->  p1        text
    <--  p2        text
    FORM LAYOUT .
      CLEAR L_LT.
      L_LT-ZEBRA = 'X'.
      L_LT-COLWIDTH_OPTIMIZE = 'X'.
      L_LT-WINDOW_TITLEBAR = 'MATERIAL DETAILS'.
    ENDFORM.                    " layout
    *&      Form  fieldcat
          text
    -->  p1        text
    <--  p2        text
    FORM FIELDCAT .
      SELECT SPRAS
               LAISO FROM t002 INTO  CORRESPONDING FIELDS OF TABLE ig_t002
          WHERE spras IN s_spras.
      DESCRIBE TABLE ig_t002 LINES gv_lines.
      LOOP AT ig_t002 INTO wg_t002.
        g_v = g_v + 1.
        Wg_t002-srno = g_v.
        MODIFY ig_t002 FROM wg_t002 TRANSPORTING SRNO.
      ENDLOOP.
      LOOP AT ig_t002 INTO wg_t002.
        CLEAR WA_IT_FLDCAT.
        MOVE SY-INDEX TO WA_COLNO.
        CONCATENATE 'MD-' wg_t002-LAISO
                          WA_COLNO
                         INTO WA_FLNAME.
        WA_IT_FLDCAT-FIELDNAME = WA_FLNAME.
        WA_IT_FLDCAT-DATATYPE = 'CHAR'.
        WA_IT_FLDCAT-SELTEXT = WA_FLNAME.
        WA_IT_FLDCAT-INTLEN = 250.
        WA_IT_FLDCAT-TABNAME = '<FS_2>'.
        APPEND WA_IT_FLDCAT TO T_FLDCAT.
        CLEAR wg_t002.
        ENDLOOP.
      LOOP AT ig_t002 INTO wg_t002.
        CLEAR WA_IT_FLDCAT.
        MOVE SY-INDEX TO WA_COLNO.
        CONCATENATE 'BD-' wg_t002-LAISO
                           WA_COLNO
                        INTO WA_FLNAME.
        WA_IT_FLDCAT-FIELDNAME = WA_FLNAME.
        WA_IT_FLDCAT-DATATYPE = 'CHAR'.
        WA_IT_FLDCAT-SELTEXT = WA_FLNAME.
        WA_IT_FLDCAT-INTLEN = 250.
        WA_IT_FLDCAT-TABNAME = '<FS_2>'.
        APPEND WA_IT_FLDCAT TO T_FLDCAT.
        CLEAR wg_t002.
        ENDLOOP.
      MOVE 'MATNR' TO WA_FLNAME.
      WA_IT_FLDCAT-FIELDNAME = WA_FLNAME.
      WA_IT_FLDCAT-DATATYPE = 'CHAR'.
      WA_IT_FLDCAT-SELTEXT = 'Material No'.
      WA_IT_FLDCAT-INTLEN = 18.
      WA_IT_FLDCAT-TABNAME = '<FS_2>'.
      INSERT WA_IT_FLDCAT INTO T_FLDCAT INDEX 1.
      MOVE 'BEGRU' TO WA_FLNAME.
      WA_IT_FLDCAT-FIELDNAME = WA_FLNAME.
      WA_IT_FLDCAT-DATATYPE = 'CHAR'.
      WA_IT_FLDCAT-SELTEXT = 'Authorization Group'.
      WA_IT_FLDCAT-INTLEN = 4.
      WA_IT_FLDCAT-TABNAME = '<FS_2>'.
      INSERT WA_IT_FLDCAT INTO T_FLDCAT INDEX 2.
      DESCRIBE TABLE T_FLDCAT LINES gv_li.
      ASSIGN LT_DATA TO <FS_DATA>.
    Creating the Dynamic Internal Table
      CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
        EXPORTING
          IT_FIELDCATALOG           = T_FLDCAT         " Fieldcatalogue
        IMPORTING
          EP_TABLE                  = <FS_DATA>   " Dynamic Internal Table
        EXCEPTIONS
          GENERATE_SUBPOOL_DIR_FULL = 1
          OTHERS                    = 2.
    Assign Dyn Table To Field Sumbol
      ASSIGN <FS_DATA>->* TO <FS_1>.
    Assigning the Internal Table TYPE ANY to Standard internal Table
      ASSIGN <FS_1> TO <FS_2>.
    Creating a Workarea
      CREATE DATA LWA_LINE LIKE LINE OF <FS_2> .
    Assigning the Content to the workares as a Pointer
      ASSIGN LWA_LINE->* TO <LWA_LINE_WA>.
      LOOP AT T_FLDCAT INTO WA_IT_FLDCAT.
        WA_IT_FLDCAT1-FIELDNAME = WA_IT_FLDCAT-FIELDNAME.
        WA_IT_FLDCAT1-TABNAME =  WA_IT_FLDCAT-TABNAME.
        WA_IT_FLDCAT1-SELTEXT_L = WA_IT_FLDCAT-SELTEXT.
       WA_IT_FLDCAT1-REF_TABNAME = 'MARC'.
        APPEND WA_IT_FLDCAT1 TO T_FLDCAT1.
        CLEAR : WA_IT_FLDCAT,WA_IT_FLDCAT1.
      ENDLOOP.
      ASSIGN LT_DATA1 TO <FS_DATA1>.
      CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
        EXPORTING
          IT_FIELDCATALOG           = T_FLDCAT         " Fieldcatalogue
        IMPORTING
          EP_TABLE                  = <FS_DATA1>  " Dynamic Internal table
        EXCEPTIONS
          GENERATE_SUBPOOL_DIR_FULL = 1
          OTHERS                    = 2.
    Assign Dyn Table To Field Sumbol
      ASSIGN <FS_DATA1>->* TO <FS_11>.
    Assigning the Internal Table TYPE ANY to Standard internal Table
      ASSIGN <FS_11> TO <FS_22>.
    Creating a Workarea
      CREATE DATA LWA_LINE1 LIKE LINE OF <FS_22> .
    Assigning the Content to the workares as a Pointer
      ASSIGN LWA_LINE1->* TO <LWA_LINE_WA1>.
    ENDFORM.                    " fieldcat
    *&      Form  show
          text
    -->  p1        text
    <--  p2        text
    FORM Display .
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
       I_INTERFACE_CHECK                 = ' '
       I_BYPASSING_BUFFER                = ' '
       I_BUFFER_ACTIVE                   = ' '
         I_CALLBACK_PROGRAM                = GV_REPID
        I_CALLBACK_PF_STATUS_SET          = 'PF_STATUS_SET'
        I_CALLBACK_USER_COMMAND           = 'USER_COMMAND'
       I_CALLBACK_TOP_OF_PAGE            = ' '
       I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
       I_CALLBACK_HTML_END_OF_LIST       = ' '
       I_STRUCTURE_NAME                  =
       I_BACKGROUND_ID                   = ' '
       I_GRID_TITLE                      =
       I_GRID_SETTINGS                   =
        IS_LAYOUT                         = L_LT
         IT_FIELDCAT                       = T_FLDCAT1[]
       IT_EXCLUDING                      =
       IT_SPECIAL_GROUPS                 =
       IT_SORT                           =
       IT_FILTER                         =
       IS_SEL_HIDE                       =
       I_DEFAULT                         = 'X'
       I_SAVE                            = ' '
       IS_VARIANT                        =
       IT_EVENTS                         =
       IT_EVENT_EXIT                     =
       IS_PRINT                          =
       IS_REPREP_ID                      =
       I_SCREEN_START_COLUMN             = 0
       I_SCREEN_START_LINE               = 0
       I_SCREEN_END_COLUMN               = 0
       I_SCREEN_END_LINE                 = 0
       I_HTML_HEIGHT_TOP                 = 0
       I_HTML_HEIGHT_END                 = 0
       IT_ALV_GRAPHICS                   =
       IT_HYPERLINK                      =
       IT_ADD_FIELDCAT                   =
       IT_EXCEPT_QINFO                   =
       IR_SALV_FULLSCREEN_ADAPTER        =
    IMPORTING
       E_EXIT_CAUSED_BY_CALLER           =
       ES_EXIT_CAUSED_BY_USER            =
        TABLES
          T_OUTTAB                          = <FS_2>
    EXCEPTIONS
       PROGRAM_ERROR                     = 1
       OTHERS                            = 2
      IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    " display
    FORM PF_STATUS_SET USING RS_EXTAB TYPE SLIS_T_EXTAB.
      SET PF-STATUS 'DISPLAY' .
    ENDFORM. "PF_STATUS_SET
    *& Form Name: user_command *
    *& Form Desc: For Handling USER_COMMAND *
    FORM USER_COMMAND USING IF_UCOMM TYPE SY-UCOMM
                         IS_SELFIELD TYPE SLIS_SELFIELD.
      CASE IF_UCOMM.
        WHEN 'DOWNLOAD'.
          CALL FUNCTION 'POPUP_TO_CONFIRM'
            EXPORTING
      TITLEBAR                    = ' '
      DIAGNOSE_OBJECT             = ' '
              TEXT_QUESTION               = 'Data download to excel'
      TEXT_BUTTON_1               = 'Ja'(001)
      ICON_BUTTON_1               = ' '
      TEXT_BUTTON_2               = 'Nein'(002)
      ICON_BUTTON_2               = ' '
      DEFAULT_BUTTON              = '1'
      DISPLAY_CANCEL_BUTTON       = 'X'
      USERDEFINED_F1_HELP         = ' '
      START_COLUMN                = 25
      START_ROW                   = 6
      POPUP_TYPE                  =
    IMPORTING
      ANSWER                      =
    TABLES
      PARAMETER                   =
    EXCEPTIONS
      TEXT_NOT_FOUND              = 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.
          CALL FUNCTION 'GUI_DOWNLOAD'
            EXPORTING
        BIN_FILESIZE                  =
              FILENAME                     = 'C:\Material-Text.xls'
             FILETYPE                      = 'ASC'
        APPEND                        = ' '
         WRITE_FIELD_SEPARATOR         = 'X'
        HEADER                        = '00'
         TRUNC_TRAILING_BLANKS         = 'X'
        WRITE_LF                      = 'X'
        COL_SELECT                    = ' '
        COL_SELECT_MASK               = ' '
         DAT_MODE                      = 'X'
       IMPORTING
         FILELENGTH                    = GL_LENGHT
            TABLES
              DATA_TAB                      = <FS_22>
      EXCEPTIONS
        FILE_WRITE_ERROR              = 1
        NO_BATCH                      = 2
        GUI_REFUSE_FILETRANSFER       = 3
        INVALID_TYPE                  = 4
        NO_AUTHORITY                  = 5
        UNKNOWN_ERROR                 = 6
        HEADER_NOT_ALLOWED            = 7
        SEPARATOR_NOT_ALLOWED         = 8
        FILESIZE_NOT_ALLOWED          = 9
        HEADER_TOO_LONG               = 10
        DP_ERROR_CREATE               = 11
        DP_ERROR_SEND                 = 12
        DP_ERROR_WRITE                = 13
        UNKNOWN_DP_ERROR              = 14
        ACCESS_DENIED                 = 15
        DP_OUT_OF_MEMORY              = 16
        DISK_FULL                     = 17
        DP_TIMEOUT                    = 18
        FILE_NOT_FOUND                = 19
        DATAPROVIDER_EXCEPTION        = 20
        CONTROL_FLUSH_ERROR           = 21
        OTHERS                        = 22
          IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
          ENDIF.
          IF GL_LENGHT NE 0.
            MESSAGE S398(00) WITH 'DATA downloaded to EXCEL'.
          ENDIF.
      ENDCASE.
    ENDFORM.                    "user_command
    Thanks

  • Dynamic internal table with problem

    Hi,
    I have developed a program to update standard table. I am using dynamic internal table creation concept. But my dynamic internal table is having width only 1200 bytes. But many standard tables have more than that width. Do you have any input create dynamic internal table with more than 1200 bytes width..
    Have a look at the error.
    [http://3.bp.blogspot.com/_O5f8iAlgdNQ/SjYXTBpO92I/AAAAAAAAErI/Fs996_APHbE/s1600-h/error-792463.JPG|http://3.bp.blogspot.com/_O5f8iAlgdNQ/SjYXTBpO92I/AAAAAAAAErI/Fs996_APHbE/s1600-h/error-792463.JPG]
    Expecting reply
    Thanks
    Venkat

    Hi,
    DATA: IT_TABSTRUC     TYPE STANDARD TABLE OF DFIES INITIAL SIZE 0,
            V_REF        TYPE REF TO DATA,
              V_I_AVL_CAT  TYPE TABLE OF LVC_S_FCAT.
    FIELD-SYMBOLS : <F_FS_DATA>   TYPE STANDARD TABLE.
    SELECTION-SCREEN:BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001
    NO INTERVALS.
    PARAMETERS: P_TABNAM TYPE X_TABNAME.
    SELECTION-SCREEN:END OF BLOCK B1.
      CALL FUNCTION 'DDIF_FIELDINFO_GET'
        EXPORTING
          TABNAME        = p_tabnam
          LANGU          = SY-LANGU
        TABLES
          DFIES_TAB      = IT_TABSTRUC
        EXCEPTIONS
          NOT_FOUND      = 1
          INTERNAL_ERROR = 2
          OTHERS         = 3.
      LOOP AT IT_TABSTRUC .
        V_LS_AVL_CAT-FIELDNAME = IT_TABSTRUC -FIELDNAME.
        V_LS_AVL_CAT-REF_TABLE = P_TABNAM.
        V_LS_AVL_CAT-REF_FIELD = IT_TABSTRUC -FIELDNAME.
        APPEND V_LS_AVL_CAT TO V_I_AVL_CAT.
      ENDLOOP.
      CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
        EXPORTING
          IT_FIELDCATALOG = V_I_AVL_CAT
        IMPORTING
          EP_TABLE        = V_REF.
      ASSIGN V_REF->* TO <F_FS_DATA>.
      FREE V_REF.
      SELECT * FROM (P_TABNAM) INTO CORRESPONDING
              FIELDS OF TABLE <F_FS_DATA> .
    Hope this resolves ur probs....

  • Create dynamic internal table with deep structure;cell coloring dynamic ALV

    Hi,
    My requirement is to do cell colouring for a dynamic ALV.
    So I am creating a dynamic internal table using the following method.
      CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog = i_fieldcatalog[]
        IMPORTING
          ep_table        = i_output.
    But how do I define field COLORS which should be again an internal table ?
    Is there any other way for cell colouring?
    Putting my problem in another way:
    How do I create a dynamic internal table with one field as another internal table.
    Quick replies are highly appreciated.
    Thanks,
    Nisha Vengal.

    halo Nisha
    Before building the display table . you can add the field in the feild catalog right . This display table gets generated from the field catalog right
    1 Create a global structute say ZEXTEND_FIELDCAT
    2 Have fields like STYLE type lvc_t_styl
                             COLOR type LVC_T_SCOL.
    3 Now you have to extend ur fieldcatalog
      l_fieldcat-fieldname = COLOR'.
      l_fieldcat-ref_field = 'COLOR'.
      l_fieldcat-ref_table = 'ZEXTEND_FIELDCAT'.
      APPEND l_fieldcat TO lt_field_catalog.
      CLEAR l_fieldcat.

  • Dynamic internal table with repeated structure

    Hi,
        I have a requirement, in which I need to create a dynamic internal table with the below structure.
       Dynamic Int. table structure: fld1 and fld2.
       If another internal table (say int2), contains 3 records, then my final output table should contain the below structure.
                    Value 1              Value 2              Value3          
         fld1     fld2     fld1     fld2     fld1     fld2     
      If in case, the int2 table contains 10 records, then my final output table should contain the structure below.
                    Value 1              Value 2           .....              Value10          
         fld1     fld2     fld1     fld2     .....     fld1     fld2     
    Please advice on how to acquire this. Thanks in advance for your help.
    Regards,
    Swetha.

    You can do it...but it won't be  table... it would be some thing like
    itab
    ref1->  strycture (field 1  field 2 field 3)
    ref2-> structure (field1 field 4 )
    ref3-> structure (field5  field7 )
    say Define a  internal table with a single field to hold  a reference of Data
    Go on creating Rows of different structures and storing the address into the table... you can use RTTS for same
    Use  the below link for RTTS (search on wiki for examples).
    http://wiki.sdn.sap.com/wiki/display/ABAP/RuntimeTypeServices+%28RTTS%29

  • Sum for Dynamic Fields in a Dynamic Table with Field Symbol

    Hi All,
    I currently have an report which I am looking to update with some totals.  The information is currently output in an ALV which is fed data from a dynamic table defined with a field symbol.  The modification that needs to be applied is a summation per currency code where each of the fields to be summed is a dynamically named field at runtime.  I am now just looking to see if anyone has any recommendations on how to obtain these totals it would be appreciated.  I have no problem doing the leg work in piecing the solution together but am just stuck on which approach I should be investigating here.  I have looked into several options but do to the fact that the totals are for dynamic fields in a dynamic table and it is a field symbol I am having some difficulties thinking of the easiest approach to obtain these totals.
    Below is a simple sample of what the report currently looks like and what we are looking to add.
    ====================================================================================
    As-Is Report:
    DETAILED DATA ALV
    Company Code  |  Plant  |  2006 Total  |  2007 Total  |  2008 Total |  CURRENCY
    0001          |   ABCD  |    1,500     |    1,200     |    1,700    |    USD
    0001          |   BCDE   |    2,300     |    4,100     |    3,600    |    GBP
    0003          |   DBCA  |    3,200     |    1,600     |    6,200    |    USD
    Addition 1:
    TOTALS PER CURRENCY
    Currency                |  2006 Total  |  2007 Total  |  2008 Total |
    USD              |    4,700     |    2,800     |    7,900    |
    GBP                       |    2,300     |    4,100     |    3,600    |
    Addition 2:
    CONVERSIONS TO USD
                                          |  2006 Curr   |  2006 USD    |  2008 Curr   |  2006 USD   |
    USD                       |  4,700 USD   |  4,700 USD   |  7,900 USD  |  7,900 USD  |
    GBP   (1.5GBP/1 USD)    |  2,300 GBP   |  1,150 USD   |  2,300 GBP  |  1,800 USD  |
    ====================================================================================
    Any recommendations will be appreciated.

    Hi,
    We cannot use the key word SUM in the loop at assigning statement.
    The way i see is
    When  you are creating the first dynamic internal table , create one more with  the structure below:
    Currency | 2006 Total | 2007 Total | 2008 Total |
    Then while populating the data into first itab,also move the contents to the second itab using collect statement.

  • Dynamic Internal Table with Dynamic Fields

    Hi all,
    My scenario is fairly simple----
    --> End user clicks a button on screen and he gets the list of HR tables.
    --> Then selects a table and list of all the fields for that table gets displayed.
    --> He/she selects the fields they want data to be retrieved for.
    So, the requirement is, the dynamic internal table should get created with the fields selected.
    The select statement should only retrieve fields which were selected by the end user
    and from the table selected by the end user.
    I  believe the fields selected by end user can be passed by a variable of  type string.
    something like this---
    select (fields)
    from (p_table)        " Table selected by end user
    into  dynamic internal table.   " should contain columns selected by end user"
    Appreciate your inputs and guidance.
    Warm regards,
    Hari Kiran

    TYPE-POOLS :ABAP.
    Parameters P_TAB      TYPE        DDOBJNAME.
    DATA  : GO_LINE_TYPE  TYPE REF TO CL_ABAP_STRUCTDESCR,
            GO_TABLE_DESC TYPE REF TO CL_ABAP_TABLEDESCR,
            GS_COMPONENTS TYPE        ABAP_COMPONENTDESCR,
            GT_COMPONENTS TYPE        ABAP_COMPONENT_TAB,
            GR_TAB        TYPE REF TO DATA,
            GT_FIELDS  TYPE TABLE OF DFIES WITH HEADER LINE.
    FIELD-SYMBOLS: <GT_TABLE> TYPE TABLE,
                   <GS_TABLE> TYPE ANY,
                   <GV_VALUE> TYPE ANY.
    CALL FUNCTION 'DDIF_FIELDINFO_GET'
      EXPORTING
        TABNAME              = P_TAB
    *   FIELDNAME            = ' '
    *   LANGU                = SY-LANGU
    *   LFIELDNAME           = ' '
    *   ALL_TYPES            = ' '
    *   GROUP_NAMES          = ' '
    *   UCLEN                =
    * IMPORTING
    *   X030L_WA             =
    *   DDOBJTYPE            =
    *   DFIES_WA             =
    *   LINES_DESCR          =
    TABLES
        DFIES_TAB            =  GT_FIELDS
    *   FIXED_VALUES         =
    EXCEPTIONS
       NOT_FOUND            = 1
       INTERNAL_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 GT_FIELDS.
      CLEAR GS_COMPONENTS.
      GS_COMPONENTS-NAME  = GT_FIELDS-FIELDNAME.
      GS_COMPONENTS-TYPE ?= CL_ABAP_STRUCTDESCR=>DESCRIBE_BY_NAME( GT_FIELDS-ROLLNAME ).
      APPEND GS_COMPONENTS TO GT_COMPONENTS.
    ENDLOOP.
    GO_LINE_TYPE  = CL_ABAP_STRUCTDESCR=>CREATE( GT_COMPONENTS ).
    GO_TABLE_DESC = CL_ABAP_TABLEDESCR=>CREATE( GO_LINE_TYPE ).
    CREATE DATA:  GR_TAB TYPE HANDLE GO_TABLE_DESC.
    ASSIGN:  GR_TAB->* TO <GT_TABLE>.
    SELECT * FROM (P_TAB) APPENDING CORRESPONDING FIELDS OF TABLE <GT_TABLE>.
    LOOP AT <GT_TABLE> ASSIGNING <GS_TABLE>.
      NEW-LINE.
      DO.
        ASSIGN COMPONENT SY-INDEX OF STRUCTURE <GS_TABLE> TO <GV_VALUE>.
        IF SY-SUBRC NE '0'.
          EXIT.
        ENDIF.
        WRITE : <GV_VALUE>.
      ENDDO.
    ENDLOOP.

  • Filling dynamic internal table with data from other internal table

    Hi Friends,
    My problem is that i have already built a dynamic internal table
    (class int_table->create) but now i want to fill it with data from other internal table.
    The dynamic table column name and the field value of the data filled internal table are same, but how to access that column name, since i cant hard code it anyway.
    Like if my werks field value is '8001'. I want to place it under the column 8001 of dynamic table, Can anybody help me in this regard?
    Awarding points is not a problem for even giving a slight hint.
    Best Regards

    Hi
    See this
    Dynamic internal table is internal table that we create on the fly with flexible column numbers.
    For sample code, please look at this code tutorial. Hopefully it can help you
    Check this link:
    http://www.****************/Tutorials/ABAP/DynamicInternaltable/DynamicInternalTable.htm
    Sample code:
    DATA: l_cnt(2) TYPE n,
    l_cnt1(3) TYPE n,
    l_nam(12),
    l_con(18) TYPE c,
    l_con1(18) TYPE c,
    lf_mat TYPE matnr.
    SORT it_bom_expl BY bom_comp bom_mat level.
    CLEAR: l_cnt1, <fs_dyn_wa>.
    Looping the component internal table
    LOOP AT it_bom_expl INTO gf_it_bom_expl.
    CLEAR: l_cnt1.
    AT NEW bom_comp.
    CLEAR: l_cnt, <fs_dyn_wa>, lf_mat.
    For every new bom component the material data is moved to
    temp material table which will be used for assigning the levels
    checking the count
    it_mat_temp[] = it_mat[].
    Component data is been assigned to the field symbol which is checked
    against the field of dynamic internal table and the value of the
    component number is been passed to the dynamic internal table field
    value.
    ASSIGN COMPONENT c_comp_list OF STRUCTURE <fs_dyn_wa> TO
    <fs_check>.
    <fs_check> = gf_it_bom_expl-bom_comp.
    ENDAT.
    AT NEW bom_mat.
    CLEAR l_con.
    ENDAT.
    lf_mat = gf_it_bom_expl-bom_mat.
    Looping the temp internal table and looping the dynamic internal table
    *by reading line by line into workarea, the materialxxn is been assigned
    to field symbol which will be checked and used.
    LOOP AT it_mat_temp.
    l_nam = c_mat.
    l_cnt1 = l_cnt1 + 1.
    CONCATENATE l_nam l_cnt1 INTO l_nam.
    LOOP AT <fs_dyn_table2> ASSIGNING <fs_dyn_wa2>.
    ASSIGN COMPONENT l_nam OF STRUCTURE <fs_dyn_wa2> TO <fs_xy>.
    ENDLOOP.
    IF <fs_xy> = lf_mat.
    CLEAR lf_mat.
    l_con1 = l_con.
    ENDIF.
    Checking whether the material exists for a component and if so it is
    been assigned to the field symbol which is checked against the field
    of dynamic internal table and the level of the component number
    against material is been passed to the dynamic internal table field
    value.
    IF <fs_xy> = gf_it_bom_expl-bom_mat.
    ASSIGN COMPONENT l_nam OF STRUCTURE <fs_dyn_wa> TO <fs_check>.
    CLEAR l_con.
    MOVE gf_it_bom_expl-level TO l_con.
    CONCATENATE c_val_l l_con INTO l_con.
    CONDENSE l_con NO-GAPS.
    IF l_con1 NE space.
    CONCATENATE l_con1 l_con INTO l_con SEPARATED BY c_comma.
    CLEAR l_con1.
    l_cnt = l_cnt - 1.
    ENDIF.
    <fs_check> = l_con.
    l_cnt = l_cnt + 1.
    ENDIF.
    ENDLOOP.
    AT END OF bom_comp.
    At end of every new bom component the count is moved to the field
    symbol which is checked against the field of dynamic internal table
    and the count is been passed to the dynamic internal table field
    value.
    ASSIGN COMPONENT c_count OF STRUCTURE <fs_dyn_wa> TO <fs_check>.
    <fs_check> = l_cnt.
    INSERT <fs_dyn_wa> INTO TABLE <fs_dyn_table>.
    ENDAT.
    ENDLOOP.
    Reward if useful
    Anji

  • Dynamic Internal Table with the same name

    Hey Guys
    I have a question.
    I know that we can create dynamic internal table taking a struct dynamically.
    But I have 2 ques on the same subject.
    1. Can we create an internal table based on a type that we have locally declared eg
    types: begin of ty_demo.
               var1(1) type c,
               var2     type p,
              end of ty_demo.
    2. If an internal table is already declared based on the above type say data: i_tab type standard table of ty_demo.
        If i need to enhance the struct of this internal table. Can i do that by dynamically redefining it based on a different structure but keepin the same name i_tab.
    In a nut shell I cannot change the name of my itab but I want to enhance the structure.
    I Hope I am clear.
    Help will be greatly apprcieated.
    Thanks
    Sameer

    hai.
    we can create an internal table based on a type that we have locally declared, but you have to use data instead of types like.
    data: begin of ty_demo.
    var1(1) type c,
    var2 type p,
    end of ty_demo.
    check the example notes for dynamic itab .
    Dynamic internal table is internal table that we create on the fly with flexible column numbers.
    For sample code, please look at this code tutorial. Hopefully it can help you
    Check this link:
    http://www.****************/Tutorials/ABAP/DynamicInternaltable/DynamicInternalTable.htm
    Sample code:
    DATA: l_cnt(2) TYPE n,
    l_cnt1(3) TYPE n,
    l_nam(12),
    l_con(18) TYPE c,
    l_con1(18) TYPE c,
    lf_mat TYPE matnr.
    SORT it_bom_expl BY bom_comp bom_mat level.
    CLEAR: l_cnt1, <fs_dyn_wa>.
    Looping the component internal table
    LOOP AT it_bom_expl INTO gf_it_bom_expl.
    CLEAR: l_cnt1.
    AT NEW bom_comp.
    CLEAR: l_cnt, <fs_dyn_wa>, lf_mat.
    For every new bom component the material data is moved to
    temp material table which will be used for assigning the levels
    checking the count
    it_mat_temp[] = it_mat[].
    Component data is been assigned to the field symbol which is checked
    against the field of dynamic internal table and the value of the
    component number is been passed to the dynamic internal table field
    value.
    ASSIGN COMPONENT c_comp_list OF STRUCTURE <fs_dyn_wa> TO
    <fs_check>.
    <fs_check> = gf_it_bom_expl-bom_comp.
    ENDAT.
    AT NEW bom_mat.
    CLEAR l_con.
    ENDAT.
    lf_mat = gf_it_bom_expl-bom_mat.
    Looping the temp internal table and looping the dynamic internal table
    *by reading line by line into workarea, the materialxxn is been assigned
    to field symbol which will be checked and used.
    LOOP AT it_mat_temp.
    l_nam = c_mat.
    l_cnt1 = l_cnt1 + 1.
    CONCATENATE l_nam l_cnt1 INTO l_nam.
    LOOP AT <fs_dyn_table2> ASSIGNING <fs_dyn_wa2>.
    ASSIGN COMPONENT l_nam OF STRUCTURE <fs_dyn_wa2> TO <fs_xy>.
    ENDLOOP.
    IF <fs_xy> = lf_mat.
    CLEAR lf_mat.
    l_con1 = l_con.
    ENDIF.
    Checking whether the material exists for a component and if so it is
    been assigned to the field symbol which is checked against the field
    of dynamic internal table and the level of the component number
    against material is been passed to the dynamic internal table field
    value.
    IF <fs_xy> = gf_it_bom_expl-bom_mat.
    ASSIGN COMPONENT l_nam OF STRUCTURE <fs_dyn_wa> TO <fs_check>.
    CLEAR l_con.
    MOVE gf_it_bom_expl-level TO l_con.
    CONCATENATE c_val_l l_con INTO l_con.
    CONDENSE l_con NO-GAPS.
    IF l_con1 NE space.
    CONCATENATE l_con1 l_con INTO l_con SEPARATED BY c_comma.
    CLEAR l_con1.
    l_cnt = l_cnt - 1.
    ENDIF.
    <fs_check> = l_con.
    l_cnt = l_cnt + 1.
    ENDIF.
    ENDLOOP.
    AT END OF bom_comp.
    At end of every new bom component the count is moved to the field
    symbol which is checked against the field of dynamic internal table
    and the count is been passed to the dynamic internal table field
    value.
    ASSIGN COMPONENT c_count OF STRUCTURE <fs_dyn_wa> TO <fs_check>.
    <fs_check> = l_cnt.
    INSERT <fs_dyn_wa> INTO TABLE <fs_dyn_table>.
    ENDAT.
    ENDLOOP.
    regards.
    sowjanya.b

  • Internal table to field symbol

    hi all,
    type-pools : abap.
    field-symbols: <dyn_table> type standard table,
                   <dyn_wa>,
                   <dyn_field>.
    data: dy_table type ref to data,
    dy_line type ref to data,
    xfc type lvc_s_fcat,
    ifc type lvc_t_fcat.
    *data : dyn_itab2 type ANY table.
    selection-screen begin of block b1 with frame.
    parameters: p_table(30) type c.
    selection-screen end of block b1.
    start-of-selection.
    BREAK-POINT.
    perform get_structure.
    perform create_dynamic_itab.
    perform get_data.
    PERFORM OUTPUT.
    *perform write_out.
    form get_structure.
    data : idetails type abap_compdescr_tab,
    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( p_table ).
    idetails = ref_table_des->components.
    *idetails] = ref_table_des->components[.
    loop at idetails into xdetails.
    clear xfc.
    xfc-fieldname = xdetails-name .
    xfc-datatype = xdetails-type_kind.
    xfc-inttype = xdetails-type_kind.
    xfc-intlen = xdetails-length.
    xfc-decimals = xdetails-decimals.
    append xfc to ifc.
    endloop.
    endform.
    form create_dynamic_itab.
    Create dynamic internal table and assign to FS
    call method cl_alv_table_create=>create_dynamic_table
    exporting
    it_fieldcatalog = ifc
    importing
    ep_table = dy_table.
    here i want  to assighn the structure of dy_table to internal atble.
    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>.
    endform.
    form get_data.
    Select Data from table.
    select * into table <dyN_table> UP TO 10 ROWS
    from (p_table).
    endform.
    Write out data from table.
    FORM OUTPUT.
    loop at <dyn_table> into <dyn_wa>.
    do.
    assign component sy-index
    of structure <dyn_wa> to <dyn_field>.
    if sy-subrc = 0.
    exit.
    endif.
    if sy-index = 1.
    write:/ <dyn_field>.
    else.
    write: <dyn_field>.
    endif.
    enddo.
    endloop.
    ENDFORM.
    how can i achieve this one.
    regards
    siva

    Hi,
    Check this Code ...
    LOOP AT <dyn_table> INTO <dyn_wa>.
        DO.
          ASSIGN COMPONENT sy-index
          OF STRUCTURE <dyn_wa> TO <fs_field> .
          IF sy-subrc NE 0.
            EXIT.
          ENDIF.
          IF sy-index = 1.
            WRITE:/ <fs_field>.
          ELSE.
            WRITE: <fs_field>.
          ENDIF.
        ENDDO.
      ENDLOOP.
    For reference check below code
    DATA: it_fieldcat        TYPE lvc_t_fcat                         . " Field catalog
    DATA: wa_fieldcat  LIKE LINE OF it_fieldcat. " Field catalog
    DATA: it_dyn_table      TYPE REF TO data,     " Dynamic table
          it_wa_dyn_table   TYPE REF TO data.     " Dynamic table
    *       Field sysmbols           Begin with <fs>                      *
    FIELD-SYMBOLS:  <fs_dyn_table>       TYPE STANDARD TABLE, " Dynamic tbale
                    <fs_dyn_table_temp>  TYPE ANY           , " Dynamic tbale
                    <fs_field>           TYPE ANY           , " Temp field for data assignment
                    <fs_field_temp>      TYPE ANY           . " Temp field for data assignment
    *       Macro                                                         *
    * Macro Defination
    * Building field catalog using macro defination
    DEFINE m_fieldcat.
      wa_fieldcat-fieldname   = &1.
      wa_fieldcat-scrtext_l   = &2.
      wa_fieldcat-coltext     = &2.
      wa_fieldcat-no_zero     = &3.
      wa_fieldcat-hotspot     = &4.
      wa_fieldcat-outputlen   = &5.
      wa_fieldcat-emphasize   = &6.
    * Appending workarea to internal table
      append wa_fieldcat to it_fieldcat.
      clear wa_fieldcat.
    END-OF-DEFINITION.
    *&      Form  f005_prepare_field_catalog
    *       text
    form f005_prepare_field_catalog .
      REFRESH: it_fieldcat.
    * Build the field catalog
      m_fieldcat text-007 text-008 c_blank  c_blank c_30 c_blank.
      m_fieldcat text-009 text-010 c_blank  c_blank c_30 c_blank.
      SORT it_final_temp BY equnr point.
      SORT it_final BY equnr point psort idate.
      w_date1 = so_date-low.
    * Loop to generate grid column at run time
    * Loop - Till the lower date not equal to higer date
      WHILE so_date-high GE w_date1.
    * Changing date into actual date format using edit mask
        WRITE w_date1 TO w_var4 USING EDIT MASK '__-__-____'.
        m_fieldcat w_var4 w_var4 c_flag c_blank c_12 c_blank.
        w_date1 = w_date1 + c_count.
        CLEAR w_var4.
      ENDWHILE.
    *&      Form  f007_create_dynamic_table
    *       text: Create dynamic table
    form f007_create_dynamic_table .
    * Call method to create dynamic internal table
      CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog           = it_fieldcat
        IMPORTING
          ep_table                  = it_dyn_table
        EXCEPTIONS
          generate_subpool_dir_full = 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.
      SORT it_final_temp BY equnr point.
      SORT it_final BY equnr point psort idate.
      ASSIGN it_dyn_table->* TO <fs_dyn_table>.
      CREATE DATA it_wa_dyn_table LIKE LINE OF <fs_dyn_table>.
      ASSIGN it_wa_dyn_table->* TO <fs_dyn_table_temp>.
      IF it_final_temp IS NOT INITIAL.
        LOOP AT it_final_temp INTO wa_final_temp.
    * Assign equipment number and it's field data to field symbols (Dynamic table)
    * Assign field name to field symbol
          ASSIGN text-007 TO <fs_field_temp>.
    * Assign component name and it's value to dynamic table
          ASSIGN COMPONENT <fs_field_temp> OF STRUCTURE <fs_dyn_table_temp> TO <fs_field>.
    * Assign equipment number value to field symbol
          <fs_field> = wa_final_temp-equnr.
    * Assign Short Description and it's field data to field symbols (Dynamic table)
    * Assign field name to field symbol
          ASSIGN text-009 TO <fs_field_temp>.
    * Assign component name and it's value to dynamic table
          ASSIGN COMPONENT <fs_field_temp> OF STRUCTURE <fs_dyn_table_temp> TO <fs_field>.
    * Assign short description value to field symbol
          <fs_field> = wa_final_temp-psort.
    * Loop to assign value of run time generated column.
          IF it_final IS NOT INITIAL.
            LOOP AT it_final INTO wa_final WHERE equnr = wa_final_temp-equnr
                                            AND point = wa_final_temp-point.
              w_date1 = wa_final-idate.
              WRITE w_date1 TO w_var4 USING EDIT MASK '__-__-____'.
              ASSIGN w_var4 TO <fs_field_temp>.
              ASSIGN COMPONENT <fs_field_temp> OF STRUCTURE <fs_dyn_table_temp> TO <fs_field>.
              <fs_field> = wa_final-cdiff.
              CLEAR: wa_final, w_var4, w_date1.
            ENDLOOP.
          ENDIF.
          CLEAR: wa_final_temp.
    * Assign field symbol temporary table to final dynamic table
          APPEND <fs_dyn_table_temp> TO <fs_dyn_table>.
          CLEAR: <fs_dyn_table_temp>.
        ENDLOOP.
      ENDIF.
    endform.                    " f007_create_dynamic_table

Maybe you are looking for

  • Error while provisioning user into Oracle resource

    I wrote a custom oracle resource adapter and an trying to create a new user and assign this user to the resource. I get the following error when I save the user account. "com.waveset.util.WavesetException: An error occurred connecting to resource " I

  • Do you know how fast your line could go?

    OK we all know that 80Mb/s down and 20Mb/s up is the best we can get with BT on a FTTC and VDSL2 connection. And that is better than their mainstream competition.  I'm not complaining. But yesterday I had some repairs done by an Openreach Engineer. I

  • Calling IP planning sequence several times

    Hi Experts, we are trying to start a IP planning sequence n-times throughout an ABAP report which is located in a  process chain.  In the planning sequence a function from type distribution is located which should distribute line of business nodes to

  • Photoshop Elements 12 editor won't open.

    I get the Adobe sign-in menu when I try to open it asking me if I want to buy or try a 30-day trial.  I can open the Organizer (by going into the program files).  I have been using PSE 12 on my MAC for several months--no problem.  Do I need to reload

  • Will AVI(mpeg-4) files from a still camera to work in iMovie 6?  How?

    I just got Casio's new EX-Z850 still camera that shoots movies in a format they call AVI (mpeg-4). I'd like them to work in iMovie, but they don't seem to work in either iMovie or iPhoto. In iPhoto6.0.2 the Quicktime player comes up, the clips' audio