Skip to main content

Query to Get Item Onhand Quantity as on date

Item On-Hand Quantity For A Specific Date

 SELECT   qslt.organization_id, qslt.inventory_item_id, as_of_date_on_hand
  FROM   (  SELECT   organization_id,
                     inventory_item_id,
                     SUM (qty) AS as_of_date_on_hand
              FROM   (  SELECT   organization_id,
                                 inventory_item_id,
                                 SUM (transaction_quantity) qty
                          FROM   mtl_onhand_quantities_detail
                         WHERE   organization_id IN
                                       (SELECT   organization_id
                                          FROM   org_organization_definitions
                                         WHERE   operating_unit = p_ou
                                                 AND organization_id =
                                                       NVL (p_organization_id,
                                                            organization_id))
                      GROUP BY   organization_id, inventory_item_id
                      UNION
                        SELECT   m.organization_id,
                                 m.inventory_item_id,
                                 SUM (m.primary_quantity * -1) qty
                          FROM   mtl_material_transactions m,
                                 org_organization_definitions org
                         WHERE   m.organization_id =
                                    NVL (p_organization_id, m.organization_id)
                                 AND org.organization_id = m.organization_id
                                 AND TRUNC (m.transaction_date) > (p_as_on_date)
                                 AND org.operating_unit = p_ou
                      GROUP BY   m.organization_id, m.inventory_item_id)
          --having sum(qty) > 0
          GROUP BY   organization_id, inventory_item_id) qslt
 WHERE   as_of_date_on_hand > 0

Comments

Popular posts from this blog

API to Create & Update Price Adjustment and Order Lines

Important Tables: select header_id from oe_order_headers_all; select line_id from oe_order_lines_all; select list_header_id from qp_list_headers_all; select list_line_id from qp_list_lines; CREATE OR REPLACE PROCEDURE apps.xxapply_discount (p_header_id number) IS    v_api_version_number           number := 1;    v_return_status                varchar2 (2000);    v_msg_count                    number;    v_msg_data                     varchar2 (2000);    -- in variables --    v_header_rec                   oe_order_pub.header_rec_type;    v_line_tbl                     oe_order_pub.line_tbl_type;    v_action_request_tbl   ...

LDT Commands in Oracle Apps

 Oracle Applications (Oracle E-Business Suite) use Loader Data files (LDT files) for migrating application configurations and data between instances. What are LDT Files? LDT files are plain text files used by the FNDLOAD utility in Oracle E-Business Suite to upload or download data from the database. They are commonly used for migrating setups, such as concurrent programs, value sets, and lookups, across different environments. LDT Commands: 1.        Download Data to LDT File FNDLOAD apps/apps_pwd 0 Y DOWNLOAD $FND_TOP/patch/115/import/afcpprog.lct output_file.ldt FND_PROGRAM APPLICATION_SHORT_NAME="Application_Short_Name" CONCURRENT_PROGRAM_NAME="Program_Name" 2.        Upload Data from LDT File FNDLOAD apps/apps_pwd 0 Y UPLOAD $FND_TOP/patch/115/import/afcpprog.lct input_file.ldt Key Parameters apps/apps_pwd : The username and password for the Oracle Apps database. 0 Y...

Uninvoiced Receipts Query Oracle r12

Uninvoiced Receipts: SELECT   pha.segment1 po_number,          TO_CHAR (pha.creation_date, 'DD-MON-RRRR') po_date,          (SELECT   vendor_name             FROM   ap_suppliers ap            WHERE   ap.vendor_id = pha.vendor_id)             supplier_name,          pla.quantity,          pla.unit_price,          pla.quantity * pla.unit_price AS line_amount,          (SELECT   concatenated_segments             FROM   gl_code_combinations_kfv gcc            WHERE   gcc.code_combination_id = pda.code_combination_id)             charge_account,          rsh...