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: 

re :urgent :getting the latest status for particular sales order

Former Member
0 Kudos

hi to all,

i am having a query in sd-abap

actually we r having one ztable ok. in that we r having two fields namely status of particular sales orderactivity and a sequenceial number.

status field name is zhhstatus and sequential no field as zhusss.data in status is like this ex ,ddd ,sss

and sequential no for this status 1,2,3 . 3 is latest status for corresponding statuss ddd. how to write the logic for getting max status for particular sales order.

plz do this help by giving possible answers.

thanks in advance.

3 REPLIES 3

former_member181962
Active Contributor
0 Kudos

select *

from ztable

into table itab

where vbeln = <sales order number>.

sort itab by <sequence number> descending.

read itab index 1.

if sy-subrc = 0.

  • your itab will noe have the latest status

v_status = itab-status.

endif.

Regards,

Ravi

0 Kudos

I'm not sure in alphabetic order the "ddd" is after the "ex"

Rgd

Frédéric

FredericGirod
Active Contributor
0 Kudos

Hi,

if you would like to go fast, and if an order could have only one time a statut and must have the first statut to pass to the status 2 ... you could simply count using a group by select.

select order count( * ) into w_data from table group by order.

if w_data = 3 you have the status sss

if w_data = 2 you have the status ddd

if w_data = 1 you have the status ex

Rgd

Frédéric

Message was edited by: Frédéric Girod