‎2007 Nov 29 7:52 AM
I have an internal table :
ITAB containing :
================
Material1 decription
Material1 decription
Material1 decription
Material1 decription
Material2 decription
Material2 decription
Material2 decription
Material2 decription
Material3 decription
Material3 decription
Material3 decription
=============
I want the outout in another table as
Material1 4
Material2 4
Material3 3
===========
Here 4 and 3 are the number of records of each material in the internal table.
Any logic?
thanks
‎2007 Nov 29 7:56 AM
loop at itab into wa.
at new materia..
flag =X.
clear count.
endat.
if flag = x.
count = count + 1.
endif.
endloop.
‎2007 Nov 29 7:56 AM
loop at itab into wa.
at new materia..
flag =X.
clear count.
endat.
if flag = x.
count = count + 1.
endif.
endloop.
‎2007 Nov 29 7:58 AM
Hi Pranu,
loop at itab into wa.
at end of matnr.
append wa to itab2.
endat.
endloop.
Regards,
Kaveri
‎2007 Nov 29 7:58 AM
hi Pranu,
DATA : BEGIN OF itab2 OCCURS 0,
material TYPE matnr,
number TYPE i,
END OF itab2.
LOOP at itab. " Your original itab
itab2-material = itab-material.
itab2-number = 1.
COLLECT itab2.
ENDLOOP.
hope this helps
ec
‎2007 Nov 29 7:59 AM
take another int table as itab1 with matnr and count field.
data : counter type i,
wtab like itab.
sort itab by matnr.
loop at itab.
counter = counter + 1.
mov-corresponding itab to wtab.
at end of itab-matnr.
itab1-matnr = wtab-matnr.
itab1-count = counter.
append itab1.
clear counter.
endat.
endloop.
regards
shiba dutta
‎2007 Nov 29 7:59 AM
data: cnt type i.
data: itab type table of spfli .
data: begin of itab1 occurs 0,
carrid type spfli-carrid,
count type i,
end of itab1.
data: wa type spfli.
cnt = 0.
select * from spfli into table itab.
loop at itab into wa.
cnt = cnt + 1.
at end of carrid.
itab1-carrid = wa-carrid.
itab1-count = cnt.
append itab1.
cnt = 0.
endat.
endloop.
loop at itab1.
write:/ itab1-carrid, itab1-count.
endloop.
‎2007 Nov 29 8:01 AM
HI Try like this.
DATA lt_newtab LIKE oldtab OCCURS 0 WITH HEADER LINE.
DATA lwa_item LIKE lt_newtab.
SORT oldtab BY material decribtion.
LOOP AT oldtab.
CLEAR lwa_item.
MOVE oldtab TO lwa_item.
AT END OF material.
APPEND lwa_item TO t_newtab.
ENDAT.
ENDLOOP.