Wednesday, October 31, 2018

XLA: Delete event XLA_EVENTS

XLA: Delete event XLA_EVENTS

-- Creted by Prudhvi </code>

DECLARE
p_event_source_info xla_events_pub_pkg.t_event_source_info;
BEGIN

p_event_source_info.source_application_id := NULL; --101 GL -- 602 XLE
p_event_source_info.application_id := 222; -- AR
p_event_source_info.legal_entity_id := 1234;
p_event_source_info.ledger_id := 1;
p_event_source_info.entity_type_code := 'TRANSACTIONS';
p_event_source_info.transaction_number := NULL;
p_event_source_info.source_id_int_1 := 1234; -- Customer Transaction ID;
p_event_source_info.source_id_int_2 := NULL;
p_event_source_info.source_id_int_3 := NULL;
p_event_source_info.source_id_int_4 := NULL;
p_event_source_info.source_id_char_1 := NULL;
p_event_source_info.source_id_char_2 := NULL;
p_event_source_info.source_id_char_3 := NULL;
p_event_source_info.source_id_char_4 := NULL;

xla_events_pub_pkg.delete_event
(p_event_source_info =&gt; p_event_source_info,
p_event_id =&gt; 1234, -- xla_events
p_valuation_method =&gt; NULL,
p_security_context =&gt; NULL
);

DBMS_OUTPUT.put_line('Updated Status');
commit;

exception when others then

DBMS_OUTPUT.put_line('Error:'||SQLERRM);
END;

API: Update event status code in XLA_EVENTS

API: Update event status code in XLA_EVENTS

-- Created by Prudhvi 

DECLARE
p_event_source_info xla_events_pub_pkg.t_event_source_info;
BEGIN

p_event_source_info.source_application_id  := NULL;     
p_event_source_info.application_id         := 222;       -- AR
p_event_source_info.legal_entity_id        := 12340;     -- change it 
p_event_source_info.ledger_id              := 1;        -- change it
p_event_source_info.entity_type_code       := 'TRANSACTIONS';       
p_event_source_info.transaction_number     := '1234';    -- change it   
p_event_source_info.source_id_int_1        := 1234; --Transaction ID;       
p_event_source_info.source_id_int_2        := NULL;       
p_event_source_info.source_id_int_3        := NULL;       
p_event_source_info.source_id_int_4        := NULL;       
p_event_source_info.source_id_char_1       := NULL;       
p_event_source_info.source_id_char_2       := NULL;       
p_event_source_info.source_id_char_3       := NULL;       
p_event_source_info.source_id_char_4       := NULL;


 xla_events_pub_pkg.update_event_status
   (p_event_source_info         =>   p_event_source_info,
    p_event_class_code          =>   'INVOICE',
    p_event_type_code           =>   'INV_CREATE',
    p_event_date                =>   '20-JAN-17',
    p_event_status_code         =>   'U', -- un processed
    p_valuation_method          =>   NULL,
    p_security_context          =>   NULL
   );
   
   
   DBMS_OUTPUT.put_line('Updated Status');
   commit;
   
exception when others then
   DBMS_OUTPUT.put_line('Error:'||SQLERRM);
END;

Oracle Apps Custom Table with ORG Access Control policy (RLS Policy)

Oracle Apps Custom Table with ORG Access Control policy (RLS Policy)

