Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

fetching field-symbol table data into normal inetrnal table

Former Member
0 Kudos

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.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

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.

12 REPLIES 12

Former Member
0 Kudos

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.

Former Member
0 Kudos

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.

0 Kudos

Hello,

To declare the internal table do this:


data:
  it_ptab TYPE TABLE OF <structure name>.

Regards.

Former Member
0 Kudos

sorry ..

its not working..

can anyone please give any code for this scenario ?

Thanks.

0 Kudos

you need to use Assign component and move the data to work area and then Append the data.

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>.

assign component 1 of structure <wa> to <wa_carr>.
it_fl-carrid = <wa_carr>.

assign component 2 of structure <wa> to <wa_carr>.
it_fl-connid = <wa_carr>.
append it_fl.

endloop.
break-point.

0 Kudos

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.

Former Member
0 Kudos

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.

0 Kudos

Post your code to get the idea how you are doing. I will suggest the modification where ever required.

Former Member
0 Kudos

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.

0 Kudos

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> .

Former Member
0 Kudos

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.

0 Kudos

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.