Customers in TCA Architecture in Release 12

Scope and Application
This note is intended for anyone who must  upgrade queries or customizations from 11i which refer to any of the following views or anyone who requires an understanding of the TCA architecture  to create new queries or customizations:
·                     RA_CUSTOMERS
·                     RA_ADDRESSES
·                     RA_SITE_USES
·                     RA_CONTACTS
·                     RA_CONTACT_ROLES
Projects Uptake of the TCA Architecture in Release 12

1. The TCA Architecture


The following sections describe the individual views that are being replaced by the TCA (HZ) tables along with a mapping of view columns to HZ table columns and the query conditions that should be used to retrieve them
2.1 RA_CUSTOMERS
·                     In the 11i architecture RA_CUSTOMERS is a synonym in the APPS schema which points to the view RA_HCUSTOMERS. 
·                     The source file for RA_HCUSTOMERS in 11i is archz.odf.
·                     The table below lists the corresponding HZ table and column for various columns in the current RA_CUSTOMERS view:

Column in RA_CUSTOMERS
Corresponding Table
Column
customer_name
hz_parties
substrb(party_name,1,50)
customer_id
hz_cust_accounts
cust_account_id
customer_number
hz_cust_accounts
account_number
status
hz_cust_accounts
status

·                     Source Tables:  HZ_PARTIES, HZ_CUST_ACCOUNTS
·                     Join Conditions:
HZ_CUST_ACCOUNTS..Party_Id = HZ_PARTIES.Party_Id

2.2 RA_ADDRESSES
·                     In the 11i architecture RA_ADDRESSES is a multi-org striped view based on RA_ADDRESSES_ALL.  RA_ADDRESSES_ALL is a synonym for the view RA_ADDRESSES_MORG.
·                     The source file for view RA_ADDRESSES_MORG in 11i is archz.odf.
·                     The table below lists the corresponding HZ table and column for various columns in the current RA_ADDRESSES view:
Column in RA_ADDRESSES
Corresponding Table
Column
address_id
hz_cust_acct_sites_all
cust_acct_site_id
status
hz_cust_acct_sites_all
status
address1
hz_locations
address1
address2
hz_locations
address2
address3
hz_locations
address3
address4
hz_locations
address4
city
hz_locations
city
state
hz_locations
state
postal_code
hz_locations
postal_code
county
hz_locations
county
country
hz_locations
country
language
hz_locations
language

·                     Source Tables:  HZ_PARTY_SITES, HZ_LOCATIONS, HZ_CUST_ACCT_SITES_ALL
·                     Join Conditions:
HZ_CUST_ACCT_SITES_ALL.party_site_id = HZ_PARTY_SITES.party_site_id 
HZ_LOCATIONS.location_id = HZ_PARTY_SITES.location_id

2.3 RA_SITE_USES
·                     In the 11i architecture RA_SITE_USES is a multi-org striped view based on RA_SITE_USES_ALL. RA_SITE_USES_ALL is a synonym for the view RA_SITE_USES_MORG.
·                     The source file for view RA_SITE_USES_MORG in 11i is archz.odf
·                      The table below lists the corresponding HZ table and column for various columns in the current RA_SITE_USES view:
Column in RA_SITE_USES
Corresponding Table
Column
site_use_id
hz_cust_site_uses
site_use_id
site_use_code
hz_cust_site_uses
site_use_code
status
hz_cust_site_uses
status
address_id
hz_cust_site_uses
cust_acct_site_id

·                     Source Tables:  HZ_CUST_SITE_USES
·                     Join Conditions:  none
2.4 RA_CONTACTS
·                     In the 11i architecture RA_CONTACTS is a synonym for the view RA_HCONTACTS
·                     The source file for view RA_HCONTACTS in 11i is archz.odf
·                     The table below lists the corresponding HZ table and column for various columns in the current RA_CONTACTS view:
Column in RA_CONTACTS
Corresponding Table
Column
contact_id
hz_cust_account_roles
cust_account_role_id
status
hz_cust_account_roles
status
customer_id
hz_cust_account_roles
cust_account_id
address_id
hz_cust_account_roles
cust_acct_site_id
first_name
hz_parties
substrb(person_first_name,1,40)
last_name
hz_parties
substrb(person_last_name,1,50)
·                     Source Tables: HZ_CUST_ACCOUNT_ROLES, HZ_PARTY_RELATIONSHIPS, HZ_PARTIES
·                     Join Conditions:
HZ_CUST_ACCOUNT_ROLES.party_id = HZ_PARTY_RELATIONSHIPS.party_id 
HZ_CUST_ACCOUNT_ROLES.role_type = 'CONTACT'
HZ_PARTIES.party_id = HZ_PARTY_RELATIONSHIPS.subject_id

