Hint ordered and cartesian product

I have a query which needs to be tuned.
The initial Query does not show cartesian product in the plan , when I change the order of the tables in the from clause ( I have placed the least # of rows first and the most rows tables in the last) and I get MERGE JOIN CARTESIAN product the where clause remaining the same and the cost escalates from 7180 to 454M .
This happens with ordered hint.

ranjus wrote:
I have a query which needs to be tuned.
The initial Query does not show cartesian product in the plan , when I change the order of the tables in the from clause ( I have placed the least # of rows first and the most rows tables in the last) and I get MERGE JOIN CARTESIAN product the where clause remaining the same and the cost escalates from 7180 to 454M .
This happens with ordered hint.Let's take a look at this with a simple test case. Assume that:
* Table T1 contains 10,000 rows
* Table T2 contains 100 rows
* Table T3 contains 100,000 rows
* Table T4 contains 10 rows
You have the following query:
SELECT
  T1.C1,
  T2.C2,
  T3.C3,
  T4.C4
FROM
  T1,
  T2,
  T3,
  T4
WHERE
  T1.C1=T2.C2
  AND T2.C2=T3.C2
  AND T3.C3=T4.C3;In the above, you can see that in the WHERE clause:
* Table T1 is joined to table T2
* Table T2 is joined to tables T1 and T3
* Table T3 is joined to tables T2 and T4
* Table T4 is joined to table T3
What it sounds like you are trying to do is something like this based on the number of rows in the tables:
SELECT /*+ ORDERED */
  T1.C1,
  T2.C2,
  T3.C3,
  T4.C4
FROM
  T4,
  T2,
  T1,
  T3
WHERE
  T1.C1=T2.C2
  AND T2.C2=T3.C2
  AND T3.C3=T4.C3;In the above, we are forcing Oracle's optimizer to join tables T4 and T2 - but there is no direct relationship between the two tables described in the WHERE clause. In such a case, Oracle's optimizer will be forced to perform a Cartesian join between tables T4 and T2. Next, table T1 has a relationship defined in the WHERE clause with table T2, so that join would not result in a Cartesian product. Finally, table T3 has a relationship between tables T2 and T4, so that would not result in a Cartesian product.
Going back to this example, assume that table T4 contained a single row. The execution plan will still show a Cartesian join, but that Cartesian join is no worse than a nested loops join because there is a single row in one of the row sources.
In short, think about what you are attempting to force the optimizer to do. You cannot always join in the order of increasing row cardinality estimates - it simply does not make sense to try in some cases.
Charles Hooper
Co-author of "Expert Oracle Practices: Oracle Database Administration from the Oak Table"
http://hoopercharles.wordpress.com/
IT Manager/Oracle DBA
K&M Machine-Fabricating, Inc.

Similar Messages

  • Question about the rescheduling of a Sales Order and its Production Order

    Hello Everybody,
    I experience something strange with the rescheduling of a Sales Order and its corresponding Production Order.
    It will be easier to explain with an example...
    For a material, I have created a Sales Order.
    And from this Sales Order, I have now a Production Order converted from a Planned Order generated by the MRP Run.
    This is what I have in transaction MD04:
    SALES ORDER
    AV DATE: 20/02/2008
    GR DATE: 20/02/2008
    PRODUCTION ORDER
    AV DATE: 20/02/2008
    GR DATE: 18/02/2008    (GR process time is 2 days).
    ==> OK !
    Now, I have to reschedule the Sales Order one week sooner.
    SALES ORDER
    AV DATE: 13/02/2008
    GR DATE: 13/02/2008
    After transaction COHV to reschedule the Production Order, I have:
    PRODUCTION ORDER
    AV DATE: 15/02/2008
    GR DATE: 13/02/2008
    But I expected to have:
    PRODUCTION ORDER
    AV DATE: 13/02/2008
    GR DATE: 11/02/2008
    Do you have an idea about what is wrong?
    Thanks in advance for your help on this subject.
    Regards,
    Rudy

    Hello.
    Thank you for your reply.
    But in fact, I am doing some tests on a test platform, which is using an "old" copy of production database.
    So, there can't be data already scheduled for the dates I am using.
    Moreover, I just tried now to do the same with dates in November 2008, exactly with the same results.
    In production platform, they experience this problem too.
    Summary of my new test:
    Before rescheduling:
    SALES ORDER:
    AV. DATE = 20/11/2008
    GR. DATE = 20/11/2008
    PROD. ORDER:
    AV. DATE = 20/11/2008
    GR. DATE = 18/11/2008
    After rescheduling of one week sooner:
    SALES ORDER:
    AV. DATE = 13/11/2008
    GR. DATE = 13/11/2008
    PROD. ORDER:
    AV. DATE = 15/11/2008  (ipo  13/11/2008)
    GR. DATE = 13/11/2008  (ipo  11/11/2008)
    I really don't understand why I don't have the same kind of dates as the ones I get before the rescheduling...
    In my mind, I expect to have all these dates set back of one week...
    Regards
    Rudy
    Rudy

  • Production order and planned order qty should not consider in MRP

    Dear All,
    i do not want to consider the previous month production order qty and plenned order qty (Nothing but WIP qty) in the current momth MRP, but the stock has to consider in MRP.
    Example,
    Before MRP,
    material : XYZ
    Stock : 1000
    Prod Qty : 500 for 02.04.2008
    PIR Qty : 2000 for 02.05.2008
    After MRP, the requirement should be as below said,
    material : XYZ
    Stock : 1000
    Prod Qty : 500 for 02.04.2008
    PIR Qty : 2000 for 02.05.2008
    Pld OrdQty : 1000 for 02.05.2008
    For the above requirement ,i have done settings in the availabilty check like , for include planned order and include production order are "DO NOT TAKE IN ACCOUNT".
    Even then also the planned order qty is generating for the "500" only.
    please give the solution for the above said requirement.
    thanx in advance
    Regards
    Srinivas

    hi
    MRP will always consider the prod order qty while doing nert req calculation.One thing u can do is TECo the prod orders and un MRP then it wont consider prod order qty.
    The Availability check will check whether the components r avalaible or not based on ur scope of check
    Reward points if useful
    Amit

  • Open planned orders and production orders

    Hi friends,
    I have one issue with my client.
    Client has 1 lac materials in sap .Now he wants extract all materials open planned orders and open production orders with quantity and dates.
    Please tell me the process how i can extract the data from sap for above requirement.
    Thanks,
    Manoj

    Hi Manoj,
    For open planned order and production order select the respective box.
    But one suggestion. Try to convince client that this report will take a lot of time as you have mentioned 1 lac materials are there.
    You can exclude system status and get it with below screen as mentioned already.
    But my suggestion is to run the report at night when the system load is very less. Please create a background job one for planned order and another for production order. Then run it in midnight as per the customer requirement in background. You can automate the process by sending automatic mail to customer. Please refer the below link to trigger mail.
    Mail Trigger with TEXT file via JOB run
    Regards,
    Krishnendu.

  • Difference between Configurable and varinant production order

    Hi All,
    1) What is difference between configurable material production order and variant  production order?
    2) What is difference between configurable material and variant material?

    Hi All,
    1) What is difference between configurable material production order and variant production order?
    Ans:
    the only difference i can see is the Account assighnment - the configurable material needs to have a sales order order or Customer independent requirment since the stock when gets produced has to be placed inanyone of the account assignment.Which in simple terms is a make to order producton order
    the Variant material production order can be a make to stock scenario also
    2) What is difference between configurable material and variant material?
    a.Configurable material - Inthis the characteristics can get any or specified values based on the requirement
    Ex: car - is configurable material
        colour is a charctertisc - red,white are the values
    b. Variant material - It will have ONLY one config material attached with it and the charatterstics would ahve the vallues prefixed
    ex: CAR_RED as a material - which means the colur of thecar is red -it is fixed
    does it clears your doubt are still require any more information..
    sap s very intresting part  is VC

  • Open PIR quantity, unconverted Pld orders and open Prod/ STO orders

    Dear all,
    How to deal with open PIR quantity, unconverted planned orders and open production/ STO orders in the next MRP run? Do we need to delete/ reduce them manually?
    Thanks and Regards,
    Raghu

    Hi Shiva,
    Thanks for your immediate response. I have still some confusion.
    Last month, I have material A with Production order quantity of 30000.
    'A' has a component 'B' which is an in-house produced material. Three planned orders each of 10000 were generated for B. Of these two planned orders were converted to production orders. One is still in planned order form.
    This month I am not going to use this planned order of B. I get new requirement for A. So during MRP run I get the planned orders for B also.
    For the last month requirement, as I have not converted one planned order of B to prod order, there will an open quantity of A prod order in this plant and open STO quantity in another plant. Again the PIR will also be not reduced to the same extent. If I reduce the PIR manually or through some reorganization, what about the open quantity of prod order and STO
    I think I can TECO the prod order of A. Is there any such thing for STO also?
    Thanks and Regards,
    Raghu

  • Sales Order Conversion to Production Order

    Dear All,
    I am from SD and have a doubt reg SD - PP ...
    If i have 3 sales orders and each sales order has 3 line items. Now i need to make a production order --- the production order to have 1 line item from each sales order so in all 3 production orders for the 3 sales orders and each production order has 3 line items and each line item is from diffrent sales orders i.e as above 3 sales orders.
    is it possible and how ?
    I am awaiting for a suitable solution ASAP...
    Thnks
    krishna

    Hi,
    In PP always 1 production order is for only 1 product ( if no co-product is added in BOM).
    In your scenario, If the PP settings & master data are maintained perfectly.
    System will create 9 production orders ( this may vary with respect to the lotsizing procedure used).
    Reward points if useful
    Thanks & regards
    Mahesh babu
    Edited by: Mahesh Babu MG on Jan 30, 2008 7:19 PM

  • Transfer Order number for Production order

    Hi,
    what is the best way to get the transfer order number (LTAK-TANUM) for picking for a production order?
    Picking can occur first in IM (via MB1A for example) or in WM (via LP10). Requirement Tracking Number cannot be used as it has only a length of 10 characters (production order number up to 12 characters).
    Reservation number (LTAK-RSNUM) is only filled in case picking is done from IM first.
    Cheers
    Mathias

    Hi,
    how are other companies handling this if they want to pick from the warehouse (e.g. using CO27) for a production order and the production order number has 12 characters? The bin (LTAP-VLPLA) and the requirement number (LTAK-BENUM) only have up to 10 characters.
    Is there a standard way in SAP to print out the complete 12 character number on the picking list? I could not find another field where the production order number appears.
    P.S. There are already some production order types in use that have a number range with 12 characters.
    Cheers
    Mathias

  • Planned order Vs Actual Production report

    Hi Experts
    We are running MRP make to stock means we maintain PIR(MD61) in system. On the basis of PIR system create planned order and we declare production against these planned orders. I need a report which show the detail of planned order and actual production declare against that planned order. Please guide.
    Regards
    Parkash Chand

    Dear Parkash,
    second possible soluction could be create a custom report using this standard Bapi BAPI_MATERIAL_STOCK_REQ_LIST in order to read MRP element and to summarize the elements desired   (DELKZ field):
    MRP Ele Ind   Object
    PP     Planned independent requirement
    FE     Production order
    Pa     Planned order
    Third possible soluction setting in customizing the writing of the MRP table MDKP for header data and MDTB for item data and create a Query on these mrp table.
    Let me know if i've been useful for you.
    Daniele

  • What is a cartesian product why we need it and where we need it

    Hi,
    One of my interview they asked this question
    Can any one please tell detail about it.
    Thanks
    Kalpana

    >
    what is a cartesian product
    >
    A cartesian join is when you do not specify any join condition between tables.
    So for two tables A and B the result is that every row of table B is appended to every row of table A.
    If there are 10 rows in Table A and 20 rows in Table b there will be 200 rows in the result set and each row will contain every column from table A and every column from table b unless you specify specific columns.
    See Cartesian Products in the SQL Language doc
    http://docs.oracle.com/cd/B28359_01/server.111/b28286/queries006.htm
    >
    Cartesian Products
    If two tables in a join query have no join condition, then Oracle Database returns their Cartesian product. Oracle combines each row of one table with each row of the other. A Cartesian product always generates many rows and is rarely useful. For example, the Cartesian product of two tables, each with 100 rows, has 10,000 rows. Always include a join condition unless you specifically need a Cartesian product. If a query joins three or more tables and you do not specify a join condition for a specific pair, then the optimizer may choose a join order that avoids producing an intermediate Cartesian product.
    >
    As for when? In earlier versions of Oracle I would use a cartesian join when creating report ready data tables and there needed to be data for every report period. One example is writing a Crystal Report (now business objects) to report sales for 2011 and you want the report to have a section for each month even if there was no data for that month.
    Then we would use a cartesian join on a date table that had 12 records (one for each month) with totals of zero. This would make sure that there was at lease one summary record for each month so that every month would show up on the report even if we only had data for March.

  • Report for open orders and amount of product confirmed

    Hi All,
    Can some one give me an idea on a report which shows open orders and also shows amount of product confirmed against these open orders?
    Thanks,
    Neelima.

    Hi Veni,
    Incomplete order are the order's in which some data is missing so that particular order can't be further processed, that is what you could check through "Incompletion Log". Whereas Open orders are the orders which are open for further processing viz. deliver billing(but open order is a complete order i.e. no data missing).
    Check this program:
    *& Report ZGM_OPENPO *
    REPORT ZGM_OPENPO NO STANDARD PAGE HEADING LINE-SIZE 132 LINE-COUNT 36(2).
    TABLES: t001w, "Plants/Branches
    ekko, "Purchasing Document Header
    ekpo, "Purchasing Document Item
    marc, "Plant Data for Material
    mara. "General Material Data
    DATA:
    BEGIN OF itab OCCURS 0,
    matnr LIKE marc-matnr,
    werks LIKE marc-werks,
    beskz LIKE marc-beskz,
    mmsta LIKE marc-mmsta,
    END OF itab.
    DATA: BEGIN OF iekpo OCCURS 0,
    ebeln LIKE ekpo-ebeln,
    menge LIKE ekpo-menge,
    aedat LIKE ekpo-aedat,
    wemng LIKE eket-wemng,
    END OF iekpo.
    DATA: BEGIN OF iekko OCCURS 0,
    ebeln LIKE ekko-ebeln,
    lifnr LIKE ekko-lifnr,
    bedat LIKE ekko-bedat,
    ekgrp LIKE ekko-ekgrp,
    END OF iekko.
    selection-screen:begin of block b1 with frame title text001.
    SELECT-OPTIONS werks FOR ekpo-werks OBLIGATORY.
    SELECT-OPTIONS matnr FOR ekpo-matnr.
    SELECT-OPTIONS beskz FOR marc-beskz.
    SELECT-OPTIONS bsart FOR ekko-bsart.
    selection-screen:end of block b1.
    INITIALIZATION.
    AT SELECTION-SCREEN ON werks. "Validate for werks
    SELECT SINGLE * FROM t001w WHERE werks IN werks.
    IF sy-subrc 0. MESSAGE e429(mo). ENDIF.
    AT SELECTION-SCREEN ON matnr.
    SELECT SINGLE * FROM mara WHERE matnr IN matnr.
    IF sy-subrc 0. MESSAGE e429(mo).ENDIF.
    START-OF-SELECTION.
    SELECT * FROM marc INTO CORRESPONDING FIELDS OF TABLE itab WHERE werks IN werks AND beskz IN beskz AND
    matnr IN matnr.
    SELECT ebeln FROM ekpo INTO CORRESPONDING FIELDS OF TABLE iekpo
    FOR ALL ENTRIES IN itab WHERE matnr = itab-matnr AND loekz EQ space.
    SELECT ebeln lifnr bedat ekgrp FROM ekko INTO CORRESPONDING FIELDS OF
    TABLE iekko
    FOR ALL ENTRIES IN iekpo WHERE ebeln = iekpo-ebeln AND bsart IN bsart.
    SELECT ebeln menge aedat FROM ekpo INTO CORRESPONDING FIELDS OF iekpo
    FOR ALL ENTRIES IN iekpo WHERE ebeln = iekpo-ebeln. MODIFY iekpo INDEX sy-dbcnt.
    ENDSELECT.
    SORT iekpo BY aedat.
    DELETE ADJACENT DUPLICATES FROM iekpo COMPARING ebeln.
    SELECT wemng FROM eket INTO CORRESPONDING FIELDS OF iekpo FOR ALL ENTRIES IN iekpo WHERE ebeln = iekpo-ebeln.
    MODIFY iekpo INDEX sy-dbcnt.
    ENDSELECT.
    END-OF-SELECTION.
    DATA : file_name TYPE string.
    file_name = 'c:\pay_det\open_po1.xls'.
    DATA : BEGIN OF it_join_fields OCCURS 0,
    field_name(20),
    END OF it_join_fields.
    CLEAR it_join_fields.
    it_join_fields-field_name = 'ebeln'.
    APPEND it_join_fields.
    CLEAR it_join_fields.
    it_join_fields-field_name = 'menge'.
    APPEND it_join_fields.
    CLEAR it_join_fields.
    it_join_fields-field_name = 'aedat'.
    APPEND it_join_fields.
    CLEAR it_join_fields.
    it_join_fields-field_name = 'wemng'.
    APPEND it_join_fields.
    CLEAR it_join_fields.
    CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
    BIN_FILESIZE =
    filename = file_name
    filetype = 'ASC'
    APPEND = 'X'
    write_field_separator = 'X'
    TABLES
    data_tab = iekpo
    FIELDNAMES = it_join_fields
    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 iekpo.
    IF iekpo-menge NE iekpo-wemng.
    WRITE:/4 iekpo-ebeln,21 iekpo-menge ,46 iekpo-aedat, 56 iekpo-wemng.
    ENDIF.
    ENDLOOP.
    if sy-subrc 0. write / 'no data exist for this plant'. endif.
    TOP-OF-PAGE.
    uline 1(80).
    WRITE :/ sy-vline, 20 ' OPEN purchase ORDERs report' color 5,
    80 sy-vline.
    uline 1(80).
    WRITE:/ sy-vline , 4 'PURSCHASE ORDER' COLOR COL_HEADING,
    20 sy-vline, 21 'ORDER QUANTITY' COLOR COL_HEADING,
    45 sy-vline, 46 'item change' color col_heading, 55 sy-vline,
    56 'RECIEVED QUANTITY' COLOR COL_HEADING, 80 sy-vline.
    uline 1(80).
    END-OF-PAGE.
    WRITE :/ 'PAGE NUMBER' ,SY-PAGNO.
    Hope this helps you.
    Regards,
    Chandra Sekhar

  • IDOC for Creation of Production order and also adding components

    Hi ,
    I have a requirement like I get the data from a 3rd party system and using that i have to create production orders and also should be able to add more materials in COMPONENTS part of that Production order. I was looking for a BAPI which can handle this process.
    And also can any one help me by letting me know is there any Message type available for handling this process of Production order creation and Adding extyra components to it.
    I have a  message type LOIPRO (for Production Order) and associated function modle CLOI_MASTERIDOC_CREATE_LOIPRO for creation of master IDoc, but not sure can i handle the Components part in this.
    Please do send replies ASAP, its very urgent.
    Or else atleast suggest me the other ways of doing this .
    Also send me any BDC program if anyone has already developed for this.
    Thanks
    Kumar
    Edited by: Phani Kumar Peddagopu on Mar 19, 2008 6:56 PM

    Resolved .

  • Production Order and Internal Order for each item of the sales order

    Hi
       I am developing Make To Order Report where I have to display the MTO Line Items and non MTO Line Items. For non MTO Line Items I have to display Internal order with Planned and Actual Costs and also Production Order with Planned and Actual Costs. Could anybody tell how to get the Internal order no and production order with Planned and Actual costs for each line item for a sales order.
    Thanks
    Naga

    Hi,
    You can get the Production orders, Planned orders, Internal orders generated for Sales order item from AFPO table (use fields KDAUF-Sales order number & KDPOS-Sales order item). Then to identify the order type use order category (AUTYP) from table AUFK.
    Once you have the Production/internal order, you can ge the cost from COSS and COSP table. Use the object number from AUFK to get the cost entries from COSS & COSP.
    You can use the following sample code as reference.
    Hope this is helps.. (Don't forget to mark it... )
    Form GET_COSTS                                                       *
    Get the material cost, labour hours and the labour cost for the      *
    sales order material.                                                *
    There are no interface parameters to be passed to this subroutine.   *
    FORM GET_COSTS.
      DATA V_OBJNR LIKE AUFK-OBJNR.
    DATA v_menge LIKE vbap-kwmeng.
      SELECT SINGLE OBJNR
        INTO V_OBJNR
        FROM AUFK
       WHERE AUFNR EQ AFPO-AUFNR.
      SELECT * FROM COSS
       WHERE OBJNR EQ V_OBJNR
         AND WRTTP IN ('01', '04'). " p_wrttp. "Labour Cost ( Plan, Actual)
        PERFORM GET_VALUES_FROM_COSS.
      ENDSELECT.
      SELECT * FROM COSP
       WHERE OBJNR EQ V_OBJNR
         AND WRTTP IN ('01', '04')         " p_wrttp
         AND KSTAR NE '0000510033'. " EQ p_kstar2.      "Material Cost
        PERFORM GET_VALUE_FROM_COSP.
      ENDSELECT.
    Get the unit cost of the production order by dividing the production
    cost by the order quantity. The result will be multiplied by the
    GL posting qunatity (Delivery quantity) to get the production cost
    for the quantity being deluivered.
      IF NOT AFPO-PSMNG IS INITIAL.
        OUT_REC-LABOUR_HOURS_ACT = OUT_REC-LABOUR_HOURS_ACT / AFPO-PSMNG.
        OUT_REC-ADDNL_LABOUR_HOURS_ACT =
                          OUT_REC-ADDNL_LABOUR_HOURS_ACT / AFPO-PSMNG.
        OUT_REC-LABOUR_HOURS_PLN = OUT_REC-LABOUR_HOURS_PLN / AFPO-PSMNG.
        OUT_REC-ADDNL_LABOUR_HOURS_PLN =
                         OUT_REC-ADDNL_LABOUR_HOURS_PLN / AFPO-PSMNG.
        OUT_REC-LABOUR_COST_ACT = OUT_REC-LABOUR_COST_ACT / AFPO-PSMNG.
        OUT_REC-ADDNL_LABOUR_COST_ACT =
                         OUT_REC-ADDNL_LABOUR_COST_ACT / AFPO-PSMNG.
        OUT_REC-LABOUR_COST_PLN = OUT_REC-LABOUR_COST_PLN / AFPO-PSMNG.
        OUT_REC-ADDNL_LABOUR_COST_PLN =
                         OUT_REC-ADDNL_LABOUR_COST_PLN / AFPO-PSMNG.
        OUT_REC-MATERIAL_COST_ACT = OUT_REC-MATERIAL_COST_ACT / AFPO-PSMNG.
        OUT_REC-ADDNL_MATERIAL_COST_ACT =
                         OUT_REC-ADDNL_MATERIAL_COST_ACT / AFPO-PSMNG.
        OUT_REC-MATERIAL_COST_PLN = OUT_REC-MATERIAL_COST_PLN / AFPO-PSMNG.
        OUT_REC-ADDNL_MATERIAL_COST_PLN =
                         OUT_REC-ADDNL_MATERIAL_COST_PLN / AFPO-PSMNG.
      ENDIF.
    Multiply the calculated Unit Production costs with the GL quantity to
    get the actual production cost of the quantity delivered.
    Calculation for Labour Hours
      OUT_REC-LABOUR_HOURS_ACT = OUT_REC-LABOUR_HOURS_ACT *
                                 OUT_REC-QUANTITY.
      OUT_REC-ADDNL_LABOUR_HOURS_ACT = OUT_REC-ADDNL_LABOUR_HOURS_ACT *
                                 OUT_REC-QUANTITY.
      OUT_REC-LABOUR_HOURS_PLN = OUT_REC-LABOUR_HOURS_PLN *
                                 OUT_REC-QUANTITY.
      OUT_REC-ADDNL_LABOUR_HOURS_PLN = OUT_REC-ADDNL_LABOUR_HOURS_PLN *
                                 OUT_REC-QUANTITY.
    Calculation for Material Cost
      OUT_REC-MATERIAL_COST_ACT = OUT_REC-MATERIAL_COST_ACT *
                                  OUT_REC-QUANTITY.
      OUT_REC-ADDNL_MATERIAL_COST_ACT =
          OUT_REC-ADDNL_MATERIAL_COST_ACT * OUT_REC-QUANTITY.
      OUT_REC-MATERIAL_COST_PLN = OUT_REC-MATERIAL_COST_PLN *
                                  OUT_REC-QUANTITY.
      OUT_REC-ADDNL_MATERIAL_COST_PLN =
          OUT_REC-ADDNL_MATERIAL_COST_PLN * OUT_REC-QUANTITY.
    Calculation for Labour cost
      OUT_REC-LABOUR_COST_ACT   = OUT_REC-LABOUR_COST_ACT *
                                   OUT_REC-QUANTITY.
      OUT_REC-ADDNL_LABOUR_COST_ACT = OUT_REC-ADDNL_LABOUR_COST_ACT *
                                  OUT_REC-QUANTITY.
      OUT_REC-LABOUR_COST_PLN   = OUT_REC-LABOUR_COST_PLN *
                                  OUT_REC-QUANTITY.
      OUT_REC-ADDNL_LABOUR_COST_PLN = OUT_REC-ADDNL_LABOUR_COST_PLN *
                                  OUT_REC-QUANTITY.
    Get the planned material cost from the total of the planned cost of
    the component materials in the production order confirmations.
      SELECT BWART MENGE MATNR SHKZG FROM AUFM
        INTO (AUFM-BWART, AUFM-MENGE, AUFM-MATNR, AUFM-SHKZG)
       WHERE AUFNR EQ AFPO-AUFNR.
        CHECK AUFM-BWART NE '101'.
        READ TABLE I_MBEW WITH KEY MATNR = AUFM-MATNR
                                   BWKEY = AFPO-DWERK.
        IF SY-SUBRC NE 0.
          SELECT MATNR BWKEY ZPLPR LPLPR PEINH
            FROM MBEW
            INTO I_MBEW
           WHERE MATNR EQ AUFM-MATNR
             AND BWKEY EQ AFPO-DWERK.
            APPEND I_MBEW.
          ENDSELECT.
        ENDIF.
        IF SY-SUBRC EQ 0.
          IF I_MBEW-ZPLPR NE 0.
            IF AUFM-SHKZG EQ 'H'.
              OUT_REC-PLANNED_MATERIAL_COST =
              OUT_REC-PLANNED_MATERIAL_COST +
                           ( I_MBEW-ZPLPR * AUFM-MENGE / I_MBEW-PEINH ).
            ELSE.
              OUT_REC-PLANNED_MATERIAL_COST =
              OUT_REC-PLANNED_MATERIAL_COST -
                           ( I_MBEW-ZPLPR * AUFM-MENGE / I_MBEW-PEINH ).
            ENDIF.
          ELSEIF I_MBEW-LPLPR NE 0.
            IF AUFM-SHKZG EQ 'H'.
              OUT_REC-CURRENT_MATERIAL_COST =
              OUT_REC-CURRENT_MATERIAL_COST +
                           ( I_MBEW-LPLPR * AUFM-MENGE / I_MBEW-PEINH ).
            ELSE.
              OUT_REC-CURRENT_MATERIAL_COST =
              OUT_REC-CURRENT_MATERIAL_COST -
                           ( I_MBEW-LPLPR * AUFM-MENGE / I_MBEW-PEINH ).
            ENDIF.
          ENDIF.
        ENDIF.
      ENDSELECT.
    Get the Future material cost per Unit by deviding the calculated
    Future material cost above with the goods reciept quantity to, then
    multiply the unit cost with the GL quantity to get the Future material
    Cost for the Quantity delivered. (Quantity in the entery from GLPCA
    Table).
      IF NOT AFPO-WEMNG IS INITIAL.
        OUT_REC-PLANNED_MATERIAL_COST =
           OUT_REC-PLANNED_MATERIAL_COST / AFPO-WEMNG * OUT_REC-QUANTITY.
        OUT_REC-CURRENT_MATERIAL_COST =
           OUT_REC-CURRENT_MATERIAL_COST / AFPO-WEMNG * OUT_REC-QUANTITY.
      ENDIF.
    ENDFORM.                               " GET_COSTS
    Form GET_VALUE_FROM_COSP                                             *
    Get the Material cost from COSP table.                               *
    There are no interface parameters to be passed to this subroutine.   *
    FORM GET_VALUE_FROM_COSP.
      FIELD-SYMBOLS: <FS> TYPE ANY.
      DATA: V_COMPONENT TYPE I.
    Cummulate the posting values of all the 16 period buckets as to get
    total production order cost. This is to handle the aprtial posting of
    prodction order values in diffrent periods.
      V_COMPONENT = 15.
      DO 16 TIMES.
        ADD 1 TO V_COMPONENT.
        ASSIGN COMPONENT V_COMPONENT OF STRUCTURE COSP TO <FS>.
        IF COSP-WRTTP EQ '04' AND COSP-KSTAR EQ P_KSTAR2.
          ADD <FS> TO OUT_REC-MATERIAL_COST_ACT.
        ELSEIF COSP-WRTTP EQ '04'.
          ADD <FS> TO OUT_REC-ADDNL_MATERIAL_COST_ACT.
        ELSEIF COSP-WRTTP EQ '01' AND COSP-KSTAR EQ P_KSTAR2.
          ADD <FS> TO OUT_REC-MATERIAL_COST_PLN.
        ELSEIF COSP-WRTTP EQ '01'.
          ADD <FS> TO OUT_REC-ADDNL_MATERIAL_COST_PLN.
        ENDIF.
      ENDDO.
    ENDFORM.                               " GET_VALUE_FROM_COSP
    Form GET_VALUES_FROM_COSS                                            *
    Get the Labour cost and Labour hours from the COSS table.            *
    There are no interface parameters to be passed to this subroutine.   *
    FORM GET_VALUES_FROM_COSS.
      FIELD-SYMBOLS: <FS1> TYPE ANY,
                     <FS2> TYPE ANY.
      DATA: V_COMPONENT1 TYPE I,
            V_COMPONENT2 TYPE I.
    Cummulate the posting values of all the 16 period buckets as to get
    total production order cost. This is to handle the aprtial posting of
    prodction order values in diffrent periods.
      V_COMPONENT1 = 15.
      V_COMPONENT2 = 111.
      DO 16 TIMES.
        ADD 1 TO: V_COMPONENT1, V_COMPONENT2.
        ASSIGN COMPONENT V_COMPONENT1 OF STRUCTURE COSS TO <FS1>.
        ASSIGN COMPONENT V_COMPONENT2 OF STRUCTURE COSS TO <FS2>.
        IF COSS-WRTTP EQ '04' AND COSS-KSTAR EQ P_KSTAR1.
          ADD <FS1> TO OUT_REC-LABOUR_COST_ACT.
          ADD <FS2> TO OUT_REC-LABOUR_HOURS_ACT.
        ELSEIF COSS-WRTTP EQ '04'.
          ADD <FS1> TO OUT_REC-ADDNL_LABOUR_COST_ACT.
          ADD <FS2> TO OUT_REC-ADDNL_LABOUR_HOURS_ACT.
        ELSEIF COSS-WRTTP EQ '01' AND COSS-KSTAR EQ P_KSTAR1.
          ADD <FS1> TO OUT_REC-LABOUR_COST_PLN.
          ADD <FS2> TO OUT_REC-LABOUR_HOURS_PLN.
        ELSEIF COSS-WRTTP EQ '01'.
          ADD <FS1> TO OUT_REC-ADDNL_LABOUR_COST_PLN.
          ADD <FS2> TO OUT_REC-ADDNL_LABOUR_HOURS_PLN.
        ENDIF.
      ENDDO.
    ENDFORM.                               " GET_VALUES_FROM_COSS

  • Open production orders and outbound delivery after go-live

    Hello All,
    I tried to search answer for this question but could not find answer.
    Could anybody suggest, what to do with open production orders and outbound delivery after go-live when WM is activated. As, after go-live WM-PP interface will be activated and system should consume material from storage bin specified in control cycle and that will happen for newly created production order after go-live,but what about existing production orders how to update production supply area against work center in production order.
    Similarly with outbound delivery how to update WM status after go-live.
    Thanks in advance

    Thanks to both Jurgen and Sander
    Regarding production order yes, one way is to re-read PP master data in production orders, but is that the only way to handle this or do we have any other option?
    I was aware of re-read PP master data but it will real time consuming and also if it will problematic for already released or partially confirmed production orders.

  • Pick List and Open Production Order

    Our WMS clerk confused about open Production Order and Pick up due list for the Production Order.We want to check the list of open production order and what are the materials due for picking up the open production order   Please suggest us the best way you are doing for your Production Order.
    Thanks

    Nick,
    Co27 will give only open orders and materials to be picked.
    Open production orders mean - orders which are not teco/closed/deleted.
    All the materials will appear in the list which have a status - FInal issue not ticked.
    You can slos use coois
    with list = components
    profile = picking profile.
    here we have more options.
    please come back if required.

Maybe you are looking for

  • How do I transfer from iphone 4 to 4s while still leaving gaming apps on the iphone 4?

    I would like to transfer all everything from my iphone 4 to a 4s while still leaving the gaming apps on the orginial iphone 4.  My plan is to tranfer my phone number to the iphone 4s so that my son can use the iphone 4 as a gaming device only.

  • AR Down Payment Invoice - Freight field needed

    Hi, I have various freight options defined in Admin>Setup>General>Freight. When I create an AR Invoice there is a Freight field in the General area near the Total field, here I can click the orange arrow and select the appropriate freight option from

  • Authorization and moving employes to another organizational assignment

    Hello! I have a big problem with authorization. Lately some employes have been moved from one organizational assignment to another organizational assignment. After moving I prepared the user and the role for this user he will be able to read infotype

  • Import Manager Issue

    Hi, I have a bunch of records which have similarities in the description field of the source file and I need to consolidate all such records and add a separate ID to all such records in a different field. Example data is like this. 1 Rajani Kumar 2 R

  • Huge mismatch between iPod 'available' space and iTunes 'free space'

    My iPod Nano reports (using the About menu): Capacity = 3.7 GB Available = 1.8 GB which feels about right (430 songs loaded). However, when plugged into iTunes for Windows 6.0.2, iTunes says about this iPod: Used = 3.64 GB Free = 95 MB and won't let