Step-1: Create Table & Insert data
create table xxcus.xx_tmp_all(id number, name varchar2(100), org_id number);
Replace XXCUS is with your custom schema name. Also make sure to have ORG_ID column and table name suffix as _ALL.
1
insert into xxcus.xx_tmp_all values (1,'a',201);
insert into xxcus.xx_tmp_all values (2,’b’,204);
COMMIT;
Step-2: Create synonyms
1
CREATE OR REPLACE SYNONYM apps.xx_tmp_all FOR xxcus.xx_tmp_all;
CREATE OR REPLACE SYNONYM apps.xx_tmp FOR xxcus.xx_tmp_all;
Step-3: Create Policy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
begin
dbms_rls.add_policy (
object_schema =&gt; 'APPS',
object_name =&gt; 'XX_TMP',
policy_name =&gt; 'ORG_SEC',
function_schema =&gt; 'APPS',
policy_function =&gt; 'MO_GLOBAL.ORG_SECURITY',
statement_types =&gt; 'INSERT, UPDATE, DELETE, SELECT',
update_check =&gt; TRUE,
enable =&gt; TRUE,
static_policy =&gt; FALSE,
policy_type =&gt; NULL,
long_predicate =&gt; FALSE,
sec_relevant_cols =&gt; NULL,
sec_relevant_cols_opt =&gt; NULL
);
end;
Step-4: Query Data
1
select * from apps.xx_tmp; -- No data retrieved
EXEC MO_GLOBAL.SET_POLICY_CONTEXT(‘S’,201);
select * from apps.xx_tmp; — 201 record retrieved
EXEC MO_GLOBAL.SET_POLICY_CONTEXT(‘S’,204);
select * from apps.xx_tmp; — 204 record retrieved
We can drop by policy with the below command.
1
2
3
begin
dbms_rls.drop_policy ('APPS','XX_TEMP','ORG_SEC');
end;
Additional Information
1
select * from dba_policies; -- should give all existing policies
Check session org access
1
2
3
4
5
6
7
8
9
DECLARE
RET VARCHAR2(100);
org NUMBER;
BEGIN
RET := MO_GLOBAL.CHECK_ACCESS (201); -- change org for which you need to check access
org := mo_global.get_current_org_id;
DBMS_OUTPUT.PUT_LINE (RET);
dbms_output.put_line (org);
END;

Inventory On-hand quantity Interface In Oracle Apps

Inventory On-hand quantity Interface

Interface Program:
Launch the Transaction Manager through Interface Manager or explicitly call the API – INV_TXN_MANAGER_PUB.PROCESS_TRANSACTIONS () to launch a dedicated transaction worker to process them.
The Transaction Manager picks up the rows to process based on the LOCK_FLAG, TRANSACTION_MODE, and PROCESS_FLAG. Only records with TRANSACTION_MODE of 3, LOCK_FLAG of ’2′, and PROCESS_FLAG of ’1′ will be picked up by the Transaction Manager and assigned to a Transaction Worker. If a record fails to process completely, then PROCESS_FLAG will be set to ’3′ and ERROR_CODE and ERROR_EXPLANATION will be populated with the cause for the error.
Base Tables:
MTL_ON_HAND_QUANTITIES
MTL_LOT_NUMBERS
MTL_SERIAL_NUMBERS
Validations:
Validate organization_id
Check if item is assigned to organization
Validate disposition_id
Check if the item for the org is lot controlled before inserting into the Lots interface table.
Check if the item for the org is serial controlled before inserting into Serial interface table.
Check if inventory already exists for that item in that org and for a lot.
Validate organization_id, organization_code.
Validate inventory item id.
Transaction period must be open.
Interface tables:
MTL_TRANSACTIONS_INTERFACE
MTL_MTL_TRANSACTION_LOTS_INTERFACE (If the item is Lot controlled)
MTL_SERIAL_NUMBERS_INTERFACE (If the item is Serial controlled)
MTL_TRANSACTIONS_INTERFACE:
TRANSACTION_SOURCE_NAME (ANY USER DEFINED VALUE),
TRANSACTION_HEADER_ID (MTL_MATERIAL_TRANSACTIONS_S.NEXTVAL)
TRANSACTION_INTERFACE_ID (MTL_MATERIAL_TRANSACTIONS_S.NEXTVAL – If item is lot or serial controlled, use this field to link to mtl_transactions_interface otherwise leave it as NULL),
TRANSACTION_DATE,
TRANSACTION_TYPE_ID,
PROCESS_FLAG (1 = Yet to be processed, 2 = Processed, 3= Error)
TRANSACTION_MODE (2 = Concurrent – to launch a dedicated transaction worker to explicitly process a set of transactions. 3 = Background – will be picked up by transaction manager polling process and assigned to transaction worker. These will not be picked up until the transaction manager is running)
SOURCE_CODE,
SOURCE_HEADER_ID,
SOURCE_LINE_ID (Details about the source like Order Entry etc for tracking purposes)
ITEM_SEGMENT1,
TRANSACTION_QTY,
TRANSACTION_UOM,
SUBINVENTORY_CODE,
ORGANIZATION_ID,
LOC_SEGMENT1.
TRANSACTION_SOURCE_ID
Source Type Foreign Key Reference
Account GL_CODE_COMBINATIONS.CODE_COMBINATION_ID
Account Alias MTL_GENERIC_DISPOSITIONS.DISPOSITION_ID
Job or schedule WIP_ENTITIES.WIP_ENTITY_ID
Sales Order MTL_SALES_ORDERS.SALES_ORDER_ID
MTL_TRANSACTION_LOTS_INTERFACE:
TRANSACTION_INTERFACE_ID,
LOT_NUMBER,
LOT_EXPIRATION_DATE,
TRANSACTION_QUANTITY,
SERIAL_TRANSACTION_TEMP_ID (This is required for items under both lot and serial control to identify child records in mtl_serial_numbers_interface)
MTL_SERIAL_NUMBERS_INTERFACE:
TRANSACTION_INTERFACE_ID,
FM_SERIAL_NUMBER,
TO_SERIAL_NUMBER,
VENDOR_SERIAL_NUMBER