2.5 RA_CONTACT_ROLES
·                     In the 11i architecture RA_CONTACT_ROLES is a synonym for the view RA_HCONTACT_ROLES
·                     The source file for view RA_HCONTACT_ROLES in 11i is archz.odf
·                     The table below lists the corresponding HZ table and column for various columns in the current RA_CONTACT_ROLES view:
Column in RA_CONTACT_ROLES
Corresponding Table
Column
contact_id
hz_role_responsibility
cust_account_role_id
usage_code
hz_role_responsibility
responsibility_type
primary_flag
hz_role_responsibility
primary_flag
·                     Source Tables: HZ_ROLE_RESPONSIBILITY
·                     Join Conditions:  none.
11i Table
R12 Change
ra_addresses_all
SELECT acct_site.cust_account_id customer_id,     acct_site.cust_acct_site_id address_id
FROM hz_party_sites party_site,
                 hz_loc_assignments loc_assign,
                 hz_locations loc,
                 hz_cust_acct_sites_all acct_site
           WHERE acct_site.party_site_id = party_site.party_site_id
             AND loc.location_id = party_site.location_id
             AND loc.location_id = loc_assign.location_id
             AND NVL (acct_site.org_id, -99) = NVL (loc_assign.org_id, -99)
ra_site_uses_all
SELECT site_use_id, LOCATION, attribute1
 FROM hz_cust_site_uses_all
ra_customers
SELECT cust_acct.cust_account_id customer_id,
                 SUBSTRB (party.party_name, 1, 50) customer_name,
                 cust_acct.account_number customer_number
            FROM hz_parties party, hz_cust_accounts cust_acct
           WHERE cust_acct.party_id = party.party_id


RA_ADDRESSES_ALL is obsolete table in Release 11.5.10 and Release 12. You can get the customer address information from the following tables in Release 12.

HZ_CUST_ACCT_SITES_ALL
HZ_PARTY_SITES
HZ_LOCATIONS

Here is the Linking information:

- HZ_CUST_ACCT_SITES_ALL & HZ_PARTY_SITES - Link column PARTY_SITE_ID
- HZ_PARTY_SITES & HZ_LOCATIONS - Link column is LOCATION_ID.

procure2pay cycle from backend

****************************************************************************
Summary of the below p2p from using.

1. To Insert Data into the staging Table.
2. after insert submit the import program"Import Standard Purchase Orders" to generate the po#.
3. after generating the po# need to approve.
4. after approving load the data in to rcv interface tables.
5. after loading into the rcv interface tables run the "Receiving Transaction Processor" program to generate receipt.
6. To generate the invoice run the concurrent program "Pay On Receipt AutoInvoice".
***************************************************************************

--1. To Insert Data into the staging Table

CREATE OR REPLACE PROCEDURE XX_TABLE_INSERT
AS
  lErrbuf  VARCHAR2(10);
  lRetcode NUMBER;
BEGIN
  INSERT
  INTO xx_po_header_stg
    (
      INTERFACE_HEADER_ID ,
      BATCH_ID ,
      ACTION ,
      ORG_ID ,
      DOCUMENT_TYPE_CODE ,
      CURRENCY_CODE ,
      AGENT_NAME ,
      VENDOR_NAME ,
      VENDOR_SITE_CODE ,
      SHIP_TO_LOCATION ,
      BILL_TO_LOCATION ,
      APPROVAL_STATUS ,
      FREIGHT_CARRIER ,
      FOB ,
      FREIGHT_TERMS
    )
    VALUES
    (
      po_headers_interface_s.NEXTVAL ,
      13 ,
      'ORIGINAL',
      204,
      'STANDARD',
      'USD',
      'Stock, Ms. Pat',
      '3M Health Care',
      'CORP HQ',
      'M1- Seattle Mfg',
      'V1- New York City',
      'APPROVED' ,
      'UPS',
      'Origin',
      'Due'
    );
  FND_FILE.PUT_LINE(FND_FILE.LOG,'DATA LOADED IN TO THE xx_po_header_stg STAGING TABLE');
  COMMIT;
  INSERT
  INTO xx_po_line_stg
    (
      interface_header_id ,
      interface_line_id ,
      LINE_NUM ,
      SHIPMENT_NUM ,
      LINE_TYPE ,
      ITEM ,
      ITEM_DESCRIPTION ,
      item_id ,
      UOM_CODE ,
      QUANTITY ,
      UNIT_PRICE ,
      SHIP_TO_ORGANIZATION_CODE ,
      SHIP_TO_LOCATION ,
      list_price_per_unit
    )
    VALUES
    (
      po_headers_interface_s.currval,
      po_lines_interface_s.nextval,
      1,
      2,
      'Goods',
      'AS54999',
      'Sentinel Standard Desktop - Rugged',
      2155,
      'Ea',
      10,
      120,
      'V1',
      'V1- New York City',
      45
    );
  FND_FILE.PUT_LINE(FND_FILE.LOG,'DATA LOADED IN TO THE xx_po_line_stg STAGING TABLE');
  COMMIT;
  --call the package for inserting the data from staging table to interface table
  XXAK_PO_IMP_PKG.XXAK_PO_IMP_PRC(lErrbuf,lRetcode);
  FND_FILE.PUT_LINE(FND_FILE.LOG,'package => XXAK_PO_IMP_PKG.XXAK_PO_IMP_PRC compiled'||'lErrbuf'||lErrbuf||'lRetcode'||lRetcode );
  UPDATE po_headers_interface SET AGENT_ID=27 WHERE creation_date LIKE sysdate;
  COMMIT;
