June 24, 2009

Calculate delivery quantity field in Sales Order

Yo can find the delivered quantity via a function, it is not as easy asreading the confirmed quantity..

Use of function may look like this

Data: lT_VBFA type VBFA occurs 0 with header line,
lT_VBUP type VBUP occurs 0 with header line,
lT_VBEP type VBEPVB occurs 0 with header line,
lT_VBAP type VBAPVB occurs 0 with header line,
l_vsmng like vbepvb-vsmng.

SELECT * FROM vbup INTO TABLE lt_vbup
WHERE vbeln EQ vbeln ANDposnr EQ my_posnr.

SELECT * FROM vbfa INTO TABLE l_vbfa
WHERE vbelv EQ vbeln ANDposnv EQ my_posnr.

SELECT * FROM vbep INTO TABLE l_vbep
WHERE vbeln EQ vbeln ANDposnr EQ my_posnr .

SELECT * FROM vbap INTO TABLE l_vbap
WHERE vbeln EQ vbeln ANDposnr EQ my_posnr .

call function 'RV_SCHEDULE_CHECK_DELIVERIES'
exporting
fbeleg = vbeln
fposnr = my_posnr

tables
fvbfa = lt_vbfa
fvbup = lt_vbup
fxvbep = lt_vbep
fvbap = lt_vbap.

loop at lt_vbep where posnr eq my_posnr.
add lt_vbep-vsmng to l_vsmng. " tot.deliv.quan
endloop.

source : sini

No comments:

Post a Comment