Skip to Content
avatar image
Former Member

fetching field-symbol table data into normal inetrnal table

Hi All,

I have data in table <FS> .

but, i want to transfer it to normal internal table ptab.

please tell me , how to define such inetrnal table ?

can i write code like :

Loop at <F_FS> into <fs_wa>.

MOVE-CORRESPONDING <fs_wa> TO wa_ptab.

append wa_ptab to it_ptab.

Endloop.

Thanks.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

6 Answers

  • Best Answer
    avatar image
    Former Member
    Sep 23, 2008 at 12:09 PM

    you can write the code as it is...

    Loop at <F_FS> into <fs_wa>.

    MOVE-CORRESPONDING <fs_wa> TO wa_ptab.

    append wa_ptab to it_ptab.

    Endloop.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 23, 2008 at 12:13 PM

    Thanks ramesh.

    But....using this code i m getting following error..

    IT_PTAB" is not a data reference variable

    i think ..i have not defined inetrnal table properly.

    can u please tell ....how i should define internal table ptab ?

    Thanks.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hello,

      To declare the internal table do this:

      data:
        it_ptab TYPE TABLE OF <structure name>.
      

      Regards.

  • avatar image
    Former Member
    Sep 23, 2008 at 12:43 PM

    sorry ..

    its not working..

    can anyone please give any code for this scenario ?

    Thanks.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hello,

      DATA:
        lt_spfli TYPE TABLE OF spfli,
        ls_spfli LIKE LINE OF lt_spfli,
        lr_spfli TYPE REF TO data.
      
      FIELD-SYMBOLS:
        <fs_spfli> TYPE INDEX TABLE.
      
      CREATE DATA lr_spfli TYPE TABLE OF spfli.
      
      ASSIGN lr_spfli->* TO <fs_spfli>.
      
      SELECT * FROM spfli INTO TABLE <fs_spfli>.
      
      * Transfering data between tables.
      
      lt_spfli = <fs_spfli>.
      
      * OR
      
      LOOP AT <fs_spfli> INTO ls_spfli.
        APPEND ls_spfli TO lt_spfli.
      ENDLOOP.
      

      Regards.

  • avatar image
    Former Member
    Sep 23, 2008 at 02:38 PM

    Hi Vijay and david,

    Thanks for your replies.

    Points assigned to you. both.

    Vijay,

    Can you please tell me how i can use your code if my stucture is dynamic.

    ( 😔 .. i cannt use this code since i am defining structure dynamically ).

    Thanks.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 23, 2008 at 02:55 PM

    My code is :

    SELECT * FROM (p_tab)

    INTO CORRESPONDING FIELDS OF TABLE <F_FS>

    WHERE (is_where-where_tab).

    • my table data is in internal table <F_FS>

    data: it_ptab TYPE TABLE OF <F_FS>,

    wa_ptab TYPE LINE OF it_ptab.

    DATA : it_ptab1 LIKE it_ptab OCCURS 0.

    Loop at <F_FS> INTO <fs_wa>.

    MOVE-CORRESPONDING <fs_wa> TO wa_ptab.

    append wa_ptab to it_ptab1.

    Endloop.

    i want to transfer my <F_FS> data to internal table it_ptab

    Thanks.

    Add comment
    10|10000 characters needed characters exceeded

    • Loop at <F_FS> INTO <fs_wa>.

      append <fs_wa> to it_ptab1. "whats wrong with this..

      Endloop.

      if there is no difference in the structure then you don;t need a loop also.

      you can equate the body of the two tables.

      it_ptab1 = <F_FS> .

  • avatar image
    Former Member
    Sep 23, 2008 at 03:48 PM

    Hi Vijay..

    Its now giving an error as:

    The type "<F_FS>" is unknown.

    Could you please give any of your code ...in which moving of data from <field-symbol> to internal table " itab " is given.

    Thanks.

    Add comment
    10|10000 characters needed characters exceeded

    • Little change in my above post..

      field-symbols: <fs> type standard table,
                      <wa> type any,
                      <wa_carr> type any.
      
      data: it_flight type table of  sflight.
      data: wa_flight type sflight.
      
      data: begin of it_fl occurs 0,
             carrid type sflight-carrid,
             connid type sflight-connid,
            end of it_fl.
      
      select * from sflight
      into table it_flight
      up to 20 rows.
      
      assign it_flight to <fs>.
      assign wa_flight to <wa>.
      
      
      loop at <fs> into <wa>.
      
      move-CORRESPONDING <wa> to it_fl. "working fine 
      append it_fl.
      
      endloop.
      break-point.