Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

describe table

Former Member
0 Likes
697

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??

6 REPLIES 6
Read only

Former Member
0 Likes
645

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.

Read only

Former Member
0 Likes
645

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.

Read only

Former Member
0 Likes
645

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.

Read only

Former Member
0 Likes
645

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

Read only

Clemenss
Active Contributor
0 Likes
645

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?

Read only

Former Member
0 Likes
645

Thnks