END XX_TABLE_INSERT;
/

--2. after insert submit the import program to generate the po#.

CREATE OR REPLACE PROCEDURE submit_po_program
 AS
    l_responsibility_id NUMBER;
    l_application_id    NUMBER;
    l_user_id           NUMBER;
    l_request_id        NUMBER;
  BEGIN

      SELECT user_id INTO l_user_id
      FROM fnd_user
      WHERE user_name = 'PRUTHVI';
--To set environment context.
 apps.fnd_global.apps_initialize (l_user_id,50578,201);
 -- --Submitting Concurrent Request
  l_request_id := fnd_request.submit_request ( application => 'PO',
                                              program => 'POXPOPDOI',
                                              description => 'Import Standard Purchase Orders',
                                              start_time => sysdate,
                                              sub_request => FALSE,
                                              argument1 => NULL ,
                                              argument2 => 'Yes',
                                              argument3 => 'APPROVED',
                                              argument4 => NULL);
                                               COMMIT;
 IF l_request_id = 0
 THEN
 FND_FILE.PUT_LINE(FND_FILE.LOG,'Concurrent request failed to submit =>Import Standard Purchase Orders');
 ELSE
 FND_FILE.PUT_LINE(FND_FILE.LOG,'Successfully Submitted the Concurrent Request =>Import Standard Purchase Orders');
 END IF;
 EXCEPTION
 WHEN OTHERS THEN
 FND_FILE.PUT_LINE(FND_FILE.LOG,'Error While Submitting Concurrent Request '||TO_CHAR(SQLCODE)||'-'||sqlerrm);
END;
/

--3. after generating the po# need to approve 

CREATE OR REPLACE procedure APPROVE_PO
AS
v_item_key VARCHAR2(100);


Cursor c_po_details is

SELECT
pha.po_header_id,
pha.org_id,
pha.segment1,
pha.agent_id,
pdt.document_subtype,
pdt.document_type_code,
pha.authorization_status
FROM apps.po_headers_all pha, apps.po_document_types_all pdt
WHERE pha.type_lookup_code = pdt.document_subtype
AND pha.org_id = pdt.org_id
AND pdt.document_type_code = 'PO'
AND authorization_status in ('INCOMPLETE', 'REQUIRES REAPPROVAL')
AND segment1 = '6259';
BEGIN
fnd_global.apps_initialize (user_id => 1013455,resp_id => 50578,resp_appl_id => 201);

FOR p_rec IN c_po_details

LOOP
mo_global.init (p_rec.document_type_code);
mo_global.set_policy_context ('S', p_rec.org_id);

SELECT p_rec.po_header_id|| '-'|| to_char(po_wf_itemkey_s.NEXTVAL)
INTO v_item_key FROM dual;
dbms_output.put_line (' Calling po_reqapproval_init1.start_wf_process for po_id=>' ||p_rec.segment1);

