Application Development 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: 

sort descending for MARD

Former Member
0 Kudos

Hello Everyone,

i am stuck , i have to print the storage location where the stock is maximum .

My select program prints the storage location where the stock appears first .

Please help.

for example :

material :-xyz

plant :abc

storage location:- 0,0,3,7,0,4,8

What i want is to print storage location where the stock is 8 but it is printing the storage location where the stock is 3.

Any suggestions , I have to use in a smartform

BR

Sumit

1 ACCEPTED SOLUTION

pramodu
Active Participant
0 Kudos

Hi,

you need to trigger the Smartform when storage location is maximum i.e.

SORT internal table with Storage Location in ascending .

This will give first record as maximum storage location.

Read the first reocrd from internal table where storage location is populated.

If this is true then call FM SSF_FUNCTION_MODULE_NAME and pass the formname .

Thanks,

Pramod

4 REPLIES 4

pramodu
Active Participant
0 Kudos

Hi,

you need to trigger the Smartform when storage location is maximum i.e.

SORT internal table with Storage Location in ascending .

This will give first record as maximum storage location.

Read the first reocrd from internal table where storage location is populated.

If this is true then call FM SSF_FUNCTION_MODULE_NAME and pass the formname .

Thanks,

Pramod

Former Member
0 Kudos

Thanks pramod for the reply . I really don not know how to make this work.

My code is as follows:-

CLEAR: LOCATION .

SELECT SINGLE LGORT
FROM MARD
INTO LOCATION
WHERE  matnr = viqmel-matnr
  AND  werks = viqmel-werk 
  and  labst NE 0.
CHECK sy-subrc = 0.

I have to print the storage location that has the maximum stock .

BR

Sumit

Edited by: sumit123 on Jun 22, 2010 12:41 PM

Former Member
0 Kudos

Hello

Try this snippet:


data: imard like mard occurs 0 with header line.
select * from mard into table imard
                   where matnr = viqmel-matnr
                   and werks = viqmel-werk.
sort imard by labst descending.
read table imard index 1.
if sy-subrc = 0.
  write: 'Maximum stock at', imard-lgort.
endif.

Former Member
0 Kudos

Thanks a lot . your solution resolved my issue

BR

Sumit