Using Jython script in ODI
Hi,
I have a requirement where I want to leverage a jython script to solve a business problem (breaking a semicolon separated string into tokens). I will be calling this script from ODI.
Do I need to download the jython interpreter for testing my script before I use it in ODI?
How do call the script from ODI ?
Hi,
Isn't possible to you create the script at ODI procedure and execute it from ODI? I mean, write the jython code at ODI.
A good example in how to use jython can be found at the LKM SQL to SQL (Jython)
Similar Messages
-
Jython scripting and ODI variables
Hi,
I've had a look through the documentation but wans't able to find the answer to this, apologies if it's in there.
Some ETL tools that we've used previously have their own scripting language embedded within the tool. This allows us to populate, refresh and evaluate variables within scripts. The values of the variables can then be used with queries as mapping or restrictions in the where clause.
The question I've got is - can ODI variables be used within Jython scripts in a similar way? Can they be passed in, values assigned, returned and used within the project? If not, can this only be achieved through the SQL query that is part of the variable definition.
Hope this question makes sense, it's really a comparison with the scripting language and variables that we use in another tool.
ThanksHello,
I see what you are trying to achieve, and I believe you got it all right.
Variables can be retrieved using the #VARIABLE_NAME expression in Jython scripts, mappings, filters, or anywhere else.
They can be set only
- Through a set variable step to a constant value.
- In a refresh variable step to the (mono-field, mono-record) result of a SELECT statement.
You cannot do in some Jython code something like: #VARIABLE_NAME = myJythonVariable
You'd need to insert the values of your variables in a temporary table (in the Jython script), then refresh the variable from the content of this temporary table.
Regards,
-FX -
Hi,
I have made one simple jython code in odi procedure which will read the script file from one location and if there is some error in the script then that error will be displayed in the odi operator.
This work has been done in place of using ODI os command which can call the script from a particular location but cannot revert back with the error in ODI operator.It only shows odi os command return 1.
here is the code:
Step 1 in odi procedure--
import os
from subprocess import Popen
from subprocess import PIPE
ScriptFile = '<%=odiRef.getOption("ScriptFile")%>'.strip()
if (ScriptFile == "") or (os.path.isfile(ScriptFile) == 0):
raise IOError("The script file " + ScriptFile + " does not exist.")
Step 2:
args = [ScriptFile]
#raise IOError(args)
process = Popen(args, stdout=PIPE, stderr=PIPE)
output, oerr = process.communicate()
if (process.returncode != 0):
stdOutString = str(output)
stdErrorString = str(oerr)
raise IOError([stdOutString,stdErrorString])
else:
pass
Here the ScriptFile is the option set in procedure where i am passing the script file location.Yes it was done through that.
One more question is to how we can pass the parameters to this script ?
I need to pass some parameters which will be internally used in the script. -
Jython script to execute OS Command based on OS
Hi,
Could anyone help me in writing Jython script in ODI to execute a OS command (create a file with list of .csv files available in specified directory) based on the OS on which code is running?
We have DEV and UAT are in Windows environment and Training is in Linux environment.
I tried following http://odiexperts.com/jython-os-bug-in-windows-7/ but I am getting errors like, SyntaxError: ("no viable alternative at character '\x93'", ('<string>', 3, 13, 'os.command(r \x93 copy /r source_path dest_path\x94) \n'))
Please help me and its urgent.
Thanks
MTHi aetl,
Thank you so much for your help!
I am trying with below code
import os
if os._getOsType('') == 'nt':
lv_command = 'dir /a/b > file_name.txt'
else:
lv_command = 'ls -l > file_name.txt'
os.command(lv_command)
but I am getting error as
org.apache.bsf.BSFException: exception from Jython:
Traceback (most recent call last):
File "<string>", line 2, in <module>
AttributeError: 'module' object has no attribute '_getOsType'
Please help me.
Regards
MT -
Jython script error..while invoking odi scenario
while running the below jython script i am getting the following error..any idea how to resolve this..not able to find any solution in the net
Jython Script
==========
import os
scen_name="DVM"
scen_ver="001"
odiscen="startcmd.bat OdiStartScen -SCEN_NAME="+scen_name+"-SCEN_VERSION="+scen_ver
if os.system(odiscen) <> 0:
raise odiscen
Error:
====
ODI-1217: Session GetFileNames (412355) fails with return code 7000.
ODI-1226: Step GetFileNames fails after 1 attempt(s).
ODI-1232: Procedure GetFileNames execution fails.
Caused By: org.apache.bsf.BSFException: exception from Jython:
Traceback (most recent call last):
File "<string>", line 6, in <module>
startcmd.bat OdiStartScen -SCEN_NAME=DVM-SCEN_VERSION=001i tried with spaces also..and also added context also in the script..but still getting the same error
import os
scen_name="DVM"
scen_ver="001"
cont="E1APS"
odiscen="startcmd.bat OdiStartScen -SCEN_NAME="+scen_name+" -SCEN_VERSION="+scen_ver+" -CONTEXT="+cont
if os.system(odiscen) <> 0:
raise odiscen -
Problem using SQL Loader with ODI
Hi,
I am having problems using SQL Loader with ODI. I am trying to fill an oracle table with data from a txt file. At first I had used "File to SQL" LKM, but due to the size of the source txt file (700MB), I decided to use "File to Oracle (SQLLDR)" LKM.
The error that appears in myFile.txt.log is: "SQL*Loader-101: Invalid argument for username/password"
I think that the problem could be in the definition of the data server (Physical architecutre in topology), because I have left blank Host, user and password.
Is this the problem? What host and user should I use? With "File to SQL" works fine living this blank, but takes to much time.
Thanks in advanceI tried to use your code, but I couldn´t make it work (I don´t know Jython). I think the problem could be with the use of quotes
Here is what I wrote:
import os
retVal = os.system(r'sqlldr control=E:\Public\TXTODI\PROFITA2/Profita2Final.txt.ctl log=E:\Public\TXTODI\PROFITA2/Profita2Final.txt.log userid=MYUSER/myPassword @ mySID')
if retVal == 1 or retVal > 2:
raise 'SQLLDR failed. Please check the for details '
And the error message is:
org.apache.bsf.BSFException: exception from Jython:
Traceback (innermost last):
File "<string>", line 5, in ?
SQLLDR failed. Please check the for details
at org.apache.bsf.engines.jython.JythonEngine.exec(JythonEngine.java:146)
at com.sunopsis.dwg.codeinterpretor.k.a(k.java)
at com.sunopsis.dwg.dbobj.SnpSessTaskSql.scripting(SnpSessTaskSql.java)
at com.sunopsis.dwg.dbobj.SnpSessTaskSql.execScriptingOrders(SnpSessTaskSql.java)
at com.sunopsis.dwg.dbobj.SnpSessTaskSql.execScriptingOrders(SnpSessTaskSql.java)
at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTaskTrt(SnpSessTaskSql.java)
at com.sunopsis.dwg.dbobj.SnpSessTaskSqlC.treatTaskTrt(SnpSessTaskSqlC.java)
at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTask(SnpSessTaskSql.java)
at com.sunopsis.dwg.dbobj.SnpSessStep.treatSessStep(SnpSessStep.java)
at com.sunopsis.dwg.dbobj.SnpSession.treatSession(SnpSession.java)
at com.sunopsis.dwg.cmd.DwgCommandSession.treatCommand(DwgCommandSession.java)
at com.sunopsis.dwg.cmd.DwgCommandBase.execute(DwgCommandBase.java)
at com.sunopsis.dwg.cmd.e.i(e.java)
at com.sunopsis.dwg.cmd.h.y(h.java)
at com.sunopsis.dwg.cmd.e.run(e.java)
at java.lang.Thread.run(Unknown Source) -
Store a value in variable from Java using Jython
Hi all,
I want to send some arguments to a java program and a small logic will be applied there and it will return a value.I need to capture that result in a variable and to store that in a target column.
For Ex:
I wrote a java program which handles the arguments and applies the logic and it will return a string.Then i made a jar out of this java class and placed in ODI Drivers:
I have done the following at Stored Procedure using Jython Technology selected.I am passing the column data using a variable created at ODI.
Logic is my Java Class and result is the method which does the logic process
import Logic
arg1=#arg1
arg2=#arg2
arg3=#arg3
arg4=#arg4
result
Logic lop= new Logic()
result=lop.result(arg1,arg2,arg3,arg4)
Now i want the result to be applied to a particular column at target table.how can i a store that result in a variable.am i going right or any other suitable way is there ?
Plz guide meUse AddResource to add Javascript in your BackingBean Code and pass the value to your javascript code.
JSCookMenu and other dynamic adding of javascript to a JSF-JSP page is done using AddResource.... -
How to call a shell script via ODI
Hi,
I need suggestion on following issues:
1) How to call a shell script via ODI?.. I tried using OSCommand utility .inspite of the execution being successful the data is not written into the new file in the desired format. After processing new file is created in the mentioned location but its empty.
2) I'm calling a procedure in ODI to load data into my fact. But once the fact gets loaded i want to update the log details (num of rows processed,num of rows inserted,num of rows rejected etc) in my log table. I'm planning to use a proc for updating but need to know from where can i find these details. Is there a table in work rep which gives me these info like how we get if we execute an interface.?
Please help me out.. Its urgent
Regards
SurabhiHello,
Question 1 appears a little vague, please elaborate. If you're looking to capture a return value from the command execution, you will need to pipe the return value to a file, then read from there.
The execution information is stored in the SNP_STEP_LOG table in the Work Repository. You will need to do a series of joins to retrieve the exact table that was updated. Good luck with this... -
How to add many hosts using jython interface to sps host database
Hi,
we want to create a huge number of virtual hosts into sps repository with jython interface.
for exemple our variables are:
hostname = sps1.internet.com
ip = 192.168.1.1
masterserver = masterserver
hardware = v550
and the script command looks like:
app.execRaw ( 'hdb.h.add' , { 'name' : hostname , 'desc' : hardware , 'tID' : 'NM:com.vodafone.osmgt#vodRAvhostHT' , 'pID' : NM:masterserver , 'attr' : 'cliServer=cliServer;RA_HOSTNAME=hostname;RA_PROVISIONING_IP_ADDR=ip;RA_DESCRIPTION=Dynamic Infrastructure container;RA_OWNER=n1sps;RA_OWNER_DIR=/var/crash/home/n1sps;RA_OWNER_CREATE_SSH_CONN=true;RA_UID=2241;RA_GROUP=n1sps;RA_GID=2241;RA_INSTALLER_USER=root;RA_SUID=y;RA_INSTALLBASE=/opt/SUNWn1sps;RA_CTYPE=ssh;RA_CTYPE_PARAM=cprefix=/opt/SUNWn1sps/N1_Service_Provisioning_System/agent;RA_LEAVEFILES=n;RA_INSTALL_JRE=/opt/SUNWn1sps/N1_Service_Provisioning_System/common/jre;RA_PORT=1131;RA_CIPHER_TYPE=1;RA_INSTALLER_WORKDIR=/tmp;RA_PARENT_HOST=masterserver;RA_PARENT_OWNER=n1sps;RA_PARENT_OWNER_DIR=/opt/SUNWn1sps/home/n1sps;RA_PARENT_TYPE=MS;RA_PACKAGE_PATH=/var/tmp/spsra;RA_PACKAGE_NAME=cr_ra_solaris_sparc_5.2.sh;RA_REMOTE_PACKAGE_TMP_DIR=/tmp;RA_REMOTE_PRIV_CMD=/usr/local/bin/sudo;RA_REMOTE_PRIV_USER=admin;RA_REMOTE_PRIV_USER_HOME=/home/admin;RA_SRC_SSH_DIR=/opt/home/.ssh;RA_DST_SSH_DIR=/home/.ssh;RA_SSH_AUTH_KEY_FILE=authorized_keys' } )
unfortunetly we are getting an error when we try to run the n1 sps hdb.h.add command.
Are we using this command in the right manner ?
Thanks in advance.
ChristianDear Tarzanek,
I am Alexis Susset a coleague of Christian.
Thank you very much for your reply, we are now able to add hosts directly from a Jython script.
Unfortunetly, we are now encourting a problem with the hdb.h.add command.
It dies if our hostname (name) is already present in the database.
We currently need to import a very high number of node and I would like to know how to simply get two outputs (1. added nodes, 2. non-added nodes ).
Please let me know if you would like me to post the scripts I have.
PS: I tried to use a hbd.h.lo command but it dies as well when I search for a host that doesn't exist.
Many thanks and best regards,
Alexis -
Jython script for loading memos
Dear All,
Has anybody tried loading memos using jython import scripts in fdmee??Have you bothered to look in the help files where they give
you examples?
And if so, make sure you note the difference between loading
a Flash movie
(SWF), and loading video (FLV)
Jeckyl -
Hello -
I was wondering if I can run a job to execuse an AIX script from ODI. I was looking thru ODI Utilitiies "OdiOSCommand" and "OS Command" - But, I couldn't see where to specify the Server Name. I do see the "Command to Execute" which is good, but I need to tell it which server this command resides in. Unless there is another ODI utility I can use..?
Thank you for any input you can provide.You will need an agent to run these scripts.
There are 2 ways this can be done.
1.) You will need to create an agent on the AIX box on which the script needs to be executed.
2.) If thats not possible, then on the machine on which the "agent" is deployed, the script should live. This script should then ssh/rsh into the AIX box in question and execute it there. -
Unable to capture the adf table column sort icons using open script tool
Hi All,
I am new to OATS and I am trying to create script for testing ADF application using open script tool. I face issues in recording two events.
1. I am unable to record the event of clicking adf table column sort icons that exist on the column header. I tried to use the capture tool, but that couldn't help me.
2. The second issue is I am unable to capture the panel header text. The component can be identified but I was not able to identify the supporting attribute for the header text.Hi keerthi,
1. I have pasted the code for the first issue
web
.button(
122,
"/web:window[@index='0' or @title='Manage Network Targets - Oracle Communications Order and Service Management - Order and Service Management']/web:document[@index='0' or @name='1824fhkchs_6']/web:form[@id='pt1:_UISform1' or @name='pt1:_UISform1' or @index='0']/web:button[@id='pt1:MA:0:n1:1:pt1:qryId1::search' or @value='Search' or @index='3']")
.click();
adf
.table(
"/web:window[@index='0' or @title='Manage Network Targets - Oracle Communications Order and Service Management - Order and Service Management']/web:document[@index='0' or @name='1c9nk1ryzv_6']/web:ADFTable[@absoluteLocator='pt1:MA:n1:pt1:pnlcltn:resId1']")
.columnSort("Ascending", "Name" );
} -
Unable to turn column headers bold in Word table using VB Script
I have created a table in Microsoft Word 2010 using VB Script (this is via the script engine that forms part of HP Quality Centre functionality). The table itself is OK, 2 columns with centred headers. However, I am unable to make the column
headers bold. I have spent hours searching the net and trying various options to no avail can somebody please help me.
Set objWord = CreateObject("Word.Application")
Set objDocument = objword.Documents.Open(Src_Dir & template_file
Const wdAlignParagraphCenter = 1'var to control justification of the table columns
Const NUMBER_OF_ROWS = 1 'number of rows in intial table
Const NUMBER_OF_COLUMNS = 2 'number of colums in the intitial table
'search for the "TAA_TABLE" bookmark embedded in the document template, this is where the table will be created
Set objRange=objDocument.Bookmarks("TAA_TABLE").Range
'create the table
objDocument.Tables.Add objRange, NUMBER_OF_ROWS, NUMBER_OF_COLUMNS
Set objTable = objDocument.Tables(2)
'populate column headers
objTable.Cell(1, 1).Range.Font.Bold = True
objTable.Cell(1, 1).Range.Text = "Sub Contractor"
objTable.Cell(1, 2).Range.text = "TAA Number"
'centre the column headers
objDocument.Tables(2).Rows(1).Select
Set objSelection = objWord.Selection
objSelection.ParagraphFormat.Alignment = wdAlignParagraphCenter
'format the table with plain grid lines
objTable.AutoFormat(16)
'set the column widths
objTable.Columns(1).Setwidth 230,0
objTable.Columns(2).Setwidth 230,0
Any help is graetfully appreciated, as this is driving me wild.
Cheers,Hi Citronax,
I haved noticed that you used objTable.AutoFormat to format the table. Based on my understanding, this fuction will applie a predefined look to a table.
After I move the code which bolder the text behind this line of code, it works well for me.
'format the table with plain grid lines
objTable.AutoFormat (16)
objTable.Cell(1, 1).Range.Font.Bold = True
Regards & Fei
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
Can we use Java Script in SAP BusinessObjects Web Intelligence 4.1?
Can we use Java Script or any other Script in BI 4.1 Web Intelligence? If possible please do let me know the method/process
Hi Kranthi,
You have option to read a cell content as html. else you will have to go for SDK. I think you will get better suggestions, if you can explain your requirement in a little detailed manner.
refer below links for more details about SDK.
http://bukhantsov.org/2013/04/how-to-create-a-webi-document-using-java-report-engine-sdk/
Regards,
Nikhil Joy -
Using Powershell Script Run simple query in MS Access 2007 and export the results of query to Excel
Hi Experts,
I have a Access 2007 DB file and 2 Big tables inside that (bigger than the size that can be easily handled by MS Excel 2007).
My requirement is automate using powershell scripts the below things.
1. Create a SQL query in Access DB and save that in access DB
2. Run the saved query and export the result in excel sheet where I can create the charts and Pivots. Thanks in advance
PrajeshDo you have to use the Access query, couldn't you just recreate the query in Powershell? Here's a link with good info that references an existing script for querying an Access database:
http://blogs.technet.com/b/heyscriptingguy/archive/2009/08/13/hey-scripting-guy-can-i-query-a-microsoft-access-database-with-a-windows-powershell-script.aspx
Once you have your dataset you can pipe it to
Export-Csv -NoType c:\pathtofile\output.csv
Maybe you are looking for
-
Error while opening modal (skillbuilder plugin) page on page load
Hi all, I'm using 4.2.1. ( on 11GR2 ), theme 25. Skillbuilder Modal page plugin v2 Modal pages are working great, on all kinds of events, but if I try to open one via a D.A. on page load it fails with "Uncaught TypeError: Object load has no method 's
-
Batch derivation in goods receipt for production order
Hi all, i have set up batch derivation for the event 'goods receipt for production order'. The field derived is HSDAT (date of manufacture) /minimum. Although in the batch derivation monitor I can see tha the derivation was performed OK and the corre
-
XI - SAP R/3 OR R/3 - XI Via Proxy
How does the data flow from XI - SAP R/3 OR R/3 - XI Via ABAP Proxy. -Naveen.
-
I cant retrieve my images from webcams that are cached any more with mozilla. With netscape all of the live webcam images from live cams were automatically saved in my cache folder and all i had to do was open it send the files to acdsee and turn the
-
Authentication in ALSB while proxying FTP, MQ
We are using ALSB for first time to proxy external messages we receive from our business partners over different protocols e.g.FTP, MQ, SOAP over HTTP. Thus we would have Proxy services configured receiving messages, one for each transport protocol,