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

CODE

Former Member
0 Likes
1,189

hi,

in my report i need fetch number of line items of a vendor.

for eg:

from lfa1 table i am fetching lifnr

for this lifnr in bsik table how many line items are there.

for eg;

gt_lfa1-lifnr = 900

for this 900 lifnr i have 2 line items in bsik i need get 2 as output.

i mean output should be.

BUKRS LIFNR NO OF LINE ITEMS

0010 900 2

PLEASE HELP HOW TO WRITE CODE FOR THIS

10 REPLIES 10
Read only

Former Member
0 Likes
1,172

select single BUZEI from bsik

where lifnr = ...

and bukrs = .....

Read only

Former Member
0 Likes
1,172

after getting data from bsik

loop at it_bsik.

v_count = v_count + 1.

at end of lifnr.

write 😕 it_bsik-bukrs , it_bsik-lifnr , v_count.

clear : v_count

endat

endloop.

Read only

Former Member
0 Likes
1,172

hi use this...

1.loop at bsik table...

2 . use at end of lifnr

3. use counter.

Read only

peter_ruiz2
Active Contributor
0 Likes
1,172

hi kiran,

use this.


SELECT count(buzei)
   INTO ld_count
   FROM bsik
    FOR ALL ENTRIES IN it_lfa1
WHERE lifnr eq it_lfa1-lifnr.

regards,

Peter

Read only

Former Member
0 Likes
1,172

Hi,

try this code....

TABLES BSIK.

TYPES: BEGIN OF TY_BSIK,

BUKRS TYPE BUKRS,

LIFNR TYPE LIFNR,

END OF TY_BSIK.

DATA : IT_BSIK TYPE STANDARD TABLE OF TY_BSIK WITH HEADER LINE.

DATA : V_COUNT TYPE I.

PARAMETERS: P_BUKRS TYPE BUKRS.

SELECT BUKRS

LIFNR

FROM BSIK

INTO TABLE IT_BSIK

WHERE BUKRS EQ P_BUKRS.

LOOP AT IT_BSIK.

V_COUNT = V_COUNT + 1.

AT END OF LIFNR.

WRITE 😕 IT_BSIK-BUKRS , IT_BSIK-LIFNR , V_COUNT.

CLEAR : V_COUNT.

ENDAT.

ENDLOOP.

-Regards.

Read only

Former Member
0 Likes
1,172

Ihave written even though i am not getting.

the code is

loop at GT_bsik.

v_count = v_count + 1.

at end of lifnr.

MOVE V_COUNT TO GT_FINAL-LV_INV.

clear : v_count.

endat.

endloop.

Read only

0 Likes
1,172

write as below ...

loop at GT_bsik.

v_count = v_count + 1.

at end of lifnr.

read table GT_bsik index sy-tabix.

move-corresponding GT_bsik to GT_FINAL.

MOVE V_COUNT TO GT_FINAL-LV_INV.

append GT_FINAL.

clear : v_count.

endat.

endloop.

Read only

0 Likes
1,172

hi,

try this

sort gt_bsik by lifnr.

loop at GT_bsik.

v_count = v_count + 1.

at end of lifnr.

MOVE V_COUNT TO GT_FINAL-LV_INV.

append gt_final.

clear : v_count.

endat.

endloop.

regards,

Peter

Read only

Former Member
0 Likes
1,172

hi to select all the line items use like this

select f1 f2 f3 from lfa1 into table t_lfa1

where lifnr = <condt>.

if not t_lfa1[] is initial.

select f1 f2 f3 f4 from bsik into table t_bsik

for all entries in t_lfa1[]

where lifnr = t_lfa1-lifnr.

endif.

use this . for whatever lifnr in lfa1 whatever entries are there in bsik will be selected in t_bsik table .

Reward if helpful

Regards

Read only

JanStallkamp
Advisor
Advisor
0 Likes
1,172

Hi.

You can increase the number of people reading your question by using a better subject. Describe your issue and more people get interested in reading your posting. Please have a look into our rules of engagement which will explain some other things you should know as a member of SDN. Postings not following the rules will be locked or deleted.

Best regards,

Jan Stallkamp