Skip to content

December 22, 2009
by kdevendr
17 Comments

Categories: Administration , How to , Logic , ODI , Tips and Tricks

Tags: ,

Single Post View


Get File Length and Header in Operator

We get so many source files and some time we have different files coming of different length and we would need to do a row count every time to see whether we have got the correct number of records in the target .

To solve this issue, I have written a small program that shows the File Length and Header or First Line of the file in the operator . Why First line so that I know whether the first line is an Header row or not .

JYTHON PROCEDURE CODE

# AUTHOR – KSHITIZ DEVENDRA
# LANG – JYTHON
# DESCRIPTION
# ——————————————————————————–
# THIS PROGRAM IS USED TO GET THE NUMBER OF RECORDS IN FILE AND
# ALSO DISPLAYS THE HEADER OF THE FILE
# THE CORRECT NO OF RECORDS ARE CALCULATED BY SUBTRACTING TOTAL LENGTH – HEADER
# ——————————————————————————–
filesrc = open(‘<— SPECIFY FILE PATH AND NAME HERE —-> ‘,’r’)
first=filesrc.readline()
lines = 0
while first:
#get the no of lines in the file
lines += 1
first=filesrc.readline()
#print lines
## THE ABOVE PART OF THE PROGRAM IS TO COUNT THE NUMBER OF LINES
## AND STORE IT INTO THE VARIABLE ‘ LINES ‘
def intWithCommas(x):
if type(x) not in [type(0), type(0L)]:
raise TypeError(“Parameter must be an integer.”)
if x < 0:
return ‘-‘ + intWithCommas(-x)
result = ”
while x >= 1000:
x, r = divmod(x, 1000)
result = “,%03d%s” % (r, result)
return “%d%s” % (x, result)
## THE ABOVE PROGRAM IS TO DISPLAY THE NUMBERS
## 1234567890 AS 1,234,567,890
s1=str(intWithCommas(lines))
s2=’ nn and the First Line of the File is —>> nn ‘
filesrc.seek(0)
s3=str(filesrc.readline())
final=s1 + s2 + s3
raise ‘ nn The Number of Lines in the File are —>> ‘ , final
## SINCE IN OPERATOR I CAN THROW ONLY SINGLE RAISE COMMAND I CONCATENATED ALL
## THE REQUIRED MESSAGE AND DISPLAYED IN THE OPERATOR AS ONE RAISE COMMAND

SAMPLE OUTPUT

image

The total execution time for 1.4 million records was 22 so i am expecting it to be fast

image

Please note i have attached the codes in two formats one for Procedure and another for LKM’s as i have done small changes so that when used in LKM it read the source file automatically , and also does the correct length calculation.

JYTHON CODE FOR LKM

# AUTHOR – KSHITIZ DEVENDRA
# LANG – JYTHON
# DESCRIPTION
# ——————————————————————————–
# THIS PROGRAM IS USED TO GET THE NUMBER OF RECORDS IN FILE AND
# ALSO DISPLAYS THE HEADER OF THE FILE
# THE CORRECT NO OF RECORDS ARE CALCULATED BY SUBTRACTING TOTAL LENGTH – HEADER
# ——————————————————————————–
filesrc = open(‘<%=odiRef.getSrcTablesList(“”, “[SCHEMA]/[RES_NAME]”, “”, “”)%>’,’r’)
first=filesrc.readline()
lines = 0
while first:
#get the no of lines in the file
lines += 1
first=filesrc.readline()
#print lines
## THE ABOVE PART OF THE PROGRAM IS TO COUNT THE NUMBER OF LINES
## AND STORE IT INTO THE VARIABLE ‘ LINES ‘
def intWithCommas(x):
if type(x) not in [type(0), type(0L)]:
raise TypeError(“Parameter must be an integer.”)
if x < 0:
return ‘-‘ + intWithCommas(-x)
result = ”
while x >= 1000:
x, r = divmod(x, 1000)
result = “,%03d%s” % (r, result)
return “%d%s” % (x, result)
## THE ABOVE PROGRAM IS TO DISPLAY THE NUMBERS
## 1234567890 AS 1,234,567,890
s1=str(intWithCommas(lines-<%=odiRef.getSrcTablesList(“”, “[FILE_FIRST_ROW]”, “, “, “”)%>))
s2=’ nn and the First Line of the File is —>> nn ‘
filesrc.seek(0)
s3=str(filesrc.readline())
final=s1 + s2 + s3
raise ‘ nn The Number of Lines in the File <%=odiRef.getSrcTablesList(“”, “[SCHEMA]/[RES_NAME]”, “”, “”)%> are —>> ‘ , final
## SINCE IN OPERATOR I CAN THROW ONLY SINGLE RAISE COMMAND I CONCATENATED ALL
## THE REQUIRED MESSAGE AND DISPLAYED IN THE OPERATOR AS ONE RAISE COMMAND

