Sunday, 4 January 2009

ODI Series - Putting it all together

In one of my last blogs I ended up with a couple of interfaces which I said could be automated with the use of the package, today I am going to go over the basics of packages and bring variables into the equation.

A package lets you execute a sequence of steps in an organised diagram, the steps can be :-
Executing an interface
Executing a procedure
Setting, declaring, evaluating or refreshing a variable,
Executing ODI tools, there are a number of tools provided which perform specific tasks at run-time. These tasks can be such as waiting for data to arrive, ftp’ing information or sending emails. There is a full pdf document available describing each tool and its parameters which can be downloaded from here

Say you have a situation where you receive files on a daily basis, when the files arrive this this information needs to be loaded into an essbase cube, once completed an area of metadata has to be extracted from the cube loaded into planning, planning refreshed, files archived and finally send an email informing that the process has been completed, this can achieved quite easily using a package and I am go through the steps to automate this scenario.

When you create a new package you start with a blank diagram.



Before I start adding objects to the diagram I am going to create some variables. A variable is an object that stores a single value. This value can be a string, a number or a date.
The value is stored in ODI, and can be updated at run-time.

I am going to create a variable that will store the location of the archive directory, a variable that will store the log directory and a variable that hold the current date.

To create a variable it is simply down by right clicking variable in the designer and selecting insert variable.



Datatypes : Alphanumeric (255 characters), Date, Numeric (Maximum 10 digits) or Text (unlimited length).

Action : This parameter shows the length of time the value of a variable is kept for:

Non-persistent : The value of the variable is kept in memory for a whole session.
Last value : ODI stores in its repository the latest value held by the variable.
Historize : ODI keeps a history of all the values held by this variable.

I created another variable just like the one above for the log directory.

To create the variable to hold the date it is exactly the same process, except you need to enter information into the refreshing tab, when you refresh a variable in the package it will perform a query based on what has been entered and the schema chosen.

In the schema dropdown I selected a schema that I had set up in the topology manager to look at SQL Server, I have chosen this, as I want to run a query against SQL server to return the current date.



The SQL to return the date is :- SELECT CONVERT(VARCHAR(10),GETDATE(),105)

This will return the current date using the function GETDATE() and format it using the CONVERT function.

If you are using Oracle then you can use "SELECT sysdate FROM dual" and use something like TO_CHAR to format it.



You can use the refreshing option in various different ways for example you could have values stored in a field in a database table and set the variable value by retrieving the information from the field.

When using variables in a package you declare them and then you can use them as an option value in a KM.
So if you open up one of the interfaces that is going to be used in the package, you use "#variable name", as shown below where I have used the LogDirectory variable.



Once the variable has been declared in the package then it will be passed into the interface, please note though this will not work if you just run the interface out of the package.

Right back to the package, the first step in our scenario is to wait for a for a file, to do this then one of the ODI tools is required – OdiFileWait



All the parameters are explained in full detail in the ODI tools documentation.
The settings that I used:-
Action - Move – this will mean when the file arrives it will be moved.
Filename Mask – any files starting measures*.csv will be checked for.
Target Directory – the file will be moved to this directory.
Target File – the file will be renamed to Measures.csv to align with the naming in the interface.
Overwrite Files – if the file already exists in the target directory it will be overwritten.
Timeout - 0 – This is the time to check for the file, 0 means an infinite time.
Polling Interval – time in milliseconds to check for the file.

It is possible to use variables for any of the parameters, all depends which settings are likely to change and can be controlled easier with the use of variables.

The next stage would be to run the interface that loads the measures into the essbase cube, as the interface uses the log directory variable it will need to be declared first, to do this you drag the variable on to the diagram and set the type to “Declare Variable”.



To create the process between the steps is done in the advanced section, it gives the ability to set what step to perform next depending if the current step is successful or fails.



The interface can be dragged onto the diagram, if the interface fails then I want the process to send a failure email and then stop, this can be achieved by using another tool – OdiSendMail.



If the process fails an email will be sent with the interface log files attached, the variable #LogDirectory will be converted into the correct stored value.

After the essbase load process has completed the next step is to add the interfaces that extract the metadata from essbase and load it into planning, I am using the interfaces from a previous blog.



Now if any of the newly added interfaces fail you could add another email failure object but this can get messy and unmanageable in the end, one way of streamlining could be the use of variables.

If you create a new variable and set it “Not Persistent” as the value is only important in the current session, in the refreshing section we can use one of the ODI API functions <%=odiRef.getPrevStepLog("STEP_NAME")%>, this will retrieve the step name from where the error occurred, you still need to use it as a query so we end up with :-



If you are using Oracle then the query would be :- SELECT '<%=odiRef.getPrevStepLog("MESSAGE")%>' FROM DUAL

In the email body we can use the variable to highlight where the step failed.



In the diagram at each point of failure the process can be updated.



This means whenever a process fails it will refresh the variable with the step name and place that in the body of the email.



Ok, say all the processes have completed we want to archive the metadata file with the current date on it.

First we need to use the date variable and refresh it.



The archive directory value also needs to be dragged onto the diagram and then the use of another ODI tool called OdiFileMove is required.



This will take the file Measures.csv from the E:\FileStore directory (most of the time I would of used a variable for the file store directory and used it throughout) and move it into the archive directory renaming it to Measures(current date).csv e.g. Measures01-01-09.csv

Finally you could use the tool OdiZip to compress the file and then send out the success email.



Another useful function of variables is the ability to evaluate them and execute a step depending on the Boolean result, for example say you have a daily and weekly process, if a variable is set to weekly it would run the weekly process otherwise run the daily process.



