Organization_id and program_update_date in RCV_SHIPMENT_HEADERS

Hello,
I have a custom program that relies on RCV_SHIPMENT_HEADERS.ORGANIZATION_ID column.
However recently there has been one receipt that does not have this column populated, along with the columns request_id, program_application_id, program_id and program_update_date, which are also null.
This has caused my program to fail, and it's the first time this has happened (for this reason!).
Does anyone know how these columns are populated, in order for me to track down the reason for the missing data?
Many thanks,
Hazel

I logged an SR for this in the end, and was directed to the following notes:
Note.745885.1 - ORGANIZATION_ID Not Consistently Populated in RCV_SHIPMENT_HEADERS For PO Receipts
Note.291187.1 - ORGANIZATION_ID is missing from RCV_SHIPMENT_HEADERS table
(They are archived so do not necessarily appear when you search for them - you have to make sure you are searching the archive too.)
Thanks
Hazel

Similar Messages

  • ORGANIZATION_ID column in RCV_SHIPMENT_HEADER  table

    Hi,
    When we create receipts, for some receipt wth RECEIPT_SOURCE_CODE is VENDOR. system is populating the ORGANIZATION_ID column in RCV_SHIPMENT_HEADER table but most of the time this column value is NULL.
    I understand that if the RECEIPT_SOURCE_CODE is INTERNAL ORDER it will populate the ORGANIZATION_ID column in RCV_SHIPMENT_HEADER table. but system is populating ORGANIZATION_DI column even for RECEIPT_SOURCE_CODE is VENDOR.
    Can any one explain me the scenario wheN system will populate the ORGANIZATION_ID in RCV_SHIPMENT_HEADER table..?
    Note : I am working in Oracle APPS 11i.
    Thanks,
    Sreekanth.

    I logged an SR for this in the end, and was directed to the following notes:
    Note.745885.1 - ORGANIZATION_ID Not Consistently Populated in RCV_SHIPMENT_HEADERS For PO Receipts
    Note.291187.1 - ORGANIZATION_ID is missing from RCV_SHIPMENT_HEADERS table
    (They are archived so do not necessarily appear when you search for them - you have to make sure you are searching the archive too.)
    Thanks
    Hazel

  • Interesting Performance problem..Query runs fast in TOAD and Reports 6i..

    Hi All,
    I have a query which runs with in 4 mins in Toad and also report 6i. But when ran through applications takes 3 to 4 hrs to complete normal.This report fetches huge amount of data will that be the reason for poor performance?? I am unable to figure that out. I was able to avoid full table scan on the tables used. But still have the problem.
    Any suggestions please.
    Thank you in advance.
    Prathima

    If you want to have a look at the query. This report gives a way to monitor the receipts entered for pay from receipt POs.
    SELECT
    hou.name "OPERATING_UNIT_NAME"
    ,glc.segment1 "UEC"
    ,glc.segment2 "DEPT"
    ,pov.vendor_name "VENDOR_NAME"
    ,msi.SEGMENT1 "ITEM_NUM"
    ,rcvs.receipt_num "RECEIPT_NUM"
    ,poh.segment1 "PO_NUMBER"
    ,pol.line_num "PO_LINE_NUM"
    ,por.RELEASE_NUM "RELEASE_NUMBER"
    ,poll.shipment_num "SHIPMENT_NUM"
    ,hrou.name "SHIP_TO_ORGANIZATION"
    ,trunc(rcv.transaction_date) "TRANSACTION_DATE"
    ,decode (transaction_type,'RECEIVE', 'ERS', 'RETURN TO VENDOR','RTS') "RECEIPT_TYPE"
    ,decode (rcv.transaction_type,'RECEIVE', 1, 'RETURN TO VENDOR', -1)* rcv.quantity "RECEIPT_QTY"
    ,rcv.po_unit_price "PO_UNIT_PRICE"
    ,decode (rcv.transaction_type,'RECEIVE', 1, 'RETURN TO VENDOR', -1)*rcv.quantity*po_unit_price "RECEIPT_AMOUNT"
    ,rcvs.packing_slip "PACKING_SLIP"
    ,poll.quantity "QUANTITY_ORDERED"
    ,poll.quantity_received "QUANTITY_RECEIVED"
    ,poll.quantity_accepted "QUANTITY_ACCEPTED"
    ,poll.quantity_rejected "QUANTITY_REJECTED"
    ,poll.quantity_billed "QUANTITY_BILLED"
    ,poll.quantity_cancelled "QUANTITY_CANCELLED"
    ,(poll.quantity_received - (poll.quantity - poll.quantity_cancelled)) "QUANTITY_OVER_RECEIVED"
    ,(poll.quantity_received - (poll.quantity - poll.quantity_cancelled))*po_unit_price "OVER_RECEIVED_AMOUNT"
    ,poh.currency_code "CURRENCY_CODE"
    ,perr.full_name "RECEIVER"
    ,perb.full_name "BUYER"
    FROM
    po.po_vendors pov
    ,po.po_headers_all poh
    ,po.po_lines_all pol
    ,po.po_line_locations_all poll
    ,po.po_distributions_all pod
    ,po.po_releases_all por
    ,hr.hr_all_organization_units hou
    ,hr.hr_all_organization_units hrou
    ,po.rcv_transactions rcv
    ,po.rcv_shipment_headers rcvs
    ,gl.gl_code_combinations glc
    ,hr.per_all_people_f perr
    ,hr.per_all_people_f perb
    ,inv.mtl_system_items_b msi
    where
    poh.org_id = hou.organization_id
    and pov.vendor_id (+) = poh.vendor_id
    and pod.po_header_id = poh.po_header_id
    and pod.po_line_id = pol.po_line_id
    and pod.line_location_id = poll.line_location_id
    and poll.po_header_id = poh.po_header_id
    and poll.po_line_id = pol.po_line_id
    and pol.po_header_id = poh.po_header_id
    and poh.pay_on_code like 'RECEIPT'
    and pod.po_header_id = rcv.po_header_id
    and pod.po_line_id = rcv.po_line_id
    and pod.po_release_id = rcv.po_release_id
    and pod.po_release_id = por.po_release_id
    and por.po_header_id = poh.po_header_id
    and hrou.organization_id = poll.ship_to_organization_id
    and pod.line_location_id = rcv.po_line_location_id
    and pod.po_distribution_id = rcv.po_distribution_id
    and rcv.transaction_type in ('RECEIVE','RETURN TO VENDOR')
    and rcv.shipment_header_id = rcvs.shipment_header_id (+)
    and pod.code_combination_id = glc.code_combination_id
    and rcvs.employee_id = perr.person_id
    and por.agent_id = perb.person_id (+)
    and perr.person_type_id = 1
    and perb.person_type_id = 1
    and msi.organization_id = 1 --poll.ship_to_organization_id
    and msi.inventory_item_id = pol.item_id
    and poh.type_lookup_code = 'BLANKET'
    and hou.organization_id = nvl(:p_operating_unit,hou.organization_id)
    and trunc(rcv.transaction_date) between :p_transaction_date_from and :p_transaction_date_to
    Message was edited by:
    Prathima

  • Urgent...on organization and their hierarchies.

    Hi,
    We have list of organization names in HR and also each organization has its hierarchies.
    Hr_all_organization_units is the table which has the list of names of the organization.
    Now can somebody tell me the table name and the column name where i can find the sub orgs for a particular org in Hr_all_organization_units and
    for example i wan't to list the names of the organizations and the list of sub organizations using SQL query, how to do that...
    Please answer, its a bit urgent for me
    thanks a ton
    kumar

    Check out if the below mentioned query is helpful to you.
    SELECT ose.ROWID, ose.org_structure_element_id, ose.business_group_id
    , ose.organization_id_parent, hou1tl.NAME, ose.org_structure_version_id
    , ose.organization_id_child, hou2tl.NAME, ose.request_id
    , ose.program_application_id, ose.program_id, ose.program_update_date
    , ose.last_update_date, ose.last_updated_by, ose.last_update_login
    , ose.created_by, ose.creation_date, ose.position_control_enabled_flag
    FROM per_org_structure_elements ose
    , hr_all_organization_units hou1
    , hr_all_organization_units hou2
    , hr_all_organization_units_tl hou1tl
    , hr_all_organization_units_tl hou2tl
    WHERE ose.organization_id_parent = hou1.organization_id
    AND ose.organization_id_child = hou2.organization_id
    AND hou1.organization_id = hou1tl.organization_id
    AND hou2.organization_id = hou2tl.organization_id
    AND hou1tl.LANGUAGE = USERENV ('LANG')
    AND hou2tl.LANGUAGE = USERENV ('LANG')
    Thanks,
    Angelica.

  • UNION ALL and UNION performance issue

    Hi All,
    I am trying to figure out the data for which only receive transaction has been done and further processing is pending. These transactions include all PO, RMA , ISO etc...
    I have to use UNION ALL in this case as for RMA and ISO, details which i want are not able to gather in a single query.
    But query is taking a lot of time ...may be around 30..mins in UNION ALL while 6 to 7 mins in UNION.
    To get all records I must have to use UNION ALL...
    So kindly suggest the solution for this problem
    Thanks
    Sachin
    Query is given below...
    SELECT /* + FIRST_ROWS */ DECODE(rsl.SOURCE_DOCUMENT_CODE,'REQ',(SELECT org1.ORGANIZATION_NAME
                                                           FROM     org_organization_definitions org1
                                                           WHERE org1.ORGANIZATION_ID =
                                                           rsl.FROM_ORGANIZATION_ID)) Vendor_Name
    ,rsh.RECEIPT_NUM Receipt_Number
         ,TO_CHAR(rt3.TRANSACTION_DATE,'Mon-DD-YYYY HH:MM:SS') Receipt_Date_and_Time
         ,msi.SEGMENT1 Part_Number
         ,msi.DESCRIPTION Part_Name
         ,rt3.QUANTITY Quantity
         ,rt3.UNIT_OF_MEASURE UOM
         ,NULL ASL_Status
         --for ISO no asl flag ASL Flag
         ,TO_CHAR(TRUNC((((86400*(SYSDATE-rt3.TRANSACTION_DATE))/60)/60)/24))|| ' Days ' || TO_CHAR(TRUNC(((86400*(SYSDATE-rt3.TRANSACTION_DATE))/60)/60)-24*(TRUNC((((86400*(SYSDATE-rt3.TRANSACTION_DATE))/60)/60)/24)))|| ' Hours' Days_and_hours_passed
         ,DECODE(
                        NVL(msi.max_minmax_quantity,0) ,
                        0 , 0 ,
                        (NVL(msi.max_minmax_quantity,0) -
                        NVL(inmohqd.onhand,0))
                             * 100
                             / NVL(msi.max_minmax_quantity,0)
                        ) gap_percent
    FROM rcv_transactions rt3
         ,rcv_shipment_headers rsh
         ,rcv_shipment_lines rsl
         ,mtl_system_items msi
         ,org_organization_definitions org
         --,MTL_ONHAND_QUANTITIES_DETAIL moqhd
         ,(SELECT NVL(SUM(primary_transaction_quantity),0) onhand,INVENTORY_ITEM_ID item_id,ORGANIZATION_ID organization_id
         FROM      mtl_onhand_quantities_detail
         WHERE SUBINVENTORY_CODE NOT IN ('Wip_SF','Wip_Int','Reject','Scrap','FG Trading','FG')
         GROUP BY INVENTORY_ITEM_ID, ORGANIZATION_ID) inmohqd
    WHERE inmohqd.item_id(+) = msi.INVENTORY_ITEM_ID
         AND inmohqd.organization_id(+) = msi.ORGANIZATION_ID
         --AND inmoqhd.SUBINVENTORY_CODE NOT IN  ('Wip_SF','Wip_Int','Reject','Scrap','FG Trading','FG')
         AND msi.INVENTORY_ITEM_ID = rsl.ITEM_ID
         AND rsh.SHIPMENT_HEADER_ID = rsl.SHIPMENT_HEADER_ID
         AND org.ORGANIZATION_ID = rt3.ORGANIZATION_ID
         AND msi.ORGANIZATION_ID = rt3.ORGANIZATION_ID
         AND rsh.SHIPMENT_HEADER_ID = rt3.SHIPMENT_HEADER_ID
         AND rsl.SHIPMENT_HEADER_ID = rt3.SHIPMENT_HEADER_ID
         AND rsl.SHIPMENT_LINE_ID = rt3.SHIPMENT_LINE_ID
         AND rt3.PO_HEADER_ID IS NULL
         AND TRUNC(rt3.TRANSACTION_DATE) <= TRUNC(p_tilldate)
         AND rsl.TO_ORGANIZATION_ID = p_organization_id
         AND rsh.ORGANIZATION_ID = p_organization_id
         AND CONCAT(TRIM(rt3.SHIPMENT_HEADER_ID),TRIM(rt3.SHIPMENT_LINE_ID)) IN
         SELECT CONCAT(TRIM(rt1.SHIPMENT_HEADER_ID),TRIM(rt1.SHIPMENT_LINE_ID))
         FROM     rcv_transactions rt1
         WHERE NOT EXISTS(
         SELECT 1
              FROM     rcv_transactions rt2
              WHERE     rt2.TRANSACTION_TYPE <> 'RECEIVE'
                        AND rt1.SHIPMENT_HEADER_ID = rt2.SHIPMENT_HEADER_ID
                        AND rt1.SHIPMENT_LINE_ID = rt2.SHIPMENT_LINE_ID
                        AND rt2.ORGANIZATION_ID = p_organization_id
    UNION
    SELECT /* + FIRST_ROWS */ pv.VENDOR_NAME Vendor_Name
         ,rsh.RECEIPT_NUM Receipt_Number
         ,TO_CHAR(rt.TRANSACTION_DATE,'Mon-DD-YYYY HH:MM:SS') Receipt_Date_and_Time
         ,msi.SEGMENT1 Part_Number
         ,msi.DESCRIPTION Part_Name
         ,rt.QUANTITY Quantity
         ,rt.UNIT_OF_MEASURE UOM
         --start 001
         ,NVL((SELECT DISTINCT DECODE (ASL_STATUS_ID,1,'New',2,'Approved','To be checked')
                   FROM po_approved_supplier_list pasl
                   WHERE pasl.item_id=rsl.ITEM_ID
                             AND pasl.VENDOR_ID(+) = pv.VENDOR_ID
                             AND pasl.VENDOR_SITE_ID(+) = pvs.VENDOR_SITE_ID),'No_data') ASL_Status
              --end 001
              ,TO_CHAR(TRUNC((((86400*(SYSDATE-rt.TRANSACTION_DATE))/60)/60)/24))|| ' Days ' || TO_CHAR(TRUNC(((86400*(SYSDATE-rt.TRANSACTION_DATE))/60)/60)-24*(TRUNC((((86400*(SYSDATE-rt.TRANSACTION_DATE))/60)/60)/24)))|| ' Hours' Days_and_hours_passed          ,DECODE(
                   NVL(msi.max_minmax_quantity,0) ,
              0 , 0 ,
              (NVL(msi.max_minmax_quantity,0) -
              NVL(inmohqd.onhand,0))
                   * 100
                   / NVL(msi.max_minmax_quantity,0)
              ) gap_percent
    FROM rcv_transactions rt
         ,po_vendors pv
         ,po_vendor_sites_all pvs
         ,rcv_shipment_headers rsh
         ,rcv_shipment_lines rsl
         ,mtl_system_items msi
         ,org_organization_definitions org
         --,mtl_onhand_quantities_detail moqhd
         ,(SELECT NVL(SUM(primary_transaction_quantity),0) onhand,INVENTORY_ITEM_ID item_id,ORGANIZATION_ID organization_id
         FROM      mtl_onhand_quantities_detail
         WHERE SUBINVENTORY_CODE NOT IN ('Wip_SF','Wip_Int','Reject','Scrap','FG Trading','FG')
         GROUP BY INVENTORY_ITEM_ID, ORGANIZATION_ID) inmohqd
    WHERE inmohqd.item_id(+) = msi.INVENTORY_ITEM_ID
         AND inmohqd.ORGANIZATION_ID(+) = msi.ORGANIZATION_ID
         --AND inmoqhd.SUBINVENTORY_CODE NOT IN  ('Wip_SF','Wip_Int','Reject','Scrap','FG Trading','FG')
         AND msi.INVENTORY_ITEM_ID = rsl.ITEM_ID
         AND rsh.SHIPMENT_HEADER_ID = rsl.SHIPMENT_HEADER_ID
         AND pv.VENDOR_ID = pvs.VENDOR_ID
         AND org.ORGANIZATION_ID = rt.ORGANIZATION_ID
         AND msi.ORGANIZATION_ID = rt.ORGANIZATION_ID
         AND pvs.VENDOR_SITE_ID = rt.VENDOR_SITE_ID
         AND pv.VENDOR_ID = rt.VENDOR_ID
         AND rsh.SHIPMENT_HEADER_ID = rt.SHIPMENT_HEADER_ID
         AND rsl.SHIPMENT_HEADER_ID = rt.SHIPMENT_HEADER_ID
         AND rsl.SHIPMENT_LINE_ID = rt.SHIPMENT_LINE_ID
         AND TRUNC(rt.TRANSACTION_DATE) <= TRUNC(p_tilldate)
         AND rsl.TO_ORGANIZATION_ID = p_organization_id
         AND CONCAT(TRIM(rt.SHIPMENT_HEADER_ID),TRIM(rt.SHIPMENT_LINE_ID)) IN
              SELECT CONCAT(TRIM(rt1.SHIPMENT_HEADER_ID),TRIM(rt1.SHIPMENT_LINE_ID))
              FROM RCV_TRANSACTIONS rt1
              WHERE rt1.TRANSACTION_TYPE = 'RECEIVE'
                   AND rt1.DESTINATION_TYPE_CODE = 'RECEIVING'
                   AND rt1.PO_HEADER_ID IS NOT NULL
                   AND NOT EXISTS(
                   SELECT 1
                        FROM     RCV_TRANSACTIONS rt2
                        WHERE     rt2.SHIPMENT_HEADER_ID = rt1.SHIPMENT_HEADER_ID
                                  AND rt2.SHIPMENT_LINE_ID = rt1.SHIPMENT_LINE_ID
                                  AND rt2.TRANSACTION_TYPE <> 'RECEIVE'
         )

    In this case, for selected columns, all data is same for one of the RMA with more than one line. So UNION will skip one of the records. However, shipment line id are different for both records, so by selecting it in select list is solving the problem and so no need to use UNION ALL. But, anyhow UNION ALL is better than UNION in performance as it does not require to sort. Then why I am facing this problem...
    Kindly suggest
    Regards,
    Sachin

  • Need to create report query to get latest open and last closed period for given application

    Hi All,
    I need to create a report query to get below result displayed in report output.
    1)   -   Application name
    2)   -    Ledger name
    -o/  -Operating Unit
    3)   -  Last Closed Period
    4)   -  Current Open Period
    5)   -  Date Closed – Last Closed Period
    6)   -  Date Open – Current Open Period
    I tr I tried to create the query below is the same. Please let me know if it looks fine.
    SELECT *
      FROM (SELECT fav.application_name ,
                   hou.name Operating_Unit_Name,
                   gl.name Ledger_name,
                   gl.latest_opened_period_name,
                   gps.period_name Period_Name,
                   DECODE(gps.closing_status, 'O', 'Open', 'C', 'Closed') status,
                   gps.last_update_date Last_status_modified_date
              FROM gl_period_statuses gps,
                   gl_sets_of_books   gsob,
                   fnd_application_vl fav,
                   hr_operating_units hou,
                   gl_ledgers         gl
             WHERE gps.period_name = gps.period_name
               AND gps.closing_status ='C'
               AND fav.application_short_name =
                   NVL('&p_application_short_name', fav.application_short_name)
               AND gps.application_id = fav.application_id
               AND gsob.set_of_books_id = gps.set_of_books_id
               AND hou.set_of_books_id = gps.set_of_books_id
               AND gl.ledger_id = gsob.set_of_books_id
               AND hou.organization_id=NVL('&p_operating_unit',hou.organization_id)
               AND gl.ledger_id=NVL('&p_ledger_id',gl.ledger_id) 
             ORDER BY gps.last_update_date desc )WHERE ROWNUM = 1 
    UNION ALL
    SELECT *
      FROM (SELECT fav.application_name Application_Name,
                   hou.name Operating_Unit_Name,
                   gl.name Ledger_name,
                   gl.latest_opened_period_name,
                   gps.period_name Period_Name,
                   DECODE(gps.closing_status, 'O', 'Open', 'C', 'Closed') status,
                   gps.last_update_date Last_status_modified_date
              FROM gl_period_statuses gps,
                   gl_sets_of_books   gsob,
                   fnd_application_vl fav,
                   hr_operating_units hou,
                   gl_ledgers         gl
             WHERE gps.period_name = gps.period_name
               AND gps.closing_status = 'O'
               AND fav.application_short_name =
                   NVL('&p_application_short_name', fav.application_short_name)
               AND gps.application_id = fav.application_id
               AND gsob.set_of_books_id = gps.set_of_books_id
               AND hou.set_of_books_id = gps.set_of_books_id
               AND gl.ledger_id = gsob.set_of_books_id
               AND hou.organization_id=NVL('&p_operating_unit',hou.organization_id)
               AND gl.ledger_id=NVL('&p_ledger_id',gl.ledger_id) 
             ORDER BY gps.last_update_date desc)
             WHERE ROWNUM = 1

    It is within the table I believe (I'm not a DBA or a developer) since I created a BLOB column and then used the file browse feature to allow users to attach a resume to the table in order to be able to perform a search of the attached documents.
    I'm just having a hard time pointing the link in the search results report to the document in the blob column.
    The information on that page is great if you're trying to create a link to the document on the initial report.
    But I created a query using Oracle Text to run a report that does a boolean search of the attached word documents in the table.
    When it displays the search results, it doesn't create a link to the document and I can't figure out how to do it.
    Here's a link the the instructions I used to create the initial search report with Oracle Text, mind you I only created the index and query, I didn't add in all the link data since they're using documents on websites and I'm using documents in a table.
    http://www.oracle.com/technology/products/database/application_express/pdf/apex_text_application_v1.6.pdf
    If you can help me with this I'd really appreciate it.
    Thanks again.
    Greg
    Edited by: gjones77 on Dec 2, 2008 8:14 AM

  • Project budget and forecast tables in R12

    Hi All,
    I had to extract the budget and forecast amounts for each project in the below format.
    Project number, budget/forecast, task, resource, PA period, burden cost..etc.+
    We are on R12. Can I use below tables to extract the above information. or should i depend on PJI% tables. please suggest.
    pa_budget_versions
    pa_budget_lines
    below is the full query i built:
    SELECT pp.NAME project_name, pp.segment1 project_number,
    haou.NAME project_organization, pp.project_type,
    pp.project_status_code, pp.start_date project_start_date,
    pp.completion_date project_completion_date,
    pfpt.NAME fin_plan_type, pfpt.description fin_plan_description,
    pfpt.plan_class_code, pbv.budget_version_id, pbv.budget_type_code, pbv.version_number,
    pbv.budget_status_code, pbv.version_name, pbv.baselined_date,
    pbv.labor_quantity project_level_labor_quantity,
    pbv.labor_unit_of_measure, pbv.raw_cost project_level_raw_cost, pbv.burdened_cost project_level_burdened_cost,
    pbv.revenue project_level_revenue, pbv.version_type,pbv.current_planning_period, pt.task_number, pt.task_name,
    prlm.alias resource_alias, prlm.expenditure_type, prlm.event_type,
    prlm.expenditure_category, prlm.resource_class_code,
    prlm.unit_of_measure, pbl.start_date, pbl.end_date, pbl.period_name,
    pbl.quantity, pbl.raw_cost, pbl.burdened_cost, pbl.revenue, prlm.resource_list_member_id,
    prlm.resource_type_code
    FROM apps.pa_projects_all pp,
    hr_all_organization_units haou,
    apps.pa_budget_versions pbv,
    apps.pa_fin_plan_types_vl pfpt,
    apps.pa_budget_lines pbl,
    pa_resource_assignments pra,
    pa_tasks pt,
    pa_resource_list_members prlm
    WHERE 1 = 1
    AND pp.project_id = pbv.project_id
    AND pp.carrying_out_organization_id = haou.organization_id
    AND pbv.fin_plan_type_id = pfpt.fin_plan_type_id
    AND pbv.budget_status_code = 'B'
    AND pbv.budget_version_id =
    (SELECT MAX (budget_version_id)
    FROM pa_budget_versions pbv1
    WHERE 1 = 1
    AND pbv1.project_id = pp.project_id
    AND pbv1.budget_status_code = 'B'
    AND pbv1.version_type = pbv.version_type)
    --AND version_type = 'COST'
    AND pbl.budget_version_id = pbv.budget_version_id
    AND pbl.resource_assignment_id = pra.resource_assignment_id
    AND pra.resource_list_member_id = prlm.resource_list_member_id
    AND pt.task_id(+) = pra.task_id
    and pp.name = 'TEST_XX'
    order by pp.segment1, pbl.period_name, pt.task_number, pbl.start_date

    Can any body please help on this note..
    thanks in advance..

  • Reports 6i and analytical function

    hi
    I have this query which wrks fine in TOAD
    SELECT rvt.receipt_num srv_no, rvt.supplier supplier,
                    rvt.transaction_date srv_date, inv.segment1 item_no,
                    rvt.item_desc item_description, hrov.NAME,               
                    (   SUBSTR (v.standard_industry_class, 1, 1)
                     || '-'
                     || po_headers.segment1
                     || '-'
                     || TO_CHAR (po_headers.creation_date, 'RRRR')
                    ) po_no,
                    po_headers.creation_date_disp po_date,   
                          (  (rvt.currency_conversion_rate * po_lines.unit_price)
                     * rvt.transact_qty
                    )aMOUNT  ,
    ----Analytic function used here                      
            SUM(          (  (rvt.currency_conversion_rate * po_lines.unit_price)
                     * rvt.transact_qty)) over(partition by hrov.NAME) SUM_AMOUNT,                                                                                 
                    (SELECT SUM (mot.on_hand)
                       FROM mtl_onhand_total_mwb_v mot
                      WHERE inv.inventory_item_id = mot.inventory_item_id
                        --  AND INV.ORGANIZATION_ID=MOT.ORGANIZATION_ID
                        AND loc.inventory_location_id = mot.locator_id
                        AND loc.organization_id = mot.organization_id
                        AND rvt.locator_id = mot.locator_id) onhand
               FROM rcv_vrc_txs_v rvt,
                    mtl_system_items_b inv,
                    mtl_item_locations loc,
                    hr_organization_units_v hrov,
                    po_headers_v po_headers,
                    ap_vendors_v v,
                    po_lines_v po_lines
              WHERE inv.inventory_item_id(+) = rvt.item_id
                AND po_headers.vendor_id = v.vendor_id
                AND rvt.po_line_id = po_lines.po_line_id
                AND rvt.po_header_id = po_lines.po_header_id
                AND rvt.po_header_id = po_headers.po_header_id
                AND rvt.supplier_id = v.vendor_id
                AND inv.organization_id = hrov.organization_id
                AND rvt.transaction_type = 'DELIVER'
                AND rvt.inspection_status_code <> 'REJECTED'
                AND rvt.organization_id = inv.organization_id(+)
                AND to_char(to_date(rvt.transaction_date, 'DD/MM/YYYY'), 'DD-MON-YYYY') BETWEEN (:p_from_date)
                                                     AND NVL (:p_to_date,
                                                              :p_from_date
                AND rvt.locator_id = loc.physical_location_id(+)
                AND transaction_id NOT IN (
                       SELECT parent_transaction_id
                         FROM rcv_vrc_txs_v rvtd
                        WHERE rvt.item_id = rvtd.item_id
                          AND rvtd.transaction_type IN
                                      ('RETURN TO RECEIVING', 'RETURN TO VENDOR'))
                                      GROUP BY rvt.receipt_num , rvt.supplier ,
                    rvt.transaction_date , inv.segment1 ,
                    rvt.item_desc , hrov.NAME,v.standard_industry_clasS,po_headers.segment1,po_headers.creation_datE,
                    po_headers.creation_date_disp,inv.inventory_item_iD,loc.inventory_location_id,loc.organization_id,
                    rvt.locator_iD,rvt.currency_conversion_rate,po_lines.unit_price, rvt.transact_qty
    but it gives blank page in reports 6i
    could it be that reports 6i donot support analytical functionskindly guide another alternaive
    thanking in advance
    Edited by: makdutakdu on Mar 25, 2012 2:22 PM

    hi
    will the view be like
    create view S_Amount as SELECT rvt.receipt_num srv_no, rvt.supplier supplier,
                    rvt.transaction_date srv_date, inv.segment1 item_no,
                    rvt.item_desc item_description, hrov.NAME,               
                    (   SUBSTR (v.standard_industry_class, 1, 1)
                     || '-'
                     || po_headers.segment1
                     || '-'
                     || TO_CHAR (po_headers.creation_date, 'RRRR')
                    ) po_no,
                    po_headers.creation_date_disp po_date,   
                          (  (rvt.currency_conversion_rate * po_lines.unit_price)
                     * rvt.transact_qty
                    )aMOUNT  ,
    ----Analytic function used here                      
            SUM(          (  (rvt.currency_conversion_rate * po_lines.unit_price)
                     * rvt.transact_qty)) over(partition by hrov.NAME) SUM_AMOUNT,                                                                                 
                    (SELECT SUM (mot.on_hand)
                       FROM mtl_onhand_total_mwb_v mot
                      WHERE inv.inventory_item_id = mot.inventory_item_id
                        --  AND INV.ORGANIZATION_ID=MOT.ORGANIZATION_ID
                        AND loc.inventory_location_id = mot.locator_id
                        AND loc.organization_id = mot.organization_id
                        AND rvt.locator_id = mot.locator_id) onhand
               FROM rcv_vrc_txs_v rvt,
                    mtl_system_items_b inv,
                    mtl_item_locations loc,
                    hr_organization_units_v hrov,
                    po_headers_v po_headers,
                    ap_vendors_v v,
                    po_lines_v po_lines
              WHERE inv.inventory_item_id(+) = rvt.item_id
                AND po_headers.vendor_id = v.vendor_id
                AND rvt.po_line_id = po_lines.po_line_id
                AND rvt.po_header_id = po_lines.po_header_id
                AND rvt.po_header_id = po_headers.po_header_id
                AND rvt.supplier_id = v.vendor_id
                AND inv.organization_id = hrov.organization_id
                AND rvt.transaction_type = 'DELIVER'
                AND rvt.inspection_status_code <> 'REJECTED'
                AND rvt.organization_id = inv.organization_id(+)
                           AND rvt.locator_id = loc.physical_location_id(+)
                AND transaction_id NOT IN (
                       SELECT parent_transaction_id
                         FROM rcv_vrc_txs_v rvtd
                        WHERE rvt.item_id = rvtd.item_id
                          AND rvtd.transaction_type IN
                                      ('RETURN TO RECEIVING', 'RETURN TO VENDOR'))
                                      GROUP BY rvt.receipt_num , rvt.supplier ,
                    rvt.transaction_date , inv.segment1 ,
                    rvt.item_desc , hrov.NAME,v.standard_industry_clasS,po_headers.segment1,po_headers.creation_datE,
                    po_headers.creation_date_disp,inv.inventory_item_iD,loc.inventory_location_id,loc.organization_id,
                    rvt.locator_iD,rvt.currency_conversion_rate,po_lines.unit_price, rvt.transact_qtyis this correct ? i mean i have not included the bind parameters in the view ..moreover shoud this view be joined with all the columns in the from clause of the original query?
    kindly guide
    thanking in advance

  • Joins between transactions and sales order tables?

    Hi all,
    SELECT ott.NAME,
                 msi.organization_id
      FROM apps.mtl_material_transactions mmt,
                apps.mtl_system_items_kfv msi,
                apps.oe_order_headers_all ooha,
                apps.oe_order_lines_all oola,
                apps.oe_transaction_types_tl ott
    WHERE     mmt.transaction_type_id = 12
           AND mmt.inventory_item_id = msi.inventory_item_id
           AND mmt.organization_id = msi.organization_id
           AND ooha.header_id = oola.header_id
           AND oola.line_id = mmt.trx_source_line_id
           AND oola.inventory_item_id= msi.inventory_item_id
           AND ooha.order_type_id= ott.transaction_type_id
           AND mmt.inventory_item_id = 1234
           AND msi.organization_id = 20
    And i don't have inventory item id with this transaction_type_id = 12

    Transaction_type_id 12 is a "Receive from Intransit".  I don't think those will join to sales orders.  What are you trying to accomplish?

  • Bad performance with many xmlqueries in select and big resultset

    I'm running into big performance problems with the following query (edited the query a bit to remove sensitive information):
    SELECT id "id",created "created",
      xmlcast(xmlquery('declare default element namespace "http://www.example.com/myproject/schema/namespace2";declare namespace c="http://www.example.com/myproject/schema/common";/element1/element2/name' passing xml returning content) as varchar2(182))"element2Name",
      xmlcast(xmlquery('declare default element namespace "http://www.example.com/myproject/schema/namespace2";declare namespace c="http://www.example.com/myproject/schema/common";/element1/element3/name' passing xml returning content) as varchar2(182))"element3Name",
      xmlcast(xmlquery('declare default element namespace "http://www.example.com/myproject/schema/namespace2";declare namespace c="http://www.example.com/myproject/schema/common";/element1/ror/gcor' passing xml returning content) as varchar2(5))"gcor",
      xmlcast(xmlquery('declare default element namespace "http://www.example.com/myproject/schema/namespace2";declare namespace c="http://www.example.com/myproject/schema/common";/element1/c:element1Header/c:status/c:cStatus' passing xml returning content) as integer)"cStatus",
      xmlcast(xmlquery('declare default element namespace "http://www.example.com/myproject/schema/namespace2";declare namespace c="http://www.example.com/myproject/schema/common";/element1/c:element1Header/c:status/c:lrrm' passing xml returning content) as integer)"lrrm",
      xmlcast(xmlquery('declare default element namespace "http://www.example.com/myproject/schema/namespace2";declare namespace c="http://www.example.com/myproject/schema/common";/element1/c:element1Header/c:status/c:sent' passing xml returning content) as integer)"sent",
      xmlcast(xmlquery('declare default element namespace "http://www.example.com/myproject/schema/namespace2";declare namespace c="http://www.example.com/myproject/schema/common";/element1/c:element1Header/c:status/c:success' passing xml returning content) as integer)"success",
      xmlcast(xmlquery('declare default element namespace "http://www.example.com/myproject/schema/namespace2";declare namespace c="http://www.example.com/myproject/schema/common";/element1/c:element1Header/c:status/c:processStep' passing xml returning content) as integer)"processStep",
      xmlcast(xmlquery('declare default element namespace "http://www.example.com/myproject/schema/namespace2";declare namespace c="http://www.example.com/myproject/schema/common";/element1/header/status/aseod' passing xml returning content) as number(1))"aseod",
      xmlcast(xmlquery('declare default element namespace "http://www.example.com/myproject/schema/namespace2";declare namespace c="http://www.example.com/myproject/schema/common";/element1/submission/deferred' passing xml returning content) as number(1))"deferred",
      xmlcast(xmlquery('declare default element namespace "http://www.example.com/myproject/schema/namespace2";declare namespace c="http://www.example.com/myproject/schema/common";/element1/header/status/eventReportReceived' passing xml returning content) as number(1))"eventReports",
      xmlcast(xmlquery('declare default element namespace "http://www.example.com/myproject/schema/namespace2";declare namespace c="http://www.example.com/myproject/schema/common";/element1/c:element1Header/c:status/c:isOpen' passing xml returning content) as number(1))"isOpen",
      xmlcast(xmlquery('declare default element namespace "http://www.example.com/myproject/schema/namespace2";declare namespace c="http://www.example.com/myproject/schema/common";/element1/c:element1Header/c:hasNotes' passing xml returning content) as number(1))"hasNotes"
    FROM tablename,xmltable(xmlnamespaces(default 'http://www.example.com/myproject/schema/namespace2','http://www.example.com/myproject/schema/common' as "c"),'/element1' passing xml columns
    created timestamp path 'c:element1Header/c:creationTime/text()',
    organization_id integer path 'c:element1Header/c:organization/c:organizationId/text()',
    is_sender number(1) path 'c:element1Header/c:isSender/text()')
    WHERE organization_id = 5 AND is_sender = 1 AND created >= sysdate-20 AND created <= sysdate+1;This query is fast as long as the results is small (<1000), but when the resultset grows bigger, the performance seems to decrease exponentially. The cause of this slowdown seems to be in the xmlqueries; commenting out the xmlqueries makes the query very fast again (in the order of a few seconds), even with a 15000+ resultset, while including the xmlqueries makes the query take many minutes.
    Workaround I tried: using a rownum < 1000 works fairly well, but only if I don't use order by (which is required). order by forces the resultset to be full built regardless of the rownum limit. (this was done with a subquery orderby and a rownum on the superquery)
    Other workaround i tried: Having the subquery only return the xml column, and doing the xmlqueries in the superquery. I couldn't get this to work, something about no longer having a key-preserved table.
    Background info about the database: Oracle 11.2.0.3.0, binary xmltype column, with a xmlindex unstructured component on all paths in this query, and a structured component with secondary indexes on the paths used in the WHERE (created, organization_id and is_sender). Database has about 140k records total.
    My question is, if anyone knows if this xmlquery bottleneck can be remedied somehow?
    Addition: graph i made indicating the performance at different resultset sizes. Horizontal axis is size of resultset, vertical axis is time spent in seconds: http://i.imgur.com/F2tyg.png

    Just count(*), nothing else in the select:
    COUNT(*)              
    15432                 
    Plan hash value: 1584286506
    | Id  | Operation                      | Name                  | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT               |                       |     1 |    39 |    31   (0)| 00:00:01 |
    |   1 |  SORT AGGREGATE                |                       |     1 |    39 |            |          |
    |*  2 |   FILTER                       |                       |       |       |            |          |
    |   3 |    NESTED LOOPS                |                       |    15 |   585 |    31   (0)| 00:00:01 |
    |   4 |     TABLE ACCESS BY INDEX ROWID| TABLENAME_SC          |    15 |   405 |    16   (0)| 00:00:01 |
    |*  5 |      INDEX RANGE SCAN          | TABLENAME_SC_SUB_IX   |    15 |       |     3   (0)| 00:00:01 |
    |   6 |     TABLE ACCESS BY USER ROWID | TABLENAME             |     1 |    12 |     1   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - filter(SYSDATE@!-500<=SYSDATE@!-50)
       5 - access("SYS_SXI_0"."ORGANIZATION_ID"=6 AND "SYS_SXI_0"."IS_SENDER"=1 AND
                  "SYS_SXI_0"."CREATION_TIME">=SYSDATE@!-500 AND "SYS_SXI_0"."CREATION_TIME"<=SYSDATE@!-50)Original query with ORDER BY on 2 structured component columns, 1 descending and 1 ascending (NOTE: While the explain plan says the time is 00:00:01, the query takes 763 seconds to complete)
    | Id  | Operation                      | Name                           | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT               |                                |    15 | 23880 |    32   (4)| 00:00:01 |
    |   1 |  SORT GROUP BY                 |                                |     1 |    41 |            |          |
    |*  2 |   TABLE ACCESS BY INDEX ROWID  | SYS63339_TABL_XML_I_PATH_TABLE |    17 |   697 |     5   (0)| 00:00:01 |
    |*  3 |    INDEX RANGE SCAN            | SYS63339_TABL_XML_I_PIKEY_IX   |    17 |       |     3   (0)| 00:00:01 |
    |   4 |  SORT GROUP BY                 |                                |     1 |    41 |            |          |
    |*  5 |   TABLE ACCESS BY INDEX ROWID  | SYS63339_TABL_XML_I_PATH_TABLE |    16 |   656 |     5   (0)| 00:00:01 |
    |*  6 |    INDEX RANGE SCAN            | SYS63339_TABL_XML_I_PIKEY_IX   |    16 |       |     3   (0)| 00:00:01 |
    |   7 |  SORT GROUP BY                 |                                |     1 |    41 |            |          |
    |*  8 |   TABLE ACCESS BY INDEX ROWID  | SYS63339_TABL_XML_I_PATH_TABLE |    15 |   615 |     4   (0)| 00:00:01 |
    |*  9 |    INDEX RANGE SCAN            | SYS63339_TABL_XML_I_PIKEY_IX   |    15 |       |     3   (0)| 00:00:01 |
    |  10 |  SORT GROUP BY                 |                                |     1 |    41 |            |          |
    |* 11 |   TABLE ACCESS BY INDEX ROWID  | SYS63339_TABL_XML_I_PATH_TABLE |    17 |   697 |     5   (0)| 00:00:01 |
    |* 12 |    INDEX RANGE SCAN            | SYS63339_TABL_XML_I_PIKEY_IX   |    17 |       |     3   (0)| 00:00:01 |
    |  13 |  SORT GROUP BY                 |                                |     1 |    41 |            |          |
    |* 14 |   TABLE ACCESS BY INDEX ROWID  | SYS63339_TABL_XML_I_PATH_TABLE |    17 |   697 |     5   (0)| 00:00:01 |
    |* 15 |    INDEX RANGE SCAN            | SYS63339_TABL_XML_I_PIKEY_IX   |    17 |       |     3   (0)| 00:00:01 |
    |  16 |  SORT GROUP BY                 |                                |     1 |    41 |            |          |
    |* 17 |   TABLE ACCESS BY INDEX ROWID  | SYS63339_TABL_XML_I_PATH_TABLE |    17 |   697 |     5   (0)| 00:00:01 |
    |* 18 |    INDEX RANGE SCAN            | SYS63339_TABL_XML_I_PIKEY_IX   |    17 |       |     3   (0)| 00:00:01 |
    |  19 |  SORT GROUP BY                 |                                |     1 |    41 |            |          |
    |* 20 |   TABLE ACCESS BY INDEX ROWID  | SYS63339_TABL_XML_I_PATH_TABLE |    17 |   697 |     5   (0)| 00:00:01 |
    |* 21 |    INDEX RANGE SCAN            | SYS63339_TABL_XML_I_PIKEY_IX   |    17 |       |     3   (0)| 00:00:01 |
    |  22 |  SORT GROUP BY                 |                                |     1 |    41 |            |          |
    |* 23 |   TABLE ACCESS BY INDEX ROWID  | SYS63339_TABL_XML_I_PATH_TABLE |    17 |   697 |     5   (0)| 00:00:01 |
    |* 24 |    INDEX RANGE SCAN            | SYS63339_TABL_XML_I_PIKEY_IX   |    17 |       |     3   (0)| 00:00:01 |
    |  25 |  SORT GROUP BY                 |                                |     1 |    41 |            |          |
    |* 26 |   TABLE ACCESS BY INDEX ROWID  | SYS63339_TABL_XML_I_PATH_TABLE |     1 |    41 |     4   (0)| 00:00:01 |
    |* 27 |    INDEX RANGE SCAN            | SYS63339_TABL_XML_I_PIKEY_IX   |     1 |       |     3   (0)| 00:00:01 |
    |  28 |  SORT GROUP BY                 |                                |     1 |    41 |            |          |
    |* 29 |   TABLE ACCESS BY INDEX ROWID  | SYS63339_TABL_XML_I_PATH_TABLE |     8 |   328 |     4   (0)| 00:00:01 |
    |* 30 |    INDEX RANGE SCAN            | SYS63339_TABL_XML_I_PIKEY_IX   |     8 |       |     3   (0)| 00:00:01 |
    |  31 |  SORT GROUP BY                 |                                |     1 |    41 |            |          |
    |* 32 |   TABLE ACCESS BY INDEX ROWID  | SYS63339_TABL_XML_I_PATH_TABLE |     1 |    41 |     4   (0)| 00:00:01 |
    |* 33 |    INDEX RANGE SCAN            | SYS63339_TABL_XML_I_PIKEY_IX   |     1 |       |     3   (0)| 00:00:01 |
    |  34 |  SORT GROUP BY                 |                                |     1 |    41 |            |          |
    |* 35 |   TABLE ACCESS BY INDEX ROWID  | SYS63339_TABL_XML_I_PATH_TABLE |    17 |   697 |     5   (0)| 00:00:01 |
    |* 36 |    INDEX RANGE SCAN            | SYS63339_TABL_XML_I_PIKEY_IX   |    17 |       |     3   (0)| 00:00:01 |
    |  37 |  SORT ORDER BY                 |                                |    15 | 23880 |    32   (4)| 00:00:01 |
    |* 38 |   FILTER                       |                                |       |       |            |          |
    |  39 |    NESTED LOOPS                |                                |    15 | 23880 |    31   (0)| 00:00:01 |
    |  40 |     TABLE ACCESS BY INDEX ROWID| TABLENAME_SC                   |    15 |  1350 |    16   (0)| 00:00:01 |
    |* 41 |      INDEX RANGE SCAN          | TABLENAME_SC_SUB_IX            |    15 |       |     3   (0)| 00:00:01 |
    |  42 |     TABLE ACCESS BY USER ROWID | TABLENAME                      |     1 |  1502 |     1   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - filter(SYS_XMLI_LOC_ISNODE("SYS_P1"."LOCATOR")=1)
       3 - access("SYS_P1"."RID"=:B1 AND "SYS_P1"."PATHID"=HEXTORAW('509D') )
       5 - filter(SYS_XMLI_LOC_ISNODE("SYS_P3"."LOCATOR")=1)
       6 - access("SYS_P3"."RID"=:B1 AND "SYS_P3"."PATHID"=HEXTORAW('4FDE') )
       8 - filter(SYS_XMLI_LOC_ISNODE("SYS_P5"."LOCATOR")=1)
       9 - access("SYS_P5"."RID"=:B1 AND "SYS_P5"."PATHID"=HEXTORAW('7129') )
      11 - filter(SYS_XMLI_LOC_ISNODE("SYS_P7"."LOCATOR")=1)
      12 - access("SYS_P7"."RID"=:B1 AND "SYS_P7"."PATHID"=HEXTORAW('73C0') )
      14 - filter(SYS_XMLI_LOC_ISNODE("SYS_P9"."LOCATOR")=1)
      15 - access("SYS_P9"."RID"=:B1 AND "SYS_P9"."PATHID"=HEXTORAW('3092') )
      17 - filter(SYS_XMLI_LOC_ISNODE("SYS_P11"."LOCATOR")=1)
      18 - access("SYS_P11"."RID"=:B1 AND "SYS_P11"."PATHID"=HEXTORAW('30AA') )
      20 - filter(SYS_XMLI_LOC_ISNODE("SYS_P13"."LOCATOR")=1)
      21 - access("SYS_P13"."RID"=:B1 AND "SYS_P13"."PATHID"=HEXTORAW('3415') )
      23 - filter(SYS_XMLI_LOC_ISNODE("SYS_P15"."LOCATOR")=1)
      24 - access("SYS_P15"."RID"=:B1 AND "SYS_P15"."PATHID"=HEXTORAW('4972') )
      26 - filter(SYS_XMLI_LOC_ISNODE("SYS_P17"."LOCATOR")=1)
      27 - access("SYS_P17"."RID"=:B1 AND "SYS_P17"."PATHID"=HEXTORAW('745F') )
      29 - filter(SYS_XMLI_LOC_ISNODE("SYS_P19"."LOCATOR")=1)
      30 - access("SYS_P19"."RID"=:B1 AND "SYS_P19"."PATHID"=HEXTORAW('6BA9') )
      32 - filter(SYS_XMLI_LOC_ISNODE("SYS_P21"."LOCATOR")=1)
      33 - access("SYS_P21"."RID"=:B1 AND "SYS_P21"."PATHID"=HEXTORAW('62DB') )
      35 - filter(SYS_XMLI_LOC_ISNODE("SYS_P23"."LOCATOR")=1)
      36 - access("SYS_P23"."RID"=:B1 AND "SYS_P23"."PATHID"=HEXTORAW('1FD9') )
      38 - filter(SYSDATE@!-500<=SYSDATE@!-50)
      41 - access("SYS_SXI_0"."ORGANIZATION_ID"=6 AND "SYS_SXI_0"."IS_SENDER"=1 AND
                  "SYS_SXI_0"."CREATION_TIME">=SYSDATE@!-500 AND "SYS_SXI_0"."CREATION_TIME"<=SYSDATE@!-50)
    Note
       - Unoptimized XML construct detected (enable XMLOptimizationCheck for more information)The same query with ORDER BY only on CREATED DESC (takes 15 seconds to complete):
    | Id  | Operation                      | Name                           | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT               |                                |    15 | 23880 |    31   (0)| 00:00:01 |
    |   1 |  SORT GROUP BY                 |                                |     1 |    41 |            |          |
    |*  2 |   TABLE ACCESS BY INDEX ROWID  | SYS63339_TABL_XML_I_PATH_TABLE |    17 |   697 |     5   (0)| 00:00:01 |
    |*  3 |    INDEX RANGE SCAN            | SYS63339_TABL_XML_I_PIKEY_IX   |    17 |       |     3   (0)| 00:00:01 |
    |   4 |  SORT GROUP BY                 |                                |     1 |    41 |            |          |
    |*  5 |   TABLE ACCESS BY INDEX ROWID  | SYS63339_TABL_XML_I_PATH_TABLE |    16 |   656 |     5   (0)| 00:00:01 |
    |*  6 |    INDEX RANGE SCAN            | SYS63339_TABL_XML_I_PIKEY_IX   |    16 |       |     3   (0)| 00:00:01 |
    |   7 |  SORT GROUP BY                 |                                |     1 |    41 |            |          |
    |*  8 |   TABLE ACCESS BY INDEX ROWID  | SYS63339_TABL_XML_I_PATH_TABLE |    15 |   615 |     4   (0)| 00:00:01 |
    |*  9 |    INDEX RANGE SCAN            | SYS63339_TABL_XML_I_PIKEY_IX   |    15 |       |     3   (0)| 00:00:01 |
    |  10 |  SORT GROUP BY                 |                                |     1 |    41 |            |          |
    |* 11 |   TABLE ACCESS BY INDEX ROWID  | SYS63339_TABL_XML_I_PATH_TABLE |    17 |   697 |     5   (0)| 00:00:01 |
    |* 12 |    INDEX RANGE SCAN            | SYS63339_TABL_XML_I_PIKEY_IX   |    17 |       |     3   (0)| 00:00:01 |
    |  13 |  SORT GROUP BY                 |                                |     1 |    41 |            |          |
    |* 14 |   TABLE ACCESS BY INDEX ROWID  | SYS63339_TABL_XML_I_PATH_TABLE |    17 |   697 |     5   (0)| 00:00:01 |
    |* 15 |    INDEX RANGE SCAN            | SYS63339_TABL_XML_I_PIKEY_IX   |    17 |       |     3   (0)| 00:00:01 |
    |  16 |  SORT GROUP BY                 |                                |     1 |    41 |            |          |
    |* 17 |   TABLE ACCESS BY INDEX ROWID  | SYS63339_TABL_XML_I_PATH_TABLE |    17 |   697 |     5   (0)| 00:00:01 |
    |* 18 |    INDEX RANGE SCAN            | SYS63339_TABL_XML_I_PIKEY_IX   |    17 |       |     3   (0)| 00:00:01 |
    |  19 |  SORT GROUP BY                 |                                |     1 |    41 |            |          |
    |* 20 |   TABLE ACCESS BY INDEX ROWID  | SYS63339_TABL_XML_I_PATH_TABLE |    17 |   697 |     5   (0)| 00:00:01 |
    |* 21 |    INDEX RANGE SCAN            | SYS63339_TABL_XML_I_PIKEY_IX   |    17 |       |     3   (0)| 00:00:01 |
    |  22 |  SORT GROUP BY                 |                                |     1 |    41 |            |          |
    |* 23 |   TABLE ACCESS BY INDEX ROWID  | SYS63339_TABL_XML_I_PATH_TABLE |    17 |   697 |     5   (0)| 00:00:01 |
    |* 24 |    INDEX RANGE SCAN            | SYS63339_TABL_XML_I_PIKEY_IX   |    17 |       |     3   (0)| 00:00:01 |
    |  25 |  SORT GROUP BY                 |                                |     1 |    41 |            |          |
    |* 26 |   TABLE ACCESS BY INDEX ROWID  | SYS63339_TABL_XML_I_PATH_TABLE |     1 |    41 |     4   (0)| 00:00:01 |
    |* 27 |    INDEX RANGE SCAN            | SYS63339_TABL_XML_I_PIKEY_IX   |     1 |       |     3   (0)| 00:00:01 |
    |  28 |  SORT GROUP BY                 |                                |     1 |    41 |            |          |
    |* 29 |   TABLE ACCESS BY INDEX ROWID  | SYS63339_TABL_XML_I_PATH_TABLE |     8 |   328 |     4   (0)| 00:00:01 |
    |* 30 |    INDEX RANGE SCAN            | SYS63339_TABL_XML_I_PIKEY_IX   |     8 |       |     3   (0)| 00:00:01 |
    |  31 |  SORT GROUP BY                 |                                |     1 |    41 |            |          |
    |* 32 |   TABLE ACCESS BY INDEX ROWID  | SYS63339_TABL_XML_I_PATH_TABLE |     1 |    41 |     4   (0)| 00:00:01 |
    |* 33 |    INDEX RANGE SCAN            | SYS63339_TABL_XML_I_PIKEY_IX   |     1 |       |     3   (0)| 00:00:01 |
    |  34 |  SORT GROUP BY                 |                                |     1 |    41 |            |          |
    |* 35 |   TABLE ACCESS BY INDEX ROWID  | SYS63339_TABL_XML_I_PATH_TABLE |    17 |   697 |     5   (0)| 00:00:01 |
    |* 36 |    INDEX RANGE SCAN            | SYS63339_TABL_XML_I_PIKEY_IX   |    17 |       |     3   (0)| 00:00:01 |
    |* 37 |  FILTER                        |                                |       |       |            |          |
    |  38 |   NESTED LOOPS                 |                                |    15 | 23880 |    31   (0)| 00:00:01 |
    |  39 |    TABLE ACCESS BY INDEX ROWID | TABLENAME_SC                   |    15 |  1350 |    16   (0)| 00:00:01 |
    |* 40 |     INDEX RANGE SCAN DESCENDING| TABLENAME_SC_SUB_IX            |    15 |       |     3   (0)| 00:00:01 |
    |  41 |    TABLE ACCESS BY USER ROWID  | TABLENAME                      |     1 |  1502 |     1   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - filter(SYS_XMLI_LOC_ISNODE("SYS_P1"."LOCATOR")=1)
       3 - access("SYS_P1"."RID"=:B1 AND "SYS_P1"."PATHID"=HEXTORAW('509D') )
       5 - filter(SYS_XMLI_LOC_ISNODE("SYS_P3"."LOCATOR")=1)
       6 - access("SYS_P3"."RID"=:B1 AND "SYS_P3"."PATHID"=HEXTORAW('4FDE') )
       8 - filter(SYS_XMLI_LOC_ISNODE("SYS_P5"."LOCATOR")=1)
       9 - access("SYS_P5"."RID"=:B1 AND "SYS_P5"."PATHID"=HEXTORAW('7129') )
      11 - filter(SYS_XMLI_LOC_ISNODE("SYS_P7"."LOCATOR")=1)
      12 - access("SYS_P7"."RID"=:B1 AND "SYS_P7"."PATHID"=HEXTORAW('73C0') )
      14 - filter(SYS_XMLI_LOC_ISNODE("SYS_P9"."LOCATOR")=1)
      15 - access("SYS_P9"."RID"=:B1 AND "SYS_P9"."PATHID"=HEXTORAW('3092') )
      17 - filter(SYS_XMLI_LOC_ISNODE("SYS_P11"."LOCATOR")=1)
      18 - access("SYS_P11"."RID"=:B1 AND "SYS_P11"."PATHID"=HEXTORAW('30AA') )
      20 - filter(SYS_XMLI_LOC_ISNODE("SYS_P13"."LOCATOR")=1)
      21 - access("SYS_P13"."RID"=:B1 AND "SYS_P13"."PATHID"=HEXTORAW('3415') )
      23 - filter(SYS_XMLI_LOC_ISNODE("SYS_P15"."LOCATOR")=1)
      24 - access("SYS_P15"."RID"=:B1 AND "SYS_P15"."PATHID"=HEXTORAW('4972') )
      26 - filter(SYS_XMLI_LOC_ISNODE("SYS_P17"."LOCATOR")=1)
      27 - access("SYS_P17"."RID"=:B1 AND "SYS_P17"."PATHID"=HEXTORAW('745F') )
      29 - filter(SYS_XMLI_LOC_ISNODE("SYS_P19"."LOCATOR")=1)
      30 - access("SYS_P19"."RID"=:B1 AND "SYS_P19"."PATHID"=HEXTORAW('6BA9') )
      32 - filter(SYS_XMLI_LOC_ISNODE("SYS_P21"."LOCATOR")=1)
      33 - access("SYS_P21"."RID"=:B1 AND "SYS_P21"."PATHID"=HEXTORAW('62DB') )
      35 - filter(SYS_XMLI_LOC_ISNODE("SYS_P23"."LOCATOR")=1)
      36 - access("SYS_P23"."RID"=:B1 AND "SYS_P23"."PATHID"=HEXTORAW('1FD9') )
      37 - filter(SYSDATE@!-500<=SYSDATE@!-50)
      40 - access("SYS_SXI_0"."ORGANIZATION_ID"=6 AND "SYS_SXI_0"."IS_SENDER"=1 AND
                  "SYS_SXI_0"."CREATION_TIME">=SYSDATE@!-500 AND "SYS_SXI_0"."CREATION_TIME"<=SYSDATE@!-50)
    Note
       - Unoptimized XML construct detected (enable XMLOptimizationCheck for more information)Removing all XmlQueries from the SELECT and adding 1 of them to the XmlTable in the FROM (full table scan, takes 25 seconds to complete):
    | Id  | Operation                    | Name                           | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT             |                                |  1522 |  2232K| 15515   (3)| 00:03:07 |
    |   1 |  TABLE ACCESS BY INDEX ROWID | TABLENAME_SC                   |     1 |    21 |     2   (0)| 00:00:01 |
    |*  2 |   INDEX RANGE SCAN           | SYS63339_63348_RID_IDX         |     1 |       |     1   (0)| 00:00:01 |
    |   3 |  TABLE ACCESS BY INDEX ROWID | TABLENAME_SC                   |     1 |    32 |     2   (0)| 00:00:01 |
    |*  4 |   INDEX RANGE SCAN           | SYS63339_63348_RID_IDX         |     1 |       |     1   (0)| 00:00:01 |
    |   5 |  TABLE ACCESS BY INDEX ROWID | TABLENAME_SC                   |     1 |    23 |     2   (0)| 00:00:01 |
    |*  6 |   INDEX RANGE SCAN           | SYS63339_63348_RID_IDX         |     1 |       |     1   (0)| 00:00:01 |
    |   7 |  TABLE ACCESS BY INDEX ROWID | TABLENAME_SC                   |     1 |    27 |     2   (0)| 00:00:01 |
    |*  8 |   INDEX RANGE SCAN           | SYS63339_63348_RID_IDX         |     1 |       |     1   (0)| 00:00:01 |
    |   9 |  TABLE ACCESS BY INDEX ROWID | TABLENAME_SC                   |     1 |    18 |     2   (0)| 00:00:01 |
    |* 10 |   INDEX RANGE SCAN           | SYS63339_63348_RID_IDX         |     1 |       |     1   (0)| 00:00:01 |
    |  11 |  TABLE ACCESS BY INDEX ROWID | TABLENAME_SC                   |     1 |    13 |     2   (0)| 00:00:01 |
    |* 12 |   INDEX RANGE SCAN           | SYS63339_63348_RID_IDX         |     1 |       |     1   (0)| 00:00:01 |
    |* 13 |  TABLE ACCESS BY INDEX ROWID | SYS63339_TABL_XML_I_PATH_TABLE |     1 |    37 |     4   (0)| 00:00:01 |
    |* 14 |   INDEX RANGE SCAN           | SYS63339_TABL_XML_I_PIKEY_IX   |    17 |       |     3   (0)| 00:00:01 |
    |* 15 |  FILTER                      |                                |       |       |            |          |
    |* 16 |   TABLE ACCESS FULL          | TABLENAME                      |  1522 |  2232K|  9423   (4)| 00:01:54 |
    |  17 |   TABLE ACCESS BY INDEX ROWID| TABLENAME_SC                   |     1 |    13 |     2   (0)| 00:00:01 |
    |* 18 |    INDEX RANGE SCAN          | SYS63339_63348_RID_IDX         |     1 |       |     1   (0)| 00:00:01 |
    |  19 |   TABLE ACCESS BY INDEX ROWID| TABLENAME_SC                   |     1 |    13 |     2   (0)| 00:00:01 |
    |* 20 |    INDEX RANGE SCAN          | SYS63339_63348_RID_IDX         |     1 |       |     1   (0)| 00:00:01 |
    |  21 |   TABLE ACCESS BY INDEX ROWID| TABLENAME_SC                   |     1 |    21 |     2   (0)| 00:00:01 |
    |* 22 |    INDEX RANGE SCAN          | SYS63339_63348_RID_IDX         |     1 |       |     1   (0)| 00:00:01 |
    |  23 |   TABLE ACCESS BY INDEX ROWID| TABLENAME_SC                   |     1 |    21 |     2   (0)| 00:00:01 |
    |* 24 |    INDEX RANGE SCAN          | SYS63339_63348_RID_IDX         |     1 |       |     1   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - access("SYS_SXI_7"."RID"=:B1)
       4 - access("SYS_SXI_6"."RID"=:B1)
       6 - access("SYS_SXI_5"."RID"=:B1)
       8 - access("SYS_SXI_4"."RID"=:B1)
      10 - access("SYS_SXI_3"."RID"=:B1)
      12 - access("SYS_SXI_2"."RID"=:B1)
      13 - filter(SYS_XMLI_LOC_ISTEXT("SYS_P0"."LOCATOR","SYS_P0"."PATHID")=1)
      14 - access("SYS_P0"."RID"=:B1 AND "SYS_P0"."PATHID"=HEXTORAW('509D') )
      15 - filter(CAST(TO_NUMBER(SYS_XQ_UPKXML2SQL(SYS_XQEXVAL( (SELECT
                  SYS_XQ_PKSQL2XML("SYS_SXI_11"."ORGANIZATION_ID",2,4,2) FROM "USERN"."TABLENAME_SC" "SYS_SXI_11" WHERE
                  "SYS_SXI_11"."RID"=:B1),0,0,54525952,0),50,1,2)) AS integer )=6 AND
                  CAST(TO_NUMBER(SYS_XQ_UPKXML2SQL(SYS_XQEXVAL( (SELECT SYS_XQ_PKSQL2XML("SYS_SXI_10"."IS_SENDER",2,4,2)
                  FROM "USERN"."TABLENAME_SC" "SYS_SXI_10" WHERE "SYS_SXI_10"."RID"=:B2),0,0,54525952,0),50,1,2)) AS
                  number(1) )=1 AND CAST(TO_TIMESTAMP(SYS_XQ_UPKXML2SQL(SYS_XQEXVAL( (SELECT
                  SYS_XQ_PKSQL2XML("SYS_SXI_9"."CREATION_TIME",180,8,2) FROM "USERN"."TABLENAME_SC" "SYS_SXI_9" WHERE
                  "SYS_SXI_9"."RID"=:B3),0,0,20971520,0),50,1,2),'SYYYY-MM-DD"T"HH24:MI:SSXFF') AS timestamp
                  )>=SYSDATE@!-300 AND CAST(TO_TIMESTAMP(SYS_XQ_UPKXML2SQL(SYS_XQEXVAL( (SELECT
                  SYS_XQ_PKSQL2XML("SYS_SXI_8"."CREATION_TIME",180,8,2) FROM "USERN"."TABLENAME_SC" "SYS_SXI_8" WHERE
                  "SYS_SXI_8"."RID"=:B4),0,0,20971520,0),50,1,2),'SYYYY-MM-DD"T"HH24:MI:SSXFF') AS timestamp
                  )<=SYSDATE@!-200)
      16 - filter(EXISTSNODE(SYS_MAKEXML(0,"SYS_ALIAS_11"."SYS_NC00003$"),'/oraxq_defpfx:element1','
                  xmlns:oraxq_defpfx="http://www.example.com/myproject/schema/namespace2"')=1)
      18 - access("SYS_SXI_11"."RID"=:B1)
      20 - access("SYS_SXI_10"."RID"=:B1)
      22 - access("SYS_SXI_9"."RID"=:B1)
      24 - access("SYS_SXI_8"."RID"=:B1)Index creation script:
    CREATE INDEX tabl_xml_ix
      ON tablename(xml)
      INDEXTYPE IS XDB.XMLIndex
      PARAMETERS('
        PATHS (INCLUDE (/element1/common:header/common:kind
    /element1/common:element1Header/common:referenceNumber
    /element1/common:element1Header/common:reference
    /element1/common:element1Header/common:organization/common:organizationId
    /element1/common:element1Header/common:status/common:cStatus
    /element1/common:element1Header/common:status/common:isOpen
    /element1/common:element1Header/common:status/common:processStep
    /element1/common:element1Header/common:status/common:lrrm
    /element1/common:element1Header/common:status/common:sent
    /element1/common:element1Header/common:status/common:success
    /element1/common:element1Header/common:creationTime)
                       NAMESPACE MAPPING (xmlns="http://www.example.com/myproject/schema/namespace2"
                            xmlns:common="http://www.example.com/myproject/schema/common"))');
    ALTER INDEX tabl_xml_ix
    PARAMETERS ('PATHS (INCLUDE ADD (/element1/e/referenceCode
    /element1/e/header/sNumber
    /element1/element2/name
    /element1/element3/name
    /element1/element4/id
    /element1/submission/deferred
    /element1/common:element1Header/common:organization/common:pNumber
    /element1/e/iNumber
    /element1/header/status/aseod
    /element1/common:element1Header/common:isSender
    /element1/ror/gcor
    /element1/header/status/eventReportReceived
    /element1/pod/eNumber)
                       NAMESPACE MAPPING (xmlns="http://www.example.com/myproject/schema/namespace2"
                            xmlns:common="http://www.example.com/myproject/schema/common"))');
    BEGIN
      DBMS_XMLINDEX.registerParameter(
        'tablename_add_sc','ADD_GROUP GROUP tablename_group
    XMLTABLE tablename_sc
    XMLNAMESPACES(
    DEFAULT ''http://www.example.com/myproject/schema/namespace2'',
    ''http://www.example.com/myproject/schema/common'' AS "common"
    ''/element1''
    COLUMNS
    is_sender NUMBER(1) path ''common:element1Header/common:isSender/text()'',
    creation_time TIMESTAMP PATH ''common:element1Header/common:creationTime/text()'',
    rn VARCHAR2(22 CHAR) PATH ''common:element1Header/common:referenceNumber/text()'',
    rc VARCHAR2(21) PATH ''e/referenceCode/text()'',
    reference VARCHAR2(35 CHAR) PATH ''common:element1Header/common:reference/text()'',
    i_nr VARCHAR2(35 CHAR) PATH ''e/iNumber/text()'',
    p_nr VARCHAR2(32) PATH ''common:element1Header/common:organization/common:pNumber/text()'',
    pod_e_nr VARCHAR2(13) PATH ''pod/eNumber/text()'',
    d_id VARCHAR2(16) PATH ''element4/id/text()'',
    organization_id INTEGER PATH ''common:element1Header/common:organization/common:organizationId/text()'',
    sequence_number INTEGER PATH ''e/eHeader/sequenceNumber/text()''
    END;
    ALTER INDEX tabl_xml_ix PARAMETERS('PARAM tablename_add_sc');
    create index tablename_sc_rn_ix on tablename_sc(rn);
    create index tablename_sc_time_ix on tablename_sc(creation_time);
    create index tablename_sc_sub_ix on tablename_sc (organization_id, is_sender, creation_time);Edited by: Michiel Weggen on Apr 11, 2012 2:02 AM Reason: Forgot secondary indexes.
    Edited by: Michiel Weggen on Apr 11, 2012 5:51 AM: changed path of d_id to element4/id in the structured component

  • APEX and Primary Keys

    Hello:
    I ran into a situation where we have a table with no primary key set. When I tried to create a form, APEX told me that a primary key must be set in order to run reports. This makes complete sense. No issue here. For some of our tables, we can set the primary key.
    The issue we have is that some of our tables are using "natural primary keys". We have tables where more than one column is designated as a primary key. For example, if I have a table with patient_id, organization_id, insurance_id, and expiration date. In order for a record to be unique in this table both the organization_id and insurance_id are set as primary keys.
    If I attempt to create a form in APEX using these tables which have more than one primary key, how will APEX know that there are more than one primary key?
    Thanks for the input.

    In that case you could also use rowid and instead of views. I have an example showing how
    this can be done:
    http://apex.oracle.com/pls/otn/f?p=31517:157
    Denes Kubicek
    http://deneskubicek.blogspot.com/
    http://www.opal-consulting.de/training
    http://apex.oracle.com/pls/otn/f?p=31517:1
    -------------------------------------------------------------------

  • Problem with a query incl. MTL_ONHAND_QUANTITIES_DETAIL and mtl_system_b

    Hi,
    The following query is giving me a list of products that have some quantity on stock. What I need to do, is alter the query in the way that is also shows products with 0 (zero) quantity on stock.
    What is the best way to approach this?
    p.s. I'm a novice in pl/sql
    select moh.inventory_item_id,
    moh.organization_id organization_id,
    sum(moh.transaction_quantity)
    ,(sum(moh.transaction_quantity) * pol.unit_price)
    ,moh.subinventory_code
    ,il.segment1
    ,il.description
    ,moh.is_consigned
    ,pol.unit_price
    ,poh.currency_code
    ,v.vendor_name
    ,i.description
    from MTL_ONHAND_QUANTITIES_DETAIL moh,
    cst_item_costs ic,
    mtl_item_locations il,
    PO_HEADERS_ALL poh,
    PO_LINES_ALL pol,
    po_vendors v,
    po_vendor_sites_all vs,
    mtl_system_items_b i
    where moh.inventory_item_id = ic.inventory_item_id
    and moh.organization_id = ic.organization_id
    and moh.organization_id = il.organization_id(+)
    and moh.subinventory_code=il.subinventory_code(+)
    and moh.locator_id = il.inventory_location_id(+)
    and moh.is_consigned = '1'
    and poh.po_header_id = pol.po_header_id
    and pol.item_id=moh.inventory_item_id
    and moh.owning_organization_id is not null
    and moh.owning_tp_type <> '2'
    and moh.owning_organization_id=vs.vendor_site_id
    and v.vendor_id=vs.vendor_id
    and poh.type_lookup_code like 'BLANKET%'
    and i.inventory_item_id(+) = moh.inventory_item_id
    and i.organization_id(+) =moh.organization_id
    group by moh.inventory_item_id,
    moh.organization_id,
    moh.subinventory_code,
    ic.item_cost,
    il.segment1,
    il.description,
    moh.is_consigned,
    pol.unit_price,
    poh.currency_code,
    v.vendor_name,
    i.description

    Perhaps, structured using ANSI syntax, you may be able to see more clearly where you require your outer join(s) to achieve what you want...
    select moh.inventory_item_id
          ,moh.organization_id organization_id
          ,sum(moh.transaction_quantity)
          ,(sum(moh.transaction_quantity) * pol.unit_price)
          ,moh.subinventory_code
          ,il.segment1
          ,il.description
          ,moh.is_consigned
          ,pol.unit_price
          ,poh.currency_code
          ,v.vendor_name
          ,i.description
    from   MTL_ONHAND_QUANTITIES_DETAIL moh
                      JOIN cst_item_costs ic      ON (moh.inventory_item_id = ic.inventory_item_id
                                                 and  moh.organization_id = ic.organization_id)
           LEFT OUTER JOIN mtl_item_locations il  ON (moh.organization_id = il.organization_id
                                                 and  moh.subinventory_code = il.subinventory_code
                                                 and  moh.locator_id = il.inventory_location_id)
                      JOIN PO_HEADERS_ALL poh     ON (poh.po_header_id = pol.po_header_id)
                      JOIN PO_LINES_ALL pol       ON (pol.item_id = moh.inventory_item_id)
                      JOIN po_vendor_sites_all vs ON (moh.owning_organization_id = vs.vendor_site_id)
                      JOIN po_vendors v           ON (v.vendor_id=vs.vendor_id)
           LEFT OUTER JOIN mtl_system_items_b i   ON (i.inventory_item_id = moh.inventory_item_id
                                                 and  i.organization_id = moh.organization_id)
    where moh.is_consigned = '1'
    and   moh.owning_organization_id is not null
    and   moh.owning_tp_type '2'
    and   poh.type_lookup_code like 'BLANKET%'
    group by moh.inventory_item_id
         ,moh.organization_id
         ,moh.subinventory_code
         ,ic.item_cost
         ,il.segment1
         ,il.description
         ,moh.is_consigned
         ,pol.unit_price
         ,poh.currency_code
         ,v.vendor_name
         ,i.descriptionAs you haven't provided any more information (table structures, database version, example data, expected output etc.) it's not easy for us to tell exactly what constitutes a "product".
    p.s. if you want to keep formatting of code and data on the forum, put the tag {noformat}{noformat} before it and also the same {noformat}{noformat} tag after it.

  • How to make relation between  gl_je_lines  and wip_transaction_accounts

    I try to write script to make relation between GL and WIP, wip_transaction_accounts and mtl_material_transactions
    1.
    SELECT
    (SELECT meaning
    FROM mfg_lookups
    WHERE lookup_type = 'WIP_TRANSACTION_TYPE'
    AND lookup_code =
    (SELECT TRANSACTION_TYPE
    FROM wip_transactions
    WHERE transaction_id = wta.transaction_id
    ) "Transaction Type" ,
    gjb.NAME "Journal Batch Name" ,
    gjh.NAME "Journal Name" ,
    gjh.je_source "JE Source" ,
    gjh.je_category "JE Category" ,
    glp.period_num "GL Month" ,
    glp.period_year "GL Year" ,
    gjh.default_effective_date "GL Date" ,
    NVL(gje.accounted_dr,0) -NVL( gje.accounted_cr,0) "GL Line Amount" ,
    gje.description "GL Line Description" ,
    (SELECT organization_code
    FROM mtl_parameters
    WHERE organization_id = wta.organization_id
    ) "ORG Name" ,
    NULL "Vendor/Customer Name" ,
    NULL "SO/PO Number" ,
    NULL "Reference Number" ,
    NULL "AP/AR Invoice Number" ,
    NULL "Doc Sequence Value" ,
    NULL "Invoice Type Lookup Code" ,
    NULL "Check Number" ,
    NULL "Line Type" ,
    NULL "Category" ,
    NVL (wta.base_transaction_value, 0) "Transaction Amt" ,
    NULL "AR/PO Receipt Number" ,
    NULL "Applied Invoice Number" ,
    (SELECT a.segment1
    FROM mtl_system_items_b a ,
    wip_discrete_jobs b
    WHERE a.inventory_item_id = b.primary_item_id
    AND a.organization_id = b.organization_id
    AND b.wip_entity_id = wta.wip_entity_id
    AND b.organization_id = wta.organization_id
    ) "Item Name" ,
    gcc.segment1 "Company" ,
    gcc.segment2 "Department" ,
    gcc.segment3 "Account" ,
    (SELECT description
    FROM fnd_flex_values_vl fnd
    WHERE flex_value_set_id = 1009707
    AND TO_CHAR (fnd.flex_value) = gcc.segment3
    ) "Account Description" ,
    gcc.segment4 "Intercompany" ,
    NULL "JE Category Description" ,
    NULL "AP Invoice Line Description"
    TRUNC (wta.transaction_date) "JE Creation/Inv Trans Date" ,
    NULL "JE Created By" ,
    NULL "Reversal Flag" ,
    NULL "Reason Code" ,
    NULL "Subinventory Name" ,
    wta.primary_quantity "Quantity" ,
    NVL (wta.base_transaction_value, 0) "Value" ,
    gje.context ,
    gje.attribute1 ,
    gje.attribute2 ,
    gje.attribute3 ,
    gje.attribute4 ,
    gje.attribute5 ,
    DECODE(gjh.status,'P','Posted','U','Unposted','Error') "Post Status"
    FROM gl_je_lines gje ,
    gl_je_headers gjh ,
    gl_je_batches gjb ,
    wip_transaction_accounts wta ,
    gl_code_combinations gcc ,
    gl_periods glp
    WHERE 1 =1
    AND gje.je_header_id = gjh.je_header_id
    AND gjh.je_batch_id = gjb.je_batch_id
    AND UPPER (gjh.je_source) = 'INVENTORY'
    AND gcc.code_combination_id = gje.code_combination_id
    AND wta.reference_account = gje.code_combination_id
    AND TRUNC(wta.transaction_date) BETWEEN glp.START_DATE AND glp.END_DATE
    AND gje.reference_1 = wta.gl_batch_id
    AND gje.gl_sl_link_table = 'WTA'
    AND glp.period_name = gjh.period_name
    AND glp.period_set_name = 'OVT_US_CAL'
    ==
    2.
    SELECT mtt.transaction_type_name "Transaction Type" ,to_char(mmt.transaction_date,'mm/dd/yyyy hh:mi:ss') as teas, mta.transaction_id,mta.organization_id, mmt.organization_id,
    gjb.NAME "Journal Batch Name" ,
    gjh.NAME "Journal Name" ,
    gjh.je_source "JE Source" ,
    gjh.je_category "JE Category" ,
    glp.period_num "GL Month" ,
    glp.period_year "GL Year" ,
    gjh.default_effective_date "GL Date" ,
    NVL(gje.accounted_dr,0) - NVL(gje.accounted_cr,0) "GL Line Amount" ,
    gje.description "GL Line Description" ,
    (SELECT organization_code
    FROM mtl_parameters
    WHERE organization_id = mta.organization_id
    ) "ORG Name" ,
    NULL "Vendor/Customer Name" ,
    NULL "SO/PO Number" ,
    mmt.TRANSACTION_REFERENCE "Reference Number" ,
    NULL "AP/AR Invoice Number" ,
    NULL "Doc Sequence Value" ,
    NULL "Invoice Type Lookup Code" ,
    NULL "Check Number" ,
    NULL "Line Type" ,
    NULL "Category" ,
    NVL (mta.base_transaction_value, 0) "Transaction Amt" ,
    NULL "AR/PO Receipt Number" ,
    NULL "Applied Invoice Number" ,
    (SELECT segment1
    FROM mtl_system_items_b
    WHERE inventory_item_id = mmt.inventory_item_id
    AND organization_id = mmt.organization_id
    ) "Item Name" ,
    gcc.segment1 "Company" ,
    gcc.segment2 "Department" ,
    gcc.segment3 "Account" ,
    (SELECT description
    FROM fnd_flex_values_vl fnd
    WHERE flex_value_set_id = 1009707
    AND TO_CHAR (fnd.flex_value) = gcc.segment3
    ) "Account Description" ,
    gcc.segment4 "Intercompany" ,
    NULL "JE Category Description" ,
    NULL "AP Invoice Line Description"
    TRUNC (mta.transaction_date) "JE Creation/Inv Trans Date" ,
    NULL "JE Created By" ,
    NULL "Reversal Flag" ,
    (SELECT MGD.SEGMENT1
    FROM MTL_GENERIC_DISPOSITIONS MGD,
    MTL_MATERIAL_TRANSACTIONS MMTT
    WHERE MGD.DISPOSITION_ID = MMTT.TRANSACTION_SOURCE_ID
    AND MMTT.TRANSACTION_SOURCE_TYPE_ID = 6
    AND MGD.ORGANIZATION_ID = MMTT.ORGANIZATION_ID
    AND MMTT.TRANSACTION_ID = MMT.TRANSACTION_ID
    ) "Reason Code" ,
    mmt.SUBINVENTORY_CODE "Subinventory Name" ,
    mta.primary_quantity "Quantity" ,
    NVL (mta.base_transaction_value, 0) "Value" ,
    gje.context ,
    gje.attribute1 ,
    gje.attribute2 ,
    gje.attribute3 ,
    gje.attribute4 ,
    gje.attribute5 ,
    DECODE(gjh.status,'P','Posted','U','Unposted','Error') "Post Status" -
    FROM gl_je_lines gje ,
    gl_je_headers gjh ,
    gl_je_batches gjb ,
    mtl_transaction_accounts mta ,
    mtl_material_transactions mmt ,
    mtl_transaction_types mtt ,
    gl_code_combinations gcc ,
    gl_periods glp
    WHERE 1 =1
    AND mta.transaction_id = mmt.transaction_id
    AND gje.je_header_id = gjh.je_header_id
    AND gjh.je_batch_id = gjb.je_batch_id
    AND UPPER (gjh.je_source) = 'INVENTORY'
    AND gcc.code_combination_id = gje.code_combination_id
    AND mta.reference_account = gje.code_combination_id
    AND TRUNC(mta.transaction_date) BETWEEN glp.START_DATE AND glp.END_DATE
    and mta.request_id=mmt.request_id
    and mta.inventory_item_id=mmt.inventory_item_id
    AND gje.reference_1 = mta.gl_batch_id
    AND gje.gl_sl_link_table = 'MTA'
    AND mtt.transaction_type_id = mmt.transaction_type_id
    AND glp.period_name = gjh.period_name
    AND glp.period_set_name = 'OVT_US_CAL'
    When gl_je_lines have multiple line this script on the same transaction_id it will get wrong information. By setup all wip_transaction_accounts.GL_SL_Lind_id and mtl_transaction_accounts.GL_SL_Lind_id is null
    Anyone can help?

    Hello.
    How are you reaching the inconsistencies ? Are you comparing report's results?
    Octavio

  • Service Contract header, line level and party data report.

    Using 11.5.9.
    In Service Contracts Module, trying to create a query that extracts header data, party data (role and name) and the name of the service from the lines/account tab, ie Full Service, Gold Service etc...
    Created query that retrieve Service Contract header and party data, but when I try to join to mtl_system_items_b, I am getting a product description instead of the name of the service. I also include code below this that pulls in the lines from the lines/account tab which captures line 1.1 and has the correct service name. Note this code does not have the header data and party data built into it, but I am willing to modify either piece of code to create the need join and get the data returned.
    SELECT
    distinct (okhb.contract_number)     contract_number,
    nvl(okhb.contract_number_modifier,'-') contract_modifier,
    okhb.sts_code,
    okhb.start_date     start_date,
    okhb.end_date          end_date,
    okprb.rle_code ROLE,
    msib.description,
    (msib.segment1) item_number,
    hp.party_name
    FROM
    hz_party_sites ps,
    hz_party_sites ps9,
    hz_locations l,
    hz_locations l9,
    hz_cust_acct_sites_all ca,
    hz_cust_acct_sites_all ca9,
    hz_cust_site_uses_all cs,
    hz_cust_site_uses_all cs9,
    hz_parties hp,
    hz_parties hp9,
    okc_rules_b orb,
    okc_rules_b orb9,
    okc_rule_groups_b ogb,
    okc_k_headers_b okhb,
    okc_k_party_roles_b okprb,
    okc_k_lines_b oklb,
    ra_customer_Trx_all rcta,
    mtl_system_items_b msib
    WHERE
    PS.LOCATION_ID = L.LOCATION_ID AND
    ps9.location_id = l9.location_id and
    L.CONTENT_SOURCE_TYPE = 'USER_ENTERED' AND
    l9.content_source_type = 'USER_ENTERED' and
    PS.PARTY_SITE_ID = CA.PARTY_SITE_ID AND
    ps9.party_site_id = ca9.party_site_id and
    CA.CUST_ACCT_SITE_ID = CS.CUST_ACCT_SITE_ID and
    ca9.cust_acct_site_id = cs9.cust_acct_site_id and
    ps9.party_id = hp9.party_id and
    ps.party_id = hp.party_id and
    cs.site_use_id=orb.object1_id1 and
    cs9.site_use_id = orb9.object1_id1 and
    orb.jtot_object1_code in ('OKX_SHIPTO'/*,'OKX_BILLTO'*/) and
    orb9.jtot_object1_code = 'OKX_BILLTO' and
    orb.rgp_id = ogb.id and
    orb9.rgp_id = ogb.id and
    okhb.id = okprb.chr_id and
    msib.inventory_item_id = orb.object1_id1 and
    okhb.contract_number = rcta.interface_header_attribute1 and
    nvl(okhb.contract_number_modifier,'-') = nvl(rcta.interface_header_attribute2,0) and
    ogb.chr_id = okhb.id and
    okhb.sts_code = 'ACTIVE' and
    okhb.contract_number in ('VO-7001','VO-7078') and
    okprb.rle_code in ('CUSTOMER','END_USER')
    --oklb.line_number||'.'||oklbs.line_number = '1.1'
    order by okhb.contract_number;
    select
         to_char(oklb.line_number)||'.'||to_char(oklbs.line_number) subline_number,
    okhb.contract_number,
         okhb.sts_code,
    (msi.segment1) item_number,
         msi.description,
         okcis.number_of_items,
    round(months_between(element.date_completed , element.date_start))     billable_days,
         oklbs.start_date          start_date,
         oklbs.end_date          end_date,
         to_date(oklbs.attribute1, 'YYYY/MM/DD HH24:MI:SS')          warranty_start_date,
         to_date(oklbs.attribute2, 'YYYY/MM/DD HH24:MI:SS')          warranty_end_date,
         oklbs.attribute4 sales_order
    from oks_level_elements_v element,
    okc_rules_v rule,     
    okc_rule_groups_v grp,
    oks_bill_cont_lines_v      obcl,
         okc_k_lines_v          oklbs,
         okc_k_items_v               okcis,
         mtl_system_items_vl     msi,
         okc_k_items_v               okci,
         okc_k_lines_v           oklb,
         okc_k_headers_v          okhb,
    OKS_BILL_TRANSACTIONS_V obtrx
    where trunc(element.date_start) = trunc(obcl.date_billed_from) and
    rule.id = element.rul_id and
    rule.rgp_id = grp.id and
    grp.rgp_type = 'KRG' and
    grp.rgd_code = 'SVC_K' and
    grp.cle_id = oklbs.id and
    oklbs.cle_id     = oklb.id      and
         oklbs.lse_id     <> '2'      and
    okhb.sts_code = 'ACTIVE' and
         msi.inventory_item_id = okci.object1_id1 and
         msi.organization_id = 3      and
         okcis.cle_id          = oklbs.id and
         okci.cle_id          = oklb.id and
         obcl.cle_id           = oklb.id      and
         oklb.chr_id           = okhb.id      and
         obcl.btn_id = obtrx.id and
         okhb.contract_number like 'VO-7078' and
    oklb.line_number||'.'||oklbs.line_number = '1.1'
    order by okhb.contract_number, to_number(oklb.line_number), to_number(oklbs.line_number), oklbs.id;
    Code that pulls in the correct description as seen at line level in Service Contracts Module.
    OUTPUT of this query
    CONTRACT_NUMBER     STS_CODE     ITEM_NUMBER     DESCRIPTION
    XX-XXXX     ACTIVE     FULL SERVICE     FULL SERVICE

    I guess you are looking for coverage name. You need to add two more table to join with items like as in
    select inventory_item_id,a.name,a.item_description from mtl_system_Items_b c,okc_k_lines_tl a,okc_k_lines_b b
    where organization_id=<organization_id>
    and contract_item_type_code in ('SERVICE','WARRANTY')
    and a.id=b.id
    and b.chr_id=-1
    and coverage_schedule_id=b.id;
    Thanks
    Nagamohan

  • Item subinventory and procurement details table info

    hi all
    i have this requirement to take a report of all Spare parts and Other Inventory Organization Items, which are active, from ERP with the Last Procurement details. If the Procurement information is not available , the supplier name field should be blank. also to provide the UOM, inventory org and sub inventory information too against each item.
    i tried the following query from the INV abc super user responsibility
    select DESCRIPTION,segment1,segment2,segment3,PRIMARY_UOM_CODE,PRIMARY_UNIT_OF_MEASURE ,
    organization_id
    from mtl_system_items where
    rowid IN
    select rowid from
    select rowid, row_number() over (partition by SEGMENT1 order by null) rn from mtl_system_items
    where  INVENTORY_ITEM_STATUS_CODE ='Active'
    and    organization_id  IN (105,121)
    where rn = 1
    )kindly guide me to include subinventory information ,when the Master Item form is opened in tools there is Item Subinventory ,i am not
    able to get the table name related to item subinventory so i could include in my query
    also how do i get the procurement information
    kindly guide
    thanking in advance

    hi
    thank you very much for the helpful guidance
    could you please guide as to which column info has to be fetched in the query
    for the procurement details from the table po_lines_all
    also which column wud show the subinventory information ( i see source_subinventory
    and secondary_inventory) from the view MTL_ITEM_SUB_INVENTORIES_ALL_V
    with the joins you have suggested i have made th query below
    SELECT DISTINCT msi.description, msi.segment1, msi.segment2, msi.segment3, msi.primary_uom_code,misalv.SECONDARY_INVENTORY,misalv.source_subinventory,
    pov.vendor_name,
                   msi.primary_unit_of_measure, msi.organization_id
              FROM mtl_system_items msi,MTL_ITEM_SUB_INVENTORIES_ALL_V misalv, po_lines_all pla,po_headers_all pha,po_vendors pov
             WHERE msi.inventory_item_id=misalv.inventory_item_id and
               msi.inventory_item_id= pla.item_id and
               pla.po_header_id=pha.po_header_id and
               pha.vendor_id=pov.vendor_id and
                msi.organization_id=misalv.organization_id and
               inventory_item_status_code = 'Active'
               AND msi.organization_id IN (105, 121)now this query has only 3586 reecords whereas the initial query you had posted had 7785 records
    i suppose the items without vendor name ,procuremnt details dont come up thts why the decrease in record count
    is it possible to show those items too which dont have subinventry,procurement,vendor info
    kindly guide
    thanking in advance

Maybe you are looking for

  • How to catch exception while validating the username and password in hbm

    Hi, I do want to set the username and password dynamically in hibernate.cfg.xml Here below is my configuration file. {code<hibernate-configuration>  <session-factory>         <property name="hibernate.bytecode.use_reflection_optimizer">false</propert

  • DVD capturing - What setting on Easy Setup?

    Hello, I'm caputuring video from my DVD player which is : connected RCA to a Canopus converter box : out firewire and into the Macbook. When I capture the video, I get the message saying "Audio/Video rate may not match sample..." after I'm finished c

  • Schedule line date is not updating in line with P.O confirmation.

    hi, when sales order created for individual requirements it automatically creates P.R and this P.R is converted to P.O. whenever this P.O is updated with confirmation category like acknowledgement or inbound delivery it should update Sales order sche

  • Connect two files to get back to the needed  info

    I had a program that reads from a text files number of lines, for example Daina/D loves/L /London and/A Italy/I Jack/J goes/G to/T the/T school/S every/E day/D And I remove everything before the delimiter to keeps just the Letters So the result will

  • Audio is out of sync when placed in the timeline!!!

    When I play a clip in the viewer, everything is fine, but when the clip is placed into the timeline and played in the canvas, the audio is out of sync by about half a second. I noticed that even when I view the sound waves, what I hear does not match