Query for Exploding all production orders needed to fulfil a sales order

I am trying to write a query that explodes all the multiple levels BOMS and brings back a list of production orders that would need to be raised to fulfil a particular sales order.
SELECT T0.[DocNum], T0.[CardCode], T0.[CardName], T1.[ItemCode], T1.[Dscription], T1.[Quantity], T2.[TreeType] FROM ORDR T0  INNER JOIN RDR1 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN OITM T2 ON T1.ItemCode = T2.ItemCode WHERE T0.[DocNum] = [%0] AND T2.[TreeType] = (N'P')
This is what i have at the moment, this only goes down one level, i cant think how i might drill down to lower levels. Any ideas?
Thanks

It will be a tough query to build.
Check this for just adding one level:
SELECT T0.DocNum, T0.CardCode, T0.CardName, T1.ItemCode, T1.Dscription, T1.Quantity
FROM ORDR T0
INNER JOIN RDR1 T1 ON T0.DocEntry = T1.DocEntry
WHERE T0.DocNum = [%0\] AND T1.ItemCode IN (SELECT Code From OITT)
UNION ALL
SELECT T0.DocNum, T0.CardCode, T0.CardName, T3.Code, T4.ItemName, T1.Quantity*T3.Quantity
FROM ORDR T0
INNER JOIN RDR1 T1 ON T0.DocEntry = T1.DocEntry
INNER JOIN OITT T2 ON T1.ItemCode = T2.Code
INNER JOIN ITT1 T3 ON T2.Code = T3.Father AND T3.Code IN (SELECT CODE FROM OITT)
INNER JOIN OITM T4 ON T3.Code = T4.ItemCode
WHERE T0.DocNum = [%0\]
Thanks,
Gordon

