Application Development 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: 

ABOUT SELECT STATEMENT

Former Member
0 Kudos

My friends i have one question i tried it out but i am not getting the required output

Q ) I WANT TO KNOW IN THIS YEAR 2008 WHAT IS THE LARGEST SELLING ITEM IN MY COMPANY

I TRIED IT OUT LIKE THIS

BUT INSTEAD OF SUMMING UP ALL THE KBMENG VALUES I AM GETTING NILL VALUES HOW TO MAKE IT

PLEASE FIND ME THE SOLUTION. SO THAT I CAN PROCEED FURTHER

TABLES : vbak,

vbap.

DATA : BEGIN OF st,

matnr LIKE vbap-matnr, "Material Number

kbmeng LIKE vbap-kbmeng, "Cumulative confirmed Quantity in sales unit

END OF st.

DATA it LIKE st OCCURS 0 WITH HEADER LINE. "Internal table 1 decleration

SELECT-OPTIONS my_erdat FOR vbak-erdat. "date field

INITIALIZATION.

START-OF-SELECTION.

SELECT amatnr SUM( aklmeng )

INTO CORRESPONDING FIELDS OF it

FROM vbap AS a

INNER JOIN vbak AS b ON avbeln = bvbeln

WHERE b~erdat IN my_erdat

GROUP BY a~matnr.

APPEND it.

ENDSELECT.

LOOP AT it.

WRITE 😕 it-matnr, it-kbmeng.

ENDLOOP.

1 ACCEPTED SOLUTION

kesavadas_thekkillath
Active Contributor
0 Kudos



check this,...
if u want to use join then write join condition from header to item table and in where clause use klmeng > 0.


or use this.


select vbeln into table it from vbak where erdat in my_erdat.
sort it ascending.
if it[] is not initial.
loop at it.
select matnr klmeng appending table it2 from vbap
where vbeln = it-vbeln.
collect it2.
endselect.
endloop.
endif.
2 REPLIES 2

kesavadas_thekkillath
Active Contributor
0 Kudos



check this,...
if u want to use join then write join condition from header to item table and in where clause use klmeng > 0.


or use this.


select vbeln into table it from vbak where erdat in my_erdat.
sort it ascending.
if it[] is not initial.
loop at it.
select matnr klmeng appending table it2 from vbap
where vbeln = it-vbeln.
collect it2.
endselect.
endloop.
endif.

Former Member
0 Kudos

hi,

what are you equating the b~vbeln in the Join??

rajesh