‎2008 Mar 18 9:05 AM
Hi all experts
my requirement is to get the number of records from a itab,
for a particular document number.
and my itab is having so many document.
how to find the number of record for particular document??
‎2008 Mar 18 9:13 AM
Hi,
Try this logic.
say L_number has the value.
sort lt_number by vnumber.
loop at lt_values where number = l_number.
count = count + 1.
endloop.
write: count.
‎2008 Mar 18 9:15 AM
REPORT zsdq_gen_test .
data: begin of itab occurs 0,
doc type bkpf-belnr,
end of itab.
data: itab1 like itab occurs 0 with header line,
itab2 like itab occurs 0 with header line.
data: lno type i.
select belnr
from bseg
into table itab
up to 50 rows.
itab1[] = itab[].
sort itab1 by doc.
delete adjacent duplicates from itab1 comparing doc.
loop at itab1.
itab2[] = itab[].
sort itab2 by doc.
delete itab2[] where doc ne itab1-doc.
if not itab2[] is initial.
describe table itab2 lines lno.
write:/ lno.
endif.
refresh: itab2.
endloop.
‎2008 Mar 19 10:43 PM
Hi nancy,
let reqd num be the document number for which u want to know the number of records.
->sort ltab by document number.
->loop the ltab where document number = reqdnum.
->Keep a counter and increment it if the stmt satisfies
->Print that counter.
Thanks & Regards,
AMK.
REWARD POINTS IF USEFUL.
‎2008 Mar 20 4:14 AM
If you know the document number,
then try the below code.
itab1[] = itab[].
delete itab1 where docnum ne lv_docnum.
describe itab1 lines lv_lines.
"now lv_lines will contain the number of records for the particular document number
If you want to know the number of records for each document number in itab.
sort itab by docnum.
loop at itab.
at new docnum.
clear: lv_count.
endat.
lv_count = lv_count + 1.
at end of docnum.
write:/ itab-docnum, lv_count.
endat.
endloop.
hope this helps.
Thanks,
Balaji
‎2008 Mar 24 1:45 PM
Hi Nancy,
Nyaz idea is quite good but it can be done faster.
loop at itab TRANSPORTING NO FIELDS
where docnum = <docnum to count entries for>.
add 1 to doccount.
endloop.
Regards,
Clemens
BTW: What is the OO relevence?
‎2010 Feb 01 7:08 AM