cancel
Showing results for 
Search instead for 
Did you mean: 

get the max number

Former Member
0 Kudos

just want to ask how to use the SQL keyword 'max' in abap?

does my code correct?

select max (pddrf_no)

from zpddr_md

into v_pddrf.

thanks.

donna

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

S ur code is correct

select max( pddrf_no ) from zpddr_md into v_pddrf.

Format it properly.

Kindly reward points and close the thread if ur problem got solved.

Former Member
0 Kudos

using this code

select max( pddrf_no ) from zpddr_md into v_pddrf

i encounter error that says unknown column name MAX. not determined until runtime you cannot specify field list.

thanks.

donna

Former Member
0 Kudos

Try like this

DATA   v_pddrf TYPE zpddr_md-pddrf_no.

SELECT MAX( pddrf_no ) 
       INTO v_pddrf 
       FROM zpddr_md . 
WRITE: / v_pddrf .

It will work try copy and paste this code.

Just now i tried this code

REPORT  y_jjtest.

DATA   v_pddrf TYPE mara-matnr.

SELECT MAX( matnr )
       INTO v_pddrf
       FROM mara .
WRITE: / v_pddrf .

Message was edited by: Judith Jessie Selvi

Former Member
0 Kudos

U shd not leave any space between max & (.

max(<space>pddrf_no<space>)

else..

delete the line releated to this & rewrite once again..

regards

gv

Answers (4)

Answers (4)

Former Member
0 Kudos

Data wa like zppdr_md-pddrf_no.

select max( pddrf_no ) into wa

from zpddr_md

.

Cheers.

Former Member
0 Kudos

Hi,

U can use MAX in ABAP.

( ( for each aggregate expression. The alias column name is used instead of the real name in the INTO and ORDER BY clauses. This is the only way of sorting by an aggregate expression in the ORDER BY clause.

If the list in the SELECT clause (excepting aggregate expressions) contains one or more field names, the field names must also be listed in the GROUP BY clause. The aggregate functions do not then apply to all of the selected lines, but to the individual groups of lines.

Hope it helps u.

Thanks&Regards,

Ruthra.R

Former Member
0 Kudos

hi ruth,

using this code

select max( pddrf_no ) from zpddr_md into v_pddrf

i encounter error that says unknown column name MAX. not determined until runtime you cannot specify field list.

Former Member
0 Kudos

Data wa like zppdr_md-pddrf_no.

select max( pddrf_no ) into wa

from zpddr_md

into v_pddrf.

Cheers.

Former Member
0 Kudos

s ur code will return the max pddrf_no from table zpddr_md

Former Member
0 Kudos

i need the max pddrf no from table zpddr_md

thanks.