‎2008 May 28 12:02 PM
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.
‎2008 May 28 12:18 PM
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.
‎2008 May 28 12:18 PM
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