‎2010 Jan 22 3:16 AM
Hi Friends,
I need logic for this problem ,
problem is like i have a internal table in which i am having some fields i need to format it and to get a new table .
e.g., This is the table with F1 , F2 , F3 , F4 ,F5 table is sorted on the base of F2 & F3
Based upon the Field F4 i need to format this given internal table .
F1 F2 F3 F4 F5
11 X 112 A -
12 X 112 A -
13 X 112 A -
14 Y 112 A -
15 Y 112 B -
16 Y 112 B -
17 Y 112 C -
Desired output .
F1 F2 F3 F4 F5
11 x 112 A 11/12/13
14 Y 112 A 14
15 Y 112 B 15/16
17 Y 112 C 17
Thanks & Regards
Digvijay
‎2010 Jan 22 4:33 AM
Hi Digvijay,
You can refer below logic and by modifying it a little bit you will be able to achieve your output.
itab[] = i_itab[]. "your internal table.
Loop at itab into wa_itab.
if sy-tabix > 1.
v_f1 = wa_itab-f1.
v_index = sy-tabix - 1.
read table itab into wa_itab_new with index v_index.
if sy-subrc eq 0.
v_f2 = wa_itab_new-f2.
v_f4 = wa_itab_new-f4.
endif.
if wa_itab-f2 eq v_f2 and wa_itab-f4 eq v_f4.
v_f5 = wa_itab_new-f1.
v_index = sy-tabix + 1.
delete itab with index v_index.
concatenate v_f5 / v_f1 to wa_itab_new-f5.
*modify new_itab from wa_itab transporting f5.
else.
continue.
endif.
endif.
clear: wa_itab, v_f5, wa_itab_new, v_f1, v_f2, v_f4.
endloop.
Thansk,
Archana
Edited by: Archana Pawar on Jan 22, 2010 5:34 AM
‎2010 Jan 22 3:24 AM
Hello digvijay...!
you can sort the interanl table according to the fields and
use control break statment
Like
LOOP AT ITAB
AT NEW <your field>.
your code
ENDAT.
AT LAST.
your code logic
ENDAT.
AT FIRST.
ENDAT.
ENDLOOP.
‎2010 Jan 22 4:33 AM
Hi Digvijay,
You can refer below logic and by modifying it a little bit you will be able to achieve your output.
itab[] = i_itab[]. "your internal table.
Loop at itab into wa_itab.
if sy-tabix > 1.
v_f1 = wa_itab-f1.
v_index = sy-tabix - 1.
read table itab into wa_itab_new with index v_index.
if sy-subrc eq 0.
v_f2 = wa_itab_new-f2.
v_f4 = wa_itab_new-f4.
endif.
if wa_itab-f2 eq v_f2 and wa_itab-f4 eq v_f4.
v_f5 = wa_itab_new-f1.
v_index = sy-tabix + 1.
delete itab with index v_index.
concatenate v_f5 / v_f1 to wa_itab_new-f5.
*modify new_itab from wa_itab transporting f5.
else.
continue.
endif.
endif.
clear: wa_itab, v_f5, wa_itab_new, v_f1, v_f2, v_f4.
endloop.
Thansk,
Archana
Edited by: Archana Pawar on Jan 22, 2010 5:34 AM
‎2010 Jan 29 12:12 PM