po_reqapproval_init1.start_wf_process(
ItemType => 'POAPPRV'
, ItemKey => v_item_key
, WorkflowProcess => 'POAPPRV_TOP'
, ActionOriginatedFrom => 'PO_FORM'
, DocumentID => p_rec.po_header_id -- po_header_id
, DocumentNumber => p_rec.segment1 -- Purchase Order Number
, PreparerID => p_rec.agent_id -- Buyer/Preparer_id
, DocumentTypeCode => p_rec.document_type_code--'PO'
, DocumentSubtype => p_rec.document_subtype --'STANDARD'
, SubmitterAction => 'APPROVE'
, forwardToID => NULL
, forwardFromID => NULL
, DefaultApprovalPathID => NULL
, Note => NULL
, PrintFlag => 'N'
, FaxFlag => 'N'
, FaxNumber => NULL
, EmailFlag => 'N'
, EmailAddress => NULL
, CreateSourcingRule => 'N'
, ReleaseGenMethod => 'N'
, UpdateSourcingRule => 'N'
, MassUpdateReleases => 'N'
, RetroactivePriceChange => 'N'
, OrgAssignChange => 'N'
, CommunicatePriceChange => 'N'
, p_Background_Flag => 'N'
, p_Initiator => NULL
, p_xml_flag => NULL
, FpdsngFlag => 'N'
, p_source_type_code => NULL);

commit;
DBMS_OUTPUT.PUT_LINE ('The PO which is Approved Now =>' || p_rec.segment1);
END LOOP;
END;
/

--4. after approving load the data in to rcv interface tables

CREATE OR REPLACE PROCEDURE RCV_PO_NUMBER
AS
X_USER_ID NUMBER;
X_PO_HEADER_ID NUMBER;
X_VENDOR_ID NUMBER;
X_SEGMENT1 VARCHAR2(20);
X_ORG_ID NUMBER;
X_LINE_NUM NUMBER;
BEGIN
DBMS_OUTPUT.PUT_LINE('***ezROI RCV API Insert Script***');
SELECT PO_HEADER_ID , VENDOR_ID , SEGMENT1 , ORG_ID
INTO X_PO_HEADER_ID , X_VENDOR_ID , X_SEGMENT1 , X_ORG_ID
FROM PO_HEADERS_ALL
WHERE SEGMENT1 = 6259;--'&PO_NUMBER';
--AND ORG_ID = &ORG_ID;
SELECT USER_ID INTO X_USER_ID
FROM FND_USER
WHERE USER_NAME = UPPER('PRUTHVI');

INSERT INTO RCV_HEADERS_INTERFACE
(
HEADER_INTERFACE_ID ,
GROUP_ID ,
PROCESSING_STATUS_CODE ,
RECEIPT_SOURCE_CODE ,
TRANSACTION_TYPE ,
LAST_UPDATE_DATE ,
LAST_UPDATED_BY ,
LAST_UPDATE_LOGIN ,
VENDOR_ID ,
EXPECTED_RECEIPT_DATE ,
VALIDATION_FLAG ,
CREATION_DATE
)
SELECT
RCV_HEADERS_INTERFACE_S.NEXTVAL ,
RCV_INTERFACE_GROUPS_S.NEXTVAL ,
'PENDING' ,
'VENDOR' ,
'NEW' ,
SYSDATE ,
X_USER_ID ,
0 ,
X_VENDOR_ID ,
SYSDATE ,
'Y' ,
SYSDATE
FROM DUAL;

