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

logic

Former Member
0 Likes
961

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

7 REPLIES 7
Read only

Former Member
0 Likes
943

Hi,

use for all entries and describe table.

Regards

Adil

Read only

ravisankara_varaprasad
Active Participant
0 Likes
943

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

Read only

Former Member
0 Likes
943

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

Read only

Former Member
0 Likes
943

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

Read only

Former Member
0 Likes
943

Hi Kiran,

Once you populate both the table then put the


Describle statement 

It will return the number

&********Reward Point if helpful***********&

Read only

Former Member
0 Likes
943

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.

Read only

Former Member
0 Likes
943

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.