‎2008 Jun 20 10:09 AM
hi,
i am fetching lifnr from lfb1 table. ineed to check for this vendor how many line items available in bsik table and need to display the total number of line items in output.
suppose in lfb1 table lifnr 10001 is there , in bsik table i have 2 line items for this lifnr, inned to get 2 in output.
gt_lfb1[] = 1
gt_bsik[] = 2.
please help me to write code do we need to take variable or is there any way.
please help
‎2008 Jun 20 10:11 AM
‎2008 Jun 20 10:13 AM
Hi,
select lifnr into table i_lfb1
from LFB1.
if sy-subrc eq 0 and i_lfba[] is not initial.
select * into i_bsik
from BSIK
for all entries in i_lfb1
where lifnr = i_lfb1-linfr.
endif.
It is better to use Company Code also.
Hope this helps you.
Kind Regards,
Ravi Sankar.Z
Edited by: Ravi Sankara. Z on Jun 20, 2008 11:13 AM
‎2008 Jun 20 10:16 AM
Hi Kiran,
First fetch the data from LFB1, and from the correspondign LIFNR, fetch the data from the other table using FOR ALL ENTRIES. Then use the statement DESCRIBE TABLE IT_BSIK LINES L, where L contains the number of line items from BSIK.
THANKS,
RAM.
Edited by: Ram K on Jun 20, 2008 11:17 AM
Edited by: Ram K on Jun 20, 2008 11:17 AM
‎2008 Jun 20 10:17 AM
Hi,
After select the data from data base use statement DESCRIBE TABLE <table name> LINES <any variable of type i>, will give the total number of records in the particular internal table.
Or
After every select statement use the system field SY-DBCNT, to get the number of records that you fetched from the data base table.
Rgds,
Bujji
‎2008 Jun 20 10:17 AM
Hi Kiran,
Once you populate both the table then put the
Describle statement
It will return the number
&********Reward Point if helpful***********&
‎2008 Jun 20 10:24 AM
Hi
first select lifnr from lfbi......
then select line items from bsik in final intrenal table
data count type i value 0.
sort final internal table
loop at final internaltable
at new lifnr.
write : ifinal-lifnr.
endat.
write : ifinal-lineitems.
count = count + 1.
at end of lifnr.
write count.
endat.
endloop.
‎2008 Jun 20 10:26 AM
Hi,
If you need to count the number of line items against that vendor, it can be done in this way.
data: cnt type i.
select lifnr bukrs
from lfb1
into table itab1
where lifnr = p_lifnr.
if not itab1 is initial.
select lifnr
bukrs
belnr
budat
form bsik
into table itab2
for all entries in itab1
where lifnr = itab1-lifnr
and bukrs = itab1-bukrs.
endif.
cnt = 0.
loop at itab2 into wa_itab2.
cnt = sy-tabix + cnt.
endloop.
write: cnt.
Hope this helps you.
Plz reward if useful.
Thanks,
Dhanashri.