FM: RV_SCHEDULE_CHECK_DELIVERIES
Hi All,
In my Program using FM: RV_SCHEDULE_CHECK_DELIVERIES (SD Functions for Sched. Line Processing) for this input is VBELN and POSNR,
After executing this FM, the below Table parameter is populating
FVBAP LIKE VBAPVB, in this structure I have a field MATNR.
Let me know from which table that MATNR is coming.
Subbu.
Hai
Check the source code of that function module which you are using. In that you may find from which table that MATNR is picking.
Similar Messages
-
How to calculate the OPEN QUANTITY in delivery Duelist Report
Hi Everybody,
I have a query for finding out the OPEN QUANTITY for schedulines for a delivery.
If for example the report is run for 2nd of February, it is necessary to
determine whether there are delivery relevant schedule lines before the
2nd.
If yes, we need to know whether there is an open quantity to this line
item.
If yes, this open quantity is a negative deviation (we delivered not
enough).
If there is no open quantity it is necessary to determine whether for the
earliest future to be deleviered schedule line, the open quantity equals
the ordered quantity (VBEP-WMENG),
if No the the difference between both values equals the positive deviation
(we delivered more than requested)
If the open quantity equals the ordered quantity there is no deviation.
The problem is to calculate the open quantity and the SAP standard there is function
builder used in SAP standard include MV45AF0O_OFFENE_WERTE_ERMITTEL, the
function builder is called RV_SCHEDULE_CHECK_DELIVERIES'. But how could we use in this formulae in a Custom delivery report.
Looking for your helpful suggestions.
Many thanks in Advance,
Mira SaikrishnaKrishna....have a look in the below threads where there was a similar requirement..
error while using BAPI_OUTB_DELIVERY_CHANGE
change outbound delivery -
How to compare delivery date in schedule lines and PGI in outbound delivery
Hi,
I want to create a report to monitor and compare different dates in sales and delivery process.
One of my key figure is the comparison between date confirmed to the customer, that I can find in the schedule line of the sales order, and the actual goods issue date from the outbound delivery.
But I can't succeed in making the link between delivery and schedule lines, means between LIKP and VBEP.
Would you have any idea?
Thank you.It seems there's no exact (table) connection / link between delivery item and schedule line item.
Those who were searching for this thing (link / connection between delivery item and schedule line) were recommended to use FM "RV_SCHEDULE_CHECK_DELIVERIES".
This FM calculates the delivered quantity for each schedule line, so it makes link between the delivery item and schedule lines - however if you check the code it's quite sophisticated...
(if you put a breakpoint in the FM and display a SO in VA03, you can check how the parameters have to be populated with data).
Schedule Line and Delivery Link
Edited by: Csaba Szommer on Aug 5, 2011 12:03 AM -
Delivery qty against schedule line
Hi,
I have specific requirement for a report where we need to determine the delivery qty against the schedule line qty for a sales order. In sales order in schedule line tab system shows the delivery qty. The field is VBEPD-VSMNG. VBEPD is a structure and I could not find the table in which this is actually stored. Does anybody know how to get the delivery qty for schedule line?
Regards,
Sachin.Dear Sachin,
the delivery is always created in the ERP system on the item level. You cannot deliver a separate schedule line. This functionality does not exist.
But if you go to the schedule line screen then the delivered quantity of the item will be distributed through all schedule lines which have the confirmed quantity. The distribution takes place starting from the earlier schedule line and goes to the later schedule lines and the delivered quantity ordered to a schedule line must be always not larger that the confirned quantity. If there will be undistributed rest of delivered quantity, it will be ordered to the last schedule line.
This distribution takes place dynamically during the transaction VA02. The main program place here is the function module RV_SCHEDULE_CHECK_DELIVERIES.
I hope, this information helps you further.
Kind regards,
Akmal Vakhidov
Development Support SAP, Walldorf/Germany -
Delivery Status at Schedule Line level.
Hi All,
I have to retrieve some data on the basis of Schedule line for which delivery is not complete. Please find below the requirement.
I am having one sales order with one line item which having two schedule line. For one schedule line confirmed qty is 1K and for other 2k. For first line item deliver qty is also 1k.
I want to know how to check the delivery status for schedule line counter so I will get the idea that for first schedule line qty is delivered and for second not.
Thanks
PiyushUse the function module
CALL FUNCTION 'RV_SCHEDULE_CHECK_DELIVERIES'
EXPORTING
fbeleg = wa_vbap-vbeln
fposnr = wa_vbap-posnr
FVERRECHNUNG = ' '
FS073_ALT = ' '
IF_NO_SORT = ' '
TABLES
fvbfa = fvbfa
fvbup = fvbup
fxvbep = it_vbepvb
FVBLB =
fvbap = fvbap
EXCEPTIONS
FEHLER_BEI_LESEN_FVBUP = 1
FEHLER_BEI_LESEN_FXVBEP = 2
OTHERS = 3
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
loop the internal table it_vbepvb.
get the open qty in that schedule line
MOVE wa_vbepvb-olfmng_flt TO wa_itab-openqty.
IF wa_vbepvb-bmeng EQ wa_itab-openqty.
check that with the schedule line confirmed qty wa_vbepvb-bmeng
If delivery is avaliable the open qty will not be equal to confirmed qty. -
Schedule line item link to delivery qty
dear all,
I used the function module RV_SCHEDULE_CHECK_DELIVERIES to find for a sales order all the shedule lines with the delivery qties.
I faced to a problem to link schedule and delivery for this case :
schedule item _______date ____________order. qty ___confirmed qty___deliver. qty
1 ________________11.02.2009 ___________4 ___________4 ___________4
2 ________________ 12.02.2009 __________7 ___________3 ___________3
3 ________________15.02.2009 ___________7 ___________0 ___________ 0
6 ________________16.02.2009 ___________0 ___________0 ___________4
7 ________________16.02.2009 ___________0 ___________0 ___________7
4 ________________20.02.2009 ___________9 ___________0 ___________ 0
5 ________________21.02.2009 ___________9 ___________9 ___________ 0
I need to keep only the delivered lines, how to remove only the "real" line with no confirmed qty or with no delivered qty.
How to distinguish the line 3 and 4 because the 3 is delivered with line 7 but the line 4 is not delivered.
Thanks for your quick answer .
Véronique
Edited by: veronique pinelli on Feb 13, 2009 11:22 AMKindly share the solution so as this can be used in future,if any one faces same problem
-
Schedule Line and Delivery Link
Hi,
I need to get schedule line info and its related delivery info. I am unable to link schedule lines ( VBEP- ETENR) to its related delivery. Is there a way to do this ?
Ex: Order 1, item 1 has 2 schedule lines 1 & 2 with delivery # 11 and 22.
From VBFA I get 2 deliveries for item 1 but unable to link sch. line 1 to 11 and sch.line 2 to 22.
SAP does this. Can anyone help on this. How does SAP provide info in doc flow of order where it links sch. line to delivery.
Thanks !Hi,
Delivered quantity at the schedule line is calculated with function module RV_SCHEDULE_CHECK_DELIVERIES. You have to feed it with document flow from sales order to delivery (FVBFA), schedule lines (FVBEP), status (FVBUP), and sales order item (FVBAP) to get the vsmng filled in FVBEP.
Also please check the following FM.
SD_VBEP_ARRAY_READ_VBELN
SD_VBEP_READ_WITH_POSNR
SD_VBEP_READ_WITH_VBELN
SD_VBEP_SELECT
SD_VBEP_SINGLE_READ
It will return VSMNG value(s) in table parameter (table strucuture VBEPVB).
Hope this will help.
Regards,
Ferry Lianto -
How to identify open schedule line item?
Hi,
I have a requirement for identifying open schedule line items. I want to identify any indicator or any field in any table which will tell me that the schedule line item is complete. Can anyone tell me how can I know that?
Ex. Sales Order 1 has 3 materials (line items) in it A, B & C.
For A the quantity is 10 and for which 3 schedule line have been created.
Out of the 3 schedule lines, 1 schedule line item is complete that is the delivery has been done and the rest 2 are open.
For B and C there are 4 & 5 schedule lines created and all are open.
How can i identify that total 12 schedule line 1 is completed and 11 are open.
Please suggest tables, field names / indicators.
Regards,
VishalHi Vishal,
You can not identify the open line items directly, rather you have to calculate the delivered quantity and copmare it with the ordered qty for each line item. The ordered qty can be idenitfy from the table VBEP and the deliverd qty can be found out by calling the function RV_SCHEDULE_CHECK_DELIVERIES.
Follow the link for more details to calculate the delvierd qty.
http://scn.sap.com/thread/279862
Rgards,
Rutvik. -
Link between schedule Line Number and Delivery
Is there a link between Schedule line Number and Delivery number ?
Eg. Line item 10 with quantity 100.
has 5 schedule lines..with 5 different delivery dates.
1 . quanity 40
2. quantity 30
3. quantity 20
4. quanity 6
5 quantity 4
For schedule line 1, 2 deliveries were created,
one with quantity 20
another with quantity 15
quantity 5 is still not delivered.
also schedule lines 2,3,4 and 5 are fully delivered.
Is there any table, FM etc in SAP which will give me the link between the schedule line and delivery number ?
Total deliveries created : 6. - But which delivery corresponds to which schedule line ?
Please dont tell me to look VGBEL and VGPOS.. that will just give line item number 10.. I need to get the schedule line number.
Also, RV_SCHEDULE_CHECK_DELIVERIES --> will give me the delivered quantity against each schedule line.
My purpose is to create an ontime delivery report .
a report which list each schedule lines, and tell, how many shipments were late/ontime/early etc..
and for Late ones, how many days late has to be found.
this is where i need the delivery.
No. Of days Late = Actual GI Date - Planned GI Date.
Actual GI date is in the delivery.
Any suggestions ?
Thank you in advance.Hi,
Check in the below link.
relation between VBEP-ETENR and LIKP-VBELN
Thanks,
Sree. -
Hi...
I need to use the Delivered Quantity present in a sales order at schedule line level.
This field can be seen if we, enter a sales order in VA02 and click on the Item and then click on the 'Schedule Lines' tab... i need to know.. how do i fetch the field 'Delivered Quantity' present there....
If no values are present .. then it means.. no delivery has been done for that material........
The F1 or Techinical help points to the field VBEPD-VSMNG...... and i found that this field is calculated at runtime in the function module RV_SCHEDULE_CHECK_DELIVERIES.....
Can someone please tell me... how do i fetch this field ...or calculate this field..... for my requirement.....
Regards.....Hi.
You can use the function module RV_SCHEDULE_CHECK_DELIVERIES to get the delivered quanity corresponding to schedule line item in sales order.
Please refer below code:
ie3mdpslx-delnr is sales order numer
ie3mdpslx-delps is line item.
internal table tl_da_vbep has got field VSMNG which is the delievred quantity for each line item
SELECT * FROM vbfa
INTO CORRESPONDING FIELDS OF TABLE tl_xvbfa
WHERE vbelv = ie3mdpslx-delnr
AND posnv = ie3mdpslx-delps
AND vbtyp_v = 'C'.
SELECT * FROM vbup
INTO CORRESPONDING FIELDS OF TABLE tl_xvbup
WHERE vbeln = ie3mdpslx-delnr
AND posnr = ie3mdpslx-delps.
SELECT * FROM vbep
INTO CORRESPONDING FIELDS OF TABLE tl_da_vbep
WHERE vbeln = ie3mdpslx-delnr
AND posnr = ie3mdpslx-delps.
SELECT * FROM vbap
INTO CORRESPONDING FIELDS OF TABLE tl_xvbap
WHERE vbeln = ie3mdpslx-delnr
AND posnr = ie3mdpslx-delps.
CALL FUNCTION 'RV_SCHEDULE_CHECK_DELIVERIES'
EXPORTING
fbeleg = ie3mdpslx-delnr
fposnr = ie3mdpslx-delps
TABLES
fvbfa = tl_xvbfa
fvbup = tl_xvbup
fxvbep = tl_da_vbep
fvbap = tl_xvbap
EXCEPTIONS
fehler_bei_lesen_fvbup = 1
fehler_bei_lesen_fxvbep = 2
OTHERS = 3. -
Link between delivery line item and sales order item schedule line.
Hello friends,
This is a continuation of my earlier query - for which I got half the solution, and this is the remaining problem.
I want to know: from delivery document line item, how to link it to sales order line item's schedule line (when there are multiple schedule lines with identical quantities).
Thanks for your help.
- ChetanThis is the code which i used for the same purpose and its working.
Hope this will help you too....
****it_itab is my final internal table.
*Internal table for manupulating the Delivery balance when
*its used in more than one schedule line
TYPES: BEGIN OF ty_new,
vbeln TYPE vbep-vbeln," so no
posnr TYPE vbep-posnr," so line no
etenr TYPE vbep-etenr," schedule line
delno TYPE lips-vbeln,"delivery no
delposnr TYPE lips-posnr,"del item no
totval TYPE vbep-wmeng," total del wise value
val TYPE vbep-wmeng," del wise used value
sdval TYPE vbep-wmeng,"schedule wise del used value
sdtotval TYPE vbep-wmeng," total Schedule value
END OF ty_new.
DATA:it_new TYPE ty_new OCCURS 0,
wa_new TYPE ty_new.
DATA: it_vbepvb TYPE TABLE OF vbepvb,
wa_vbepvb LIKE LINE OF it_vbepvb,
fvbfa TYPE TABLE OF vbfa,
fvbup TYPE TABLE OF vbup,
fvbap TYPE TABLE OF vbapvb.
LOOP AT it_vbak INTO wa_vbak.
LOOP AT it_vbap INTO wa_vbap
WHERE vbeln = wa_vbak-vbeln.
SELECT * FROM vbfa INTO TABLE fvbfa WHERE vbelv = wa_vbap-vbeln
AND posnv = wa_vbap-posnr.
SELECT * FROM vbup INTO TABLE fvbup WHERE vbeln = wa_vbap-vbeln
AND posnr = wa_vbap-posnr.
SELECT * FROM vbap INTO TABLE fvbap WHERE vbeln = wa_vbap-vbeln
AND posnr = wa_vbap-posnr.
SELECT * FROM vbep INTO TABLE it_vbepvb WHERE vbeln = wa_vbap-vbeln
AND posnr = wa_vbap-posnr.
CALL FUNCTION 'RV_SCHEDULE_CHECK_DELIVERIES'
EXPORTING
fbeleg = wa_vbap-vbeln
fposnr = wa_vbap-posnr
FVERRECHNUNG = ' '
FS073_ALT = ' '
IF_NO_SORT = ' '
TABLES
fvbfa = fvbfa
fvbup = fvbup
fxvbep = it_vbepvb
FVBLB =
fvbap = fvbap
EXCEPTIONS
FEHLER_BEI_LESEN_FVBUP = 1
FEHLER_BEI_LESEN_FXVBEP = 2
OTHERS = 3
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
SORT it_vbepvb BY vbeln posnr edatu.
LOOP AT it_vbepvb INTO wa_vbepvb
WHERE vbeln = wa_vbap-vbeln
AND posnr = wa_vbap-posnr.
to write data of schedule line with no delivery
MOVE wa_vbepvb-olfmng_flt TO wa_itab-openqty.
IF wa_vbepvb-bmeng EQ wa_itab-openqty.
CLEAR wa_itab.
PERFORM schedule_data. "schedule line based data to be displayed
MOVE: wa_vbap-lgort TO wa_itab-lgort.
MOVE: wa_vbepvb-etenr TO wa_itab-etenr,
wa_vbepvb-bmeng TO wa_itab-kwmeng,
wa_vbepvb-olfmng_flt TO wa_itab-openqty.
APPEND wa_itab TO it_itab .
CLEAR wa_itab.
ENDIF.
LOOP AT it_vbfa INTO wa_vbfa WHERE vbelv = wa_vbepvb-vbeln
AND posnv = wa_vbepvb-posnr.
READ TABLE it_likp INTO wa_likp WITH KEY vbeln = wa_vbfa-vbeln.
CHECK wa_likp-bldat >= wa_vbepvb-edatu.
check the Delivery doc date with the schedule line confirmed date
CLEAR: delbal, deltot,wa_new.
LOOP AT it_new INTO wa_new WHERE vbeln = wa_vbepvb-vbeln
AND posnr = wa_vbepvb-posnr
AND etenr = wa_vbepvb-etenr.
deltot = deltot + wa_new-sdval.
ENDLOOP.
delbal = wa_new-sdtotval - deltot.
CHECK sy-subrc <> 0 OR delbal GT 0.
MOVE wa_vbepvb-olfmng_flt TO wa_itab-openqty.
CHECK wa_vbepvb-bmeng NE wa_itab-openqty.
****To check whether this delivery is already fully allocated against
any other schedule.
LOOP AT it_lips INTO wa_lips WHERE vbeln = wa_vbfa-vbeln
AND posnr = wa_vbfa-posnn.
MOVE: wa_likp-bolnr TO wa_itab-vesname.
MOVE: wa_likp-vbeln TO wa_itab-delno.
MOVE: wa_likp-wadat TO wa_itab-wadat.
MOVE: wa_likp-anzpk TO wa_itab-anzpk.
MOVE: wa_likp-lddat TO wa_itab-lddat.
MOVE: wa_likp-ernam TO wa_itab-ernam.
******end of code added by IVL1 on sep 27 2007 #3618
PERFORM schedule_data.
IF wa_lips-umvkz <> 0.
tempquant = wa_lips-umvkn / wa_lips-umvkz.
ELSE.
tempquant = wa_lips-umvkn. "delivery qty
ENDIF.
tempquant = tempquant * wa_vbfa-rfmng.
***New logic added to get delivery qty schedule wise****
MOVE: wa_vbepvb-etenr TO wa_itab-etenr,
wa_vbepvb-bmeng TO wa_itab-kwmeng,
wa_vbepvb-olfmng_flt TO wa_itab-openqty. "jo
**if delivery qty is less than or equal to schedule line qty******
IF tempquant LE wa_vbepvb-bmeng.
wa_itab-delqty = tempquant.
LOOP AT it_new INTO wa_new WHERE vbeln = wa_vbepvb-vbeln
AND posnr = wa_vbepvb-posnr
AND etenr = wa_vbepvb-etenr
AND delno = wa_lips-vbeln
AND delposnr = wa_lips-posnr.
MOVE-CORRESPONDING wa_itab TO wa_new.
wa_new-delposnr = wa_lips-posnr.
wa_new-val = tempquant.
wa_new-totval = tempquant.
wa_new-sdval = tempquant.
wa_new-sdtotval = wa_vbepvb-bmeng.
MODIFY TABLE it_new FROM wa_new .
IF NOT sy-subrc IS INITIAL.
APPEND wa_new TO it_new.
ENDIF.
ENDLOOP.
IF sy-subrc <> 0.
MOVE-CORRESPONDING wa_itab TO wa_new.
wa_new-delposnr = wa_lips-posnr.
wa_new-val = tempquant.
wa_new-totval = tempquant.
wa_new-sdval = tempquant.
wa_new-sdtotval = wa_vbepvb-bmeng.
APPEND wa_new TO it_new.
ENDIF.
wa_itab-delqty = tempquant.
CLEAR tempquant.
ELSE.
lips qty > so schedule lineqty
CLEAR deltol.
LOOP AT it_new INTO wa_new WHERE vbeln = wa_vbepvb-vbeln
AND posnr = wa_vbepvb-posnr
AND etenr = wa_vbepvb-etenr
AND delno = wa_lips-vbeln
AND delposnr = wa_lips-posnr.
deltol = deltol + wa_new-val.
ENDLOOP.
LOOP AT it_new INTO wa_new WHERE vbeln = wa_vbepvb-vbeln
AND posnr = wa_vbepvb-posnr
AND delno = wa_lips-vbeln
AND delposnr = wa_lips-posnr.
MOVE-CORRESPONDING wa_itab TO wa_new.
wa_new-val = wa_new-totval - deltol.
wa_itab-delqty = wa_new-val.
wa_new-delposnr = wa_lips-posnr.
wa_new-totval = tempquant.
wa_new-sdval = wa_new-val.
wa_new-sdtotval = wa_vbepvb-bmeng.
MODIFY TABLE it_new FROM wa_new .
IF NOT sy-subrc IS INITIAL.
APPEND wa_new TO it_new.
ENDIF.
ENDLOOP.
IF sy-subrc <> 0.
MOVE-CORRESPONDING wa_itab TO wa_new.
wa_itab-delqty = wa_vbepvb-bmeng.
wa_new-delposnr = wa_lips-posnr.
wa_new-val = wa_vbepvb-bmeng.
wa_new-totval = tempquant.
wa_new-sdval = wa_vbepvb-bmeng.
wa_new-sdtotval = wa_vbepvb-bmeng.
APPEND wa_new TO it_new.
ENDIF.
ENDIF.
IF NOT wa_lips-lgort IS INITIAL.
MOVE: wa_lips-lgort TO wa_itab-lgort.
ELSE.
MOVE: wa_vbap-lgort TO wa_itab-lgort.
ENDIF.
APPEND wa_itab TO it_itab .
CLEAR wa_itab.
ENDLOOP.
ENDLOOP.
CLEAR wa_vbepvb.
ENDLOOP.
ENDLOOP.
CLEAR wa_vbak.
ENDLOOP. -
Delivered Quantity in Scheduling agreement ?
Hi,
I have to read out the delivered quantities (Transaction VA33) of the schedule lines which are under the position. I already have the data from the table VBEP, but I don't have the delivered quantities (VSMNG) in this table. How can I read this information?
Thank you,
JeetHi,
Delivered quantity at the schedule line is calculated with function module RV_SCHEDULE_CHECK_DELIVERIES. You have to feed it with document flow from sales order to delivery (FVBFA), schedule lines (FVBEP), status (FVBUP), and sales order item (FVBAP) to get the vsmng filled in FVBEP.
Also please check the following FM.
SD_VBEP_ARRAY_READ_VBELN
SD_VBEP_READ_WITH_POSNR
SD_VBEP_READ_WITH_VBELN
SD_VBEP_SELECT
SD_VBEP_SINGLE_READ
It will return VSMNG value(s) in table parameter (table strucuture VBEPVB).
Hope this will help.
Regards,
Ferry Lianto -
hello dear,
how can i calculate total from a fields to get value,i am using table bset and i have to calculate total of fields fwste in according to hkont and belnr to get exice amount please refer some related programs.If you want to calculate th e third filed based on other two, you would need to do it programatically using control break statements like AT NEW / AT END OF ect ..
Below is sample program which does summary based on mrp controllers and other parameeters.
Modification Log
Program Name:ZCD0R_PDC_PERCENT_FILL
Author:Santosh Sarda
Date Written:7/19/2007
Request #:CDXK961051
Requested by:Blanca Ramirez.
Description: Get the percent fill of PDC Service Parts Requirements
Program Specifications:Service Store Percent Fill
Mod date Programmer Reference Description
REPORT zcd0r_pdc_percent_fill.
Includes
types
tables
types
internal tables
Work Areas
internal data fields
Internal table for field catalogue
Internal table for sort and sum
Structure for layout control settings
Structure for sort and Sum
Parameters and Selection Options
Initialization
at selection screen
event Start of Selection
Get ReQuired Data
Calculate % FILL MRP Controllerwise.
Calculate % Fill material wise.
forms
---- This Subroutine does not take any parameters.
*07/19/2007 Santosh S. CDXK961051 Initial Creation
*08/01/2007 Santosh S. CDXK961295 Layout change
*eject
TYPE-POOLS : slis.
Select data as per selection screen conditions .
TABLES:vbep, " Sales Document: Schedule Line Data
vbap, " Sales Document: Item Data
vbak, " Sales Document: Header Data
marc. " Plant Data for Material
This Subroutine does not take any parameters.
TYPES:
BEGIN OF t_vbak,
vbeln TYPE vbak-vbeln, "Sales document
kunnr TYPE vbak-kunnr, "Sold-to party
END OF t_vbak,
BEGIN OF t_vbap,
vbeln TYPE vbap-vbeln, "Sales document
posnr TYPE vbap-posnr, "Item
werks TYPE vbap-werks, "Plant
matnr TYPE vbap-matnr, "Material
END OF t_vbap,
BEGIN OF t_marc,
werks TYPE marc-werks, "Plant
matnr TYPE marc-matnr, "Material
dispo TYPE marc-dispo, "MRP Controller
END OF t_marc,
BEGIN OF t_makt,
matnr TYPE makt-matnr, "Material
maktx TYPE makt-maktx, "Material Description
END OF t_makt,
BEGIN OF t_vbpa,
vbeln TYPE vbpa-vbeln, "Sales document
parvw TYPE vbpa-parvw, "Partner Function
kunnr TYPE vbpa-kunnr, "Ship To Party
END OF t_vbpa,
BEGIN OF t_t024d,
werks TYPE t024d-werks, "Plant
dispo TYPE t024d-dispo, "MRP Controller
dsnam TYPE t024d-dsnam, "Controller Name
END OF t_t024d,
BEGIN OF t_vbep,
vbeln TYPE vbep-vbeln, "Sales document
posnr TYPE vbep-posnr, "Item
etenr TYPE vbep-etenr, "Schedule line
edatu TYPE vbep-edatu, "Delivery Date
wmeng TYPE vbep-wmeng, "Order quantity
END OF t_vbep,
BEGIN OF t_vbep_all,
vbeln TYPE vbep-vbeln, "Sales document
posnr TYPE vbep-posnr, "Item
etenr TYPE vbep-etenr, "Schedule line
matnr TYPE marc-matnr, "Material
maktx TYPE makt-maktx, "Material Description
dispo TYPE t024d-dispo, "MRP Controller
dsnam TYPE t024d-dsnam, "Controller Name
edatu TYPE vbep-edatu, "Delivery Date
wmeng TYPE vbep-wmeng, "Order Quantity
olfmng TYPE olfmng, "Open Quantity
soldto TYPE vbak-kunnr, "Sold To Party
shipto TYPE vbpa-kunnr, "Ship To Party
END OF t_vbep_all,
BEGIN OF t_marc_all,
werks TYPE marc-werks, "Plant
matnr TYPE marc-matnr, "Material
dispo TYPE marc-dispo, "MRP Controller
maktx TYPE makt-maktx, "Material Description
dsnam TYPE t024d-dsnam, "Controller Name
END OF t_marc_all,
BEGIN OF t_output,
dispo TYPE marc-dispo, "MRP Controller
dsnam TYPE t024d-dsnam, "Controller Name
matnr TYPE vbap-matnr, "Material
maktx TYPE makt-maktx, "Material Description
vbeln TYPE vbak-vbeln, "Sales document
posnr TYPE vbap-posnr, "Item
edatu TYPE vbep-edatu, "Delivery Date
wmeng TYPE i, "Order Quantity
shipqty TYPE i, "Shipped Quantity
olfmng TYPE i, "Open Quantity
fill TYPE olfmng, "%Fill
materialfill TYPE olfmng,
controllerfill TYPE olfmng,
soldto TYPE vbak-kunnr, "Sold To Party
shipto TYPE vbpa-kunnr, "Ship To Party
END OF t_output,
BEGIN OF t_date,
edatu TYPE sy-datum, "Delivery date
END OF t_date.
******************* Do Nothing
Do Nothing
Do Nothing
Do Nothing
Begin Of CDXK961295********************************
TYPES:BEGIN OF t_sum_mrpcontro,
dispo TYPE marc-dispo, "MRP Controller
dsnam TYPE t024d-dsnam, "Controller Name
wmeng TYPE i, "Order Quantity
shipqty TYPE i, "Shipped Quantity
olfmng TYPE i, "Open Quantity
controllerfill TYPE olfmng,
END OF t_sum_mrpcontro,
BEGIN OF t_sum_material,
dispo TYPE marc-dispo, "MRP Controller
dsnam TYPE t024d-dsnam, "Controller Name
matnr TYPE vbap-matnr, "Material
maktx TYPE makt-maktx, "Material Description
wmeng TYPE i, "Order Quantity
shipqty TYPE i, "Shipped Quantity
olfmng TYPE i, "Open Quantity
materialfill TYPE olfmng,
END OF t_sum_material.
*******************Get Data from VBEP: schedule line data within Date range of EDATU.
End Of CDXK961295 This Subroutine does not take any parameters.
Do Nothing .
DATA:
i_vbak TYPE STANDARD TABLE OF t_vbak,
i_vbap TYPE STANDARD TABLE OF t_vbap,
i_marc TYPE STANDARD TABLE OF t_marc,
i_makt TYPE STANDARD TABLE OF t_makt,
i_vbpa TYPE STANDARD TABLE OF t_vbpa,
i_t024d TYPE STANDARD TABLE OF t_t024d,
i_vbep TYPE STANDARD TABLE OF t_vbep,
i_vbep_all TYPE STANDARD TABLE OF t_vbep_all,
i_marc_all TYPE STANDARD TABLE OF t_marc_all,
o_output TYPE STANDARD TABLE OF t_output,
i_date TYPE STANDARD TABLE OF t_date,
i_sum_mrpcontro TYPE STANDARD TABLE OF t_sum_mrpcontro,"CDXK961295
i_sum_material TYPE STANDARD TABLE OF t_sum_material. "CDXK961295
DATA:
wa_vbak LIKE LINE OF i_vbak,
wa_vbap LIKE LINE OF i_vbap,
wa_marc LIKE LINE OF i_marc,
wa_makt LIKE LINE OF i_makt,
wa_vbpa LIKE LINE OF i_vbpa,
wa_t024d LIKE LINE OF i_t024d,
wa_vbep LIKE LINE OF i_vbep,
wa_vbep_all LIKE LINE OF i_vbep_all,
wa_marc_all LIKE LINE OF i_marc_all,
wa_output LIKE LINE OF o_output,
wa_date LIKE LINE OF i_date,
wa_sum_mrpcontro LIKE LINE OF i_sum_mrpcontro, "CDXK961295
wa_sum_material LIKE LINE OF i_sum_material. "CDXK961295
Process material and mrp controller data.
CONSTANTS:
c_spras(2) TYPE c VALUE 'EN', "To get material Description In EN
c_parvw(2) TYPE c VALUE 'WE', "To get Ship to party ( SH=WE )
c_act_auth_03 LIKE tactz-actvt VALUE '03', "03 --> Plant check
c_x TYPE c VALUE 'X', "Field catelogue
c_c TYPE c value 'C'. "field catelogue
DATA: g_date TYPE sy-datum, "To keep track of delivery date
g_totalopen TYPE olfmng, "To Split OLFMNG in given date range
g_tabix TYPE sy-tabix. "To keep loop track
*Declartion of t_code for authority check.
DATA: g_tcode LIKE sy-tcode. "variable for TCODE.
************************** This Subroutine does not take any parameters.
ALVObject**********************************
DATA:
i_fieldcat TYPE slis_t_fieldcat_alv,
Process VBEP data with material data.
i_sort TYPE slis_t_sortinfo_alv,
This Subroutine does not take any parameters.
fs_layout TYPE slis_layout_alv,
fs_sort LIKE LINE OF i_sort ,
*internal table to set pf status
i_extab TYPE standard table of slis_extab.
SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
SELECT-OPTIONS:
s_werks FOR marc-werks OBLIGATORY, " Producing Plant
s_matnr FOR marc-matnr, " Material
s_dispo FOR marc-dispo. " MRP Controller
SELECTION-SCREEN END OF BLOCK blk1.
SELECTION-SCREEN BEGIN OF BLOCK blk2 WITH FRAME TITLE text-002.
SELECT-OPTIONS:
s_vkorg FOR vbak-vkorg , " Sales Organisation
s_vbeln FOR vbak-vbeln , " Sales Order
s_auart FOR vbak-auart DEFAULT 'ZLCW' TO 'ZLIF', " Sales Doc Type
s_lgort FOR vbap-lgort, " Storage Location
s_kunnr FOR vbak-kunnr DEFAULT '99999PDY00', " Sold to party
s_edatu FOR vbep-edatu OBLIGATORY. " Delivery Date
SELECTION-SCREEN END OF BLOCK blk2.
**********************This subroutine is copied from transaction ZCSRS to get open quantity.
Naming Conventions have been changed as per standards.
BEGIN OF CDXK961295 This Subroutine does not take any parameters.
*To add select radiobutton group for choosing layout as per users
*requirement to see detail or summary.
SELECTION-SCREEN BEGIN OF BLOCK blk3 WITH FRAME TITLE text-026.
PARAMETER r_lay1 RADIOBUTTON GROUP r1.
PARAMETER r_lay2 RADIOBUTTON GROUP r1 DEFAULT 'X'.
PARAMETER r_lay3 RADIOBUTTON GROUP r1.
SELECTION-SCREEN END OF BLOCK blk3.
**********************Consider only Sch Agmts here to proceed further
CHECK NOT t_sch_agmts[] IS INITIAL.
Doc Flow entries from VBFA
Sales Document: Item Status from VBUP
Sch Line items from VBEP
Sch Agmt Items from VBAP
Now, use the FM for each line item and get the open qty. Make a copy
of iT_SCH_AGMTS for use later on.
Call the FM now
END OF CDXK961295*****************************
To populate final output table
INITIALIZATION.
PERFORM t_code_check.
This Subroutine does not take any parameters.
*Check Authorisation For Plant.
AT SELECTION-SCREEN ON s_werks.
PERFORM plant_auth_check.
*Validate MRP Controller.
AT SELECTION-SCREEN ON s_dispo.
PERFORM validate_mrp_controller.
*Validate Document type.
AT SELECTION-SCREEN ON s_auart.
PERFORM validate_doc_type.
if s_edatu-high value is enterd by user
if only s_edatu-low value is enterd by user
sort for getting orders with shedule lines in reverse order TO adjust
open quantity as per earliest delivery date.
START-OF-SELECTION.
*Check Delivery Dates Entered By user and MODIFY the same.
PERFORM chk_del_date.
PERFORM get_data.
*Loop To Process Number Of Single Values Entered Of EDATU.
LOOP AT s_edatu .
g_tabix = sy-tabix.
READ TABLE i_date INTO wa_date INDEX g_tabix.
IF sy-subrc = 0.
g_date = wa_date-edatu.
PERFORM get_vbep_data. "Get Data from VBEP
PERFORM process_material_data. "Material Detail
PERFORM process_data. "Process Data
PERFORM get_rem_quantity. "Get Open Qty From FM
PERFORM get_final_output. "Add data to output table
CLEAR: i_vbep[],i_vbep_all[].
ENDIF. " IF SY-SUBRC = 0.
ENDLOOP. " LOOP AT s_edatu .
**********************To Calculate TOTAL % fill MRP ControllerWise
BEGIN OF CDXK961295 This subroutine does not take any parameters.
*Display alv as per layout selection.
IF r_lay1 = 'X'.
PERFORM calc_mrpcontroller_%fill.
PERFORM calc_material_%fill.
PERFORM fill_catalogue. " Fill catelogue
PERFORM display_output. " Display OUTPUT ON AlV GRID using FM.
ELSEIF r_lay2 = 'X'.
PERFORM process_sum_mrpcontro.
PERFORM fill_catelogue_mrpcontro. " Fill catelogue
PERFORM display_sum_mrpcontro. " Display OUTPUT ON AlV GRID using FM
ELSEIF r_lay3 = 'X'.
PERFORM process_sum_material.
PERFORM fill_catelogue_material. " Fill catelogue
PERFORM display_sum_material. " Display OUTPUT ON AlV GRID using FM.
ENDIF. " IF r_lay1 = 'X'.
**********************END OF CDXK961295 This subroutine does not take any parameter.
&---- To fill FieldCatelogue to be passed to FM
*& Form chk_del_date
This Subroutine does not take any parameters.
&----To sort output on MRP Controller AND Material and do subtotal.
Sort on controller name ,material description to get
displayed controller name and material description along with mrp
controller and material at subtotals level.
*check if delivery date is less than today,then modify date till today
*else search in given range.
---- Call alv display function module
This Subroutine does not take any parameters.
SORT AS per MRP Controller,Material and delete duplicates.
Set the Layout attributes
Call FUNCTION MODULE FOR DISPLAY
DO NOTHING
----FORM chk_del_date.
LOOP AT s_edatu.
wa_date = s_edatu-high.
IF s_edatu-low LT sy-datum AND s_edatu-high LT sy-datum.
s_edatu-high = sy-datum.
s_edatu-option = 'BT'.
MODIFY s_edatu.
ENDIF. "IF s_edatu-low LT sy-datum AND s_edatu-high LT sy-datum.
APPEND wa_date TO i_date.
CLEAR:wa_date.
ENDLOOP. " LOOP AT s_edatu.
ENDFORM. " chk_del_date
Check authorization against transaction code
&---- This subroutine does not take any parameters.
*& Form get_data
Validate Document type.
This subroutine does not take any parameters.
Authorisation and validation of Plant
---- This subroutine does not take any parameters.
FORM get_data.
*Get data from VBAK SD agreement and Sold To Party
SELECT vbeln
kunnr
FROM vbak
INTO TABLE i_vbak
WHERE vbeln IN s_vbeln
AND kunnr IN s_kunnr
AND auart IN s_auart
AND vkorg IN s_vkorg.
IF sy-subrc = 0.
SORT i_vbak BY vbeln.
ELSE.
MESSAGE e208(00) WITH 'No Scheduling Agreements Found '(003).
ENDIF. " IF SY-SUBRC = 0.
*Get data from VBAP item data and related material for SD Agrrement from
*VBAK
IF NOT i_vbak[] IS INITIAL.
SELECT vbeln
posnr
werks
matnr
FROM vbap
INTO TABLE i_vbap
FOR ALL ENTRIES IN i_vbak
WHERE vbeln EQ i_vbak-vbeln
AND werks IN s_werks
AND matnr IN s_matnr
AND lgort IN s_lgort
AND abgru EQ space.
IF sy-subrc = 0.
SORT i_vbap BY vbeln posnr.
ELSE.
MESSAGE e368(00) WITH
'No SD Agreements Found for Plant'(004) s_werks.
ENDIF. " IF SY-SUBRC = 0
ENDIF. "IF NOT i_vbak[] IS INITIAL
IF NOT i_vbap[] IS INITIAL.
*Get data from MARC material and MRP Controller for given PLANT.
SELECT werks
matnr
dispo
FROM marc
INTO TABLE i_marc
FOR ALL ENTRIES IN i_vbap
WHERE werks EQ i_vbap-werks
AND matnr EQ i_vbap-matnr
AND dispo IN s_dispo.
IF sy-subrc = 0.
SORT i_marc BY werks matnr.
ELSE.
Validation for PlantSELECT SINGLE WERKS
ENDIF. " IF SY-SUBRC = 0.
*To DELETE Entries from VBAP AS per dispo from select option .
LOOP AT i_vbap INTO wa_vbap.
READ TABLE i_marc INTO wa_marc WITH KEY werks = wa_vbap-werks
matnr = wa_vbap-matnr BINARY SEARCH.
IF sy-subrc <> 0.
DELETE i_vbap.
CONTINUE.
ENDIF. " IF SY-SUBRC <> 0.
ENDLOOP. " LOOP AT i_vbap INTO wa_vbap.
*Get Ship To Party FROM VBPA.
SELECT vbeln
parvw
kunnr
FROM vbpa
INTO TABLE i_vbpa
FOR ALL ENTRIES IN i_vbap
WHERE vbeln EQ i_vbap-vbeln
AND parvw EQ c_parvw.
IF sy-subrc = 0.
SORT i_vbpa BY vbeln.
DELETE ADJACENT DUPLICATES FROM i_vbpa COMPARING vbeln.
ELSE.
ENDIF. " IF SY-SUBRC = 0.
ENDIF. " IF i_vbap[] IS INITIAL
IF NOT i_marc[] IS INITIAL.
*Get Material Description in English from MAKT.
SELECT matnr
maktx
FROM makt
INTO TABLE i_makt
FOR ALL ENTRIES IN i_marc
WHERE matnr EQ i_marc-matnr
AND spras = c_spras.
IF sy-subrc = 0 .
SORT i_makt BY matnr.
DELETE ADJACENT DUPLICATES FROM i_makt COMPARING matnr.
ELSE.
Validate MRP Controller
ENDIF. " IF SY-SUBRC = 0 .
*Get MRP Controller Name from T024D.
SELECT werks
dispo
dsnam
FROM t024d
INTO TABLE i_t024d
FOR ALL ENTRIES IN i_marc
WHERE werks EQ i_marc-werks
AND dispo EQ i_marc-dispo.
IF sy-subrc = 0 .
SORT i_t024d BY werks dispo.
ELSE.
This subroutine does not take any parameters.
ENDIF. " IF SY-SUBRC = 0 .
ENDIF. " IF NOT i_marc[] IS INITIAL
ENDFORM. " get_data
*& Form get_vbep_data
&----Display summary by MRP Controller
This subroutine does not take any parameter.
Field Catelogue for summary by MRP Controller
This Subroutine doen not take any parameter
----FORM get_vbep_data.
IF NOT i_vbap[] IS INITIAL.
IF s_edatu-low GE sy-datum AND s_edatu-high IS INITIAL.
SELECT vbeln
posnr
etenr
edatu
wmeng
FROM vbep
INTO TABLE i_vbep
FOR ALL ENTRIES IN i_vbap
WHERE vbeln EQ i_vbap-vbeln
AND posnr EQ i_vbap-posnr
AND edatu EQ s_edatu-low.
ELSE.
SELECT vbeln
posnr
etenr
edatu
wmeng
FROM vbep
INTO TABLE i_vbep
FOR ALL ENTRIES IN i_vbap
WHERE vbeln = i_vbap-vbeln
AND posnr = i_vbap-posnr
AND edatu BETWEEN s_edatu-low and s_edatu-high.
ENDIF. "IF s_edatu-low GE sy-datum AND s_edatu-high IS INITIAL.
IF sy-subrc = 0 .
ELSE.
MESSAGE e208(00) WITH
'No Scheduling Agreements Found Within Given Delivery Date'(018).
ENDIF. " IF SY-SUBRC = 0 .
ENDIF. " i_vbap[] IS INITIAL.
ENDFORM. " get_vbep_data
Call alv display function module
&---- This Subroutine does not take any parameters.
*& Form process_material_data
SORT AS per MRP Controller and delete duplicates.
Do nothing
Set the Layout attributes
Call FUNCTION MODULE FOR DISPLAY
DO NOTHING
&---- This subRoutine calculates summary line by material and store in
internal table to display as in alv
this subroutine does not take any parameter.
Fills Field Catelogue for alv display for summary by material
---- This subRoutine does not take any parameter.
FORM process_material_data.
*To get Mterial Description and MRP Controller.
LOOP AT i_marc INTO wa_marc .
wa_marc_all-werks = wa_marc-werks.
wa_marc_all-matnr = wa_marc-matnr.
wa_marc_all-dispo = wa_marc-dispo.
READ TABLE i_t024d INTO wa_t024d WITH KEY werks = wa_marc-werks
dispo = wa_marc-dispo BINARY SEARCH.
IF sy-subrc = 0.
wa_marc_all-dsnam = wa_t024d-dsnam.
ENDIF. " IF SY-SUBRC = 0
READ TABLE i_makt INTO wa_makt WITH KEY matnr = wa_marc-matnr
BINARY SEARCH.
IF sy-subrc = 0.
wa_marc_all-maktx = wa_makt-maktx.
ENDIF. " IF SY-SUBRC = 0.
APPEND wa_marc_all TO i_marc_all.
CLEAR :wa_marc_all,wa_marc,wa_t024d,wa_makt.
ENDLOOP. " i_marc INTO wa_marc
*Sort by palnt,material.
SORT i_marc_all BY werks matnr.
ENDFORM. " process_material_data
*& Form process_data
Call Function module For Display of summary my material.
&---- This SubRoutine Does not take any parameter.
SORT AS per MRP Controller,Material and delete duplicates.
do nothing.
Set the Layout attributes
Call FUNCTION MODULE FOR DISPLAY
DO NOTHING
---- Fills fieldcatelogue to be passed to ALV
p_output--> internal table for field catelogue type i_fieldcat.
FORM process_data.
*To get i-vbep_all
IF NOT i_vbep IS INITIAL.
LOOP AT i_vbep INTO wa_vbep.
wa_vbep_all-vbeln = wa_vbep-vbeln.
wa_vbep_all-posnr = wa_vbep-posnr.
wa_vbep_all-etenr = wa_vbep-etenr.
wa_vbep_all-edatu = wa_vbep-edatu.
wa_vbep_all-wmeng = wa_vbep-wmeng.
READ TABLE i_vbap INTO wa_vbap WITH KEY vbeln = wa_vbep-vbeln
posnr = wa_vbep-posnr BINARY SEARCH.
IF sy-subrc = 0.
wa_vbep_all-matnr = wa_vbap-matnr.
READ TABLE i_marc_all INTO wa_marc_all WITH KEY
werks = wa_vbap-werks matnr = wa_vbap-matnr BINARY SEARCH.
IF sy-subrc = 0.
wa_vbep_all-dispo = wa_marc_all-dispo.
wa_vbep_all-dsnam = wa_marc_all-dsnam.
wa_vbep_all-maktx = wa_marc_all-maktx.
ENDIF. " IF SY-SUBRC = 0.
ENDIF. " IF SY-SUBRC = 0.
READ TABLE i_vbak INTO wa_vbak WITH KEY vbeln = wa_vbep-vbeln
BINARY SEARCH.
IF sy-subrc = 0.
wa_vbep_all-soldto = wa_vbak-kunnr.
ENDIF. " IF SY-SUBRC = 0.
READ TABLE i_vbpa INTO wa_vbpa WITH KEY vbeln = wa_vbep-vbeln
BINARY SEARCH.
IF sy-subrc = 0.
wa_vbep_all-shipto = wa_vbpa-kunnr.
ENDIF. " IF SY-SUBRC = 0.
APPEND wa_vbep_all TO i_vbep_all.
CLEAR: wa_vbep,wa_vbap,wa_marc_all,wa_vbep_all,wa_vbak,wa_vbpa.
ENDLOOP. " LOOP AT i_vbep
ENDIF. "i_vbep is INITIAL
ENDFORM. " process_data
*& Form get_rem_quantity
FORM get_rem_quantity.
*Types Declaration
TYPES: BEGIN OF lt_sch_agmts ,
vbeln LIKE vbak-vbeln, "Sales Document
posnr LIKE vbap-posnr, "Item No
END OF lt_sch_agmts,
BEGIN OF lt_doc_types,
vbeln LIKE vbak-vbeln, "Sales Document
vbtyp LIKE vbak-vbtyp, "Document type
END OF lt_doc_types.
*Internal Tables Declaration.
DATA: it_vbfa_data TYPE STANDARD TABLE OF vbfa,
it_vbup_data TYPE STANDARD TABLE OF vbup,
it_vbep_data TYPE STANDARD TABLE OF vbepvb,
it_vbap_data TYPE STANDARD TABLE OF vbapvb,
it_sub_vbfa_data TYPE STANDARD TABLE OF vbfa,
it_sub_vbup_data TYPE STANDARD TABLE OF vbup,
it_sub_vbep_data TYPE STANDARD TABLE OF vbepvb,
it_sub_vbap_data TYPE STANDARD TABLE OF vbapvb,
it_sch_agmts TYPE STANDARD TABLE OF lt_sch_agmts,
it_doc_types TYPE STANDARD TABLE OF lt_doc_types.
*Work area declaration.
DATA: l_vbfa_data LIKE LINE OF it_vbfa_data,
l_vbup_data LIKE LINE OF it_vbup_data,
l_vbep_data LIKE LINE OF it_vbep_data,
l_vbap_data LIKE LINE OF it_vbap_data,
l_sub_vbfa_data LIKE LINE OF it_sub_vbfa_data,
l_sub_vbup_data LIKE LINE OF it_sub_vbup_data,
l_sub_vbep_data LIKE LINE OF it_sub_vbep_data,
l_sub_vbap_data LIKE LINE OF it_sub_vbap_data,
l_sch_agmts LIKE LINE OF it_sch_agmts,
l_doc_types LIKE LINE OF it_doc_types.
*ranges
RANGES: r_vbtyp FOR vbak-vbtyp.
*local variables
DATA: l_tabix LIKE sy-tabix.
CLEAR r_vbtyp[].
r_vbtyp-sign = 'I'. r_vbtyp-option = 'EQ'. r_vbtyp-low = 'E'.
APPEND r_vbtyp. CLEAR r_vbtyp.
r_vbtyp-sign = 'I'. r_vbtyp-option = 'EQ'. r_vbtyp-low = 'F'.
APPEND r_vbtyp. CLEAR r_vbtyp.
CLEAR it_doc_types[].
IF NOT i_vbep_all[] IS INITIAL.
SELECT vbeln
vbtyp
INTO TABLE it_doc_types
FROM vbak
FOR ALL ENTRIES IN i_vbep_all
WHERE vbeln = i_vbep_all-vbeln.
ENDIF.
SORT it_doc_types BY vbtyp.
DELETE it_doc_types WHERE NOT vbtyp IN r_vbtyp.
SORT it_doc_types BY vbeln.
LOOP AT i_vbep_all INTO wa_vbep_all.
READ TABLE it_doc_types INTO l_doc_types
WITH KEY vbeln = wa_vbep_all-vbeln BINARY SEARCH.
IF sy-subrc = 0 .
l_sch_agmts-vbeln = wa_vbep_all-vbeln.
l_sch_agmts-posnr = wa_vbep_all-posnr.
APPEND l_sch_agmts TO it_sch_agmts.
CLEAR l_sch_agmts.
ENDIF.
CLEAR : wa_vbep_all,l_doc_types.
ENDLOOP.
SORT it_sch_agmts.
DELETE ADJACENT DUPLICATES FROM it_sch_agmts COMPARING
vbeln posnr.
IF NOT it_sch_agmts[] IS INITIAL.
SELECT *
FROM vbfa
INTO TABLE it_vbfa_data
FOR ALL ENTRIES IN it_sch_agmts
WHERE vbelv = it_sch_agmts-vbeln
AND posnv = it_sch_agmts-posnr.
SELECT *
FROM vbup
INTO TABLE it_vbup_data
FOR ALL ENTRIES IN it_sch_agmts
WHERE vbeln = it_sch_agmts-vbeln
AND posnr = it_sch_agmts-posnr.
SELECT *
FROM vbep
INTO TABLE it_vbep_data
FOR ALL ENTRIES IN it_sch_agmts
WHERE vbeln = it_sch_agmts-vbeln
AND posnr = it_sch_agmts-posnr.
SELECT *
FROM vbap
INTO TABLE it_vbap_data
FOR ALL ENTRIES IN it_sch_agmts
WHERE vbeln = it_sch_agmts-vbeln
AND posnr = it_sch_agmts-posnr.
LOOP AT it_sch_agmts INTO l_sch_agmts .
CLEAR: it_sub_vbfa_data[], it_sub_vbup_data[],it_sub_vbep_data[],
it_sub_vbap_data[].
LOOP AT it_vbfa_data INTO l_vbfa_data
WHERE vbelv = l_sch_agmts-vbeln AND posnv = l_sch_agmts-posnr.
l_sub_vbfa_data = l_vbfa_data.
APPEND l_sub_vbfa_data TO it_sub_vbfa_data.
CLEAR : l_sub_vbfa_data,l_vbfa_data.
ENDLOOP. "LOOP AT it_vbfa_data into l_vbfa_data
LOOP AT it_vbup_data INTO l_vbup_data
WHERE vbeln = l_sch_agmts-vbeln AND posnr = l_sch_agmts-posnr.
l_sub_vbup_data = l_vbup_data.
APPEND l_sub_vbup_data TO it_sub_vbup_data.
CLEAR : l_sub_vbup_data,l_vbup_data.
ENDLOOP. " LOOP AT it_vbup_data Into l_vbup_data
LOOP AT it_vbep_data INTO l_vbep_data
WHERE vbeln = l_sch_agmts-vbeln AND posnr = l_sch_agmts-posnr.
l_sub_vbep_data = l_vbep_data.
APPEND l_sub_vbep_data TO it_sub_vbep_data.
CLEAR : l_sub_vbep_data,l_vbep_data.
ENDLOOP. " LOOP AT it_vbep_data INTO l_vbep_data
LOOP AT it_vbap_data INTO l_vbap_data
WHERE vbeln = l_sch_agmts-vbeln AND posnr = l_sch_agmts-posnr.
l_sub_vbap_data = l_vbap_data.
APPEND l_sub_vbap_data TO it_sub_vbap_data.
CLEAR : l_sub_vbap_data, l_vbap_data.
ENDLOOP. " LOOP AT it_vbap_data INTO l_vbap_data
CALL FUNCTION 'RV_SCHEDULE_CHECK_DELIVERIES'
EXPORTING
fbeleg = l_sch_agmts-vbeln
fposnr = l_sch_agmts-posnr
TABLES
fvbfa = it_sub_vbfa_data
fvbup = it_sub_vbup_data
fxvbep = it_sub_vbep_data
fvbap = it_sub_vbap_data
EXCEPTIONS
fehler_bei_lesen_fvbup = 1
fehler_bei_lesen_fxvbep = 2
OTHERS = 3.
IF sy-subrc EQ 0.
LOOP AT i_vbep_all INTO wa_vbep_all
WHERE vbeln = l_sch_agmts-vbeln.
l_tabix = sy-tabix.
READ TABLE it_sub_vbep_data INTO l_sub_vbep_data
WITH KEY vbeln = wa_vbep_all-vbeln
posnr = wa_vbep_all-posnr
etenr = wa_vbep_all-etenr.
IF sy-subrc EQ 0.
wa_vbep_all-olfmng = l_sub_vbep_data-olfmng.
MODIFY i_vbep_all FROM wa_vbep_all
INDEX l_tabix TRANSPORTING olfmng.
ENDIF. " IF SY-SUBRC EQ 0.
ENDLOOP. " LOOP AT i_vbep_all INTO wa_vbep_all
ENDIF. " IF SY-SUBRC EQ 0.
CLEAR l_sch_agmts.
ENDLOOP. "LOOP AT it_sch_agmts INTO l_sch_agmts .
ENDIF. "IF NOT it_sch_agmts[] IS INITIAL.
ENDFORM. " get_rem_quantity
*& Form get_final_output
FORM get_final_output.
DATA:l_vbeln LIKE vbep-vbeln, "Sales Document
l_posnr LIKE vbep-posnr, "Item
l_edatu LIKE vbep-edatu, "Delivery Date
l_tabix TYPE sy-tabix. "Index
IF NOT i_vbep_all IS INITIAL.
*Delete records which are beyond given deleivery date only.
LOOP AT i_vbep_all INTO wa_vbep_all.
l_vbeln = wa_vbep_all-vbeln.
l_posnr = wa_vbep_all-posnr.
l_edatu = wa_vbep_all-edatu.
AT NEW posnr.
IF NOT g_date IS INITIAL.
IF l_edatu > g_date.
DELETE i_vbep_all WHERE vbeln = l_vbeln
AND posnr = l_posnr.
IF sy-subrc = 0.
CONTINUE.
ENDIF. " IF SY-SUBRC = 0.
ENDIF. " IF l_edatu > g_date.
ELSE.
IF l_edatu > s_edatu-low.
DELETE i_vbep_all WHERE vbeln = l_vbeln
AND posnr = l_posnr.
IF sy-subrc = 0.
CONTINUE.
ENDIF. "IF SY-SUBRC = 0.
ENDIF. "IF l_edatu > s_edatu-low.
ENDIF. " g_date IS INITIAL
ENDAT. " AT NEW posnr.
*Delete Records where order quantity is 0 and open quantity is also 0.
IF wa_vbep_all-wmeng EQ 0 AND wa_vbep_all-olfmng EQ 0.
DELETE i_vbep_all. "Deletes current row.
ENDIF. " IF wa_vbep_all-wmeng EQ 0 AND wa_vbep_all-olfmng EQ 0.
CLEAR:wa_vbep_all,l_vbeln,l_posnr.
ENDLOOP. " LOOP AT i_vbep_all INTO wa_vbep_all.
SORT i_vbep_all DESCENDING.
LOOP AT i_vbep_all INTO wa_vbep_all.
l_tabix = sy-tabix.
AT NEW posnr .
SUM.
g_totalopen = wa_vbep_all-olfmng.
ENDAT. " AT NEW posnr .
IF g_totalopen > 0 AND wa_vbep_all-wmeng > 0.
IF wa_vbep_all-wmeng < g_totalopen.
wa_vbep_all-olfmng = wa_vbep_all-wmeng.
g_totalopen = g_totalopen - wa_vbep_all-wmeng.
ELSEIF wa_vbep_all-wmeng GE g_totalopen.
wa_vbep_all-olfmng = g_totalopen.
g_totalopen = 0.
ENDIF. " IF wa_vbep_all-wmeng < g_totalopen.
MODIFY i_vbep_all FROM wa_vbep_all
INDEX l_tabix TRANSPORTING olfmng.
ENDIF. " IF g_totalopen > 0 AND wa_vbep_all-wmeng > 0.
ENDLOOP. " LOOP AT i_vbep_all INTO wa_vbep_all.
*Sort Back In Ascending Order
SORT i_vbep_all.
*DELETE Records where open quantity is 0 .
IF NOT i_vbep_all IS INITIAL.
DELETE i_vbep_all WHERE wmeng = 0 .
ENDIF. " IF NOT i_vbep_all IS INITIAL.
*DELETE Records to get records within delivery date range.
IF NOT g_date IS INITIAL.
DELETE i_vbep_all WHERE edatu > g_date.
ELSEIF g_date IS INITIAL.
DELETE i_vbep_all WHERE edatu > s_edatu-low.
ENDIF. " IF NOT g_date IS INITIAL.
*Populate Final Output Internal Table
LOOP AT i_vbep_all INTO wa_vbep_all.
wa_output-dispo = wa_vbep_all-dispo.
wa_output-dsnam = wa_vbep_all-dsnam.
wa_output-matnr = wa_vbep_all-matnr.
wa_output-maktx = wa_vbep_all-maktx.
wa_output-vbeln = wa_vbep_all-vbeln.
wa_output-posnr = wa_vbep_all-posnr.
wa_output-edatu = wa_vbep_all-edatu.
wa_output-dispo = wa_vbep_all-dispo.
wa_output-wmeng = wa_vbep_all-wmeng.
wa_output-olfmng = wa_vbep_all-olfmng.
wa_output-soldto = wa_vbep_all-soldto.
wa_output-shipto = wa_vbep_all-shipto.
wa_output-shipqty = wa_vbep_all-wmeng - wa_vbep_all-olfmng.
wa_output-fill =
( wa_output-shipqty / wa_vbep_all-wmeng ) * 100.
APPEND wa_output TO o_output.
CLEAR: wa_output,wa_vbep_all.
ENDLOOP. " LOOP AT i_vbep_all INTO wa_vbep_all.
ENDIF. " IF NOT i_vbep_all IS INITIAL.
ENDFORM. " get_final_output
*& Form process_output
FORM calc_mrpcontroller_%fill.
DATA:l_shipqty TYPE olfmng, "Shipped Quantity
l_wmeng LIKE vbep-wmeng, "Order Quantity
l_fill TYPE olfmng, "%fill
l_dispo LIKE t024d-dispo. "Mrp Controller
IF NOT o_output IS INITIAL.
SORT o_output BY dispo.
LOOP AT o_output INTO wa_output.
l_dispo = wa_output-dispo.
AT NEW dispo.
SUM.
l_shipqty = wa_output-shipqty.
l_wmeng = wa_output-wmeng.
ENDAT. " AT NEW dispo
l_fill = ( l_shipqty / l_wmeng ) * 100 .
wa_output-controllerfill = l_fill.
MODIFY o_output FROM wa_output TRANSPORTING controllerfill
WHERE dispo = l_dispo.
CLEAR:wa_output.
ENDLOOP. "LOOP AT o_output INTO wa_output.
ENDIF. "IF NOT o_output IS INITIAL.
ENDFORM. " calc_mrpcontroller_%fill
*& Form calc_material_%fill
*To Calculate Total % Fill By Material.
FORM calc_material_%fill.
DATA: l_shipqty TYPE olfmng, "Shipped Quantity
l_wmeng TYPE vbep-wmeng, "Order Quantity
l_fill TYPE olfmng, "%fill
l_matnr TYPE mara-matnr. "Material
IF NOT o_output IS INITIAL.
SORT o_output BY dispo matnr.
LOOP AT o_output INTO wa_output.
l_matnr = wa_output-matnr.
AT NEW matnr.
SUM.
l_shipqty = wa_output-shipqty.
l_wmeng = wa_output-wmeng.
ENDAT. " AT NEW matnr.
l_fill = ( l_shipqty / l_wmeng ) * 100 .
wa_output-materialfill = l_fill.
MODIFY o_output FROM wa_output TRANSPORTING materialfill
WHERE matnr = l_matnr.
CLEAR:wa_output.
ENDLOOP. "LOOP AT o_output INTO wa_output.
ENDIF. "IF NOT o_output IS INITIAL.
ENDFORM. " calc_material_%fill
*& Form fill_catalogue
FORM fill_catalogue.
CLEAR: i_fieldcat[].
PERFORM build_fieldcat using 1 'DISPO' 'O_OUTPUT' 15 ' '
'MRP Controller'(005) ' ' i_fieldcat.
PERFORM build_fieldcat using 2 'DSNAM' 'O_OUTPUT' 15 ' '
'Controller Name'(006) ' ' i_fieldcat.
PERFORM build_fieldcat using 3 'MATNR' 'O_OUTPUT' 10 ' '
'Material'(007) c_c i_fieldcat.
PERFORM build_fieldcat using 4 'MAKTX' 'O_OUTPUT' 20 ' '
'Material Description'(008) ' ' i_fieldcat.
PERFORM build_fieldcat using 5 'VBELN' 'O_OUTPUT' 12 ' '
'SD Agreement'(009) c_c i_fieldcat.
PERFORM build_fieldcat using 6 'POSNR' 'O_OUTPUT' 4 ' '
'Item'(010) ' ' i_fieldcat.
PERFORM build_fieldcat using 7 'EDATU' 'O_OUTPUT' 13 ' '
'Delivery Date'(011) ' ' i_fieldcat.
PERFORM build_fieldcat using 8 'WMENG' 'O_OUTPUT' 20 c_x
'Scheduled Quantity'(012) c_c i_fieldcat.
PERFORM build_fieldcat using 9 'SHIPQTY' 'O_OUTPUT' 16 c_x
'Shipped Quantity'(013) c_c i_fieldcat.
PERFORM build_fieldcat using 10 'OLFMNG' 'O_OUTPUT' 12 c_x
'REM Quantity'(014) c_c i_fieldcat.
PERFORM build_fieldcat using 11 'FILL' 'O_OUTPUT' 6 ' '
'% Fill Per SchedLine'(025) c_c i_fieldcat.
PERFORM build_fieldcat using 12 'MATERIALFILL' 'O_OUTPUT' 21 ' '
'Tot %Fill By Material'(023) c_c i_fieldcat.
PERFORM build_fieldcat using 13 'CONTROLLERFILL' 'O_OUTPUT' 24 ' '
'Tot %Fill By MRP Contro.'(024) c_c i_fieldcat.
PERFORM build_fieldcat using 14 'SOLDTO' 'O_OUTPUT' 8 ' '
'SoldTo'(016) ' ' i_fieldcat.
PERFORM build_fieldcat using 15 'SHIPTO' 'O_OUTPUT' 8 ' '
'ShipTo'(017) ' ' i_fieldcat.
*Sort by mrp Controller.
fs_sort-spos = 1.
fs_sort-fieldname = 'DISPO'.
fs_sort-up = c_x.
APPEND fs_sort TO i_sort.
CLEAR fs_sort.
*Sort and subtotal by controller description and subtotal.
fs_sort-spos = 2.
fs_sort-fieldname = 'DSNAM'.
fs_sort-up = c_x.
fs_sort-subtot = c_x.
APPEND fs_sort TO i_sort.
CLEAR fs_sort.
*Sort by material.
fs_sort-spos = 3.
fs_sort-fieldname = 'MATNR'.
fs_sort-up = c_x.
APPEND fs_sort TO i_sort.
CLEAR fs_sort.
*Sort and subtotal by material description.
fs_sort-spos = 4.
fs_sort-fieldname = 'MAKTX'.
fs_sort-up = c_x.
fs_sort-subtot = c_x.
APPEND fs_sort TO i_sort.
CLEAR fs_sort.
ENDFORM. " fill_catalogue
*& Form display_output
FORM display_output.
IF o_output IS INITIAL.
MESSAGE e208(00) WITH text-022.
ELSE.
SORT o_output BY dispo matnr vbeln posnr edatu.
ENDIF. " IF o_output IS INITIAL.
MOVE c_x TO fs_layout-colwidth_optimize.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
is_layout = fs_layout
it_fieldcat = i_fieldcat
it_sort = i_sort
i_save = 'A'
TABLES
t_outtab = o_output.
IF sy-subrc <> 0.
ENDIF.
ENDFORM. " display_output
*& Form t_code_check
FORM t_code_check.
**validate authorization against transaction code
SELECT tcode FROM tstc
UP TO 1 ROWS
INTO g_tcode
WHERE pgmna = sy-repid.
ENDSELECT.
IF sy-subrc = 0.
AUTHORITY-CHECK OBJECT 'S_TCODE'
ID 'TCD' FIELD g_tcode.
IF sy-subrc NE 0.
MESSAGE e261(sf) WITH g_tcode.
ENDIF. "IF SY-SUBRC NE 0.
ENDIF. "IF SY-SUBRC = 0.
ENDFORM. " t_code_check
*& Form validate_doc_type
FORM validate_doc_type.
DATA:l_auart LIKE tvak-auart. "validate document type
SELECT auart
FROM tvak
UP TO 1 ROWS
INTO l_auart
WHERE auart IN s_auart.
ENDSELECT.
IF sy-subrc NE 0 AND NOT l_auart IS INITIAL .
MESSAGE e000(oo)
WITH 'Please enter a valid document type'(019).
ENDIF.
ENDFORM. " validate_doc_type
*& Form plant_auth_check
FORM plant_auth_check.
*Types declaration for werks
TYPES:BEGIN OF lt_werks,
werks TYPE marc-werks,
END OF lt_werks.
*internal table and wrk area to hold multiple plants
DATA :li_werks TYPE STANDARD TABLE OF lt_werks,
l_werks LIKE LINE OF li_werks.
SELECT werks
FROM t001w
INTO TABLE li_werks
WHERE werks IN s_werks.
IF sy-subrc EQ 0.
LOOP AT li_werks INTO l_werks.
AUTHORITY-CHECK OBJECT 'Z_MM_PLANT'
ID 'ACTVT' FIELD c_act_auth_03
ID 'WERKS' FIELD l_werks
ID 'TCD' FIELD g_tcode.
IF sy-subrc NE 0.
MESSAGE e004(co) WITH l_werks.
ENDIF. " IF SY-SUBRC NE 0..
ENDLOOP. " LOOP AT li_werks INTO l_werks..
ELSE.
MESSAGE e174(q3) WITH s_werks.
ENDIF. " IF SY-SUBRC EQ 0.....
ENDFORM. " plant_auth_check
*& Form validate_mrp_controller
FORM validate_mrp_controller.
DATA: l_dispo LIKE t024d-dispo. "mrp Controller
SELECT dispo
FROM t024d
UP TO 1 ROWS
INTO l_dispo
WHERE dispo IN s_dispo.
ENDSELECT.
IF sy-subrc NE 0 AND NOT l_dispo IS INITIAL.
MESSAGE e000(oo)
WITH 'Please enter a valid MRP Controller'(020).
ENDIF. "SY-SUBRC NE 0 AND NOT l_dispo IS INITIAL.
ENDFORM. " validate_mrp_controller
**********************BEGIN OF CDXK961295****************************
*& Form display_summary
FORM process_sum_mrpcontro.
DATA:l_shipqty TYPE olfmng, "Shipped Quantity
l_wmeng LIKE vbep-wmeng, "Order Quantity
l_fill TYPE olfmng, "%fill
l_olfmng TYPE olfmng. "Open Quantity
IF NOT o_output IS INITIAL.
SORT o_output BY dispo.
LOOP AT o_output INTO wa_output.
wa_sum_mrpcontro-dispo = wa_output-dispo.
wa_sum_mrpcontro-dsnam = wa_output-dsnam.
AT END OF dispo.
SUM.
wa_sum_mrpcontro-shipqty = wa_output-shipqty.
wa_sum_mrpcontro-wmeng = wa_output-wmeng.
wa_sum_mrpcontro-olfmng = wa_output-olfmng.
l_fill = ( wa_output-shipqty / wa_output-wmeng ) * 100 .
wa_sum_mrpcontro-controllerfill = l_fill.
APPEND wa_sum_mrpcontro TO i_sum_mrpcontro.
ENDAT. " AT END OF dispo
CLEAR:wa_sum_mrpcontro,wa_output, l_fill.
ENDLOOP. "LOOP AT o_output INTO wa_output.
SORT i_sum_mrpcontro BY dispo.
*Calculate 'total' and add as lastline to internal table .
LOOP AT i_sum_mrpcontro INTO wa_sum_mrpcontro.
l_shipqty = l_shipqty + wa_sum_mrpcontro-shipqty.
l_wmeng = l_wmeng + wa_sum_mrpcontro-wmeng.
l_olfmng = l_olfmng + wa_sum_mrpcontro-olfmng.
CLEAR:wa_sum_mrpcontro.
ENDLOOP. "LOOP AT i_sum_mrpcontro
l_fill = ( l_shipqty / l_wmeng ) * 100 .
wa_sum_mrpcontro-dsnam = 'Total'(015).
wa_sum_mrpcontro-wmeng = l_wmeng.
wa_sum_mrpcontro-shipqty = l_shipqty.
wa_sum_mrpcontro-olfmng = l_olfmng.
wa_sum_mrpcontro-controllerfill = l_fill.
APPEND wa_sum_mrpcontro TO i_sum_mrpcontro.
ENDIF. "IF NOT o_output IS INITIAL.
ENDFORM. " process_sum_mrpcontro.
*& Form fill_catelogue_summary
FORM fill_catelogue_mrpcontro.
CLEAR: i_fieldcat[].
PERFORM build_fieldcat using 1 'DISPO' 'I_SUM_MRPCONTRO' 15 ' '
'MRP Controller'(005) ' ' i_fieldcat.
PERFORM build_fieldcat using 2 'DSNAM' 'I_SUM_MRPCONTRO' 15 ' '
'Controller Name'(006) ' ' i_fieldcat.
PERFORM build_fieldcat using 3 'WMENG' 'I_SUM_MRPCONTRO' 20 ' '
'Scheduled Quantity'(012) c_c i_fieldcat.
PERFORM build_fieldcat using 4 'SHIPQTY' 'I_SUM_MRPCONTRO' 16 ' '
'Shipped Quantity'(013) c_c i_fieldcat.
PERFORM build_fieldcat using 5 'OLFMNG' 'I_SUM_MRPCONTRO' 12 ' '
'REM Quantity'(014) c_c i_fieldcat.
PERFORM build_fieldcat using 6 'CONTROLLERFILL' 'I_SUM_MRPCONTRO' 24
' ' 'Tot %Fill By MRP Contro.'(024) c_c i_fieldcat.
ENDFORM. " fill_catelogue_mrpcontro.
*& Form display_output
FORM display_sum_mrpcontro.
IF i_sum_mrpcontro IS INITIAL.
MESSAGE e208(00) WITH text-022.
ELSE.
ENDIF. " IF o_output IS INITIAL.
fs_layout-colwidth_optimize = c_x.
*To disable option of sort,and sum.
DATA:lr_extab TYPE slis_extab.
lr_extab-fcode = '&OUP'.
APPEND lr_extab TO i_extab.
lr_extab-fcode = '&ODN'.
APPEND lr_extab TO i_extab.
lr_extab-fcode = '&UMC'.
APPEND lr_extab TO i_extab.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
is_layout = fs_layout
it_fieldcat = i_fieldcat
i_save = 'A'
IT_EXCLUDING = i_extab
TABLES
t_outtab = i_sum_mrpcontro.
IF sy-subrc <> 0.
ENDIF.
ENDFORM. " display_sum_mrpcontro
*& Form process_sum_material
FORM process_sum_material.
DATA:l_shipqty TYPE olfmng, "Shipped Quantity
l_wmeng LIKE vbep-wmeng, "Order Quantity
l_fill TYPE olfmng, "%fill
l_olfmng TYPE olfmng. "Open Quantity
IF NOT o_output IS INITIAL.
SORT o_output BY dispo matnr.
LOOP AT o_output INTO wa_output.
wa_sum_material-dispo = wa_output-dispo.
wa_sum_material-dsnam = wa_output-dsnam.
wa_sum_material-matnr = wa_output-matnr.
wa_sum_material-maktx = wa_output-maktx.
AT END OF matnr.
SUM.
l_fill = ( wa_output-shipqty / wa_output-wmeng ) * 100 .
wa_sum_material-wmeng = wa_output-wmeng.
wa_sum_material-shipqty = wa_output-shipqty.
wa_sum_material-olfmng = wa_output-olfmng.
wa_sum_material-materialfill = l_fill.
APPEND wa_sum_material TO i_sum_material.
ENDAT. " AT END OF matnr
CLEAR:wa_sum_material,wa_output, l_fill.
ENDLOOP. "LOOP AT o_output INTO wa_output.
SORT i_sum_material BY dispo matnr.
*Calculate 'total' and add as lastline to internal table .
LOOP AT i_sum_material INTO wa_sum_material.
l_shipqty = l_shipqty + wa_sum_material-shipqty.
l_wmeng = l_wmeng + wa_sum_material-wmeng.
l_olfmng = l_olfmng + wa_sum_material-olfmng.
CLEAR:wa_sum_material.
ENDLOOP. "LOOP AT i_sum_material
l_fill = ( l_shipqty / l_wmeng ) * 100 .
wa_sum_material-dsnam = 'Total'(015).
wa_sum_material-wmeng = l_wmeng.
wa_sum_material-shipqty = l_shipqty.
wa_sum_material-olfmng = l_olfmng.
wa_sum_material-materialfill = l_fill.
APPEND wa_sum_material TO i_sum_material.
ENDIF. "IF NOT o_output IS INITIAL.
ENDFORM. " process_sum_material
*& Form fill_catelogue_material
FORM fill_catelogue_material.
CLEAR: i_fieldcat[].
PERFORM build_fieldcat using 1 'DISPO' 'I_SUM_MATERIAL' 15 ' '
'MRP Controller'(005) ' ' i_fieldcat.
PERFORM build_fieldcat using 2 'DSNAM' 'I_SUM_MATERIAL' 15 ' '
'Controller Name'(006) ' ' i_fieldcat.
PERFORM build_fieldcat using 3 'MATNR' 'I_SUM_MATERIAL' 10 ' '
'Material'(007) c_c i_fieldcat.
PERFORM build_fieldcat using 4 'MAKTX' 'I_SUM_MATERIAL' 20 ' '
'Material Description'(008) ' ' i_fieldcat.
PERFORM build_fieldcat using 5 'WMENG' 'I_SUM_MATERIAL' 20 ' '
'Scheduled Quantity'(012) c_c i_fieldcat.
PERFORM build_fieldcat using 6 'SHIPQTY' 'I_SUM_MATERIAL' 16 ' '
'Shipped Quantity'(013) c_c i_fieldcat.
PERFORM build_fieldcat using 7 'OLFMNG' 'I_SUM_MATERIAL' 12 ' '
'REM Quantity'(014) c_c i_fieldcat.
PERFORM build_fieldcat using 8 'MATERIALFILL' 'I_SUM_MATERIAL' 24
' ' 'Tot %Fill By Material'(023) c_c i_fieldcat.
ENDFORM. " fill_catelogue_material
*& Form display_sum_material
FORM display_sum_material.
IF i_sum_material IS INITIAL.
MESSAGE e208(00) WITH text-022.
ELSE.
ENDIF. " IF o_output IS INITIAL.
fs_layout-colwidth_optimize = c_x.
*To disable option of sort,and sum.
DATA:lr_extab TYPE slis_extab.
lr_extab-fcode = '&OUP'.
APPEND lr_extab TO i_extab.
lr_extab-fcode = '&ODN'.
APPEND lr_extab TO i_extab.
lr_extab-fcode = '&UMC'.
APPEND lr_extab TO i_extab.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
is_layout = fs_layout
it_fieldcat = i_fieldcat
IT_EXCLUDING = i_extab
i_save = 'A'
TABLES
t_outtab = i_sum_material.
IF sy-subrc <> 0.
ENDIF.
ENDFORM. " display_sum_material
*& Form Build field catelogue
*This subroutine takes paremeters.
*p_colpos-->column no. in alv
*p_fieldname-->name of column in internal table type char
*p_tabname-->name of internal table type char
*p-outputlen--> output length of column.
*p_do_sum--> flag to set subtotal
*p_coltext--> column heading type char
*p_just--> flag to set center justify type char
FORM build_fieldcat USING p_colpos p_fieldname p_tabname p_outputlen
p_do_sum p_coltext p_just p_output like i_fieldcat[].
DATA : l_fieldcat LIKE LINE OF i_fieldcat. "wrk area for field catelog
l_fieldcat-col_pos = p_colpos.
l_fieldcat-fieldname = p_fieldname.
l_fieldcat-tabname = p_tabname.
l_fieldcat-outputlen = p_outputlen.
l_fieldcat-do_sum = p_do_sum.
l_fieldcat-seltext_l = p_coltext.
l_fieldcat-just = p_just.
APPEND l_fieldcat TO p_output.
CLEAR l_fieldcat.
ENDFORM. " BUILD_FIELDCAT
**********************END OF CDXK961295**************************** -
Pending Value Field. In SO reports
Hy All Experts.
Please give me Details of Pending Order Value & Total Order Value Field for Sales Order Reports.
I used following Tables in Reports.
TABLES: VBEP , VBAP , VBPA , VBKD , VBAK , LIKP , LIPS , VBUP , KNA1.
Thnaks in Advance.
Bhavesh Panchal.hi, hope this code will help u.
MOVE-CORRESPONDING it_vbep to IT_VBEPVB.
append it_VBEPVB.
ALL FUNCTION 'RV_SCHEDULE_CHECK_DELIVERIES'
EXPORTING
fbeleg = it_vbap-vbeln
fposnr = it_vbap-Posnr
VERRECHNUNG = ' '
S073_ALT = ' '
F_NO_SORT = ' '
tables
fvbfa = it_vbfa
fvbup = it_vbup
fxvbep = it_VBEPVB
VBLB =
fvbap = it_VBAPVB
EXCEPTIONS
FEHLER_BEI_LESEN_FVBUP = 1
FEHLER_BEI_LESEN_FXVBEP = 2
OTHERS = 3
LOOP AT it_VBEPVB WHERE POSNR = IT_VBAP-POSNR.
IT_FINAL-KWMENG_d = IT_FINAL-KWMENG_d + it_VBEPVB-VSMNG. " COMPUTE DELIVERY QTY
IT_FINAL-KWMENG_p = IT_FINAL-KWMENG - IT_FINAL-KWMENG_d. "COMPUTE pENDING QTY
in this way u will get pending order quantity.
multiply this quantity with ur list amout which u will get it from konv-KSCHL = ZLSP .
multiply pending quantiy with konv-kwert where kschl = 'ZLSP' -
How do i get Delivered quantity in sales units
Hi all,
How do i get Delivered quantity in sales units, in schedule lines (SD - VA02).
I tried RV_SCHEDULE_CHECK_DELIVERIES, it not works.I m unable to find any table.
Please suggest ...
regards,
prasad gorehi,
try this.
* Fill Pending and Delivered Quantity *
SELECT *
from vbup
into table it_vbup
where vbeln = it_vbap-vbeln
and posnr = it_vbap-POSNR.
READ TABLE IT_VBUP WITH KEY VBELN = IT_VBAP-VBELN POSNR = IT_VBAP-POSNR.
IF SY-SUBRC EQ 0.
IT_FINAL-lv_status = IT_VBUP-LFSTA.
ENDIF.
SELECT *
from vbfa
into table it_vbfa
where VBELV = it_vbap-vbeln
and POSNV = it_vbap-posnr.
loop at it_vbap into wa_vbap where vbeln = it_vbak-vbeln.
MOVE-CORRESPONDING wa_vbap to it_VBAPVB.
append it_VBAPVB.
endloop.
loop at it_vbEp where vbeln = it_vbak-vbeln.
MOVE-CORRESPONDING it_vbep to IT_VBEPVB.
append it_VBEPVB.
ENDLOOP.
CALL FUNCTION 'RV_SCHEDULE_CHECK_DELIVERIES'
EXPORTING
fbeleg = it_vbap-vbeln
fposnr = it_vbap-Posnr
* FVERRECHNUNG = ' '
* FS073_ALT = ' '
* IF_NO_SORT = ' '
tables
fvbfa = it_vbfa
fvbup = it_vbup
fxvbep = it_VBEPVB
* FVBLB =
fvbap = it_VBAPVB
EXCEPTIONS
FEHLER_BEI_LESEN_FVBUP = 1
FEHLER_BEI_LESEN_FXVBEP = 2
OTHERS = 3
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
LOOP AT it_VBEPVB WHERE POSNR = IT_VBAP-POSNR.
IT_FINAL-KWMENG_d = IT_FINAL-KWMENG_d + it_VBEPVB-VSMNG. " COMPUTE DELIVERY QTY
ENDLOOP.
Maybe you are looking for
-
Photoshop images with spot channels in Indesign CS6 (layout question)
I've got an Indesign CS6 layout that will have a spot varnish when it goes to press. Right now I've got a layout with psd files that have spot channels in them that will be used for the spot varnish. My question is, in Indesign when I'm laying this o
-
Which Intel CPU is used for MacBook Pro 13" 2.26 GHz
Hello, I want to buy the above-mentioned MacBook Pro, however, I don't know which CPU model is used (P7550 or P8400), since I need the CPU feature "IVT" (Intel® Virtualization Technology) which is only available in P8400. In some German discussions I
-
How to handle Third party management WRT to Lease out in SAP - REFX
Dear Friends, I would like to have an advice on Third party management of a property WRT to (SAP REFX) Lease out. Example: Under a company code – 1000, I have some 8000 number of properties which is my own and I am doing Lease out with the same. Out
-
I am currently working abroad on my macbook pro. I have a imac at home and need to access my iphoto. I am not the greatest tech wizard but please can someone explain in simple terms how I can access my files at home. i have someone at home who can ch
-
I installed R12 as Prod , in the beginning it was running perfectly, but from last week I have observed that browser is giving this message constantly HTTP 404 not Found while I have check all the services are running perfectly but When I restart the