‎2008 Feb 26 4:37 AM
Hi all,
I have output data like.
belnr wrbtr1 wrbtr2 wrbtr3
89990 290
89990 234
89990 897
89991 342
89991 586
89991 562
But need output like thes.
belnr wrbtr1 wrbtr2 wrbtr3
89990 290 234 897
89991 342 586 562
‎2008 Feb 26 4:56 AM
Hi,
Try like this
data : v_index type i.
v_index = 2.
loop at itab into wa_tab.
read table itab into wa_tab1 index v_index.
if wa_tab1-belnr = wa_tab-belnr and wa_tab-wrbtr2 is initial.
move : wa_tab1-wrbtr1 to wa_tab-wrbtr2.
modify itab from wa_tab index 1.
clear : wa_tab,
wa_tab1.
elseif wa_tab1-belnr = wa_tab-belnr and wa_tab-wrbtr3 is initial.
move : wa_tab1-wrbtr1 to wa_tab-wrbtr3.
modify itab from wa_tab index 1.
clear : wa_tab,
wa_tab1.
endif.
v_index = v_index + 1.
endloop.
Regards,
Nagaraj
‎2008 Feb 26 4:55 AM
hi,
You can use ALV list or grid for this. or use the write statement in such a way to appear like this. Iys better to use ALV.
Hope this helps u.
Regards,
Arunsri
‎2008 Feb 26 4:55 AM
Hi,
SORT for Internal Tables
Sorts internal tables.
Syntax
SORT <itab> [ASCENDING|DESCENDING] [AS TEXT] [STABLE]
... BY <fi> [ASCENDING|DESCENDING] [AS TEXT]...
Sorts the internal table <itab>. If you omit the BY addition, the table is sorted by its key. You can define a different sort key by using the BY addition. The other additions specify whether you want to sort in ascending or descending order, and whether strings should be sorted alphabetically.
It might be useful.
Regards,
Priya.
‎2008 Feb 26 4:56 AM
Hi,
Try like this
data : v_index type i.
v_index = 2.
loop at itab into wa_tab.
read table itab into wa_tab1 index v_index.
if wa_tab1-belnr = wa_tab-belnr and wa_tab-wrbtr2 is initial.
move : wa_tab1-wrbtr1 to wa_tab-wrbtr2.
modify itab from wa_tab index 1.
clear : wa_tab,
wa_tab1.
elseif wa_tab1-belnr = wa_tab-belnr and wa_tab-wrbtr3 is initial.
move : wa_tab1-wrbtr1 to wa_tab-wrbtr3.
modify itab from wa_tab index 1.
clear : wa_tab,
wa_tab1.
endif.
v_index = v_index + 1.
endloop.
Regards,
Nagaraj
‎2008 Feb 26 4:57 AM
Ankita,
Take one internal table which should have your required structure.
DATA : v_temp TYPE I,
v_cnt TYPE I .
LOOP AT ITAB.
v_temp = v_temp + 1.
ON CHANGE OF ITAB-belnr
v_cnt = v_cnt + 1.
MOVE : ITAB-belnr To i_final-belnr.
ITAB-wrbtr1 TO i_final-wrbtr1.
APPEN I_final.
CLEAr i_final.
ENDON.
IF v_temp Eq 2.
MOVE : ITAB-wrbtr1 TO i_final-wrbtr2.
INSERT i_FINAL INDEX v_CNT
ELSEIF v_temp Eq 3
MOVE : ITAB-wrbtr1 TO i_final-wrbtr3.
INSERT i_FINAL INDEX v_CNT
CLEAR v_temp.
ENDIF.
ENDLOOP.
‎2008 Feb 26 5:01 AM
Hi,
Please try the following,
Suppose your internal table contains your fields as mentioned.
Please use
SORT <internal_table> DESCENDING BY BELNR WRBTR1 WRBTR2 WRBTR3.
Reward if Helpful.
‎2008 Feb 26 5:06 AM
Hi,
try like dis.....
DATA c.
LOOP AT itab.
c = c + 1.
CASE c.
WHEN 2.
itab-wrbtr2 = itab-wrbtr1.
WHEN 3.
itab-wrbtr3 = itab-wrbtr1.
AT END OF belnr.
APPEND itab.
CLEAR c.
ENDAT.
ENDCASE.
ENDLOOP.
LOOP AT itab WHERE itab-wrbtr2 IS INITIAL
AND itab-wrbtr3 IS INITIAL.
DELETE itab.
ENDLOOP.Cheers,
jose.
‎2008 Feb 26 5:15 AM