Java BeanShell expression in ODI

hi experts,
i am working on ODI 11 g (11.1.1)
i have found java beanshell expression in standard ODI KM (IKM "IKM Oracle Slowly Changing Dimension", step 192 "Analyze integration table"):
<%=odiRef.getTable("L","INT_NAME","A").replaceAll("","").replaceAll("..>",".replaceAll(odiRef.getInfo( \\u0022DEST_WORK_SCHEMA\\u0022 )+\\u0022.\\u0022,\\u0022\\u0022)?>")%>
It translates, for example, "DWH_ETL.I$_SC_INTERMEDIARY" to "I$_SC_INTERMEDIARY"
Please explain in detail how it works?
specifically, i don't understand how works the expression:
replaceAll("..>",".replaceAll(odiRef.getInfo( \\u0022DEST_WORK_SCHEMA\\u0022 )+\\u0022.\\u0022,\\u0022\\u0022)?>")
Java function "replaceAll" (http://download.oracle.com/javase/6/docs/api/):
public String replaceAll(String regex,
String replacement)
replaces each substring of this string that matches the given regular expression with the given replacement.
What does mean the expression "..>" in this calling replaceAll?
it looks like a nested call to the substitution API (http://www.business-intelligence-quotient.com/?p=812)
thanks in advance

HI,
I have re configured as mentioned in your blog . But still getting same exception . Something I missed in my previous thread is below.
<Sep 19, 2012 3:34:46 PM EDT> <Error> <HTTP> <BEA-101216> <Servlet: "AgentServlet" failed to preload on startup in Web application: "trellisagent".
ODI-1400: Agent trellisagent start failure: JDBC connection error occurs while connecting to the master repository.
Caused by: java.security.AccessControlException: access denied (oracle.security.jps.service.credstore.CredentialAccessPermission context=SYSTEM,mapName=oracle.odi.credmap,keyName=SUPERVISOR read)
at oracle.odi.runtime.agent.servlet.AgentServlet.startup(AgentServlet.java:318)
at oracle.odi.runtime.agent.servlet.AgentServlet.init(AgentServlet.java:226)
at javax.servlet.GenericServlet.init(GenericServlet.java:242)
at weblogic.servlet.internal.StubSecurityHelper$ServletInitAction.run(StubSecurityHelper.java:283)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
I am stuck in asituation here :(
Ashish

Similar Messages

  • JAVA BEANSHELL EXCEPTION HANDLING

    Hi
    still new to ODI
    I have created a java beanshell script in ODI which calls a simple java class, cars, then sets the no of seats to a value designed to raise an exception. Exception raised but procedure works OK,
    How can I register the fact that it has failed through exception handling? (It is possible that my java exception handling isn't quite right)
    The no of seats has no effect on the success/failure of the ODI procedure, but the log shows that the exception is caught !
    any assistance gratefully received.
    Regards
    Terry
    cars class: (added to agent start)
    ====================
    public class cars {
    private int seats;
    public void setSeats (int seats) throws tooManySeatsException {
    if (seats) < 100) {
    this .seats = seats;
    } else {
    throw new tooManySeatsException("Too many seats");
    public int getSeats () {
    return this.seats;
    class tooManySeatsException extends Exception {
    public tooManySeatsException (String msg){
    super();
    Java beanshell procedure in ODI
    ====================
    import cars;
    public class carsTest {
    public carsTest(){
    public void init(){
    cars c = new cars();
    c.setSeats(20);
    //c.setseats(200);
    try {
    carsTest ct = new carsTest();
    ct.init();
    } catch (Exception e) {
    throw Error (e);
    }

    Your code throws exception when you set value >100 but you are setting 20 thus it would not throw exception.
    In the procedure step you can uncheck "Ignore error" flag to let execution failed on throwing any exception from your code. If you check that flag then the execution would not fail rather lease the task in warning state.

  • Retrieving ODI variable in Java Beanshell (Target Beanshell Source Oracle)

    Hi Guys:
    I'm facing a simple problem, but I'm not able to find the solution in the documentation or any post in this forum. I have a procedure where I use both tabs (Source and Target) and need to retrive the result of the "StrParam" (Oracle query) into a BeanShell variable (OracleMessageData).
    In the target tab I have these commands (Java BeanShell Techonology):
    <@
    import java.io.FileNotFoundException;
    import java.io.InputStream;
    import java.io.BufferedReader;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.InputStreamReader;
    import java.io.PrintWriter;
    import java.io.UnsupportedEncodingException;
    import java.util.ArrayList;
    String OracleMessageData = "#strParam";
    String PathOfXMLFiles = "<%=odiRef.getSchemaName("LS_FILE_XMLFULL", "D")%>";
    @>
    In the Source Tab, I have this command (Oracle Techonology):
    SELECT MESSAGEDATA FROM <%=odiRef.getSchemaName("LS_ORACLE_ODI_WRK", "D")%>.CONTENT_RIB_MSGDATA strParam
    How can I retrieve the content of the Source Command into the variable in the Target? The line bellow doesn't work:
    String OracleMessageData = "#strParam";
    I'm using ODI_11.1.1.6.0_GENERIC_111219.1055
    Regards.
    Luiz Araujo
    Edited by: Luiz_Araujo on 25/07/2012 06:43
    Edited by: Luiz_Araujo on 25/07/2012 06:45

    Hi Luiz
    Use Below query on source tab.
    SELECT MESSAGEDATA STRPARAM FROM <%=odiRef.getSchemaName("LS_ORACLE_ODI_WRK", "D")%>.CONTENT_RIB_MSGDATA
    Then on target tab use
    String OracleMessageData = "#STRPARAM ";
    If it wont work try putting colon.
    String OracleMessageData = ":STRPARAM ";
    Thanks.

  • SQL expression in ODI

    I Have the following interface in oracle data integrator
    http://i44.tinypic.com/2mrsmxt.png
    # it execute successfully before inserting the following expression 
      In the mapping I insert the following SQL expression to get the average when the quantity is 0
    AVG(
    CASE WHEN TEST.QUN = 0 THEN
    (SELECT TEST.QUN FROM TEST
    WHERE TEST1.PRUDU=TEST.PRUDU
    AND TEST1.FLOW=TEST.UNIT
    AND TEST1.UNIT=TEST.UNIT
    AND to_char(TEST.DATEDDD,'MON')= to_char(TEST1.DATEDDD,'MON')
    AND TEST1.DATEDDD !=TEST.DATEDDD
    GROUP BY TEST.QUN
    ELSE TEST.QUN
    END)
    when I check this expression in ODI ..
    # the sql expression is correct for this  RDMS 
    when I executed the interface i get this error
    Caused By: java.sql.SQLSyntaxErrorException: ORA-00937: not a single-group group function
    any idea ?

    I changed the code a little ..
    CASE WHEN TEST.QUN = 0 THEN
    (SELECT AVG(TEST.QUN) FROM TEST
    WHERE TEST1.PRUDU=TEST.PRUDU
    AND TEST1.FLOW=TEST.FLOW
    AND TEST1.UNIT=TEST.UNIT
    AND to_char(TEST.DATEDDD,'MON')= to_char(TEST1.DATEDDD,'MON')
    AND to_char(TEST.DATEDDD,'YYYY')!= to_char(TEST1.DATEDDD,'YYYY')
    ELSE TEST.QUN
    END
    And I get this error ..
    ORA-01427: single-row subquery returns more than one row tips.
    The TEST Table from the source and TEST1 is a lookup table because I couldn't  do the alais in ODI
    In sql developer I did the following code that will do the same thing and work successfully ..
    update test B
    set B.qun=
    (SELECT AVG(TEST.QUN) FROM TEST
    WHERE  TEST.FLOW=B.UNIT
    AND TEST.UNIT=B.UNIT
    AND TEST.PRUDU=b.prudu
    AND TEST.FLOW=b.flow
    AND to_char(TEST.DATEDDD,'MON')= to_char(B.DATEDDD,'MON')
    AND to_char(TEST.DATEDDD,'YYYY')!= to_char(B.DATEDDD,'YYYY')
    where B.qun=0;
    any help ?
    thanksssss
    naif ..

  • Variable from Java Beanshell procedure for usage in interface

    A variable from my package contains value: ' text',' text2',' text3',....etc.
    I need to use this variable in my interface as: 'text','text2','text3',...etc.
    So I wrote a Java beanshell procedure with following code and with this input variable as an option: forecastOrgCode
    String forOrgCode = "<%=odiRef.getOption("forecastOrgCode")%>";
    String orgCodeTrimmed = forOrgCode.replaceAll (" ","");
    Any other code between <@ or <? or <% gets me messed up because of the ' characters present in the variable, so I just chose the beanshell technology and this does the trick...
    However...how can I reach this orgCodeTrimmed variable from my interface?

    As you are directly passing the value in Option , why not lets do it directly inside interface
    Using ODI Variable
    Step 1. Set Variable = ' text',' text2',' text3','text4 '
    Step 2. Inside Interface
    '<@ out.print("#VAR".replace(" ", "").replace("'", "''"));@>'You will need to convert '(single quotes) to double single quotes else oracle will throw error ,similar to what we do in pl/sql
    Directly
    '<@ out.print("' text','  text2',' text3'".replace(" ", "").replace("'", "''"));@>'

  • Java Variable Assignment from ODI Proc

    Hello,
    I have a requirement of purging the records in a set of table in DB.
    The table list to be purged is maintained in a Table Custom_Tab_List. Addition to that I need to record the total number of records deleted in another Logging table for this session.
    Wrote an ODI Procedure for the same.
    <b>Command on Source</b>
    Select table_name from custom_tab_list<b>Command on Target</b>
    delete from #table_nameFor additional Number of Counts thought of adding a Java Variable which would be global to the session. So added Step 1 in procedure
    <@ java.lang.Integer V_Count @>
    Step 2 of the Procedure
    <b>Command on Source</b>
    Select table_name from custom_tab_list<b>Command on Target</b>
    DECLARE
    v_c number;
    BEGIN
    select count(*) into v_c from #table_name;
    <@V_Count@>:= v_c+ <@out.println.(V_Count); @>;
    delete from #table_name;
    END;Not able to assignt the sql variable to the Java Variable. Is there any other way other than creating objects in the Database as an solution.

    I dont think that is possible. Two ways you can store the oracle value to a java variable.
    1.
    command on source, you can select the table name or any value with alias name
    command on target(java beanshell) just store the alias name as follows
    <@String java_v="SOURCE_ALIAS":@>
    2.
    You have to use the java program to do the dml operation as follows and retrieve the affected rows.
    not: I have not tested these codes but it will be allmost same. you just need to debug it.
    <@
    import java.sql.*;
    import java.lang.*;
    try {
    Connection myCon = snpRef.getJDBCConnection("SRC");
    Statement myStmt = myCon.createStatement();
    int cnt = myStmt.executeUpdate("delete from #SOURCE_ALIAS");
    catch(Exception s){
    System.out.println("Table is not exists!");
    myStmt .close();
    myCon.close();
    @>

  • HOW DO I REASSIGN A PACKAGE VARIABLE VALUE FROM WITHIN JAVA BEANSHELL PROC

    Hi all
    I am trying to something that I would consider quite normal in programming applications.
    create a variable - systemId
    create a procedure that runs some code (Java BeanShell), and then sets the varable to a value depending on that code
    create a second procdure that runs some code(Java BeanShell), but uses the value of the variable set from the previous stage
    In the package editor I have created a declare variable step, two procedures, and a flow: declare variable -> procedure 1 -> procedure 2
    If I declare the variable with a vue of 10 initially then try #systemId = 400, I get an error along the lines of '10 = 400'
    I am probably doing something basically wrong
    regards
    Terry

    My friend it depends on you. What ever you mentioned that can be achieved in package level but in procedure level.
    For example:
    Odi procedure: Java beanshell techonlogy
    <@
    String empname="ALEX";
    @>
    odivariable1: refresh mode in package
    select sal from emp where empname='<@=empname@>'
    Package diagram:
    ODIprocedure------ok--->ODIvariable inrefreshmode
    if you will execute this then the odivariable will have value 2000( alex salary)
    Till now it was easy to achieve. But tell me how to assign the alex salary inside the 1st procedure without taking the help of a package. You just have to execute only the procedure.Hmmm nail on your head ? you might be thinking of something like this #odivariable=<@=empname@> which is not correct.
    In this scenario you have update the snp_var_data table. So that the underlying value can be updated. Another approach could be to generate a scenario of the odi variable given above and invoke the scenario inside the procedure(this way you can refrsh it without using a package)
    Ok my friend. Seems to be a long explanation.
    Let me know if it is helpful or not.
    Bhabani
    http://dwteam.in

  • Logical AND in Java Regular Expressions

    I'm trying to implement logical AND using Java Regular Expressions.
    I couldn't figure out how to do it after reading Java docs and textbooks. I can do something like "abc.*def", which means that I'm looking for strings which have "abc", then anything, then "def", but it is not "pure" logical AND - I will not find "def.*abc" this way.
    Any ideas, how to do it ?
    Baken

    First off, looks like you're really talking about an "OR", not an "AND" - you want it to match abc.*def OR def.*abc right? If you tried to match abc.*def AND def.*abc nothing would ever match that, as no string can begin with both "abc" and "def", just like no numeric value can be both 2 and 5.
    Anyway, maybe regex isn't the right tool for this job. Can you not simply programmatically match it yourself using String methods? You want it to match if the string "starts with" abc and "ends with" def, or vice-versa. Just write some simple code.

  • Java – Regular Expressions – Finding any non digit byte in a multiple byte

    Hello,
    I’m new to JAVA and Regular Expressions; I’m trying to write a regular expression that will find any records that contain a non digit byte in a multiple byte field.
    I thought the following was the correct expression but it is only finding records that contain “all” non digit bytes.
    \D{1,}
    \D = Non Digit
    {1,} = at least 1 or more
    Below is my sample data. I would like the regular expression to find all of the records that are not all numeric. However when I use the regular expression \D{1,} it is only finding the 2 records that all bytes are non digits. (i.e. “ “ and “A “)
    “ 111229”
    “2 111229”
    “20091229”
    “200912c9”
    “201#1229”
    “20101229”
    “20110229”
    “20111*29”
    “20111029”
    “20111229”
    “20B11229”
    “A “
    “A0111229”
    Please note I have also tried \D{1,}+ and \D{1,}? And they also do not return my desired results
    Any assistance someone can provide would be greatly appreciated.

    You don't show the code you are using but I surmise you are using String.matches() which requires that the whole target must match the regular expression not just part of it. Instead you should create a Pattern and then a Matcher and use the Matcher.find() method. Check the Javadoc for Pattern and Matcher and look at the Java regex tutorial - http://docs.oracle.com/javase/tutorial/essential/regex/ .
    P.S. You can re-use the Pattern object - you don't have to create it every time you need one.
    P.P.S. Java regular expressions work with characters not bytes and characters are not not not bytes.

  • Java Regular Expressions in J2EE

    Does anybody know when Java Regular Expressions will be available in J2EE. They are currently in the latest release of J2SE in the java.util.regex package.

    They are in the Standard Edition, so it does not make sense that they will also be in Enterprise Edition some day. You need to have the standard JRE installed before you can use the J2EE classes anyway.
    If you want to use the regular expressions, install version 1.4 (beta) of the J2SE and use the current version of J2EE on top of that.
    Jesper

  • Problems with java regular expressions

    Hi everybody,
    Could someone please help me sort out an issue with Java regular expressions? I have been using regular expressions in Python for years and I cannot figure out how to do what I am trying to do in Java.
    For example, I have this code in java:
    import java.util.regex.*;
    String text = "abc";
              Pattern p = Pattern.compile("(a)b(c)");
              Matcher m = p.matcher(text);
    if (m.matches())
                   int count = m.groupCount();
                   System.out.println("Groups found " + String.valueOf(count) );
                   for (int i = 0; i < count; i++)
                        System.out.println("group " + String.valueOf(i) + " " + m.group(i));
    My expectation is that group 0 would capture "abc", group 1 - "a" and group 2 - "c". Yet, I I get this:
    Groups found 2
    group 0 abc
    group 1 a
    I have tried other patterns and input text but the issue remains the same: no matter what, I cannot capture any paranthesized expression found in the pattern except for the first one. I tried the same example with Jakarta Regexp 1.5 and that works without any problems, I get what I expect.
    I am using Java 1.5.0 on Mac OS X 10.4.
    Thank to all who can help.

    paulcw wrote:
    If the group count is X, then there are X plus one groups to go through: 0 for the whole match, then 1 through X for the individual groups.It does seem confusing that the designers chose to exclude the zero-group from group count, but the documentation is clear.
    Matcher.groupCount():
    Group zero denotes the entire pattern by convention. It is not included in this count.

  • SQL Injection and Java Regular Expression: How to match words?

    Dear friends,
    I am handling sql injection attack to our application with java regular expression. I used it to match that if there are malicious characters or key words injected into the parameter value.
    The denied characters and key words can be " ' ", " ; ", "insert", "delete" and so on. The expression I write is String pattern_str="('|;|insert|delete)+".
    I know it is not correct. It could not be used to only match the whole word insert or delete. Each character in the two words can be matched and it is not what I want. Do you have any idea to only match the whole word?
    Thanks,
    Ricky
    Edited by: Ricky Ru on 28/04/2011 02:29

    Avoid dynamic sql, avoid string concatenation and use bind variables and the risk is negligible.

  • Adobe Java Script Expressions

    Question #1    I have a check box field and two data fields containing only letters no numbers in an Adobe Acrobat Form. I would like to have a java script expression that if the Check box 1 field is checked, the contents of Data Field 1 will be automatically entered into Data Field 2 .
    Please provide script and below are the 3 fields.
    Check box 1 field: Checked
    Data Field 1
    Data Field 2
    Question #2    I have a field labeled Full Address that I am trying to get the following fields to populate from. The problem in my expression is when there is no Suite then there is an extra comma still showing.
    Please provide script.
    Sample of my script below.
    event.value = this.getField("Merchant_Addr1").value.concat( ", ", this.getField("Merchant_Addr2").value) + ", " + this.getField("Merchant_City").value + ", " + this.getField("Merchant_State").value + "  " + this.getField(" Merchant_Zip").value;
    This is what displays if no Suite is in Address (Two commas after the word Drive: 23175 La King Drive, , Irvine, CA  92656
    Data Field Street Address
    Data Field Suite (If empty then don't show comma)
    Data Field City
    Data Field State
    Data Field Zip

    For question number 2, I would use a reusable document level function to combine 3 fields a time and adjust for null field values.
    // Concatenate 3 strings with separators where needed
    function fillin(s1, s2, s3, sep) {
    Purpose: concatenate up to 3 strings with an optional separator
    inputs:
    s1: required input string text or empty string
    s2: required input string text or empty string
    s3: required input string text or empty string
    sep: optional separator sting
    returns:
    sResult concatenated string
    // variable to determine how to concatenate the strings
      var test = 0; // all strings null
      var sResult; // re slut string to return
    // force any number string to a character string for input variables
      s1 = s1.toString();
      s2 = s2.toString();
      s3 = s3.toString();
      if(sep.toString() == undefined) sep = ''; // if sep is undefined force to null
    assign a binary value for each string present 
    so the computed value of the strings will indicate which strings are present
    when converted to a binary value
      if (s1 != "") test += 1; // string 1 present add binary value: 001
      if (s2 != "") test += 2; // string 2 present add binary value: 010
      if (s3 != "") test += 4; // string 3 present add binary value: 100
      /* return appropriate string combination based on
      calculated test value as a binary value
      switch (test.toString(2)) {
      case "0": // no non-empty strings passed - binary 0
         sResult = "";
      break;
      case "1": // only string 1 present - binary 1
         sResult = s1;  
      break;
      case "10": // only string 2 present - binary 10
         sResult = s2;  
      break;
      case "11": // string 1 and 2 present - binary 10 + 1
         sResult = s1 + sep + s2; 
      break;
      case "100": // only string 3 present - binary 100
         sResult = s3;
      break;
      case "101": // string 1 and 3 - binary 100 + 001
         sResult = s1 + sep + s3; 
      break;
      case "110": // string 2 and 3 - binary 100 + 010
         sResult = s2 + sep + s3; 
      break;
      case "111": // all 3 strings  - binary 100 + 010 + 001
         sResult = s1 + sep + s2 + sep + s3; 
      break;
      default: // any missed combinations
         sResult = "";
      break;
    return sResult;
    var Addr1 = this.getField("Merchant_Addr1").valueAsString;
    var Addr2 = this.getField("Merchant_Addr2").valueAsString;
    var City = this.getField("Merchant_City").valueAsString; 
    var State = this.getField("Merchant_State").valueAsString;
    var Zip = this.getField(" Merchant_Zip").valueAsString;
    var s = fillin(Addr1, Addr2, City, ", ");
    var s = fillin(s, State, "", ", ");
    event.value = fillin(s, Zip, "", "  ");
    Or the custom calculation script could be reduced to:
    // custom calculation script;
    var Addr1 = this.getField("Merchant_Addr1").valueAsString;
    var Addr2 = this.getField("Merchant_Addr2").valueAsString;
    var City = this.getField("Merchant_City").valueAsString;
    var State = this.getField("Merchant_State").valueAsString;
    var Zip = this.getField(" Merchant_Zip").valueAsString;
    event.value = fillin(fillin(Addr1, Addr2, fillin(City, State,"", ", "), "", ", "), Zip, "", "  ");
    Do not forget the fillin function.

  • Java BeanShell

    Hi again.
    Is it possible to use a java beanshell in jcreator???
    I use an option called "Interpret" in xemacs which enables me to test individual classes without having a main test class. Does jcreator have this facility??
    Thanx

    Ok i searched on the net and i downloaded a beanshell jar file. I have put the beanshell in the folder of the java files, but it says:
    // Error: Typed variable declaration : Class: Room not found in namespace: <at unknown location>
    i have set the environment variables.
    Anyone have any idea to use this beanshell in windows????
    Thanx

  • Java regular expression for Arabic

    i want to use java regular expression to evaluate some string in Arabic
    can some body tell me how to do a match for arabic characters

    i have this code :
    String poem="���";
          //String m1="\\p?";   
           String m1= "\\p{�}";
            Matcher m =
          Pattern.compile(m1)
            .matcher(poem);
        while(m.find()) {
          for(int j = 0; j <= m.groupCount(); j++)
            System.out.print("[" + m.group(j) + "]");
          System.out.println();
        }i get the error:
    Exception java.util.regex.PatternSyntaxException: Unknown character property name {?} near index 2
    \p?
    if you find that is hard to help with Arabic regex, can someone post a code on how to match Arabic regex or chineese or any thing not latin regex match
    because a need to match a Strings in Arabic if some one can tell me how?

Maybe you are looking for

  • Vendor master field customisation

    Hi all, I have added a new field to the LFM1 table and want to include the field in the XK01 transaction screen. However, there exists no screen exit for the XK01 transaction and as it stands, it needs to be done though customisation. Could anyone gu

  • Change font size in Skype?

    Hello skype users, someone could help me how to change the size of fonts on Skype? Its default font is smaller and I almost can not see it. Thank you.

  • How do I get my newly purchased music from my computer to my ipod

    How do I get my newly purchased music from my computer to my ipod ??

  • SAP GUI Scripting: Script Is Running.....Help!

    Hello all, I'm new to the forums and have an SAP question problem. I'm an end user of SAP and have been using it since 2002. A couple of weeks ago when I logged into SAP I noticed a red/white icon in the lower right corner of my screen. When I hover

  • Unable to Open Change Organisation Form

    Hi All, i have added Change Organisation - MRP, Change Organisation - CST Form Function to a custom Menu, and it does not show list of Inventory Organisation. and i have also added "Change Organisation" Self Service Function and now it shows my Defau