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 statement not working

Former Member
0 Likes
1,457

Dear experts,

I am using a MAX statement in one of my query but it fails to work and there is data present in the database table.

      

          SELECT MAX( aznum ) INTO l_aznum FROM febko

                      WHERE   bukrs  = wa_ff67_hdr-bukrs

                     AND         hbkid  = wa_ff67_hdr-hbkid

                     AND         hktid  = wa_ff67_hdr-hktid.

though it is very easy but still not working.

9 REPLIES 9
Read only

matt
Active Contributor
0 Likes
1,182

It is unlikely in the extreme that the max statement has suddenly stopped working. Far more likely is that you've made a mistake.

Have you checked that wa_ff67_hdr-bukrs -hbkid and -hktid contain any data?

Have you checked whether there are conversion exits on the domains these fields are built upon?

Read only

manukapur
Active Participant
0 Likes
1,182

Please ensure l_aznum is of the same type as aznum. Query seems to be fine.

Check if have data issues.

The other way is to fetch the data and sort it in descending order on aznum.

Regards,

Manu

Read only

former_member420878
Active Participant
0 Likes
1,182

Hi,

Please check whether database is containing any record with given selection.

Type of l_aznum should be matched with AZNUM_EB.

Otherwise query is OK.

Regards,

Neha

Read only

Former Member
0 Likes
1,182

Hi,

Check whether the condition you specified has any record or not. There is no problem with the query.

Read only

arindam_m
Active Contributor
0 Likes
1,182

Hi,

May be you have multiple statement number lines try this:

          SELECT MAX( DISTINCT aznum ) INTO l_aznum FROM febko

                      WHERE   bukrs  = wa_ff67_hdr-bukrs

                     AND         hbkid  = wa_ff67_hdr-hbkid

                     AND         hktid  = wa_ff67_hdr-hktid.

Hope it helps.

Cheers,

Arindam

Read only

Former Member
0 Likes
1,182

Hi Mahesh

Pls try the below code:

       SELECT single MAX( aznum ) INTO l_aznum

       FROM febko

       WHERE   bukrs  = wa_ff67_hdr-bukrs

       AND         hbkid  = wa_ff67_hdr-hbkid

       AND         hktid  = wa_ff67_hdr-hktid.

Regards,

Suganya

Read only

Former Member
0 Likes
1,182

Hi Mahesh,

Is there any error message you got...?

If not the where condition not match with you data available in your database table.

Regards,

R.S.K

Read only

Former Member
0 Likes
1,182

Dear all,

wa_ff67_hdr-hbkid was passed in small case and it needs to be passed in upper case. So solved the issue by observing it.

Thanks for reply.

Read only

0 Likes
1,182

So it was a data issue.