Application Development 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: 

getting dumb when using MAX query

Former Member
0 Kudos

hi all,

i have to use MAX keyword in my coding, so i have write this code:

SELECT SINGLE MAX( bedat )  badat  
      FROM    eban
      INTO    gi_reqdate
      WHERE   EBELN IN S_EBELN
      AND     banfn eq gi_eban-banfn
      AND     ekorg eq p_ekorg
      AND     spras eq 'E'
      GROUP BY bedat badat.

when i execute it will give me dump at SELECT SINGLE MAX( bedat ) badat .I can't understand why it is given me Dump...

Thanks.

20 REPLIES 20

former_member188827
Active Contributor
0 Kudos

Remove "Single" from Select Statement.

Edited by: abapuser on Sep 15, 2010 1:38 PM

0 Kudos

hi abapuser,

i have remove SINGLE keyword but still getting dump.do you have any other suggestion..?

Thanks

0 Kudos

well you are selecting two fields from the table into one variable, i dont really wonder that this dumps.

0 Kudos

but in such cases system gives syntax error.How the program got activated is a surprise to me..

0 Kudos

Hi abapuser,

If you give single into clause for two selected fields, the system won't give syntax error when you use GROUP BY.But when you execute it, you'll get dump. So he has to use two variable in INTO clause, otherwise he'll get dump.

Regards,

Selva M

0 Kudos

hi selva,

i have tried it the code which had two internal table.following is the code:

SELECT SINGLE MAX( bedat ) badat
FROM eban
INTO (gi_reqdate , gi_reqdate1) 
WHERE EBELN IN S_EBELN
AND banfn eq gi_eban-banfn
AND ekorg eq p_ekorg
AND spras eq 'E'
GROUP BY bedat badat

At gi_reqdate1 i also declare it but after execution i got dump again,can't understand what is the problem in my code.

Thanks.

0 Kudos

yes you are right..never noticed that this would not raise any syntax error.

0 Kudos

Paste the message in dump here.

0 Kudos

Hi,

What is gi_eban-banfn that you used in the select query. If gi_eban is an internal table then use FOR ALL ENTRIES.

I think this is what u made mistake. Check this.

or

I think you are using this select query inside the loop... End loop or inside the select ... Endselect.

If you paste ur code, then it'll be easy for us to find the solution.

Regards,

Selva M

0 Kudos

hi selva,

when i use FOR ALL ENTRIES, it give me this error:

The addition "FOR ALL ENTRIES IN" is not allowed for SELECT SINGLE.

and this is my code after using FOR ALL ENTRIES:

SELECT SINGLE MAX( bedat ) badat
      FROM    eban
      INTO    gi_reqdate FOR ALL ENTRIES IN gi_eban
      WHERE   EBELN IN S_EBELN
      AND     banfn eq gi_eban-banfn
      AND     ekorg eq p_ekorg
      AND     spras eq 'E'
      GROUP BY bedat.

Thanks.

0 Kudos

Hi,

Yes you can't use FOR ALL ENTRIES when you use Select Single. I said if you use gi_eban-banfn in where condition then you should use FOR ALL ENTRIES or you should use this select query in loop...endloop or Select....Endselect.

Try this,

SELECT SINGLE MAX( bedat ) badat

FROM eban

INTO ( gi_reqdate , gi_reqdate1)

WHERE EBELN IN S_EBELN

AND ekorg eq p_ekorg

AND spras eq 'E'

GROUP BY bedat badat.

If you don't get any error, then problem is with your gi_eban-banfn. Then analyze according to that.

Regards,

Selva M

0 Kudos

hi Selve,

i have tried the coding which you have given me but still it giving me DUMB.Following are the codes:

gi_reqdate1 type eban,

   SELECT SINGLE MAX( bedat ) badat
    FROM eban
   INTO (gi_reqdate , gi_reqdate1)
   WHERE EBELN IN S_EBELN
   AND ekorg eq p_ekorg
   AND spras eq 'E'
   GROUP BY bedat badat.

and this is the DUMB:

Error Analysis

An exception occurred that is explained in detail below.

The exception, which is assigned to class 'CX_SY_OPEN_SQL_DB', was not caught

in

procedure "F_GET_DATA" "(FORM)", nor was it propagated by a RAISING clause.

Since the caller of the procedure could not have anticipated that the

exception would occur, the current program is terminated.

The reason for the exception is:

In a SELECT access, the read file could not be placed in the target

field provided.

Either the conversion is not supported for the type of the target field,

the target field is too small to include the value, or the data does not

Source Code

-


SELECT SINGLE MAX( bedat ) badat

FROM eban

INTO (gi_reqdate , gi_reqdate1)

WHERE EBELN IN S_EBELN

AND ekorg eq p_ekorg

AND spras eq 'E'

GROUP BY bedat badat.

have the format required for the target field.

Thanks.

0 Kudos

really sad, that you dont see it yourself by now, the error message from dumP is quite telling.

It tells you that what you select doesnt fit in the field into which you select it, so you may want to rethink your declarations of

gi_reqdate and gi_reqdate1.

0 Kudos

Hi,

The problem is , declare like this

Data: gi_reqdate1 type eban-bedat. not like this gi_reqdate1 type eban,

Regards,

Selva M

0 Kudos

I really should have locked this thread yesterday. I suggest you take a course in ABAP and English.

pk

Edited by: kishan P on Sep 16, 2010 11:54 AM

Former Member
0 Kudos

Hi,

write as :

SELECT SINGLE MAX( bedat ) badat

FROM eban

INTO (gi_reqdate , gi_reqdate1) <-- declare another field and pass here .. Dump says "Too few fields in INTO clause."

WHERE EBELN IN S_EBELN

AND banfn eq gi_eban-banfn

AND ekorg eq p_ekorg

AND spras eq 'E'

GROUP BY bedat badat.

Regards,

Srini.

Former Member
0 Kudos

If you have only one variable in into clause and you are selecting more that one variable, it will not prompt you any error but it will give you a dump saying "Few parameters in INTO clause".

If this is the dump you are getting then add one more variable. or give us what kind of dump you are getting.

faisal_altaf2
Active Contributor
0 Kudos

Hi,

Please Check the following Sample Code. I think something is wrong with gi_reqdate use INTO CORRESPONDING

DATA: it_eban LIKE STANDARD TABLE OF eban.

SELECT-OPTIONS: s_ebeln FOR eban-ebeln,
                s_banfn FOR eban-banfn,
                s_ekorg FOR eban-ekorg.

SELECT MAX( bedat ) badat
      FROM  eban
      INTO CORRESPONDING FIELDS OF TABLE it_eban
      WHERE ebeln IN s_ebeln
        AND banfn IN s_banfn
        AND ekorg IN s_ekorg
        AND spras EQ 'E'
      GROUP BY bedat badat.

Thanks and Regards,

Faisal

0 Kudos

hi faisal,

thank for your reply but issue is that i don't want to use EBAN in selection option that's way i have write my code as this:

SELECT SINGLE MAX( bedat ) badat
      FROM    eban
      INTO    gi_reqdate FOR ALL ENTRIES IN gi_eban
      WHERE   EBELN IN S_EBELN
      *AND     banfn eq gi_eban-banfn*
      *AND     ekorg eq p_ekorg*
      AND     spras eq 'E'.
      GROUP BY bedat.

do you have any other suggestion.

Thanks.

0 Kudos

i have the suggestion that you move your mouse over the "FOR ALL ENTRIES" statement and hit F1.

you'd be surprised what will happen once your syntax errors are corrected.