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

Max function

Former Member
0 Likes
657

Hi experts,

I want to fetch records(PR PO bwart) against maximum movement type(bwart).

Is there max function in abap or tell me some alternative

Select PR PO max(bwart) from ekbe into i_ekbe

group by PR PO bwart.

Is this code correct.

Savita

3 REPLIES 3
Read only

Former Member
0 Likes
555

Hi,

yes the code is right. the max fucntion u used is the right way to find the max value.

regards,

madhu

Read only

0 Likes
555

Hi madhu,

Can u tell me , the group by clause with left join & where caluse.

It is showing an error The field "AEBELP" from the SELECT list is missing in the GROUP BY clause. addition INTO wa or INTO (g1,...,gn) is required. fields of type "" or "BWERKS".

select abanfn aekgrp aafnam atxz01 amatnr awerks algort abednr

amenge ameins abadat afrgdt aebeln aebelp bebeln bebelp

bbelnr max( bbwart ) bbudat bmenge b~matnr

b~werks

from ( eban as a left outer join ekbe as b on

aebeln eq bebeln and

aebelp eq bebelp )

into corresponding fields of

table eban_ekbe

where a~ekgrp in s_ekgrp and

a~afnam in s_afnam and

a~matnr in s_matnr and

a~werks eq p_werks and

a~lgort in s_lgort and

a~badat in s_badat

group by bebeln bebelp bbelnr bbwart bbudat bmenge b~matnr

b~werks.

I have to put group by on my second table

Savita

Read only

Former Member
0 Likes
555

Hi,

The movement types are defined as numbers like 561 etc.So if you use MAX then highest number is selected.If you wish to have the same thing then your code is correct.