Skip to Content
avatar image
Former Member

ABAP code to select maximum value of a characteristic

Hello All,

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


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


Please advice..



Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • avatar image
    Former Member
    Jan 24, 2012 at 12:37 PM

    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.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member


      I solved my requirement by the following statement:

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


      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