Skip to Content
0
Former Member
Oct 23, 2007 at 08:35 AM

MIN in select SINGLE query.

599 Views

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.