Comparing the above Procedure , LKM codes have small changes to get the File and the correct Length calculated smartly.

filesrc = open(‘<%=odiRef.getSrcTablesList(“”, “[SCHEMA]/[RES_NAME]”, “”, “”)%>’,’r’)

This code will be the correct File name and would open it for reading .

s1=str(intWithCommas(lines-<%=odiRef.getSrcTablesList(“”, “[FILE_FIRST_ROW]”, “, “, “”)%>))

This code will subtract the Total lines – Heading(No of Lines) so that in operator it shows the correct value.

image

raise ‘ nn The Number of Lines in the File <%=odiRef.getSrcTablesList(“”, “[SCHEMA]/[RES_NAME]”, “”, “”)%> are —>> ‘ , final

This code will display the File path and Name in the operator Message box.

image

As you can see it displayed the File Path and Name with Total Number of Lines , Comparing to the above procedure where it displayed 1,453,389 , here smartly it read from the Data store definition and found out that the Heading (no of lines ) is one and while displaying showing the correct output.

Please find the codes below in XML format and import in INSERT_UPDATE mode and also enable ” IGNORE ERRORS ” option as Jython raise command is used to throw warning message in the operator and I have used raise to display the output required.

To use in any LKM File to KM , just copy paste the code from -PROCEDURE FILE_LENGTH_HEADER TO BE USED IN LKM’s and enable the option -IGNORE ERRORS and move it to the first order so that as soon the load starts you would get the required details in the operator.

PROCEDURE FILE_LENGTH_HEADER

http://cid-d7195c8badc40d0b.skydrive.live.com/embedicon.aspx/odiexperts.com/TRT_PROC_FILE_LENGTH_HEADER.xml

PROCEDURE FILE_LENGTH_HEADER TO BE USED IN LKM’s
http://cid-d7195c8badc40d0b.skydrive.live.com/embedicon.aspx/odiexperts.com/TRT_LKM_FILE_LENGTH_HEADER.xml

December 22, 2009
by kdevendr
0 comments

Categories: How to , Logic , ODI , Tips and Tricks

Tags: ,

Single Post View


Find the Value of the Variable in Operator ?

In ODI  value of the variable is calculated at the run time but not shown in the operator.

Please find this ODI procedure using Jython to show the value of the Variable.

Step 1

Create an ODI Procedure and Insert an option called  “VAR” and give the default as

<%=odiRef.getPrevStepLog("STEP_NAME")%> , reason being so that by default when using this procedure after the variable, ODI  automatically  takes the name and throws the variable value in Operator .

image

Create another Option called “PROJECT” and give the default value as your project code. The reason i have created an option for Project code is that so that you can modify in the option without any need for change in code also you can use for global variables too.

image

Step 2 .

Add an option  in the ODI procedure  and give the technology – Jython  and check “ Ignore Errors “ and paste the following code

raise  ‘  n THE VALUE OF THE VARIABLE <%=odiRef.getOption("VAR")%>  IS  –  <%=#odiRef.getOption("PROJECT")%>.<%=odiRef.getOption("VAR")%> ‘

make sure that everything inside the raise command  have single quotes before and after .

Lets test this Procedure.

image

and for Jython is

image

image

This above example shows that i want to find the value of  variable of  variable other than the previous step , just change the var value to that name of the required variable.

image

hope this helps who are looking for a way to know the value of the variable at run time.

For global variables you don’t need to mention the project code. Just type ‘GLOBAL’ instead of the project code.

image

 image

 

Please find below the codes ,download and all you would need to do is to change your default project codes in the option from XMT to whatever desired and you can make any kind of changes desired.

Just import in an Insert_Update mode and change the project code to your default.

 

VALUE OF VARIABLE – JYTHON

http://cid-d7195c8badc40d0b.skydrive.live.com/embedicon.aspx/odiexperts.com/TRT_VALUE_OF_VARIABLE_JYTHON.xml

December 22, 2009
by kdevendr
1 Comment

Categories: How to , Logic , ODI , Tips and Tricks

Single Post View


Invisible Join

I would like to show a simple invisible join between tables in the interface. The reason why i am calling the joins invisible is because I am not defining the joins at the build but rather at run time.

Such a scenario can exist while doing lookup of staging table with other Lookup or join tables and so the joining condition can keep getting changed so there way I can have only one interface rather than two or multiple interfaces.

image

As you can see there are two joins but they are not connected.  Looking at each join as you can see I have declared the Table_Name. Variable = Join_Table_name.Variable

TO do so ,just connect any two columns of the two tables and then change the joining condition column with variables.

image

similarly for the second one two.

image

 

I have specified the join columns in the variable ,as for this example i am making the join between S_COL.I_TABLE.SNP_COL.I_TABLE  and S_COL.I_TABLE=SNP_TABLE.I_TABLE

image

Specify your variable with the required column names  as i did with I_TABLE and run your interface. You can have different column conditions with a same variables and one interface.

