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

Select max / Dump

Former Member
0 Likes
478

Hello gurus I has there a small problem with a selection.

Source base table

1233456789 01.01.2007

9999999999 02.02.2007

I must determine only the first record (select max. ( ) ).

Then with this record I get into the next selection.

The Coding

  • Deklaration

DATA: BEGIN OF ls_fkkmako,

gpart TYPE fkkmako-gpart,

vkont TYPE fkkmako-vkont,

ausdt TYPE fkkmako-ausdt,

mahnv TYPE fkkmako-mahnv,

mgrup TYPE fkkmako-mgrup,

mahns TYPE fkkmako-mahns,

mstyp TYPE fkkmako-mstyp,

END OF ls_fkkmako.

DATA: lt_fkkmako LIKE TABLE OF ls_fkkmako.

SELECT SINGLE * FROM fkkmako "FR01/ G

WHERE vkont = c_fkkmako-vkont "FR01

AND mahns = '10' "FR01

AND formkey = 'ZB_MAASV1' . "FR01

  • AND ausdt = ls_fkkmako-ausdt.

IF sy-subrc = 0. "FR01 "Hit found

I Try it like this. But there was a Dump. (SQL) Why ??

  • SELECT MAX( ausdt )

  • FROM fkkmako "FR02

  • INTO ls_fkkmako

  • WHERE vkont = c_fkkmako-vkont "FR02

  • AND mahns = '10' "FR02

  • AND formkey = 'ZB_MAASV1'. "FR02

Thanks for your help .

BY christian

1 ACCEPTED SOLUTION
Read only

kostas_tsioubris
Contributor
0 Likes
378

Hi,

the statement

 SELECT MAX( ausdt )
 FROM fkkmako "FR02
 INTO ls_fkkmako
 WHERE vkont = c_fkkmako-vkont "FR02
 AND mahns = '10' "FR02
 AND formkey = 'ZB_MAASV1'. "FR02

will only select the ausdt value but you are reading it into ls_fkkmako structure that's why you get a sort dump. Alternatively you can use this

 SELECT * 
 FROM fkkmako "FR02
 INTO ls_fkkmako
 WHERE vkont = c_fkkmako-vkont "FR02
 AND mahns = '10' "FR02
 AND formkey = 'ZB_MAASV1' "FR02
order by ausdt descending.

exit.
endselect.

Kostas.

1 REPLY 1
Read only

kostas_tsioubris
Contributor
0 Likes
379

Hi,

the statement

 SELECT MAX( ausdt )
 FROM fkkmako "FR02
 INTO ls_fkkmako
 WHERE vkont = c_fkkmako-vkont "FR02
 AND mahns = '10' "FR02
 AND formkey = 'ZB_MAASV1'. "FR02

will only select the ausdt value but you are reading it into ls_fkkmako structure that's why you get a sort dump. Alternatively you can use this

 SELECT * 
 FROM fkkmako "FR02
 INTO ls_fkkmako
 WHERE vkont = c_fkkmako-vkont "FR02
 AND mahns = '10' "FR02
 AND formkey = 'ZB_MAASV1' "FR02
order by ausdt descending.

exit.
endselect.

Kostas.