cancel
Showing results for 
Search instead for 
Did you mean: 

ABAP code to select maximum value of a characteristic

Former Member
0 Kudos

Hello All,

we have a requirement to select the value of A based on the highest value of VALID TO field.

Eg:

If my DSO has the following values:

If A = 1 for VALID TO = 201111,

A =2 for VALID TO = 201112

and A =3 for VALID TO = 201201.

then while moving the data to the Infocube, we need to write code to pickup the data of A =3 since it hs the highest VALID TO value. I tried writing the following statement

select single max ([DISTINCT] /BIC/ZVLID_TO) from /BIC/AZTESTB00

but this is giving me a syntax error

'E:Unknown column name "MAX" until runtime, you cannot specify a field

list.'

Please advice..

Regards

Sneha

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

First there seems to a problem with the information u have given. There should be a key for which these values are changing, coz here both A & valid to are changing.

Assuming that there is another field which is key for ur source DSO, why dont u try this in the start routine.

Select * from /BIC/AZTESTB00 into itab1.

sort itab1 by /BIC/ZVLID_TO descending.

delete adjacent records comparing keyfield.

This way you would get the value of A for the highest valid to, as all the other records would be deleted.

Former Member
0 Kudos

Hello Rahul,

Sorry i forgot to mention, there will be one field Comp Code whch will be have a constant value.

Former Member
0 Kudos

Hi,

I solved my requirement by the following statement:

Select MAX( /BIC/ZVALID_TO ) from /BIC/AZTESTB00

into L_VLDTO where COMP_CODE = SOURCE_FIELDS-COMP_CODE.

Please note the spaces are very much important in the MAX statement. there should be no space between MAX & (

whereas there should be a space after the (

Hope this helps who face similar requirement.

Thanks & Regards

Sneha