DECLARE
CURSOR PO_LINE IS
SELECT PL.ITEM_ID , PL.PO_LINE_ID , PL.LINE_NUM ,
PLL.QUANTITY , PL.UNIT_MEAS_LOOKUP_CODE ,
MP.ORGANIZATION_CODE , PLL.LINE_LOCATION_ID ,
PLL.CLOSED_CODE , PLL.QUANTITY_RECEIVED ,
PLL.CANCEL_FLAG, PLL.SHIPMENT_NUM
FROM PO_LINES_ALL PL ,
PO_LINE_LOCATIONS_ALL PLL ,
MTL_PARAMETERS MP
WHERE PL.PO_HEADER_ID = X_PO_HEADER_ID
AND PL.PO_LINE_ID = PLL.PO_LINE_ID
AND PLL.SHIP_TO_ORGANIZATION_ID = MP.ORGANIZATION_ID;
BEGIN
FOR CURSOR1 IN PO_LINE LOOP
IF CURSOR1.CLOSED_CODE IN ('APPROVED','OPEN')
AND CURSOR1.QUANTITY_RECEIVED < CURSOR1.QUANTITY
AND NVL(CURSOR1.CANCEL_FLAG,'N') = 'N'
THEN
INSERT INTO RCV_TRANSACTIONS_INTERFACE
(
INTERFACE_TRANSACTION_ID ,
GROUP_ID ,
LAST_UPDATE_DATE ,
LAST_UPDATED_BY ,
CREATION_DATE ,
CREATED_BY ,
LAST_UPDATE_LOGIN ,
TRANSACTION_TYPE ,
TRANSACTION_DATE ,
PROCESSING_STATUS_CODE ,
PROCESSING_MODE_CODE ,
TRANSACTION_STATUS_CODE ,
PO_HEADER_ID,
PO_LINE_ID ,
ITEM_ID ,
QUANTITY ,
UNIT_OF_MEASURE ,
PO_LINE_LOCATION_ID ,
AUTO_TRANSACT_CODE ,
RECEIPT_SOURCE_CODE ,
TO_ORGANIZATION_CODE ,
SOURCE_DOCUMENT_CODE ,
HEADER_INTERFACE_ID ,
VALIDATION_FLAG
)
SELECT
RCV_TRANSACTIONS_INTERFACE_S.NEXTVAL ,
RCV_INTERFACE_GROUPS_S.CURRVAL ,
SYSDATE ,
X_USER_ID ,
SYSDATE ,
X_USER_ID ,
0 ,
'RECEIVE' ,
SYSDATE ,
'PENDING' ,
'BATCH' ,
'PENDING' ,
X_PO_HEADER_ID,
CURSOR1.PO_LINE_ID ,
CURSOR1.ITEM_ID ,
CURSOR1.QUANTITY ,
CURSOR1.UNIT_MEAS_LOOKUP_CODE ,
CURSOR1.LINE_LOCATION_ID ,
'RECEIVE' ,
'VENDOR' ,
CURSOR1.ORGANIZATION_CODE ,
'PO' ,
RCV_HEADERS_INTERFACE_S.CURRVAL ,
'Y'
FROM DUAL;
DBMS_OUTPUT.PUT_LINE('PO line: '||CURSOR1.LINE_NUM||' Shipment: '||CURSOR1.SHIPMENT_NUM||' has been inserted into ROI.');
ELSE
DBMS_OUTPUT.PUT_LINE('PO line '||CURSOR1.LINE_NUM||' is either closed, cancelled, received.');
END IF;
END LOOP;
DBMS_OUTPUT.PUT_LINE('***COMPLETE - End ***');
END;
COMMIT;
END;
/

--5. after loading into the rcv interface tables run the "Receiving Transaction Processor" program to generate receipt.

CREATE OR REPLACE PROCEDURE submit_rcv_trans_program
 AS
    l_responsibility_id NUMBER;
    l_application_id    NUMBER;
    l_user_id           NUMBER;
    l_request_id        NUMBER;
  BEGIN

      SELECT user_id INTO l_user_id
      FROM fnd_user
      WHERE user_name = 'PRUTHVI';
--To set environment context.
 apps.fnd_global.apps_initialize (l_user_id,50578,201);
 -- --Submitting Concurrent Request
  l_request_id := fnd_request.submit_request ( application => 'PO',
                                              program => 'RVCTP',
                                              description => 'Receiving Transaction Processor',
                                              start_time => sysdate,
                                              sub_request => FALSE,
                                              argument1 => 'BATCH' ,
                                              argument2 => NULL,
                                              argument3 => NULL);
                                               COMMIT;
 IF l_request_id = 0
 THEN
 FND_FILE.PUT_LINE(FND_FILE.LOG,'Concurrent request failed to submit =>Receiving Transaction Processor');
 ELSE
 FND_FILE.PUT_LINE(FND_FILE.LOG,'Successfully Submitted the Concurrent Request =>Receiving Transaction Processor'||'REQUEST_ID'||l_request_id);
 END IF;
 EXCEPTION
 WHEN OTHERS THEN
 FND_FILE.PUT_LINE(FND_FILE.LOG,'Error While Submitting Concurrent Request '||TO_CHAR(SQLCODE)||'-'||sqlerrm);
 END;
 /


--------------------------------------------------------------------------------------------------------
CODE FOR PACKAGE XXAK_PO_IMP_PKG
---------------------------------------------------------------------------

create or replace PACKAGE XXAK_PO_IMP_PKG IS
PROCEDURE XXAK_PO_IMP_PRC(Errbuf OUT VARCHAR2, Retcode OUT number) ;
END;

