05-21-2008 6:52 AM
Hi ,
I have internal table with 5 colums .I want to move the contents of column number 3 to column number 2 and column 2 contents to column 3 with out affecting my data .
Any points are appriciated.
Edited by: zareena molla on May 21, 2008 7:58 AM
05-21-2008 7:00 AM
use another temporary table and move the data accordingly.
Ex:
Suppose you have a internal table itab1 with column c1, c2, c3, c4, c5.
Declare an internal table itab2 same as itab1.
Loop at itab1.
Itab2-c1 = itab1-c1.
Itab2-c2 = itab1-c3.
Itab2-c3 = itab1-c2.
Itab2-c4 = itab1-c4.
Itab2-c5 = itab1-c5.
Append itab2.
Clear itab1.
Endloop.
Clear: itab1[].
Itab1[] = itab2[].
05-21-2008 7:06 AM
Hi,
While ur internal table declaration just interchange the column 2 and column 3 names .
eg.
conside first case:
DATA: BEGIN OF it_zfit_tds OCCURS 0,
zseqno LIKE zfit_tds-zseqno,
gl LIKE bsas-hkont,
ztdsdes LIKE zfit_tds-ztdsdes,
END OF it_zfit_tds.
After Interchanging:
DATA: BEGIN OF it_zfit_tds OCCURS 0,
zseqno LIKE zfit_tds-zseqno,
ztdsdes LIKE zfit_tds-ztdsdes,
gl LIKE bsas-hkont,
END OF it_zfit_tds.
05-21-2008 7:06 AM
Hi zareena,
You can do this way.
data: begin of itab occurs 0,
row1 type char5,
row2 type char5,
row3 type char5,
row4 type char5,
row5 type char5,
end of itab.
data: l_row2 type char5.
loop at itab.
l_row2 = itab-row2.
itab-row2 = itab-row3.
itab-row3 = l_row2.
modify itab index sy-tabix transporting itab-row2 itab-row3.
clear l_row2.
endloop.
regards
raja
05-21-2008 7:21 AM
You can use field symbols as well this will be more efficent
Loop at it_tab assigning <fs_it_tab>.
temp = <fs_it_tab>-col3.
<fs_it_tab>-col3 =<fs_it_tab>-col2.
<fs_it_tab>-col2 = temp.
Endloop.
Reward points if helpful
Regards
Bikas