‎2007 Sep 24 1:40 PM
Hi,
I would like to read from table where more than one entry for each material is. I would like to get just the higher one. How to maintain the code?
Example:
***
SELECT SINGLE * FROM AUSP WHERE ( OBJEK = MVKE-MATNR ) AND
( ATWRT IN ATWRT ) AND
( ATZHL ?????????????? ).
In the field ATZHL are numbers from 1-4. How can I write the code, that the program will give to me the higher entry?
BR
Saso
‎2007 Sep 24 2:15 PM
try this
SELECT * FROM AUSP
into wa_ausp
up to 1 rows
WHERE ( OBJEK = MVKE-MATNR ) AND
( ATWRT IN ATWRT )
order descending by atzhl.
endselect.
reward if solved**
‎2007 Sep 24 1:47 PM
Hi
There will be multiple characteristics(ATINN) for a same single material
and the characteristic values (ATWRT) are stored in this table.
So which characteristci value you need
decide and use this table
So pass Material number and as well as ATINN field also to take a particular value.
you can use the BAPI or fun module
BAPI_OBJCL_GETDETAIL
or use the fun module:
CLAF_CLASSIFICATION_OF_OBJECTS.
for this purpose.
Regards
Anji
Message was edited by:
Anji Reddy Vangala
‎2007 Sep 24 1:51 PM
Use aggregate functions , in below format
select MAX(x)
y
z
from tab1
where....
‎2007 Sep 24 1:58 PM
Uf , sorry I don't understand ) Can you change my select ?
SELECT SINGLE * FROM AUSP WHERE ( OBJEK = MVKE-MATNR ) AND
( ATWRT IN ATWRT ) AND
( ATZHL = MAX *******).
thanks a lot
saso
‎2007 Sep 24 2:15 PM
try this
SELECT * FROM AUSP
into wa_ausp
up to 1 rows
WHERE ( OBJEK = MVKE-MATNR ) AND
( ATWRT IN ATWRT )
order descending by atzhl.
endselect.
reward if solved**
‎2007 Sep 24 2:22 PM
Hi Saso, depending on the use of the program you are planning to write and your level of comfort with the values of ATZHL you could always try a while loop. It may be faster than reading the BAPI. Using a temporary value for ATZHL you could use the following code.
data: t_atzhl type ausp-atzhl.
t_atzhl = 4.
while t_atzhl > 0.
SELECT SINGLE * FROM AUSP WHERE ( OBJEK = MVKE-MATNR ) AND
( ATWRT IN ATWRT ) AND
( ATZHL = t_atzhl ).
if sy-subrc = 0.
t_atzhl = 0.
else.
t_atzhl = t_atzhl - 1.
endif.
endwhile.
Kevin
‎2007 Sep 24 2:35 PM
Hi Saso,
Check the query below, this should give you the total idea
how to get the desired result...
tables : ausp.
select * from ausp into ausp up to 1 rows
where OBJEK = '000000000000000001'
order BY ATINN DESCENDING.
endselect.
Hope this worked for u..
Happy coding .......
Regards,
SJ