Item import (Item conversion) In Oracle Apps

Item import (Item conversion)

Overview: Item import program can be used to create new Inventory items or to update existing inventory items.  We can import items with all attributes information or use item templates to set attributes and import items linking with item template.
Uses:
  1. Import New Inventory Items in Master Organization
  2. Assign Items to child Organization (Step1 has to be finished before this task can be executed)
  3. Update existing Inventory item attributes information
  4. Assign Item Category Assignments
  5. Lot numbers can be imported along with items
  6. Serial numbers can be imported along with items
Execution Methods:
  1.  Run  “Import Items” concurrent program from inventory responsibility manually.
  2. Use PLSQL wrapper code to kick of the “Import Items” Concurrent program from backend.
Parameters:
All Organizations: Yes / No (Select Yes if you want to import items belonging to various organizations reglardless of  current selection in form)
Validate Items: Yes / No (Select Yes if you would like to validate Items. With out validation we can not proceed to Processing)
Process Items: Yes / No (Select Yes to process / import items)
Delete Processed Items: Yes / No (Select Yes to purge data in interface tables for the processed records)
Process Set: You can use this parameter to process records in batches. It will use SET_PROCESS_ID column in interface table.
Create or Update Items: 1 / 2/ 3. (1- Create New Items, 2 – Update Existing Items, 3 – Sync Items. Option 3 should be used if we have some items to be created and some to be updated)
Gather Statistics: Yes / No. (Helps to increase performance of SQL queries based on items table)
Pre-requisites:
  1. Master Organization should be defined.
  2. Child Organization should be defined.
  3. Code Combinations should be defined.
  4. Item Templates (If using item templates in interface table)
  5. Defining Item Status Codes
  6. Item Types should be defined.
Common Issues:
  1. Don’t try to load both master item record and child item record at a time. If you want to do that make sure you use process set column.
  2. Revision numbers have to be in chronological order, meaning it can be like AA, BB, CC … or 1,2,3,….but i can’t be AA, 1, BB, 2 etc.
  3. Category assingments, Lot numbers, serial numbers has to be linked properly to the respective tables.
Interface tables:
MTL_SYSTEM_ITEMS_INTERFACE
MTL_ITEM_REVISIONS_INTERFACE (If importing revisions)
MTL_ITEM_CATEGORIES_INTERFACE (If importing categories)
Error Tracking Tables:
MTL_INTERFACE_ERRORS (View errors after import)
Base tables:
MTL_SYSTEM_ITEMS_B
MTL_ITEM_REVISIONS_B
MTL_CATEGORIES_B
MTL_CATEGORY_SETS_B
MTL_ITEM_STATUS
MTL_ITEM_TEMPLATES