````````````````````````````````````````
create or replace PACKAGE BODY XXAK_PO_IMP_PKG
IS
PROCEDURE XXAK_PO_IMP_PRC (errbuf OUT VARCHAR2, retcode OUT number)
IS
CURSOR cur_head
IS
SELECT *
FROM xx_po_header_stg;
CURSOR cur_line (p_interface_header_id NUMBER)
IS
SELECT *
FROM xx_po_line_stg where interface_header_id=p_interface_header_id;
CURSOR cur_dist (p_interface_line_id NUMBER)
IS
SELECT *
FROM xx_po_distribution_stg where interface_line_id=p_interface_line_id;
lv_vendor_id NUMBER (10);
lv_agent_id NUMBER(10);
lv_itemid NUMBER;
lv_site_code VARCHAR2 (100);
lv_lookup_code VARCHAR2(25);
lv_curr_code VARCHAR2 (10);
lv_org_id NUMBER (6);
BEGIN
BEGIN
SELECT organization_id
INTO lv_org_id
FROM hr_operating_units
WHERE NAME LIKE 'Vision Operations';
EXCEPTION
WHEN OTHERS
THEN
fnd_file.put_line (fnd_file.LOG, 'invalid org_id');
END;
BEGIN
FOR var1 IN cur_head
LOOP
BEGIN
SELECT vendor_id
INTO lv_vendor_id
FROM po_vendors
WHERE vendor_name=var1.vendor_name;
EXCEPTION
WHEN OTHERS
THEN
fnd_file.put_line (fnd_file.LOG, 'invalid vendor_id');
END;
BEGIN
SELECT vendor_site_code
INTO lv_site_code
FROM po_vendor_sites_all
WHERE vendor_site_code = var1.vendor_site_code;
EXCEPTION
WHEN OTHERS
THEN
fnd_file.put_line (fnd_file.LOG,
'invalid vendor_site_code');
END;
BEGIN
SELECT currency_code
INTO lv_curr_code
FROM fnd_currencies
WHERE currency_code = var1.currency_code;
EXCEPTION
WHEN OTHERS
THEN
fnd_file.put_line (fnd_file.LOG, 'invalid currency_code');
END;
BEGIN
SELECT DOCUMENT_TYPE_CODE
INTO lv_lookup_code
FROM PO_DOCUMENT_TYPES
WHERE DOCUMENT_TYPE_CODE = var1.DOCUMENT_TYPE_CODE;
EXCEPTION
WHEN OTHERS
THEN
fnd_file.put_line (fnd_file.LOG, 'invalid typecode');
END;
BEGIN
SELECT person_id
INTO lv_agent_id
FROM PER_ALL_PEOPLE_F
WHERE full_name= var1.full_name;
EXCEPTION
WHEN OTHERS
THEN
fnd_file.put_line (fnd_file.LOG, 'invalid Buyer');
END;
BEGIN
INSERT INTO po_headers_interface
(interface_header_id
, batch_id
, org_id
,action
, document_type_code
, currency_code
,agent_id
, agent_name
, vendor_name
, vendor_site_code
, ship_to_location
, bill_to_location
,approval_status
, freight_terms
,fob
,freight_carrier
,created_by
, creation_date
, last_update_date
, last_updated_by
)
VALUES
(PO_HEADERS_INTERFACE_S.NEXTVAL
, var1.batch_id
, lv_org_id
,var1.action
, var1.document_type_code
, var1.currency_code
, lv_agent_id
,var1.full_name
,var1.vendor_name
, var1.vendor_site_code
, var1.ship_to_location
, var1.bill_to_location
, var1.approval_status
, var1.freight_terms
,var1.fob
,var1.freight_carrier
, -1
, SYSDATE
, SYSDATE
, -1
);
EXCEPTION WHEN OTHERS THEN
FND_FILE.put_line(FND_FILE.output,'insertion successful into headers int');
END;
FOR var2 IN cur_line (var1.interface_header_id)
LOOP
BEGIN
SELECT INVENTORY_ITEM_ID
INTO lv_itemid
FROM mtl_system_items_b
WHERE segment1 = var2.item
AND organization_id =lv_org_id;
EXCEPTION
WHEN OTHERS
THEN
-- lv_item := NULL;
fnd_file.put_line (fnd_file.LOG, 'invalid item');
END;
BEGIN
INSERT INTO po_lines_interface
(interface_line_id
, interface_header_id
, line_num
, shipment_num
, line_type
,item
, item_description
, item_id
, uom_code
, quantity
, unit_price
,ship_to_organization_code
, ship_to_location
,NEED_BY_DATE
-- ,PROMISED_DATE
, list_price_per_unit
, created_by
, creation_date
, last_update_date
, last_updated_by
)
VALUES
(PO_LINES_INTERFACE_S.NEXTVAL
,PO_HEADERS_INTERFACE_S.CURRVAL
, var2.line_num
, var2.shipment_num
, var2.line_type
, var2.item
, var2.item_description
, var2.item_id
,var2.uom_code
, var2.quantity
, var2.unit_price
,var2.ship_to_organization_code
,var2.ship_to_location
,SYSDATE
-- ,SYSDATE
, var2.list_price_per_unit
, -1
,SYSDATE
, SYSDATE
, -1
);
EXCEPTION WHEN OTHERS THEN
FND_FILE.put_line(FND_FILE.output,'insertion successful into lines int');
END;
for var3 in cur_dist(var2.interface_line_id)
LOOP
BEGIN
INSERT INTO po_distributions_interface (
interface_header_id ,
interface_line_id ,
interface_distribution_id ,
org_id ,
quantity_ordered ,
destination_organization_id ,
set_of_books_id ,
charge_account_id ,
distribution_num
, created_by
, creation_date
, last_update_date
, last_updated_by
)
VALUES
(
PO_HEADERS_INTERFACE_S.CURRVAL,
PO_LINES_INTERFACE_S.CURRVAL,
PO_DISTRIBUTIONS_INTERFACE_S.NEXTVAL ,
lv_org_id ,
var3.quantity_ordered ,
var3.destination_organization_id ,
var3.set_of_books_id ,
var3.charge_account_id ,
var3.distribution_num
, -1
,SYSDATE
, SYSDATE
, -1 );
EXCEPTION WHEN OTHERS THEN
FND_FILE.put_line(FND_FILE.output,'insertion successful into dist int');
END;
END LOOP;
END LOOP;
END LOOP;
END;
COMMIT;
END XXAK_PO_IMP_PRC;
END XXAK_PO_IMP_PKG ;

