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 single from EKEK

Former Member
0 Likes
909

Hello All,

I have EBELN and EBELP with me.

WIth this I want to select only one record from EKEK where the field ABRUF has the max. value.

I don't want to select all the records and then sort it and the n delete the records with index gt 1.

Instead I want to Select from the EKEK Table only one record at once using Select single .

But I'm not able to get an Idea of how-to ?

Can any one tell me how to fetch this single record ?

Regards,

Deepu.K

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
840

use select max( ABRUF ) from EKEK into table itab

7 REPLIES 7
Read only

Former Member
0 Likes
841

use select max( ABRUF ) from EKEK into table itab

Read only

Former Member
0 Likes
840

SELECT ebeln ebelp max( abruf ) from EKEK

into itab

where .....

Hope this helps.

Sudha

Message was edited by:

Sudha Mohan

Read only

Former Member
0 Likes
840

Hi,

Please try this.


DATA: V_ABRUF LIKE EKEK-ABRUF.

SELECT MAX( ABRUF )
INTO V_ABRUF
FROM EKEK
WHERE EBELN = P_EBELN
  AND EBELP = P_EBELP.

WRITE: / V_ABRUF.

Regards,

Ferry Lianto

Read only

Former Member
0 Likes
840

Hi,

MAX( [DISTINCT] col ) Determines the maximum value of the value in the column col in the resulting set or in the current group

Select MAX( ABRUF )

from EKEK

into Itab

where EBELN eq ______

and EBELP eq ______ .

with regards,

jay.

Read only

0 Likes
840

Hello All,

Thanks for ur reply.

But I was getting an error when I used ur Statements as it is.

SO I used like this:-


    LOOP AT gt_temp_data INTO gwa_temp_data.
      SELECT ebeln ebelp MAX( abruf ) FROM ekek
      INTO CORRESPONDING FIELDS OF TABLE gt_ekek
      WHERE ebeln  = gwa_temp_data-ebeln
      AND   ebelp = gwa_temp_data-ebelp
      GROUP BY ebeln ebelp abruf.
    ENDLOOP.

This solved my problem .

But I want to use for-all-entries.

Can u guys tell me how to use this bcoz I'm getting an error once again saying :-

"The addition for-all-entries excludes all aggregate functions with the exceptionof count(*) as the single element of the select clause ".

Regards,

Deepu.K

null

null

Read only

0 Likes
840

You cant use aggregate funtion in FOR ALL ENTRY statement.

Read only

Former Member
0 Likes
840

Hi Deepu,

If you use FOR ALL ENTRIES, you can not have aggregate functions other than COUNT(*).

Regards,

Ferry Lianto