Tuesday, November 29, 2016

How to create FlexiField and usage of Flexifield?

Scenario:

xyz company, it is having 2 braches one in hyderabad and another one is Chennai. By End of Day I need to populate sales information into Main branch along with branch code but in my source datastore there is no branch_code attributes whereas in my target datastore there is branch_code attribute.

I need to populate branch_code value based on context selection I need populate value into my target datastore.

Scripts:
CREATE USER R_HYD IDENTIFIED BY R_HYD;
/
CREATE USER R_CHN IDENTIFIED BY R_CHN;
/
CREATE USER XYZ IDENTIFIED BY XYZ;
/
GRANT ALL PRIVILEGES TO R_CHN;
/
TARGET DATASTORE
CREATE TABLE XYZ.PROD_SALES (PRODUCT_ID NUMBER(4),
PNAME VARCHAR2(100),
SALES_COUNT NUMBER(3),
BRANCH_CODE VARCHAR2(3),
SALES_DATE DATE);
/
SOURCE DATASTORE (HYDERABAD)
CREATE TABLE R_HYD.PROD_SALES (PRODUCT_ID NUMBER(4),
PNAME VARCHAR2(100),
SALES_COUNT NUMBER(3),
SALES_DATE DATE);
/
SOURCE DATASTORE(CHENNAI)
CREATE TABLE R_CHN.PROD_SALES (PRODUCT_ID NUMBER(4),
PNAME VARCHAR2(100),
SALES_COUNT NUMBER(3),
SALES_DATE DATE);
/
INSERT INTO R_HYD.PROD_SALES
VALUES ( 1,'SOAP',20,SYSDATE);
/
INSERT INTO R_HYD.PROD_SALES
VALUES ( 2,'BRUSH',10,SYSDATE);
/
INSERT INTO R_HYD.PROD_SALES
VALUES ( 3,'PASTE',30,SYSDATE);
/
INSERT INTO R_HYD.PROD_SALES
VALUES ( 4,'MUG',4,SYSDATE);
/
SELECT * FROM R_HYD.PROD_SALES;
/
INSERT INTO R_CHN.PROD_SALES
VALUES ( 1,'SOAP',23,SYSDATE);
/
INSERT INTO R_CHN.PROD_SALES
VALUES ( 2,'BRUSH',11,SYSDATE);
/
INSERT INTO R_CHN.PROD_SALES
VALUES ( 3,'PASTE',21,SYSDATE);
/
INSERT INTO R_CHN.PROD_SALES
VALUES ( 4,'MUG',2,SYSDATE);
/
SELECT * FROM R_CHN.PROD_SALES;

ODI Steps:

1.Login to ODI
2.Go to Security Navigator
3.Expand Profiles Accordion
4.Expand Topology Admin
5.Double click on Context
6.Go to FlexiFields tab --> Add one flexifield by pressing + symbol
7.Save it
8.Go to Topology Navigator
9.Expand Context Accordion
10.Double click on the Chennai Context
11.Go to FlexiFields tab --> Provide values as 'CHN'

12. Repeat 8-11 steps for Hyderabad context as well
Provide value as 'HYD'
13. Create mapping and drag and drop appropriate datastores from model and select automap. For branch_code the mapping is as shown below


Here BRANCH_CODE is nothing but flexiField Code value if you observe the flexifield in screenshot one you can see this value.

14. Based on context value the branch_code will populated.
For Example if you selected Hyderabad then branch_code value for those records is 'HYD'
if you selected Chennai then branch_Code values for those records is 'CHN'

Completed Successfully!!!!!!!!!!!!!!

No comments:

Post a Comment