Skip to Content
author's profile photo Former Member
Former Member

convert field symbol to internal table

hi experts,

is there any way to convert field symbol to internal table?

my field symbols is declared as a table.

field-symbols: <f_fs> type any table.

thx in advance.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Posted on Jan 07, 2008 at 10:05 PM

    Hello Meei

    If you want to create itabs dynamically the answer is yes.

    Example:

    DATA:
      ld_tabname   TYPE tabname,
      ldo_data        TYPE REF TO data.
    
    FIELD-SYMBOLS:
      <lt_itab>  TYPE TABLE,
      <ls_line>  TYPE any.
    
      ld_tabname = 'KNB1'.
      CREATE DATA ldo_data TYPE TABLE OF (ld_tabname).
    
      ASSIGN ldo_data->* TO <lt_itab>.  " de-referencing of data object
    
      LOOP AT <lt_itab> ASSIGNING <ls_line>.
      "  do processing...
      ENDLOOP.
    

    Regards,

    Uwe

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 07, 2008 at 10:10 PM

    Its not possible to convert directly - you should move the data from the field symbol to internal table.

    regards,

    Satya

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 08, 2008 at 04:07 AM

    Hello meei,

    See this code, i'm not sure if its exactly what you want

    DATA : LV_DBTAB1 LIKE DD02L-TABNAME.

    DATA : DREF TYPE REF TO DATA.

    FIELD-SYMBOLS: <ITAB> TYPE ANY TABLE, " used to store dynamic tables

    <WA> TYPE ANY, " used to store record data

    <WA1> TYPE ANY . " used to store field data

    LV_DBTAB1 = 'MARA'.

    data: it_mara like mara occurs 0 with header line.

    CREATE DATA DREF TYPE STANDARD TABLE OF (LV_DBTAB1)

    WITH NON-UNIQUE DEFAULT KEY.

    ASSIGN DREF->* TO <ITAB> .

    selects all data

    SELECT * FROM (LV_DBTAB1) INTO TABLE <ITAB> .

    LOOP AT <ITAB> ASSIGNING <WA>.

    APPEND <WA>

    Reward if useful

    thanks,

    swaroop.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 08, 2008 at 04:10 AM

    Hai meei,

    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.saptechnical.com/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.

    With Regards,

    Sowjanya.B

    Please reward points if helpful.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.