Similar Messages

  • Query for Alert on production order to be released

    Dear all users and experts,
    I need a query for getting an alert on production orders to be released (from planned status to release status) by whether reading the release date of production orders created from 'order recommendation window' or by reading the due date of production order and substract the lead time(days) of the item from its due date or by any means you know best.
    Thanks and best regards,
    Farhan Sufi

    Hi Gordon and Joseph,
    Thanks to both of you for giving me queries.
    Gordon, I made 3 production orders for testing from MRP order recommendation window from which 2 production orders has release date of today 9th July, 2010 (due date 12th July monday) and the 3rd one has release date of after weekend i.e. 12th July 2010 (due date is 13th July). release dates are calculated by MRP acording to the items' lead time and due date.
    Gordon, when I applied your query It gave me msg 'no data was found as a result of this selection criteria' Can you explain what your query will give me in result?
    where as Joseph, when I applied your query on alert, it gave me all 3 production orders as an alert to be released. I was expecting it will give me alert for 2 production order for today as their release date in MRP is today(9th July, 2010) and the alert for 3rd production order should come on 12th July and not today.
    what I understood your query is displaying all production orders which have status 'planned' regardless of their release date.is it?
    Joseph can you edit this query in such a way that It should consider the release date (calculated from due date and lead time in MRP order recommendation window) and display only those production orders which should be released today and exclude those which have release date in future. so that I can get alert for only those production orders which should be released today.
    I hope good response from both of you
    Thanks and best regards,
    Farhan

  • Query for getting Outtanding Production Order items

    Dear Experts,
    With a query, please advice how I can get a list of outstanding Production Order items?
    Much Thanks in Advance for your advice.
    Warmest Regards,
    Chinho

    Production Reports --->Open Item List --.> Production Orders

  • How to get all production orders for a workcenter

    Hello ...
    I have a requirement to create a report of all production orders for a given workcenter.  The user enters the workcenter (CRHD-ARBPL), plant (CRHD-WERKS) and a date range, and wants to see a list of orders (AUFNR) that fall within that date range along with some other data from AFKO and AFPO. 
    I can't figure out a good, consistent way to get from workcenter to production orders.
    Any ideas?
    Thanks!
    Sharon

    Hi there check this program for relation between SO PO and Production order
    REPORT z_so_info.
    TABLES: vbak, vbap, afko, afpo.
    *Field catalog
    TYPE-POOLS: slis.
    DATA: lv_repid TYPE sy-repid VALUE sy-repid,
    xfield TYPE slis_t_fieldcat_alv,
    afield TYPE slis_fieldcat_alv.
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 1(25) text-002.
    SELECT-OPTIONS: so_so FOR vbak-vbeln OBLIGATORY.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN END OF BLOCK b1.
    SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-003.
    PARAMETERS:
    p_kunnr LIKE vbak-kunnr, " sold-to
    p_kunwe LIKE vbak-kunnr. " ship-to
    SELECTION-SCREEN END OF BLOCK b2.
    *Constants
    CONSTANTS: c_zor TYPE vbak-auart VALUE 'ZOR',
    c_we TYPE vbpa-parvw VALUE 'WE',
    c_ag TYPE vbpa-parvw VALUE 'AG'.
    * c_space TYPE space.
    *Ranges
    RANGES: ra_parvw FOR vbpa-parvw,
    ra_kunnr FOR vbpa-kunnr.
    *Tables
    DATA: BEGIN OF gt_output OCCURS 0,
    vbeln LIKE vbak-vbeln, " sales order number
    posnr LIKE vbap-posnr, " SO item number
    matnr LIKE vbap-matnr, " material number
    sh LIKE vbpa-kunnr, " Ship-to
    sp LIKE vbpa-kunnr, " Sold-to
    lifnr LIKE ekko-lifnr, " Vendor
    bstnk LIKE vbak-bstnk, " PO number
    banfn LIKE vbep-banfn, " Purchase requi
    po_st TYPE char30, " PO status text
    pstyv TYPE vbap-pstyv, " Item catagory
    aufnr LIKE afpo-aufnr, " Production Order
    prd_stat TYPE string, " Prd order status
    END OF gt_output.
    DATA: wa_output LIKE gt_output.
    FIELD-SYMBOLS: <fs_output> LIKE gt_output.
    *Table for sales order and PO
    TYPES : BEGIN OF gs_data,
    vbeln TYPE vbak-vbeln,
    posnr TYPE vbap-posnr,
    pstyv TYPE vbap-pstyv,
    matnr TYPE vbap-matnr,
    END OF gs_data.
    DATA: gt_data TYPE STANDARD TABLE OF gs_data,
    wa_data TYPE gs_data.
    *Table for Production Orders
    TYPES: BEGIN OF gs_prd,
    aufnr TYPE afpo-aufnr,
    posnr TYPE afpo-posnr,
    kdauf TYPE afpo-kdauf,
    kdpos TYPE afpo-kdpos,
    wepos TYPE afpo-wepos, "Goods Receipt Indicator
    elikz TYPE afpo-elikz, "Delivery Completed Indicator
    objnr TYPE aufk-objnr, "Object number
    * getri TYPE afko-getri, "Confirmed Order Finish Date
    * gltri TYPE afko-gltri, "Actual finish date
    END OF gs_prd.
    DATA: gt_prd TYPE STANDARD TABLE OF gs_prd,
    wa_prd TYPE gs_prd.
    *Table for partner data
    TYPES: BEGIN OF gs_partner,
    vbeln TYPE vbak-vbeln,
    posnr TYPE vbap-posnr,
    parvw TYPE vbpa-parvw,
    kunnr TYPE vbpa-kunnr,
    END OF gs_partner.
    DATA: gt_partner TYPE STANDARD TABLE OF gs_partner,
    wa_partner TYPE gs_partner.
    TYPES: BEGIN OF gs_po,
    ebeln TYPE ekkn-ebeln,
    ebelp TYPE ekkn-ebelp,
    vbeln TYPE ekkn-vbeln,
    vbelp TYPE ekkn-vbelp,
    END OF gs_po.
    DATA: gt_po TYPE STANDARD TABLE OF gs_po,
    wa_po TYPE gs_po.
    TYPES: BEGIN OF gs_preq,
    vbeln TYPE vbep-vbeln,
    posnr TYPE vbep-posnr,
    banfn TYPE vbep-banfn,
    END OF gs_preq.
    DATA: gt_preq TYPE STANDARD TABLE OF gs_preq,
    wa_preq TYPE gs_preq.
    TYPES: BEGIN OF gs_po_stat,
    ebeln TYPE ekko-ebeln,
    procstat TYPE ekko-procstat,
    lifnr TYPE ekko-lifnr,
    END OF gs_po_stat.
    DATA: gt_po_stat TYPE STANDARD TABLE OF gs_po_stat,
    wa_po_stat TYPE gs_po_stat.
    *Field symbols
    FIELD-SYMBOLS: <fs> TYPE tj02t-txt04,
    <fs_temp> TYPE tj02t-txt04,
    <fs_stat> TYPE char30.
    START-OF-SELECTION.
    PERFORM fr_build_range.
    PERFORM fr_get_data.
    PERFORM fr_build_fc.
    PERFORM fr_output.
    *& Form fr_get_data
    * text
    * --> p1 text
    * <-- p2 text
    FORM fr_get_data.
    *Get SO
    SELECT a~vbeln a~posnr a~pstyv a~matnr
    FROM vbap AS a
    JOIN vbak AS b
    ON a~vbeln = b~vbeln
    JOIN vbpa AS c
    ON b~vbeln = c~vbeln
    INTO TABLE gt_data
    WHERE b~vbeln IN so_so
    AND b~auart EQ c_zor "Only Sales Orders
    AND c~kunnr IN ra_kunnr. "from selection screen
    DELETE ADJACENT DUPLICATES FROM gt_data COMPARING vbeln posnr.
    *get data of the production order
    IF NOT gt_data[] IS INITIAL.
    SELECT a~aufnr a~posnr a~kdauf a~kdpos a~wepos a~elikz
    b~objnr
    FROM afpo AS a
    JOIN aufk AS b
    ON a~aufnr = b~aufnr
    INTO TABLE gt_prd
    FOR ALL ENTRIES IN gt_data
    WHERE a~kdauf EQ gt_data-vbeln
    AND a~kdpos EQ gt_data-posnr.
    ENDIF.
    *Get partner data
    IF NOT gt_data[] IS INITIAL.
    SELECT vbeln posnr parvw kunnr
    FROM vbpa
    INTO TABLE gt_partner
    FOR ALL ENTRIES IN gt_data
    WHERE vbeln EQ gt_data-vbeln.
    ENDIF.
    *Get Purchase Order
    IF NOT gt_data[] IS INITIAL.
    SELECT ebeln ebelp vbeln vbelp
    FROM ekkn
    INTO TABLE gt_po
    FOR ALL ENTRIES IN gt_data
    WHERE vbeln EQ gt_data-vbeln
    AND vbelp EQ gt_data-posnr.
    SELECT vbeln posnr banfn
    FROM vbep
    INTO TABLE gt_preq
    FOR ALL ENTRIES IN gt_data
    WHERE vbeln EQ gt_data-vbeln
    AND posnr EQ gt_data-posnr.
    ENDIF.
    IF NOT gt_po[] IS INITIAL.
    SELECT a~ebeln a~procstat a~lifnr
    FROM ekko AS a
    JOIN ekpo AS b
    ON a~ebeln = b~ebeln
    INTO TABLE gt_po_stat
    FOR ALL ENTRIES IN gt_po
    WHERE b~ebeln EQ gt_po-ebeln
    AND b~ebelp EQ gt_po-ebelp.
    ENDIF.
    *Move data to output table
    LOOP AT gt_data INTO wa_data.
    wa_output-vbeln = wa_data-vbeln.
    wa_output-posnr = wa_data-posnr.
    wa_output-pstyv = wa_data-pstyv.
    wa_output-matnr = wa_data-matnr.
    READ TABLE gt_po INTO wa_po WITH KEY vbeln = wa_data-vbeln
    vbelp = wa_data-posnr.
    IF sy-subrc EQ 0.
    wa_output-bstnk = wa_po-ebeln.
    READ TABLE gt_po_stat INTO wa_po_stat WITH KEY ebeln = wa_po-ebeln.
    IF sy-subrc EQ 0.
    wa_output-lifnr = wa_po_stat-lifnr.
    CASE wa_po_stat-procstat.
    WHEN '01'.
    wa_output-po_st = 'Version in process'.
    WHEN '02'.
    wa_output-po_st = 'Active'.
    WHEN '03'.
    wa_output-po_st = 'In release'.
    WHEN '04'.
    wa_output-po_st = 'Partially released'.
    WHEN '05'.
    wa_output-po_st = 'Released Completely'.
    WHEN '08'.
    wa_output-po_st = 'Rejected'.
    ENDCASE.
    ENDIF. "inner read subrc
    ENDIF. "outer read subrc
    READ TABLE gt_preq INTO wa_preq WITH KEY vbeln = wa_data-vbeln
    posnr = wa_data-posnr.
    IF sy-subrc EQ 0.
    wa_output-banfn = wa_preq-banfn.
    ENDIF.
    READ TABLE gt_prd INTO wa_prd WITH KEY kdauf = wa_data-vbeln
    kdpos = wa_data-posnr.
    IF sy-subrc EQ 0.
    wa_output-aufnr = wa_prd-aufnr.
    *get the purchase requisition for production order as well
    SELECT SINGLE banfn
    FROM ebkn
    INTO wa_output-banfn
    WHERE aufnr EQ wa_prd-aufnr.
    *Get the status of the production order
    PERFORM fr_get_prd_stat USING wa_prd-objnr
    CHANGING wa_output-prd_stat.
    ENDIF. " sy-subrc
    READ TABLE gt_partner INTO wa_partner WITH KEY vbeln = wa_data-vbeln
    parvw = c_we.
    IF sy-subrc EQ 0.
    wa_output-sh = wa_partner-kunnr.
    ENDIF.
    READ TABLE gt_partner INTO wa_partner WITH KEY vbeln = wa_data-vbeln
    parvw = c_ag.
    IF sy-subrc EQ 0.
    wa_output-sp = wa_partner-kunnr.
    ENDIF.
    APPEND wa_output TO gt_output.
    CLEAR: wa_data, wa_prd,wa_partner,wa_output.
    ENDLOOP.
    ENDFORM. " fr_get_data
    *& Form fr_build_range
    * text
    * --> p1 text
    * <-- p2 text
    FORM fr_build_range .
    *Range for partner function
    MOVE 'I' TO ra_parvw-sign.
    MOVE 'EQ' TO ra_parvw-option.
    MOVE 'SH' TO ra_parvw-low. " we
    APPEND ra_parvw.
    CLEAR ra_parvw.
    MOVE 'I' TO ra_parvw-sign.
    MOVE 'EQ' TO ra_parvw-option.
    MOVE 'SP' TO ra_parvw-low. " ag
    APPEND ra_parvw.
    CLEAR ra_parvw.
    *Range for ship-to and sold-to
    MOVE 'I' TO ra_kunnr-sign.
    MOVE 'EQ' TO ra_kunnr-option.
    MOVE p_kunnr TO ra_kunnr-low.
    APPEND ra_kunnr.
    CLEAR ra_kunnr.
    MOVE 'I' TO ra_kunnr-sign.
    MOVE 'EQ' TO ra_kunnr-option.
    MOVE p_kunwe TO ra_kunnr-low.
    APPEND ra_kunnr.
    CLEAR ra_kunnr.
    ENDFORM. " fr_build_range
    *& Form fr_build_fc
    * text
    * --> p1 text
    * <-- p2 text
    FORM fr_build_fc .
    * sales order number
    afield-fieldname = 'VBELN'.
    afield-seltext_s = 'Sales #'.
    afield-ref_tabname = 'VBAK'.
    APPEND afield TO xfield. CLEAR afield.
    * sales ITEM number
    afield-fieldname = 'POSNR'.
    afield-seltext_s = 'Item #'.
    afield-ref_tabname = 'VBAP'.
    APPEND afield TO xfield. CLEAR afield.
    * Material Number
    afield-fieldname = 'MATNR'.
    afield-seltext_s = 'Material #'.
    afield-ref_tabname = 'VBAP'.
    afield-outputlen = 10.
    APPEND afield TO xfield. CLEAR afield.
    *Vendor Number
    afield-fieldname = 'LIFNR'.
    afield-seltext_s = 'Vendor Num.'.
    afield-ref_tabname = 'EKKO'.
    APPEND afield TO xfield. CLEAR afield.
    * ship-to-party
    afield-fieldname = 'SH'.
    afield-seltext_s = 'Ship-to'.
    afield-ref_tabname = 'VBPA'.
    APPEND afield TO xfield. CLEAR afield.
    * sold-to-party
    afield-fieldname = 'SP'.
    afield-seltext_s = 'Sold-to'.
    afield-ref_tabname = 'VBPA'.
    APPEND afield TO xfield. CLEAR afield.
    *PO number
    afield-fieldname = 'BSTNK'.
    afield-seltext_s = 'PO NUM'.
    afield-ref_tabname = 'EKKO'.
    APPEND afield TO xfield. CLEAR afield.
    *PO status
    * afield-fieldname = 'PO_STAT'.
    * afield-seltext_s = 'Step'.
    * afield-ref_tabname = 'zbacklog_v2'.
    * APPEND afield TO xfield. CLEAR afield.
    *PO step status
    afield-fieldname = 'PO_ST'.
    afield-seltext_s = 'PO.Status'.
    afield-ref_tabname = 'zbacklog_v2'.
    APPEND afield TO xfield. CLEAR afield.
    *Purchase requisition
    afield-fieldname = 'BANFN'.
    afield-seltext_s = 'Pur. Req.'.
    afield-ref_tabname = 'VBEP'.
    APPEND afield TO xfield. CLEAR afield.
    *Item catagory
    afield-fieldname = 'PSTYV'.
    afield-seltext_s = 'Itm. Catg'.
    afield-ref_tabname = 'VBAP'.
    APPEND afield TO xfield. CLEAR afield.
    *Prodcution Order number
    afield-fieldname = 'AUFNR'.
    afield-seltext_m = 'Prod.Order'.
    afield-ref_tabname = 'AFKO'.
    APPEND afield TO xfield. CLEAR afield.
    *PRODCUTION status
    afield-fieldname = 'PRD_STAT'.
    afield-seltext_s = 'Prd. Step'.
    afield-ref_tabname = 'zbacklog_v2'.
    afield-outputlen = 20.
    APPEND afield TO xfield. CLEAR afield.
    *PRODUCTION step status
    * afield-fieldname = 'PRD_ST'.
    * afield-seltext_s = 'Prd. Status'.
    * afield-ref_tabname = 'zbacklog_v2'.
    * APPEND afield TO xfield. CLEAR afield.
    ENDFORM. " fr_build_fc
    *& Form fr_output
    * text
    * --> p1 text
    * <-- p2 text
    FORM fr_output .
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
    i_callback_program = sy-repid
    * I_CALLBACK_PF_STATUS_SET = ' '
    * I_CALLBACK_USER_COMMAND = ' '
    * I_STRUCTURE_NAME =
    * IS_LAYOUT =
    it_fieldcat = xfield[]
    i_default = 'X'
    i_save = 'A'
    TABLES
    t_outtab = gt_output
    EXCEPTIONS
    program_error = 1
    OTHERS = 2.
    ENDFORM. " fr_output
    *& Form fr_get_prd_stat
    * text
    * -->P_WA_PRD_OBJNR text
    FORM fr_get_prd_stat USING p_objnr CHANGING p_prd_stat.
    DATA: lt_status TYPE STANDARD TABLE OF jstat,
    wa_status TYPE jstat,
    lv_status TYPE tj02t-txt04,
    lv_temp2 TYPE char5,
    lv_buff TYPE string.
    CALL FUNCTION 'STATUS_READ'
    EXPORTING
    client = sy-mandt
    objnr = p_objnr
    only_active = 'X'
    TABLES
    status = lt_status
    EXCEPTIONS
    object_not_found = 1
    OTHERS = 2.
    LOOP AT lt_status INTO wa_status.
    IF wa_status-stat(1) EQ 'I'.
    SELECT txt04 FROM tj02t
    INTO lv_status
    WHERE istat EQ wa_status-stat
    AND spras EQ 'E'.
    ENDSELECT.
    lv_temp2 = lv_status.
    CONCATENATE lv_temp2 p_prd_stat INTO p_prd_stat
    SEPARATED BY ','.
    ENDIF.
    CLEAR: wa_status, lv_status, lv_temp2.
    ENDLOOP.
    lv_buff = p_prd_stat.
    *Status of Production Order
    IF lv_buff CS 'CRTD'.
    p_prd_stat = 'Not Active'.
    ENDIF.
    IF lv_buff CS 'REL'.
    IF lv_buff CS 'GMPS'.
    p_prd_stat = 'Printed In Prod'.
    ELSE.
    p_prd_stat = 'Printed'.
    ENDIF.
    ENDIF.
    IF lv_buff CS 'TECO'.
    p_prd_stat = 'Technically Compt.'.
    ENDIF.
    ENDFORM. " fr_get_prd_stat

  • Phantom Assembly not exploding in production order

    Hi All,
    We are using phantom assembly as a BOM component.
    When we create a planed order from MD03 or MD02 and try to convert this planed order to production order the components of Phantom assembly are not explode in production order. When I tried with read PP master data option it get explode.
    Can you please let me know the reason?
    Thanks,
    SAP PQ

    Dear ,
    Couple of points on this issue which may help you understand the problem  : Bom Explosion With Phantom Assemblies will happen based on the following set up .
    1. You need to maintain the special procurement key-50 for the phantom Assembly
    in the MRP 2 View of the material master
    2. We can override the Phantom Assembly Setting by defining in SPRO --->
    Define Explosion Types so that MRP Creates Procurement Propasals for the
    Phantom Assembly itself.ie We can Swith off the Phantom Assembly Settings.
    This settting need to be defined in the BOM Item details screen in the Basic
    Data Tab Page under MRP Area.
    So check in your Bom whether switch off phantom assembly is defined.Make the Explosion Type-Blank
    3.Run MRP Single Item - Multi level - Transaction MD02 with Planning Mode 2 : 'Re-explode BOM and Routing'. The Phantom Item will now get exploded correctly in the Planned Order.
    4.Check the Validity of the BOM  and planning date
    5.Check the MRP4 set up in FG where you have kept the BOM/Routing selection
    6.Check wether dependent requirement  material master -MRP4 view -MRP  for Depent Requ should be blank .
    Check the above points and come back
    Regards
    JH
    Edited by: Jiaul Haque on Jun 14, 2010 2:15 PM
    Edited by: Jiaul Haque on Jun 14, 2010 2:18 PM

  • FM for creation of production order creation

    Hi All,
    Can anyone tell me the BAPI for the production order creation.
    BAPI for creation of production order through CO01 transaction code.
    Thanks in advance
    Ramesh.

    Hi,
    Please check this FM CO_ZF_PRODUCTIONORDER_CREATE.
    Regards,
    Ferry Lianto

  • Committed Date For Components in Production Order

    Dear All,
    I m facing this,  Committed Date For Components in Production Order,
    the date appeared as 31.12.9999,
    How can i make this correct.
    please tell me..
    Thanks
    Raghu

    Hi, Thnkx,
    You Are correct, I got this while doing Availability Check, 2 dates.
    Requirement Date, and Committed Date.
    I tried your solution,
    I change the Quantity of one of my BOM , I tried to change the Quantity by Change Number,
    So in CS 03 I can see the Validity of that component up to 01-09-2010,
    I run MRP agian, new planned Order, tried to convert, the question is same.
    I still get the date as 31-12-9999.
    Thanks
    Regards
    Raghu

  • Performance Issue, Unable to pull all production Orders in given statuses

    HI All,
    I have a requirement to pull all production orders that are in the created or released status and then action some different things in the program such as adjusting dates, etc. The issue I'm having is that as the volume of production orders grows the select statement stops being able to complete and pull these production orders. I've tweaked this before and it was able to work for a few weeks but has now reached it's limit again. I tried using the trace and SE30 to analyze the program as I've read suggested here, however it's been difficult to try adjustments as the program runs in about 3 second in the development environment. Our quality environment, which has roughly half the volume of the production system ran in about 15 seconds. So I am unable to duplicate the issue until the program is moved to production.
    Here is the select statement:
      SELECT k~aufnr
        FROM aufk as k INNER JOIN afko as f ON f~aufnr = k~aufnr
          INNER JOIN jest as j ON k~objnr = j~objnr
        INTO CORRESPONDING FIELDS OF TABLE it_aufk
        WHERE k~aufnr IN s_aufnr     "Order Number select option
          AND k~werks IN s_werks             "Plant select option
          AND k~auart EQ u2018PP01u2019              "PP01 std orders only
          AND k~kokrs EQ u20181000u2019              "Seneca Controlling Area
          AND k~autyp EQ u201810u2019                "PP Production Order
          AND k~loekz EQ space                 "Deletion indicator
          AND ( j~stat EQ u2018I001u2019             "CTRD, created status
            OR  j~stat EQ u2018I002u2019 )           "REL, released status
          AND j~inact EQ space.              "status not inactive
    There are a couple thoughts I have to try, but I don't know of any good way to verify if helping given the volume differences until in production so am looking for feedback. Here's the ideas:
    1. Use the field IDAT2 in AUFK to determine if an order is not TECO'd , rather than using the JEST table. Testing this in Dev had increased run time versus how I have it written now, but may be helpful with larger volume and/or if an index is put on this field. Thoughts?
    2. Separate the select statements to read AUFK and JEST separately and instead use the FOR ALL ENTRIES command. Seems to be a lot of conflicting thoughts on which works better, thoughts on this particular case?
    Also, there is another program that pulls only production orders in Created status, and it doesn't have this same issue.
    Thanks in advance for any help,
    Kyndal
    Edited by: Kyndal Copley on Oct 1, 2009 6:46 PM

    I have three recommendations for your join.
    1) Assuming that fields AUART and KOKRS are always known (constants) I recommend that you move them up in the where clause (like illustrated) to ensure that the system uses index C.
    2) AUTYP EQ '10' seems superflous. In addition it seems to increase the search time. Check with your functional consultant if there could be a production order with AUART EQ 'PP01' and AUTYP NE '10'. If you will never encounter this situation it makes more sense to drop the clause AUTYP EQ '10'.
    3) INTO CORRESPONDING FIELDS OF TABLE usually takes longer than INTO TABLE. Define the table with AUFK with just field AUFNR so that you can use the clause INTO TABLE.
    SELECT k~aufnr
      FROM       aufk AS k
      INNER JOIN afko AS f
      ON f~aufnr EQ k~aufnr
      INNER JOIN jest AS j
      ON k~objnr EQ j~objnr
      INTO TABLE it_aufk
      WHERE k~auart EQ 'PP01'
      AND   k~kokrs EQ '1000'
      AND   k~aufnr IN s_aufnr
      AND   k~werks IN s_werks
      AND   k~loekz EQ space
      AND ( j~stat  EQ 'I001' OR j~stat EQ 'I002' )
      AND   j~inact EQ space.

  • We want the Engg BOM ( usage 2 ) to be exploded in Production Order.

    Hi Gurus,
    We want the Engg BOM ( usage 2 ) to be exploded in Production Order.
    Please let us how this could be done.
    Regards,
    Ram

    Dear Ram,
    1.Check what selection ID is maintained in OPPQ for the plant for BOM selection.
    2.For this selection ID set the first priority to Engg BOM for BOM usage - 2 in OS31.
    Check with this and revert back.
    Regards
    Mangalraj.S

  • Query for getting all function and procedure inside the packages

    hi All
    Please provide me Query for getting all function and procedure inside the packages
    thanks

    As Todd said, you can use user_arguments data dictionary or you can join user_objects and user_procedures like below to get the name of the packaged function and procedure names.
    If you are looking for the packaged procedures and functions source then use user_source data dictionary
    select a.object_name,a.procedure_name from user_procedures a,
                  user_objects b
    where a.object_name is not null
    and a.procedure_name is not null
    and b.object_type='PACKAGE'        
    and a.object_name=b.object_name

  • BAPI/FM for Confirmation of Production order at operation level

    Hi ABAPers,
    I am using the 'BAPI_PRODORDCONF_CREATE_ACT'for Confirmation of Production order at operation level.
    I am able to pass the Production order number and Active Operation get the confirmation done.
    But the Confirmed Qty is not being updating in AFKO table.
    The 'BAPI_PRODORDCONF_CREATE_HDR' cannot be used for Confirmation of Production order at operation level as there is no Operation/Activity(Vornr) field in the input table. Hence using this bapi confirmation of Prod order can be only at Order level.
    Can someone know any FM/BAPI which can be used for the Confirmation of Production order at operation level(not order level).
    Thanks in Advance
    Ramesh Babu Cikka

    Hi Ramesh,
    Please use FUNCTION 'BAPI_PRODORDCONF_CREATE_TT'.
    This will work as like as T/Code "CO11".
    I hope this will help you.
    Example :
      CALL FUNCTION 'BAPI_PRODORDCONF_CREATE_TT'
        EXPORTING
          POST_WRONG_ENTRIES = '0'
          TESTRUN            = ' '
        IMPORTING
          RETURN             = ZRETURN
        TABLES
          TIMETICKETS        = ZBAPI_PP_TIMETICKET
          DETAIL_RETURN      = ZBAPI_CORU_RETURN.
      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
        EXPORTING
          WAIT = 'W'.
    Lanka

  • Worklfow for GR of Production order.

    HI .... is there any standard worflow template for GR of production order using MB31.
    Thanks in advance.

    Hi ,
    Please check this SAP provide WF: WS20000387.
    You can copy and make changes as per your requirement.
    Thanks and Regards,
    Swaminathan

  • Need to change Storage location for reservations in production order

    During Production order creation we need to assign storage location against all the reservations in production order. Is there a way it can be done??

    Hi,
          check the user exit EXIT_SAPLCOSD_001.
    Sudheer.A

  • SQL Query for members of dynamic group - Need to include Name, Path and Type

    Hello,
    I built a custom dynamic group that has all my SQL databases in it using SCOM 2012 SP1.  The group works fine as I can see the Name(ie, Database name), Health State, Path (ie, hostname/instance) and Types (ie; SQL 2005).  Now I'm trying to
    build a custom report based off this same information using a SQL query.   I'm no DBA and could use some help.  So far this is what i have
    use
    select
    SourceObjectDisplayName as
    'Group Name',
    TargetObjectDisplayName,TargetObjectPath
    from RelationshipGenericView
    where isDeleted=0
    AND SourceObjectDisplayName
    like
    'SQL_Databases_All'
    ORDERBY TargetObjectDisplayName
    This gets me the Group Name (which i really don't care about), database name, and hostname/instance. What I am missing is the Health State and most importantly the Type (ie, SQL Server 2005 DB, SQL Server 2008DB).
    If someone could assist me here I would appreciate it. I believe I need to do some type of INNER JOIN but have no idea where the SQL type info lives or the proper structure to use. Thanks
    OperationsManager

    Here's the updated Query for OpsMan 2012 R2:
    To find all members of a given group (change the group name below):
    select SourceObjectDisplayName as 'Group Name', TargetObjectDisplayName as 'Group Members' 
    from RelationshipGenericView 
    where isDeleted=0 
    AND SourceObjectDisplayName = 'Agent Managed Computer
    Group' 
    ORDER BY TargetObjectDisplayName

  • Tolerance limit for GI against production order

    HI
    Is there any standard functionality of having tolerance limits at Goods issue level - against the production order?
    Just like GR.
    or can we make this functionality using any Exits?
    -ashok

    Dear,
    Rstriction of excess goods issue against production order is not possible in standard setting.
    For achiving this you have to go for User exit.
    The logic should be
    In MIGO check mvt. type 261
    Pass the order through table RESB and select all the components with quantity.
    Capture the header material of order and use this as input along with the order creation date, plant and BOM application to explode function module CS_BOM_EXPLOSION.
    This will give you the BOM components which were valid at the time of order creation.
    Now compare these BOM components with the components from RESB with quantity.
    Here conditions will come in picture
    If quantity is exactly matching then GI will be possible
    or if you want to keep tolerance limit say for 10% then accordingly you can map the condition.
    Regards,
    R.Brahmankar

Maybe you are looking for

  • Can't Consolidate Referenced Files

    When I turn on iCloud Photo Sharing, Photos tells me that referenced files can't be uploaded and that I should consolidate them. I created a smart folder to identify the referenced files but when I try to consolidate, Photos says it can't find the fi

  • What happen no volume could be found

    install osb on t4-2(solaris) and sl150 2013/09/04.12:23:51 ______________________________________________________________________ 2013/09/04.12:23:51 2013/09/04.12:23:51         Transcript for job admin/1.1 running on t4-2 2013/09/04.12:23:51 2013/09

  • Adding a second optical drive

    Hi, I've have just added a second optical drive to my MP, it's an LG, "HL-DT-ST DVDRAM GSA-4120B" according to system profiler. I'v left the original apple superdrive as-is, and put this in the second bay. I'm pretty sure I've set it's jumpers to "sl

  • Optiarc  DVD RW AD-5630A problem

    I have a problem with my iMac. It reads dvds just fine but it doesn't read any cds. I've tried to use different brands of blank cds and also I tried to put in several audio cds, it doesn't read them. There's a sound like it is starting reading it, th

  • Dropped ipod in water a few weeks ago

    when i dropped it in water i stucked out the water and dried it out right away. but now it's starting to click on random apps, typing in random words and trying to send emails without me even touching it. i was wondering if anyone else has had the sa