You can also use a variable in a DataStore, for example if have a file DataStore and use it in an interface to create an output text file you could use the Select date variable to always output the file with the current date on it.



As long as you set the variable in the package you will be able to pass it to the DataStore.

There are many possibilities with using variables in your packages and with all the provided ODI tools you can be build up complex packages. I only just touched the surface today to give a start to using them and will hopefully give you ideas to achieve your integrations.

Next I will move on to running integrations over the web and putting the invocation API to good use.

10 comments:

Parvathi said...

Hi,

I am currently working with ODI. Your posts are really helpful for me. I have one doubt, how can i evaluate a variable with the value of another variable. Could you please let me know how to do that?

Regards,
Parvathi Mohan.

Jonathan said...

Hello, my team and I are currently trying to create an Incremental Variable in ODI to set up a surrogate key in our target table. Do you have any experience with this?

Regards,
Jon Hanson

Ankit Jain said...

Jonathan,

Did you try using sequences instead of variables for populating surrogate keys of the target table.

Thanks
Ankit Jain
askankit.blogspot.com

來自大海的心 said...

Hi,

May I use variable be the filter condition IN THE interface?

thanks.

123 said...

素食餐廳 交友 婚友 婚友社 婚友聯誼 愛情公寓 相親 相親銀行 聯誼 命理網 姓名學Hook and Loop 婚禮佈置 情人花束 新竹花店婚友聯誼社 愛情會場佈置 氣球佈置二手車健檢 醫學美容 淨膚雷射 汽車美容 法拍屋 水餃 清潔公司 塑膠袋批發 塑膠袋工廠 實驗動物 到府坐月子 坐月子 坐月子中心 坐月子餐 孕婦 月子餐 到府坐月子 中古車 今日金價 坐月子中心 坐月子中心台中 坐月子中心台北 台北人力銀行

123 said...

金價查詢 月子餐 月子中心 坐月子餐 月子餐外送 月子餐食譜 統一發票9 10月 金價 統一發票9 10月 找工作 統一發票7 8月 求職 1111求職人力銀行 104求職人力銀行 104人力銀行 統一發票5 6月 104人力銀行 104求職人力銀行 塑膠袋 統一發票1 2月 金價 黃金價格 金價查詢 黃金買賣 環保袋 肉毒桿菌 黃金 統一發票3 4月 坐月子 sum中古車 1111人力銀行 104求職人力銀行 1111人力銀行求職 黃金價格查詢 中古車買賣 塑膠袋 統一發票9 10月 塑膠袋批發 中古車 中古車買賣消防公司 地板施工 網路廣告 網路行銷

123 said...

網路行銷食品批發 拉麵 T恤 慈善 店面租賃 店面出租 店面出售 花茶 花草茶 肝癌 健康檢查 身體檢查 飛梭雷射 雷射溶脂 直航機票 養生茶 招牌 led招牌 招牌製作 美國月子中心 保養 美國月子中心 美國月子中心 團體服 OBU 投審會 會計師事務所 會計師 工商登記 彌月蛋糕 公司登記 保時捷 法拉利 福利 <包子 肉粽 宅配美食 四神湯 搬家公司 訂房網花東旅遊 桃園土地 桃園房屋仲介 桃園房屋 桃園房屋網 桃園房屋買賣

123 said...

馬桶 馬桶不通 國外旅遊 國外機票 團體旅遊 直航機票 簽證熱水器 蘭花 化糞池 抽化糞池 便宜機票 國內旅遊 抽水肥 太陽能 水管不通 洗水塔 消毒 通水管 通馬桶 馬桶 馬桶不通 上順旅行社 五福旅行社 大興旅行社 天喜旅行社 天福旅行社 日本旅行社 日本旅遊 日本機票 日本自由行 日本訂房 包通 抽化糞池 抽水肥 水管不通 洗水塔 自由行 訂房 雄獅旅遊 汽車美容 汽車美容 三久太陽能黃金價格查詢 貸款 信用貸款

123 said...

漆彈 搬家公司 會場設計紙盒訂裝 展覽設計展場設計 展覽設計 消防設備 消防設備 機電 崴立機電 牙齒美白 植牙 牙周病治療方法 植牙費用 牙周病 光纖美白除毛 肉毒桿菌除皺 紙盒印刷 紙袋包裝 當鋪 當舖 借錢 手提紙袋 紙袋工廠 包裝紙袋 手提袋 包裝盒 股票教學 股市分析 股市億萬贏家 股票軟體 股票行情 ferrari 賣車 賓士 lexus紙袋印刷 會場設計 貸款 票貼 二胎 包裝紙盒融資 工商融資 支票貼現 借款 微晶瓷 3D飛梭雷射 淨膚雷射 汽車借款 汽車貸款 徵信 徵信社 外遇 彌月送禮 喜餅

123 said...

彌月 離婚 獸醫院 寵物住宿 白內障 心絲蟲 腎衰竭 狗皮膚病RF PCB Rigid-Flex PCB 動物醫院 洗鞋店 加盟 洗鞋 洗包包 洗鞋加盟 酒店式公寓旅行社slot machine manufacturer 杭州旅遊北京自由行上海自由行旅遊網律師
台北民宿 房屋仲介 法拍屋 法拍 法拍屋查詢系統板橋法拍屋 大台北法拍屋 原裝進口燈飾 流行燈飾 3D立體印刷 印刷服務回收 照明 彩盒 回收電腦 水晶燈 日租套房 台北日租 apartment 太平山民宿 宜蘭民宿推薦 法律事務所