09-23-2008 1:06 PM
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.
09-23-2008 1: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.
09-23-2008 1: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.
09-23-2008 1: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.
09-23-2008 1:18 PM
Hello,
To declare the internal table do this:
data:
it_ptab TYPE TABLE OF <structure name>.
Regards.
09-23-2008 1:43 PM
sorry ..
its not working..
can anyone please give any code for this scenario ?
Thanks.
09-23-2008 1:57 PM
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.
09-23-2008 1:59 PM
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.
09-23-2008 3: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.
09-23-2008 3:44 PM
Post your code to get the idea how you are doing. I will suggest the modification where ever required.
09-23-2008 3: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.
09-23-2008 4:33 PM
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> .
09-23-2008 4: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.
09-23-2008 5:38 PM
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.