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

select query

Former Member
0 Likes
331

hi friends,

i have problem with this query . can any one help me. here i need to get the max value of stlal comparing matnr.

SELECT a~stlnr

a~stlkn

a~stlal

b~matnr

c~annam

c~idnrk

c~posnr

c~menge

c~meins

c~ausch

INTO TABLE it_final

FROM stas AS a

INNER JOIN mast AS b ON ( bstlnr EQ astlnr

AND bstlal EQ astlal )

LEFT OUTER JOIN stpo AS c ON ( cstlnr EQ astlnr

AND cstlkn EQ astlkn )

WHERE b~matnr IN so_matnr

AND (( bmatnr astlal ) in (SELECT MATNR MAX( stlal ) FROM mast group by matnr)) .

thank you,

looking for your quick reply.

2 REPLIES 2
Read only

Former Member
0 Likes
296

hi,

i was gone through your code. i cannot directly assign any value to variable .

so first you have to find maximum number and store it in variable.

now use this variable in that query .

if still there is prob reply me.

and try to use FOR ALL ENTRIES with the help of that you can improve your code performance.

Give rewards if Help full.

regards,

vipul.

Read only

Former Member
0 Likes
296

Hi friend

Try like this

SELECT a~stlnr

a~stlkn

MAX ( a~stlal ) <--

b~matnr

c~annam

c~idnrk

c~posnr

c~menge

c~meins

c~ausch

INTO TABLE it_final

FROM stas AS a

INNER JOIN mast AS b ON ( bstlnr EQ astlnr

AND bstlal EQ astlal )

LEFT OUTER JOIN stpo AS c ON ( cstlnr EQ astlnr

AND cstlkn EQ astlkn )

WHERE b~matnr IN so_matnr

AND (( bmatnr astlal ) in (SELECT MATNR MAX( stlal ) FROM mast group by matnr)) .

Reward points if helpfull