Monday, 27 May 2024

DML to Update Bill-To and Ship-To on Sale Order in Oracle APPS R12

We may use below DML if Ship-Confirm has not been done yet :


UPDATE
 oe_order_headers_all
SET    ship_to_org_id = (SELECT site_use_id
                         FROM   hz_cust_site_uses_all ship_su
                         WHERE  location = :P_SHIP_TO_LOCATION),
       invoice_to_org_id = (SELECT site_use_id
                            FROM   hz_cust_site_uses_all ship_su
                            WHERE  location = :P_BILL_TO_LOCATION)
WHERE  order_number = <ORDER_NUMBER>
       AND org_id = <ORG_ID>;

UPDATE oe_order_lines_all
SET    ship_to_org_id = (SELECT site_use_id
                         FROM   hz_cust_site_uses_all ship_su
                         WHERE  location = :P_SHIP_TO_LOCATION),
       invoice_to_org_id = (SELECT site_use_id
                            FROM   hz_cust_site_uses_all ship_su
                            WHERE  location = :P_BILL_TO_LOCATION)
WHERE  header_id = <HEADER_ID>
       AND org_id = <ORG_ID>;

UPDATE wsh_delivery_details
SET    ship_to_location_id = (SELECT hl.location_id
                              FROM   hz_cust_site_uses_all hcsu,
                                     hz_cust_acct_sites_all hcas,
                                     hz_party_sites hps,
                                     hz_locations hl
                              WHERE  1 = 1
                                     AND hps.location_id = hl.location_id
                                     AND hps.party_site_id = hcas.party_site_id
                                     AND hcas.cust_acct_site_id = hcsu.cust_acct_site_id
                                     AND hcsu.site_use_code = 'SHIP_TO'
                                     AND hcsu.location = :P_SHIP_TO_LOCATION),
       deliver_to_location_id = (SELECT hl.location_id
                                 FROM   hz_cust_site_uses_all hcsu,
                                        hz_cust_acct_sites_all hcas,
                                        hz_party_sites hps,
                                        hz_locations hl
                                 WHERE  1 = 1
                                        AND hps.location_id = hl.location_id
                                        AND hps.party_site_id = hcas.party_site_id
                                        AND hcas.cust_acct_site_id = hcsu.cust_acct_site_id
                                        AND hcsu.site_use_code = 'SHIP_TO'
                                        AND hcsu.location = :P_SHIP_TO_LOCATION),
       ship_to_site_use_id = (SELECT site_use_id
                              FROM   hz_cust_site_uses_all ship_su
                              WHERE  location = :P_SHIP_TO_LOCATION)
WHERE  source_line_id IN (SELECT line_id
                          FROM   oe_order_lines_all
                          WHERE  header_id = <HEADER_ID>                              AND org_id = <ORG_ID>);  

No comments:

Post a Comment