12-18-2006 11:08 AM
Hi Folks,
How can I get open quantity for each schedule line in VA32. Is there any function module to calculate the open quantity for each schedule line?
If function module doesn't exists please advise how to calculate the open quantity for each schedule line in VA32(Schedule agreement).
Thanks,
Vijay.
12-18-2006 11:39 AM
just check this and verify from the tables .
declare a table as
DATA : BEGIN OF itm_sales OCCURS 0,
vbeln LIKE vbap-vbeln,
posnr LIKE vbap-posnr,
matnr LIKE vbap-matnr,
kwmeng like vbap-kwmeng, "for open qty
lfsta LIKE vbup-lfsta,
lfgsa LIKE vbup-lfgsa,
fksta LIKE vbup-fksta,
fksaa LIKE vbup-fksaa,
gbsta LIKE vbup-gbsta,
END OF itm_sales.
select a~vbeln
a~posnr
a~matnr
a~kwmeng
b~lfsta
b~lfgsa
b~fksta
b~fksaa
b~gbsta
INTO TABLE itm_sales
FROM vbap AS a JOIN vbup AS b
ON avbeln EQ bvbeln "sales order
AND aposnr EQ bposnr "item
AND b~gbsta NE 'C' . "overall processing status
"processing status should be <> 'C' means open order
once fetch .
IF NOT itm_sales IS INITIAL.
LOOP AT itm_sales.
at end of vbeln .
sum.
v_openqty = itm_sales-kwmeng. "sum the open quantity
endat.
WRITE:/5 itm_sales-vbeln,
itm_sales-posnr,
itm_sales-matnr,
itm_sales-kwmeng,
itm_sales-lfsta,
itm_sales-lfgsa,
itm_sales-fksta,
itm_sales-fksaa,
itm_sales-gbsta.
ENDLOOP.
ENDIF.
skip 2.
write:/ 'open Quantity for the order is ', v_openqty .
hope this helps ,
regards,
vijay
Message was edited by:
Vijay
12-18-2006 11:11 AM
12-18-2006 11:46 AM
In VBEP table we have fields like order quantity in sales units, confirmed quantity, and required quantity for each schedule line but not the open quantity.
My requirement is to have the open quantity for each schedule line. Help me to resolve the issue.
Thanks,
Vijay.
12-18-2006 11:55 AM
For that u need to query the sales order number in tabke VBUK and check the field GBSTK ne C then it will be an open order .
u can look in table VBAKUK for this ..
This is nothing but a Join of VBAK and VBUK entries. u can eliminate a join if u fetch it from VbakUk
Now once it is confirmed that it is open then fetch the entries from VBAP..
regards,
vijay
12-18-2006 11:12 AM
Hi,
You'll get all the data related to a schedule line in table EKET.
12-18-2006 11:39 AM
just check this and verify from the tables .
declare a table as
DATA : BEGIN OF itm_sales OCCURS 0,
vbeln LIKE vbap-vbeln,
posnr LIKE vbap-posnr,
matnr LIKE vbap-matnr,
kwmeng like vbap-kwmeng, "for open qty
lfsta LIKE vbup-lfsta,
lfgsa LIKE vbup-lfgsa,
fksta LIKE vbup-fksta,
fksaa LIKE vbup-fksaa,
gbsta LIKE vbup-gbsta,
END OF itm_sales.
select a~vbeln
a~posnr
a~matnr
a~kwmeng
b~lfsta
b~lfgsa
b~fksta
b~fksaa
b~gbsta
INTO TABLE itm_sales
FROM vbap AS a JOIN vbup AS b
ON avbeln EQ bvbeln "sales order
AND aposnr EQ bposnr "item
AND b~gbsta NE 'C' . "overall processing status
"processing status should be <> 'C' means open order
once fetch .
IF NOT itm_sales IS INITIAL.
LOOP AT itm_sales.
at end of vbeln .
sum.
v_openqty = itm_sales-kwmeng. "sum the open quantity
endat.
WRITE:/5 itm_sales-vbeln,
itm_sales-posnr,
itm_sales-matnr,
itm_sales-kwmeng,
itm_sales-lfsta,
itm_sales-lfgsa,
itm_sales-fksta,
itm_sales-fksaa,
itm_sales-gbsta.
ENDLOOP.
ENDIF.
skip 2.
write:/ 'open Quantity for the order is ', v_openqty .
hope this helps ,
regards,
vijay
Message was edited by:
Vijay