query we can find the custom top path in oracle apps.

query we can find the custom top path.

select distinct variable_name, value
from fnd_env_context
where variable_name like '%CUS%_TOP' --escape '\'
order by variable_name;

Get concurrent request id in pl sql program in oracle

FND_PROFILE and FND_GLOBAL values

Following are the FND_PROFILE values that can be used in the PL/SQL code:

   fnd_profile.value('PROFILEOPTION');
   fnd_profile.value('MFG_ORGANIZATION_ID');
   fnd_profile.value('ORG_ID');
   fnd_profile.value('LOGIN_ID');
   fnd_profile.value('USER_ID');
   fnd_profile.value('USERNAME');
   fnd_profile.value('CONCURRENT_REQUEST_ID');
   fnd_profile.value('GL_SET_OF_BKS_ID');
   fnd_profile.value('SO_ORGANIZATION_ID');
   fnd_profile.value('APPL_SHRT_NAME');
   fnd_profile.value('RESP_NAME');
   fnd_profile.value('RESP_ID');

Following are the FND_GLOBAL values that can be used in the PL/SQL code:

   FND_GLOBAL.USER_ID;
   FND_GLOBAL.APPS_INTIALIZE;
   FND_GLOBAL.LOGIN_ID;
   FND_GLOBAL.CONC_LOGIN_ID;
   FND_GLOBAL.PROG_APPL_ID;
   FND_GLOBAL.CONC_PROGRAM_ID;
   FND_GLOBAL.CONC_REQUEST_ID;

For example, I almost always use the following global variable assignments in my package specification to use throughout the entire package body:

   g_user_id      PLS_INTEGER  :=  fnd_global.user_id;
   g_login_id     PLS_INTEGER  :=  fnd_global.login_id;
   g_conc_req_id  PLS_INTEGER  :=  fnd_global.conc_request_id;
   g_org_id       PLS_INTEGER  :=  fnd_profile.value('ORG_ID');
   g_sob_id       PLS_INTEGER  :=  fnd_profile.value('GL_SET_OF_BKS_ID');

And initialize the application environment as follows:

   v_resp_appl_id  := fnd_global.resp_appl_id;
   v_resp_id       := fnd_global.resp_id;
   v_user_id       := fnd_global.user_id;
   
   FND_GLOBAL.APPS_INITIALIZE(v_user_id,v_resp_id, v_resp_appl_id);

link between order table,customer table and shipping tables in oracle apps r12

link between OE ,HZ AND WSH Tables in oracle apps r12


select DISTINCT wnd.name shipper_no,
       wnd.confirm_date,
       hp.party_name,
       hcsua.location "Customer address",
       hl.address1,
       hl.city,
       hl.state,
       hl.postal_code,
       hl.country,
       ool.header_id,
       msi.segment1 L_L_Item_No,
       wlp.license_plate_number,
       ool.ordered_item "Customer_Part_No",
       wda.delivery_id,
       msi.inventory_item_id,
     ool.ordered_item "CUST_1",
   msi.segment1 "ITEM_1"
  from wsh_new_deliveries wnd,
       hz_cust_accounts_all hca,
       hz_parties hp,
       hz_locations hl,
       wsh_delivery_assignments wda,
       wsh_delivery_details wdd,
       oe_order_lines_all ool,
       mtl_system_items_b msi,
       mtl_parameters mp,
       wsh_delivery_details wdd_p,
       wms_license_plate_numbers wlp,
        hz_cust_site_uses_all hcsua
 where wnd.customer_id = hca.cust_account_id
   and hca.party_id = hp.party_id
   and wnd.delivery_id = wda.delivery_id
   and wda.delivery_detail_id = wdd.delivery_detail_id
   and hl.location_id = wnd.ultimate_dropoff_location_id
   and wdd.source_line_id = ool.line_id
   and wdd.source_header_id = ool.header_id
   and ool.inventory_item_id = elss.inventory_item_id
   and ool.inventory_item_id = msi.inventory_item_id
   and ool.ship_from_org_id = msi.organization_id
   and mp.organization_code='000'
   and wda.parent_delivery_detail_id = wdd_p.delivery_detail_id
   and wdd_p.lpn_id = wlp.lpn_id
   and ool.ship_to_org_id = hcsua.site_use_id(+)
   and wnd.name='7453179';