MTL_SYSTEM_ITEMS_INTERFACE: (Important columns to be populated)
PROCESS_FLAG = 1 (1= Pending, 2= Assign Complete,3= Assign/Validation Failed, 4= Validation succeeded; Import failed, 5 = Import in Process, 7 = Import succeeded)
TRANSACTION_TYPE = ‘CREATE’, ‘UPDATE’
SET_PROCESS_ID = 1
ORGANIZATION_ID
DESCRIPTION
ITEM_NUMBER and/or SEGMENT (n)
MATERIAL_COST
REVISION
TEMPLATE_ID
SUMMARY_FLAG
ENABLED_FLAG
PURCHASING_ITEM_FLAG
SALES_ACCOUNT (defaulted from MTL_PARAMETERS.SALES_ACCOUNT)
COST_OF_SALES_ACCOUNT (defaulted from MTL_PARAMETERS.COST_OF_SALES_ACCOUNT)

MTL_ITEM_CATEGORIES_INTERFACE: (Mandatory columns to be populated)
INVENTORY_ITEM_ID or ITEM_NUMBER.
ORGANIZATION_ID or ORGANIZATION_CODE or both.
TRANSACTION_TYPE = ‘CREATE’ (‘UPDATE’ or ‘DELETE’ is not possible through Item Import).
CATEGORY_SET_ID or CATEGORY_SET_NAME or both.
CATEGORY_ID or CATEGORY_NAME or both.
PROCESS_FLAG = 1
SET_PROCESS_ID (The item and category interface records should have the same set_process_id, if you are importing item and category assignment together)
MTL_ITEM_REVISIONS_INTERFACE: (Mandatory columns to be populated)
INVENTORY_ITEM_ID or ITEM_NUMBER (Must match the item_number in mtl_system_items_interface table)
ORGANIZATION_ID or ORGANIZATION_CODE or both
REVISION
CHANGE_NOTICE
ECN_INITIATION_DATE
IMPLEMENTATION_DATE
IMPLEMENTED_SERIAL_NUMBER
EFFECTIVITY_DATE
ATTRIBUTE_CATEGORY
ATTRIBUTEn
REVISED_ITEM_SEQUENCE_ID
DESCRIPTION
PROCESS_FLAG = 1
TRANSACTION_TYPE = ‘CREATE’
SET_PROCESS_ID = 1
Each row in the mtl_item_revisions_interface table must have the REVISION and EFFECTIVITY_DATE in alphabetical (ASCII sort) and chronological order.
Notes:
Through the import process, we can only create item category assignment(s). Updating or Deletion of item category assignment is not supported.
Sample Script
Staging Table:
1
2
3
4
5
6
7
8
9
10
11
CREATE TABLE erps_item_import
(segment1 varchar2(100),
organization_id number,
process_flag varchar2(100),
set_process_id number,
transaction_type varchar2(100),
description varchar2(100),
primary_UOM_code varchar2(100),
validation_flag varchar2(10),
validation_errors varchar2(100)
);


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
-- SCRIPT FOR CUSTOM VALIDATIONS AND INSERT DATA FROM STAGING TABLE INTO INTERFACE TABLE
declare
v_organization_check NUMBER := 0;
Begin
--CUSTOM VALIDATIONS
begin
for i in (select * from APPS.erps_item_import) -- Staging table
Loop
SELECT 1
INTO v_organization_check
FROM mtl_parameters mp
WHERE mp.organization_id = i.organization_id ;
update erps_item_import
set validation_flag = 'Y'
where organization_id = i.organization_id;
end loop;
exception when others then
null;
end;
-- INSERT DATA FROM STAGING INTO INTERFACE TABLE
INSERT INTO mtl_system_items_interface
(segment1,
organization_id,
process_flag,
set_process_id,
transaction_type,
description,
primary_UOM_code
)
SELECT
segment1,
organization_id,
process_flag,
set_process_id,
transaction_type,
description,
primary_UOM_code
FROM APPS.erps_item_import
WHERE VALIDATION_FLAG ='Y'
;
COMMIT;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('Error while inserting record in interface table '
||SUBSTR(SQLERRM,1,200));
END;

 
If you have any questions let us know in comments section.

SQL Important Queries

  How to delete rows with no where clause The following example deletes  all rows  from the  Person.Person  the table in the AdventureWork...