Application Development and Automation 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: 
Read only

Get Last Document from document flow

Former Member
0 Likes
951

I would like to retrieve last document flow's document. i use VBFA and pass Preceding sales and distribution document to where condition and get Subsequent sales and distribution document but i don't know how to get the latest one.

I use

select single VBELN into last_doc from vbfa

where VBELV = 'preceding doc'

order by ERDAT ERZET

but it's not work. How can i do that. Thanks!

4 REPLIES 4
Read only

Former Member
0 Likes
741

Hi,

Give descending..

select VBELN UP TO 1 ROWS

into last_doc from vbfa

where VBELV = 'preceding doc'

order by ERDAT ERZET <b>DESCENDING</b>

ENDSELECT.

THanks,

Naren

Read only

0 Likes
741

The Error "The SELECT SINGLE statement cannot contain the clause ORDER BY." Thanks

Read only

Former Member
0 Likes
741

Use Decending keyword

Regards

Read only

Former Member
0 Likes
741

try like this


data : begin of vbfat occurs 0,
        last_doc like vbfa-vbeln,       
        last_date like vbfa-erdat,
        end of vbfat.
        
 select vbeln max( erdat ) into table vbfat from vbfa
        where VBELV = 'preceding doc'
          group by vbeln.
loop at vbfat.
<do the processing.>
endloop.

regards

shiba dutta