Skip to Content
author's profile photo Former Member
Former Member

MIN in select SINGLE query.

I need to find a single record with lowest DDUP.

If there are 2 records exist, then i need a single record with lowest DDUP.

loop at it_mara.

***

***

SELECT SINGLE EKORG MATNR MFRPN ZEINR KUNNRS MIN( DDUP ) DCURR

FROM ZNVT_PRICE

INTO CORRESPONDING FIELDS OF LW_ZNVT_PRICE

WHERE EKORG EQ P_EKORG AND

MATNR EQ IT_MARA-MATNR AND

MFRPN EQ IT_MARA-MFRPN AND

ZEINR EQ IT_MARA-ZEINR AND

KUNNRS EQ IT_MARA-KUNNR AND

DATAB LE SY-DATLO AND

DATBI GE SY-DATLO

GROUP BY EKORG MATNR MFRPN ZEINR KUNNRS DCURR.

****

***

endloop.

there is only one record in the table ZNVT_PRICE. (1234.00)

Some times i am getting 1234.

Some times 0.00.

I need to find a single record with lowest DDUP.

If there are 2 records exist, then i need a single record with lowest DDUP.

if I do not use GROUP BY i am getting error.

I have to use SELECT SINGLE.

Guys...please help me to write reliable query.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Oct 23, 2007 at 08:40 AM

    Hi,

    Instead of SELECT SINGLE use

    SELECT.. UP TO 1 ROWS

    ENDSELECT.

    It will also be very fast and suit your requirement.

    Regards,

    Atish

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 23, 2007 at 08:43 AM

    hi

    instead to select single in the loop

    select all the records outside the loop

    then sort your internal table in decending order with DDUP

    then read the first record

    now u will have the lowest ddup

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.