Order Management Tables

Order Management Tables. Entered
oe_order_headers_all 1 record created in header table
oe_order_lines_all Lines for particular records
oe_price_adjustments When discount gets applied
oe_order_price_attribs If line has price attributes then populated
oe_order_holds_all If any hold applied for order like credit check etc.
Booked
oe_order_headers_all Booked_flag=Y Order booked.
wsh_delivery_details Released_status Ready to release
Pick Released 
wsh_delivery_details Released_status=Y Released to Warehouse (Line has been released to Inventory for processing)
wsh_picking_batches After batch is created for pick release. 
mtl_reservations This is only soft reservations. No physical movement of stock
Full Transaction
mtl_material_transactions No records in mtl_material_transactions
mtl_txn_request_headers
mtl_txn_request_lines
wsh_delivery_details Released to warehouse.
wsh_new_deliveries if Auto-Create is Yes then data populated.
wsh_delivery_assignments deliveries get assigned
Pick Confirmed
wsh_delivery_details Released_status=Y Hard Reservations. Picked the stock. Physical movement of stock
Ship Confirmed
wsh_delivery_details Released_status=C Y To C:Shipped ;Delivery Note get printed Delivery assigned to trip stopquantity will be decreased from staged
mtl_material_transactions On the ship confirm form, check Ship all box
wsh_new_deliveries If Defer Interface is checked I.e its deferred then OM & inventory not updated. If Defer Interface is not checked.: Shipped
oe_order_lines_all Shipped_quantity get populated.
wsh_delivery_legs 1 leg is called as 1 trip.1 Pickup & drop up stop for each trip.
oe_order_headers_all If all the lines get shipped then only flag N
Autoinvoice
wsh_delivery_details Released_status=I Need to run workflow background process.
ra_interface_lines_all Data will be populated after wkfw process.
ra_customer_trx_all After running Autoinvoice Master Program for
ra_customer_trx_lines_all specific batch transaction tables get populated
Price Details
qp_list_headers_b To Get Item Price Details.
qp_list_lines
Items On Hand Qty
mtl_onhand_quantities TO check On Hand Qty Items.

Payment Terms
ra_terms Payment terms

AutoMatic Numbering System
ar_system_parametes_all you can chk Automactic Numbering is enabled/disabled.
Customer Information
hz_parties Get Customer information include name,contacts,Address and Phone
hz_party_sites
hz_locations
hz_cust_accounts
hz_cust_account_sites_all
hz_cust_site_uses_all
ra_customers
Document Sequence
fnd_document_sequences Document Sequence Numbers
fnd_doc_sequence_categories
fnd_doc_sequence_assignments
Default rules for Price List
oe_def_attr_def_rules Price List Default Rules
oe_def_attr_condns
ak_object_attributes
End User Details 
csi_t_party_details To capture End user Details

Sales Credit Sales Credit Information(How much credit can get)
oe_sales_credits

Attaching Documents 
fnd_attached_documents Attched Documents and Text information
fnd_documents_tl
fnd_documents_short_text

Blanket Sales Order
oe_blanket_headers_all Blanket Sales Order Information.
oe_blanket_lines_all

Processing Constraints
oe_pc_assignments Sales order Shipment schedule Processing Constratins
oe_pc_exclusions
Sales Order Holds
oe_hold_definitions Order Hold and Managing Details.
oe_hold_authorizations
oe_hold_sources_all
oe_order_holds_all

Hold Relaese
oe_hold_releases_all Hold released Sales Order.

Credit Chk Details
oe_credit_check_rules To get the Credit Check Againt Customer.
Cancel Orders
oe_order_lines_all Cancel Order Details

WIP Tables with description

  Table Name Description     WIP_ACCOUNTING_CLASSES stores accounting flexfield information for standard discrete jobs, non-standard asset j...