November 26, 2009
by kdevendr
0 comments

Categories: Administration , ODI , Tips and Tricks

Tags: ,

Single Post View


Shortcuts Keys

 

Short cut for keys for ODI

F5 REFRESH
F11 FULL SCREEN MODE
F3 SEARCH
F1 HELP
F2 RENAME AN OBJECT [ Click on an Interface , Package or other Object and Press F2 , you can rename the object code ]

 Shortcuts for ODI Designer

CNTL+ALT+P PROJECT                          
CNTL+ALT+M MODEL
CNTL+ALT+S SOLUTION
CNTL+ALT+G OTHERS

 

Shortcuts of ODI Operator

 

CNTL +ALT+E SESSION LIST
CNTL+ALT+H HIERARCHICAL SESSION
CNTL+ALT+P SCHEDULING
CNTL+ALT+S SCENARIO
CNTL+ALT+O SOLUTION
 
 Shortcuts of ODI Topology

  

CNTL +ALT+P PHYSICAL ARCHITECTURE
CNTL+ALT+C CONTEXT
CNTL+ALT+L LOGICAL ARCHITECTURE
CNTL+ALT+A LANGUAGES
CNTL+ALT+R REPOSITORIES
CNTL+ALT+H HOSTS
CNTL+ALT+A GENERIC ACTION


November 26, 2009
by kdevendr
1 Comment

Categories: Administration , Architecture , How to , Logic , ODI , Tips and Tricks

Single Post View


Export – Import DWR to EWR having same Master Rep

For this particular Example I am exporting Project, Models and all the other objects under it from ODI_DEV [ DWR ] environment to ODI_WORK_EWR [ EWR ]

DWR – Development Work Repository

EWR – Execution Work Repository



Step 1 – Export the scenarios

Right click and export the scenario to the required folder


Step 2 – Select the Folder to export the scenarios


Step 3 – Repeat the above steps for all the scenarios to be exported.

Login into other EWR environment and go the Operator – scenarios tab ,as the EWR don’t have designer enabled.

Step 1 – Right click on the Scenario and select ‘ Import Scenario .. ‘


Step 2 – Select the right Import Type ” INSERT_UPDATE ” and the directory to be imported and you would find the list of scenarios to be imported.


The best practice is to use import type ” INSERT_UPDATE ” for the reason being that if the scenarios are already present they would be updated else inserted.

Click ok to the warning


And all the scenarios imported will be visible.


Run the test for one or two for successful scenario import and it works.


November 26, 2009
by kdevendr
0 comments

Categories: How to , ODI , Tips and Tricks

Single Post View


Smart Search

When you have multiple Interface under a folder and you would like to go for a quick search , just expand the folder and start typing your search and  the match would be highlighted.

Please find a screenshot of the example ,as you can see i was searching for INT_SMODEL and the particular item is highlighted.

image

Here i was looking for  DB2/400 LKM and the particular KM is highlighted.

image

November 23, 2009
by kdevendr
2 Comments

Categories: Administration , Architecture , Logic , ODI , Technology , Tips and Tricks

Tags: , , , ,

Single Post View


Export – Import DWR to DWR having same Master Repository

For this particular Example I am exporting Project, Models and all the other objects under it from ODI_DEV [ DWR ] environment to ODI_TEST [ DWR ] where DWR is Development Work Repository

Step 1 – Export the Project

Specify the directory to be exported

Step 2 – Export the models as shown above and you will find all the exported objects are created as XML Files as shown below.

Lets now move the objects to the other ODI_TEST [ DWR ] environment.

Step 1 – Export the Models

Login into ODI_TEST [DWR] , Right click on the Import Model folder option under the Model Tab.

Go the Folder where the objects are created.

Use only ‘ INSERT_UPDATE’ option as this way it would maintain the internal ID of the objects.

Don’t worry about this warning and click ok.

The models are imported . The next step is to import the project

Repeat the above step to import using the INSERT_UPDATE mode and select the project to be import and as you can see all the packages, interface , KM are also imported .

Now lets test the interface for its validity.

Voila it works

  1.  
  2. For this example I have not used any variable in that case I would suggest this order for Import.

  3. Import Models
  4. Import Global Variables , Sequences , Functions
  5. Import Project
  6. Lets look at the Internal Id of both the environment, they are same , you can compare other objects too and you will find that their internal ID are the same.

Using ODI Solution

Right click on the Solution and click ‘ Insert Solution ‘

As You can see that , the Project and the Model are created with the required versions.

Now Log into the other DWR environment and since the solution is stored in the Master Repository and we have the same Master Repository . The solution will be visible in the other DWR.

Right click on ” Restore All Elements ” to restore all the objects of the solution.

Click ok on all the warnings

Do so for all the other objects and finally all the objects will be restored to the required version.

I ran the package again and it worked.

 

Please find my future post on more best practices and method of Export and Import of ODI Objects.