‎2008 Dec 16 7:52 AM
My internal table contains data like.
123102 | CAR | computer | 987654321 | Y010 | Z000000001 | 107999 | WASHINGTON | 300 DR. | HOUSTON | US | PA | 15342 |
How can i read data field by field into anthor internal table.
i want data like
123102 car computer 987654321
Regards,
Suresh
‎2008 Dec 16 8:01 AM
Hi Suresh,
I assume that you want to copy only the first four fields into another internal table.
If my assumption is correct you can do as follows.
it_tab1, wa_tab1 of structure:
123102 CAR computer 987654321 Y010 Z000000001 107999 WASHINGTON 300 DR. HOUSTON US PA 15342
it_tab2, wa_tab2 of structure:
123102 CAR computer 987654321
loop at it_tab1 into wa_tab1.
wa_tab2-f1 = wa_tab1-f1.
wa_tab2-f2 = wa_tab1-f2.
wa_tab2-f3 = wa_tab1-f3.
wa_tab2-f4 = wa_tab1-f4.
append wa_tab2 to it_tab2.
endloop.Regards,
Manoj Kumar P
‎2008 Dec 16 8:01 AM
Hi Suresh,
I assume that you want to copy only the first four fields into another internal table.
If my assumption is correct you can do as follows.
it_tab1, wa_tab1 of structure:
123102 CAR computer 987654321 Y010 Z000000001 107999 WASHINGTON 300 DR. HOUSTON US PA 15342
it_tab2, wa_tab2 of structure:
123102 CAR computer 987654321
loop at it_tab1 into wa_tab1.
wa_tab2-f1 = wa_tab1-f1.
wa_tab2-f2 = wa_tab1-f2.
wa_tab2-f3 = wa_tab1-f3.
wa_tab2-f4 = wa_tab1-f4.
append wa_tab2 to it_tab2.
endloop.Regards,
Manoj Kumar P
‎2008 Dec 16 8:09 AM
What i understand from this is that the new table should be like this
123102 CAR computer 987654321
Y010 Z000000001 107999 WASHINGTON
300 DR. HOUSTON US PA 15342
For this
LOOP at MAIN_table into wa.
wa1-f1 = wa-f1.
wa1-f2 = wa-f2.
wa1-f3= wa-f3.
append wa1 to final_table.
wa1-f1 = wa-f4
wa1-f2 = wa-f5
wa1-f3 = wa-f6
append wa1 to final_table.
wa1-f1 = wa-f7
wa1-f2 = wa-f8
wa1-f3 = wa-f9
append wa1 to final_table.
endloop.
final_table will have the desired output.
Regards,
Prashant
‎2008 Dec 16 8:10 AM
Hi,
Try like this:
data: begin of o_list occurs 0,
output(1500) type c,
end of o_list.
data: begin of i_list occurs 0,
fld1(32) type c,
fld2(50) type c,
end of i_list.
o_list-output = '123102 CAR computer 987654321 Y010 Z000000001 107999 WASHINGTON 300 DR. HOUSTON US PA 15342 '.
append o_list.
loop at o_list.
write:/ o_list-output.
endloop.
i_list-fld1 = o_list-output+0(32).
i_list-fld2 = o_list-output+34(68).
append i_list.
loop at i_list.
write:/ i_list-fld1,
/ i_list-fld2.
endloop.
Regards,
Bhaskar
‎2008 Dec 16 8:29 AM
>
> |123102 |CAR |computer |987654321 |Y010|Z000000001|107999 |WASHINGTON|300 DR.| |HOUSTON| |US |PA |15342 | |
> Suresh
Is this a string? Is this a list of field components? Or whatever?
‎2008 Dec 16 8:49 AM
Hello,
You can do like:
let the 1st internal table be itab1 and its work area is wa1,
and the 2nd internal statement is itab2 and its work area is wa2.
Then we can write:
loop at itab1 into wa1.
move : wa1-field1 to wa2-field2.
wa1-field2 to wa2-field2.
wa1-field3 to wa2-field3.
append wa2 to itab2.
Hope this helps you.
Mansi
‎2008 Dec 16 9:01 AM
Hi Suresh,
Say you have two internal tables 'itab1' and 'itab2' with work areas 'wa1' and 'wa2' respectively.
Suppose 'itab1' contains some records in it.
To copy all contents of 'itab1' to 'itab2', you can use:-
itab2 = itab1.
To copy values of selected fields from 'itab1' to 'itab2', you can use:-
loop at itab1 into wa1.
wa2-field1 = wa1-field1. "move field values from wa1 to wa2
wa2-field2 = wa1-field2.
wa2-field3 = wa1-field3.
wa2-field4 = wa1-field4.
append wa2 to itab2. "append itab2
clear wa2. "clear wa2
endloop.
Hope this solves your problem.
Thanks & Regards
Tarun Gambhir
‎2008 Dec 16 10:32 AM
Hi there,
If I were you .. I wud make row into column.
for eg:
loop at ur internal table1 into work area1.
split workarea at '|' into
another work area2 with all the fields in the workarea1
append workarea2 to inttable2.
endloop.
hope this helps
reg