User-Defined Function and Context Manipulation

Hi Mapping Gurus, I need your help.
I have a user-defined function and one of my input parameter (c) is in a loop (EDI segment).  So one, if I execute my function I get:
Exception:[java.lang.ArrayIndexOutOfBoundsException: 0]
If I change the context or use the remove context node function it’s working but it’s always taking the first row in consideration since I'm using c[0] .  Here is the logic:
String WHERE_CLAUSE = "A"" = ""'"b[0]"'"" and B = ""'"c[0]"'";
So since c is an array [], I have tried different logic to get to the right row.
1- I tried using another parameter (e) to pass a counter or an index to my function.  So each time it's looping, it's passing a new value to the function but I’m still getting the first row and I’m not to sure why?
int G = Integer.parseInt(e[0]);  // e[] = My counter field
String WHERE_CLAUSE = "A"" = ""'"b[0]"'"" and B = ""'"c[G]"'";
2- I tried using a parameter stored in the container:
String Num;
Num = (String)getParameter(“counter”);
if (Num == null)  G = 0;
else
G = Integer.parseInt(Num);
G = G + 1;
String WHERE_CLAUSE = "A"" = ""'"b[0]"'"" and B = ""'"c[G]"'";
Num = "" + G;
setParameter(e[0], Num);
and I’m still getting the first one, look like it’s using a different container each time it’s looping so the Value is always the same?
4- I created a new user-defined function with the container logic, then it’s working but I’m back to the same problem in my main function, it’s only looking at e[0] for my counter all the time.
5- I tried using the Seeburger Java Variables and guess what in the main fonction, as new UDF,... and guess what, same result!
So anybody out there that was able to get UDF's working into a multiple context scenario?
Am I missing something?
I will reward points and beer for any help!

This is one of the text with passing a counter to the function to try to go to the right row in the array since I'm doing a remove context and I'm getting all the d_234's:
public void ReadTable(String[] a,String[] b,String[] c,String[] d,String[] e,ResultList result,Container container){
int G = Integer.parseInt(e[0]); // My counter
String var;
String DBTABLE = a[0];
String lookUpField = d[0];
String WHERE_CLAUSE = "A"" = ""'"b[0]"'"" and B = ""'"c[G]"'";
Now this one was with the internal container logic:
int G;
String DBTABLE = a[0];
String lookUpField = d[0];
String Num;
Num = (String)getParameter(e[0]);
if (Num == null)  G = 0;
else
G = Integer.parseInt(Num);
G = G + 1;
Num = "" + G;
setParameter(e[0], Num);
String WHERE_CLAUSE = "A"" = ""'"b[0]"'"" and B = ""'"c[G]"'";
And now with the Seeburger Variables:
int G;
try {
VariableBean be=VariableFactory.getVariableInstance("");
G = Integer.parseInt(String.valueOf(be.getStringVariable("yves")));
} catch (Exception f) {
throw new RuntimeException(f);
String DBTABLE = a[0];
String lookUpField = d[0];
String WHERE_CLAUSE = "A"" = ""'"b[0]"'"" and B = ""'"c[G]"'";
try {
G = G + 1;
Num = "" + G;
VariableBean be=VariableFactory.getVariableInstance("");
be.setStringVariable("yves",Num);
catch (Exception f) {
throw new RuntimeException(f);
All 3 logics were returning always the first row or a counter of 1 if the logic is in the main ReadTable function.

Similar Messages

  • Advanced User Defined Functions - Handling Contexts

    Hi All,
    Are there any blogs on Advanced User Defined functions? I would like to get some information on how the queue is accessed, manipulation of the ResultList object etc.
    Many Thanks,
    Sandeep

    Hi,
    This blog talks about context handling
    /people/riyaz.sayyad/blog/2006/04/23/introduction-to-context-handling-in-message-mapping
    This is will give you a clear idea and will be hwlpful for sure
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/9202d890-0201-0010-1588-adb5e89a6638
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/190eb190-0201-0010-0ab3-e69f70b6c257
    Thanks
    Prakash

  • Where are User Defined Functions and Stored Procedures kept in SQL Server?

    Hi,
    I have a growing list of Stored Procedures and User-Defined Functions in SQL Server, and would like to be able to list all my user SP and UDF easily.
    Is it possible to write a query to list all SP and UDF?
    I saw the following specimen code in an SQL book, but am not sure this is what I need because I could not make it work.
    SELECT *
        FROM INFORMATION_SCHEMA.ROUTINES
    WHERE SPECIFIC_SCHEMA = N'CustomerDetails'
        AND SPECIFIC_NAME = N'apf_CusBalances'
    I tried:
    SELECT *
        FROM INFORMATION_SCHEMA.ROUTINES
    but it does not work.
    Suppose all my SP are named following this pattern:
        dbo.usp_Storeproc1
    How would I modify the above code? or is there a better code?
    Thanks
    Leon Lai

    Hi ,
    try this to get list of all stored procedures:
    SELECT *
    FROM sys.procedures where name like 'dbo.usp%'
    Thanks,
    Neetu

  • User defined function and returning resultset

    Hi all,
    Following query, if I comment the statement in where clause which refers to a returning value of a function in the subquery, it takes 1 sec to finish. when uncomment it however, can't finish in 30 mins. Please help me on finding out the problem.
    I'm also wondering how to get a returning cursor in this case(to bypass above trouble)..
    Many thanks
    -s
    --pseudocode for how can I get a cursor in an anonymous block for host app
    begin
    -- get the resultset1 in someway
    select t1.showit,...
    from t1..;
    -- based on resultset1
    open myrefcursor for
    select * from resultset1 -- what is the resultset1?
    where resultset1.showit=1;
    end;
    --end pseudocode for getting a cursor
    -- hanging(takes too long) query (simplified)
    select t1.*,t2.account,t2.showit
    from (select t3.account,myfunc(t3.account) showit
    from tbl2 t3) t2,
    tbl1 t1
    where t1.account=t2.account
    and ...
    /* "hang" this query by uncomment this */
    -- and t2.showit=1;
    -- functions
    function myfunc(p_acc varchar2)
    return number is
    v_tmpdate date;
    v_invdate date;
    v_tmpcount number(8);
    v_accid number(8);
    v_curodisp number(14,4);
    v_curdisp number(14,4);
    v_curdisprev number(14,4);
    v_rowcount number(8);
    v_tmpshow number(8);
    p_vkey number(8);
    p_inv varchar(50);
    cursor cur(cv_vkey number, cv_accid number, cv_lastdate date) is
    select a.vkey vkey,a.invdate invdate, b.odisp odisp
    from inv a, recon b
    where a.vkey=cv_vkey
    and a.akey = cv_accid
    and a.invdate between to_date('01/01/2000','DD/MM/YYYY')
    and cv_lastdate
    and b.vkey = a.vkey
    and b.inv# = a.inv#
    order by invdate DESC;
    begin
    select vkey,inv#,akey, invdate into p_vkey,p_inv,v_accid, v_invdate
    from inv
    where akey = p_acc;
    v_tmpdate := add_months(v_invdate, 1);
    select count(*) into v_tmpcount
    from recon a, inv b
    where b.vkey = p_vkey
    and b.akey = v_accid
    and b.invdate between to_date('01/01/2000','DD/MM/YYYY')
    and v_tmpdate
    and a.inv# = b.inv#
    and a.vkey = b.vkey;
    if v_tmpcount = 0 then
    return 0;
    end if;
    v_rowcount := 0;
    for c1 in cur(p_vkey,v_accid,v_tmpdate) loop
    v_rowcount := v_rowcount + 1;
    v_curdisp := getcurdisp(c1.vkey,c1.inv#);
    v_curdisprev := getcurdisprev(c1.vkey,c1.inv#);
    v_curodisp := nvl(c1.odisp, 0) - v_curdisp - v_curdisprev;
    if v_curodisp >= 1000 then
    return 1;
    elsif v_curodisp = 0 then
    return 0;
    end If;
    end if;
    if extract(month from c1.invdate) in ('1','01')
    and extract(year from c1.invdate) = '2000' then
    select a.showodisp into v_tmpshow
    from acc a, inv b
    where b.vkey = c1.vkey
    and b.inv# = c1.inv#
    and a.akey = b.akey;
    return v_tmpshow;
    end If;
    end loop;
    return 0;
    end myfunc;
    function getcurdisp(p_vkey,p_inv)
    return number is
    v_tmp number(15,4);
    begin
    select sum(amount) into v_tmp
    from cost
    where vkey=p_vkey
    and inv#=p_inv
    and desc like '%disp';
    return v_tmp;
    end;
    function getcurdisprev(p_vkey,p_inv)
    return number is
    v_tmp number(15,4);
    begin
    select sum(amount) into v_tmp
    from cost
    where vkey=p_vkey
    and inv#=p_inv
    and desc like '%disprev';
    return v_tmp;
    end;

    Autotrace only showed the index usage on the main query, but nothing on the queries within the functions, so here is the tkprof that shows index usage on the queries within the functions.
    TKPROF: Release 9.2.0.1.0 - Production on Mon Jan 17 00:31:39 2005
    Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.
    Trace file: ora92_ora_4092.trc
    Sort options: default
    count    = number of times OCI procedure was executed
    cpu      = cpu time in seconds executing
    elapsed  = elapsed time in seconds executing
    disk     = number of physical reads of buffers from disk
    query    = number of buffers gotten for consistent read
    current  = number of buffers gotten in current mode (usually for update)
    rows     = number of rows processed by the fetch or execute call
    alter session set sql_trace=true
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        0      0.00       0.00          0          0          0           0
    Execute      1      0.00       0.00          0          0          0           0
    Fetch        0      0.00       0.00          0          0          0           0
    total        1      0.00       0.00          0          0          0           0
    Misses in library cache during parse: 0
    Optimizer goal: CHOOSE
    Parsing user id: 59 
    select t1.*, t2.account, t2.showit
    from   tbl1 t1,
           (select account, myfunc(account) showit
            from   tbl2) t2
    where  t1.account = t2.account
    and    t2.showit = 1
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.00          0          0          0           0
    Execute      1      0.00       0.00          0          0          0           0
    Fetch        1      0.11       1.81          0          1          0           0
    total        3      0.11       1.81          0          1          0           0
    Misses in library cache during parse: 0
    Optimizer goal: CHOOSE
    Parsing user id: 59 
    Rows     Row Source Operation
          0  NESTED LOOPS 
          0   INDEX FULL SCAN OBJ#(69662) (object id 69662)
          0   INDEX RANGE SCAN OBJ#(69661) (object id 69661)
    select user#
    from
    sys.user$ where name = 'OUTLN'
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.00          0          0          0           0
    Execute      1      0.00       0.00          0          0          0           0
    Fetch        1      0.00       0.00          0          2          0           1
    total        3      0.00       0.00          0          2          0           1
    Misses in library cache during parse: 0
    Optimizer goal: CHOOSE
    Parsing user id: SYS   (recursive depth: 2)
    Rows     Row Source Operation
          1  TABLE ACCESS BY INDEX ROWID USER$
          1   INDEX UNIQUE SCAN I_USER1 (object id 44)
    select a.vkey, a.invdate, b.odisp, a.inv#
         from   inv a, recon b
         where  a.akey = :b1
         and    a.invdate between to_date ('01/01/2000', 'DD/MM/YYYY')
                          and     add_months (a.invdate, 1)
         and    b.vkey = a.vkey
         and    b.inv# = a.inv#
         order  by a.invdate DESC
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.10          0          0          0           0
    Execute    105      0.00       0.01          0          0          0           0
    Fetch      105      0.01       0.01          0        309          0         100
    total      211      0.01       0.13          0        309          0         100
    Misses in library cache during parse: 1
    Optimizer goal: CHOOSE
    Parsing user id: 59     (recursive depth: 1)
    Rows     Row Source Operation
        100  SORT ORDER BY
        104   TABLE ACCESS BY INDEX ROWID RECON
        313    NESTED LOOPS 
        104     INDEX FULL SCAN INV_IDX (object id 69658)
        104     INDEX RANGE SCAN RECON_IDX (object id 69659)
    SELECT sum (amount)
      from   cost
      where  vkey = :b2
      and    inv# = :b1
      and    descr like '%disp'
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.00          0          0          0           0
    Execute    100      0.00       0.00          0          0          0           0
    Fetch      100      0.01       0.00          0        100          0         100
    total      201      0.01       0.01          0        100          0         100
    Misses in library cache during parse: 1
    Optimizer goal: CHOOSE
    Parsing user id: 59     (recursive depth: 1)
    Rows     Row Source Operation
        100  SORT AGGREGATE
          0   TABLE ACCESS BY INDEX ROWID COST
          0    INDEX RANGE SCAN COST_IDX (object id 69657)
    SELECT sum (amount)
      from   cost
      where  vkey = :b2
      and    inv# = :b1
      and    descr like '%disprev'
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.00          0          0          0           0
    Execute    100      0.00       0.00          0          0          0           0
    Fetch      100      0.01       0.00          0        100          0         100
    total      201      0.01       0.01          0        100          0         100
    Misses in library cache during parse: 1
    Optimizer goal: CHOOSE
    Parsing user id: 59     (recursive depth: 1)
    Rows     Row Source Operation
        100  SORT AGGREGATE
          0   TABLE ACCESS BY INDEX ROWID COST
          0    INDEX RANGE SCAN COST_IDX (object id 69657)
    SELECT a.showodisp
          from   acc a, inv b
          where  b.vkey = :b2
          and    b.inv# = :b1
          and    a.akey = b.akey
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.00          0          0          0           0
    Execute    100      0.01       0.00          0          0          0           0
    Fetch      100      0.03       0.00          0        299          0          99
    total      201      0.04       0.01          0        299          0          99
    Misses in library cache during parse: 1
    Optimizer goal: CHOOSE
    Parsing user id: 59     (recursive depth: 1)
    Rows     Row Source Operation
         99  TABLE ACCESS BY INDEX ROWID ACC
        299   NESTED LOOPS 
        100    INDEX RANGE SCAN INV_IDX (object id 69658)
         99    INDEX RANGE SCAN ACC_IDX (object id 69660)
    begin
        for x in ( select * from session_trace_file_name )
        loop
            if ( dbms_lob.fileexists( bfilename('UDUMP_DIR', x.filename ) ) = 1 )
            then
                insert into avail_trace_files (filename) values (x.filename);
            end if;
        end loop;
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.00          0          0          0           0
    Execute      1      0.01       0.00          0          0          0           1
    Fetch        0      0.00       0.00          0          0          0           0
    total        2      0.01       0.00          0          0          0           1
    Misses in library cache during parse: 0
    Optimizer goal: CHOOSE
    Parsing user id: 736     (recursive depth: 1)
    select *
    from
    session_trace_file_name
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.00          0          0          0           0
    Execute      1      0.00       0.00          0          0          0           0
    Fetch        2      0.00       0.00          0          0          0           1
    total        4      0.00       0.00          0          0          0           1
    Misses in library cache during parse: 0
    Optimizer goal: CHOOSE
    Parsing user id: 736     (recursive depth: 2)
    INSERT into avail_trace_files (filename)
    values
    (:b1)
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.00          0          0          0           0
    Execute      1      0.00       0.00          0          0          3           1
    Fetch        0      0.00       0.00          0          0          0           0
    total        2      0.00       0.00          0          0          3           1
    Misses in library cache during parse: 0
    Optimizer goal: CHOOSE
    Parsing user id: 736     (recursive depth: 2)
    OVERALL TOTALS FOR ALL NON-RECURSIVE STATEMENTS
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.00          0          0          0           0
    Execute      2      0.00       0.00          0          0          0           0
    Fetch        1      0.11       1.81          0          1          0           0
    total        4      0.11       1.81          0          1          0           0
    Misses in library cache during parse: 0
    OVERALL TOTALS FOR ALL RECURSIVE STATEMENTS
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        8      0.00       0.11          0          0          0           0
    Execute    409      0.02       0.04          0          0          3           2
    Fetch      408      0.06       0.03          0        810          0         401
    total      825      0.08       0.19          0        810          3         403
    Misses in library cache during parse: 4
        9  user  SQL statements in session.
        1  internal SQL statements in session.
       10  SQL statements in session.
    Trace file: ora92_ora_4092.trc
    Trace file compatibility: 9.00.01
    Sort options: default
           1  session in tracefile.
           9  user  SQL statements in trace file.
           1  internal SQL statements in trace file.
          10  SQL statements in trace file.
          10  unique SQL statements in trace file.
         945  lines in trace file.

  • User-defined function in FILTER clause

    hi,
    can i create the user-defined functions and use them in the FILTER clause in the sem_match function? there are some built-in functions for the FILTER clasue. however, only one function (DATATYPE(literal)) support for date/time in the built-in functions. i want to implement some user-defined funcitons in the FILTER clause which can check time intervals in ontology. there are some functions about valid time in the WorkSpace Manager such as WM_OVERLAPS, WM_CONTAINS,WM_MEETS, etc. so, can i write some functions using the these valid time functions in WM and use them in the FILTER clause? thanks a lot in advance.
    hong

    Hi Hong,
    You don't need user-defined functions to do time interval comparisons. You can directly compare xsd:dateTime values with the built-in comparison operators: <, >, =, !=, <=, >=
    For example, the query pattern below could find events that happened during event1 if we have data such as:
    :event1 :startTime "2013-01-01T03:15:00Z"^^xsd:dateTime .
    :event1 :endTime "2013-02-01T02:15:00Z"^^xsd:dateTime .
    :event2 :startTime "2013-01-11T14:15:00Z"^^xsd:dateTime .
    :event2 :startTime "2013-01-14T12:15:00Z"^^xsd:dateTime .
    SELECT ?e2
    WHERE
    { :event1 :startTime ?e1_st; :endTime ?e1_et .
    ?e2 :startTime ?e2_st; endTime ?e2_et .
    FILTER (?e1_st < ?e2_st && ?e2_et < ?e1_et) }
    In general, it is trivial to convert interval relations such as meets and overlaps to conditions on start and end times.
    Hope this helps.
    - Matt

  • User Defined Function Error - Can't find function

    Hi All,
    Version: 11.1.1.4
    I created a user defined function and added it to one of my BPEL Processes. I can see the function in JDeveloper and can compile the project without issue. We placed the jar file out on the SOA Server following the oracle user defined function examples. After placing the file out on weblogic I was able to successfully deploy the project.
    Oracle Deployment Steps:
    To deploy user-defined functions to runtime:
    1. Copy the user-defined function JAR files to BEA_Home/user_projects/domains/domain_name/lib or a subdirectory of lib.  Where domain_name is the name of the Oracle WebLogic Server domain (for example, soainfra).
    2. Restart the Oracle WebLogic Server.However, when I try to run the composite application I get the below error. I am not really sure why it can't find the Function? The jar is out on the server and the jar was added to the project?
    Error:
    Non Recoverable System Fault :
    <bpelFault><faultType>0</faultType><subLanguageExecutionFault xmlns="http://schemas.oracle.com/bpel/extension"><part name="summary"><summary>XPath expression failed to execute. An error occurs while processing the XPath expression; the expression is pnl:GetManager(string(bpws:getVariableData('inputVariable','payload','/client:process/client:input'))). The XPath expression failed to execute; the reason was: Function 'GetManager' not found.. Check the detailed root cause described in the exception message text and verify that the XPath query is correct. </summary></part><part name="code"><code>XPathExecutionError</code></part></subLanguageExecutionFault></bpelFault>Any suggestions would be greatly appreciated!
    Thanks,
    S
    Edited by: Scarpacci on Apr 1, 2011 6:06 AM

    try putting the jar location explicitly in weblogic server's classpath i.e. add BEA_Home/user_projects/domains/domain_name/lib to wls classpath and restart server.

  • Java user-defined function for mapping a complex structure

    All,
    Hope one of you can help me with this. I have a structure with over 15 fields and would like to concatenate all the fields into one target field and while I do this, I need to ensure that each field is padded with blanks as defined the data type. Can one of tell me if this is possible with a java user-defined function and if so, what type of logic is needed.
    Input_MT
    Field_1  string len=10 "need"
    Field_2  string len=6 "java"
    Field_3  string len=7 "help"
    Field_4  string len=8  "asap"
    etc,
    Output_MT 
    DataOut string  "need      java  help   asap    "
    (for some reason the exact spaces in between the words disappear in my Preview message)
    I have several fields in the input mt and therefore I find graphical mapping using concatenate and my own user defined function padWithSpace too messy.
    Thank you for you help.

    Hi,
    If your final req is to write all these fields next each other in a file, you can configure this in receiver file adapter by specifying the fixed length for each field.
    If you want the padded string as your MM o/p, you can create a simple user defined funtion with 15 fields as input and 15 constants for their lengths, and find out the length of the each string and pad it with required no of spaces.
    int max_len = 10;
    int actual_len;
    actual_len = a.lengh();
    for(int i=0; i < (max_len-actual_len; i++)
    a = a.append(" ");
    return a;
    praveen

  • How to call User defined functions in Mathscript Node ?

    Hi,
    I have created a user defined function and saved it to Search path of Labview as an M file. If I run my program in Math script window, the function is recognized and the program works properly. If I do the same with MathScript node , the user defined functions are not identified.
    Kindly help me with this problem. Thanks in advance
    Cheers
    Lenord Melvix

    This page may help:
    http://zone.ni.com/reference/en-XX/help/373123C-01/lvtextmathmain/caveats_recommendations_ms_search_...
    Kevin C.

  • Getting "Unexpected end of formula" error in user-defined function

    I created a user-defined function and registered it successfully in Discoverer Admin (10g), and it shows up in Discoverer Plus. However, when I call the function, I get this error:
    "Error in formula -- unexpected end of formula"
    If I hard-code in parameters, I can successfully run the function as such from Oracle SQL Developer:
    SELECT PAYLINETOT('2324', '111', to_date('01-Sep-2010'), to_date('31-Oct-2010'))
    FROM DUAL;
    But I still get the same error if I enter this in the calculation dialog in Discoverer:
    PAYLINETOT('2324', '111', to_date('01-Sep-2010'), to_date('31-Oct-2010'))
    Any idea what's going on and how to get this to work?

    Michael,
    I tried your suggestion, and this time I got a different error message that said that the function had not been registered with the EUL. I thought I had registered it, but when I checked, the return data type was wrong. I corrected it, and the function is "valid" in Discoverer Admin. Yet, when I go back to Discoverer Plus and attempt to use the function (and yes, I logged out and logged back in), I get the same error message:
    "Error in formula - unexpected end of formula - Error: Function PAYLINETOT has not been registered with the EUL."
    Any idea where the disconnect is? Are these two separate errors? How could Discoverer Admin tell me that the function is registered and Discoverer Plus tell me otherwise? And yes, I've made sure that the "Available in Desktop/Plus" checkbox is checked.

  • User - defined functions for calculating the taxes of state and country

    hi expects,
        how can write user-defined function in message mapping in which i want to calculate the states taxes (2500) and country taxes (5000) and give the result as grand total in output.please help me?

    Hi,
    Activities
    1. To create a new user-defined function, in the data-flow editor, choose Create New Function (This
    graphic is explained in the accompanying text), which is located on the lower left-hand side of the
    screen. In the menu, choose Simple Function or Advanced Function.
    2. In the window that appears, specify the attributes of the new function:
    Name
    Technical name of the function. The name is displayed in the function chooser and on the data-flow
    object.
    Description
    Description of how the function is used.
    Cache
    Function type (see above)
    Argument Count
    In this table, you specify the number of input values the function can process, and name them. All
    functions are of type String.
    3. In the window that appears, you can create Java source code:
    a. You can import Java packages to your methods from the Imports input field, by specifying them
    separated by a comma or semi-colon:
    You do not need to import the packages java.lang., java.util., java.io., and java.lang.reflect. since
    all message mappings require these packages and therefore import them. You should be able to
    access standard JDK and J2EE packages of the SAP Web Application Server by simply specifying the
    package under Import. In other words, you do not have to import it as an archive into the Integration
    Repository. You can also access classes of the SAP XML Toolkit, the SAP Java Connector, and the
    SAP Logging Service (see also: Runtime Environment (Java-Mappings)).
    In addition to the standard packages, you can also specify Java packages that you have imported as
    archives and that are located in the same, or in an underlying software component version as the
    message mapping.
    b. Create your Java source text in the editor window or copy source text from another editor.
    4. Confirm with Save and Close.
    5. User-defined functions are limited to the message mapping in which you created the function. To
    save the new function, save the message mapping.
    6. To test the function, use the test environment.
    The new function is now visible in the User-Defined function category. When you select this category,
    a corresponding button is displayed in the function chooser pushbutton bar. To edit, delete, or add the
    function to the data-flow editor, choose the arrow next to the button and select from the list box
    displayed.
    Regards
    Seshagiri

  • How do you create a user defined functions  UDF and passing a value like a ID to GEt a Value.

    How do you create a user defined functions UDF and passing a
    value like a ID to GEt a Value.
    using a query.
    are there example.
    Thanks

    tons of examples at cflib.org - good place to start, even
    though many
    udfs there are a bit outdated in their code...
    Azadi Saryev
    Sabai-dee.com
    http://www.sabai-dee.com

  • Error when use User-Defined Function

    I just create User defined function "getfilename" and I put there:
    "DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
    String ourSourceFileName = conf.get(key);
    return ourSourceFileName; ".
    But In test mapping I have worning:
    "Runtime exception during processing target field mapping /ns1:Z_KBFI_INPUT_FILE/IS_IFILE/FILE_NAME. The message is: Exception:[java.lang.NullPointerException] in class com.sap.xi.tf._KBFIMsgMapping_ method get_fname$[com.sap.aii.mappingtool.tf3.rt.Context@37d4662c] com.sap.aii.mappingtool.tf3.MessageMappingException: Runtime exception during processing target field mapping /ns1:Z_KBFI_INPUT_FILE/IS_IFILE/FILE_NAME. The message is: Exception:[java.lang.NullPointerException] in class com.sap.xi.tf._KBFIMsgMapping_ method get_fname$[com.sap.aii.mappingtool.tf3.rt.Context@37d4662c] at com.sap.aii.mappingtool.tf3.AMappingProgram.processNode(AMappingProgram.java:284) at com.sap.aii.mappingtool.tf3.AMappingProgram.processNode(AMappingProgram.java:238)...."
    And in RWB in Communication Channel Monitoring I can not see file name in the payload.
    Maby I do something wrong, please tell me.

    my source file 200610.txt is like this:
    HR 0610 061030 061021
    DR 03 C 0610 820114 00010111 0000015000 PLN descr...
    DR 03 D 0610 403201 00010111 0000015000 PLN descr..
    TR 0000000002
    Then in sxmb_moni in inbound message (payload) I have:
    <?xml version="1.0" encoding="utf-8" ?>
    - <ns:KBFIMsgTypeSource xmlns:ns="http://p4.org/xi/KBFI/Interface">
    - <FIRecordset>
    - <HeaderLine>
      <LineKey>HR</LineKey>
      <PostingPeriod>0610</PostingPeriod>
      <PostingEndDate>061030</PostingEndDate>
      <PostingDate>061021</PostingDate>
      </HeaderLine>
    - <PostingLine>
      <LineKey>DR</LineKey>
      <ServerID>03</ServerID>
      <DCFlag>C</DCFlag>
      <PostingPeriod>0610</PostingPeriod>
      <GLAccount>820114</GLAccount>
      <SubAccount>00010111</SubAccount>
      <NetValue>0000015000</NetValue>
      <Currency>PLN</Currency>
      <Description>descr...</Description>
      </PostingLine>
    - <PostingLine>
      <LineKey>DR</LineKey>
      <ServerID>03</ServerID>
      <DCFlag>D</DCFlag>
      <PostingPeriod>0610</PostingPeriod>
      <GLAccount>403201</GLAccount>
      <SubAccount>00010111</SubAccount>
      <NetValue>0000015000</NetValue>
      <Currency>PLN</Currency>
      <Description>descr..</Description>
      </PostingLine>
      </FIRecordset>
      </ns:KBFIMsgTypeSource>
    But I don't have payload for Response (black and white flag).
    In DynamicConfiguration i have:
    <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
    - <!--  Response
      -->
    - <SAP:DynamicConfiguration xmlns:SAP="http://sap.com/xi/XI/Message/30" xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" SOAP:mustUnderstand="1">
      <SAP:Record namespace="http://sap.com/xi/XI/System/File" name="SourceFileSize">141</SAP:Record>
      <SAP:Record namespace="http://sap.com/xi/XI/System/File" name="FileType">txt</SAP:Record>
      <SAP:Record namespace="http://sap.com/xi/XI/System/File" name="SourceFileTimestamp">20061212T121622Z</SAP:Record>
      <SAP:Record namespace="http://sap.com/xi/XI/System/File" name="FileEncoding">ISO646-US</SAP:Record>
      <SAP:Record namespace="http://sap.com/xi/XI/System/File" name="FileName">200610.txt</SAP:Record>
      <SAP:Record namespace="http://sap.com/xi/XI/System/File" name="Directory">/usr/sap/PXD/put/archive</SAP:Record>
      </SAP:DynamicConfiguration>

  • Using a User Defined Function as a constraint within a temporary table.

    Hello, 
    I am trying to create a temp table that uses a UDF in a constraint. I'm getting the following error message 
    Msg 4121, Level 16, State 1, Line 1
    Cannot find either column "dbo" or the user-defined function or aggregate "dbo.CK_LoseTeamSportExists", or the name is ambiguous.
    I've tested the function and it works in other contexts. Any idea? All code below:  
    Thanks, 
    - Bryon
    create function dbo.CK_LoseTeamSportExists (@loseteam int, @sportid int)
    returns bit
    as
    begin
    declare @return bit
    if exists 
    select TeamID, sportid from Link_TeamSport
    where 
    TeamID = @loseteam 
    and
    SportID = @sportid
    set @return = 1
    else set @return = 0
    return @return
    end
    go
    create table #check
    SportID int
    ,WinTeamID int
    ,LoseTeamID int
    ,check 
    (dbo.CK_LoseTeamSportExists(LoseTeamID,SportID) = 1)

    Please post DDL, so that people do not have to guess what the keys, constraints, Declarative Referential Integrity, data types, etc. in your schema are. Learn how to follow ISO-11179 data element naming conventions and formatting rules. Temporal data should
    use ISO-8601 formats. Code should be in Standard SQL as much as possible and not local dialect. 
    This is minimal polite behavior on SQL forums. 
    >> I am trying to create a temp table that uses a UDF in a constraint. <<
    You do not understand how SQL or any declarative language works! 
    We do not use UDFs (procedural programming)
    We do not use bit flags (assembly language).
    We do not use temp tables (mag tape files).
    We do not use integer as identifiers (what math do you do on them?)
    Your silly “Link_TeamSport” implies a pointer chain; we have no links in SQL. Where is the DDL? 
    Constraints are always predicates in any declarative language. 
    Do you know why you have to create a local variable to pass the non-relational flag back to the calling environment? FORTRAN I and II! These early languages has to use hardware registers in the first IBM computers to return results. In your ignorance, you mimic
    them! 
    We do not use if-then-else control flow in any declarative language. We have CASE expressions that we put where you have a local variable getting an assignment. 
    I see you also put the comma at the start of the line. We did that with punch cards, so we could re-use them 50 years ago. 
    In SQL, we would use REFERENCES to assure a team reference exists. We use names for teams because they are entities, not quantities: 
    CREATE TABLE Game_Results
    (sport_name CHAR(10) NOT NULL PRIMARY KEY,
     win_team_name CHAR(12) NOT NULL
      REFERENCES Teams(team_name)
       ON DELETE CASCADE,
     lose_team_name CHAR(12) NOT NULL
      REFERENCES Teams(team_name)
       ON DELETE CASCADE,
     CHECK (win_team_name <> lose_team_name)); 
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • User Defined Function Missing In EF 6?

    I'm using Entity Framework 6 and I have imported several user-defined functions like the one shown below, but it doesn't
    appear when I try to select the function in intellisense and the model doesn't recognize this function as a method on the EF context.  How do I call this function in EF 6?
    <Function Name="getCycleDate" Aggregate="false" BuiltIn="false" NiladicFunction="false" IsComposable="true" ParameterTypeSemantics="AllowImplicitConversion" Schema="dbo" ReturnType="date" />
    MCSD .NET developer in Dallas, Texas

    Hello DallasSteve,
    >> I have imported several user-defined functions like the one shown below,
    What is your UDF? If it is a TVF, starting from EF5, it is supported already:
    https://msdn.microsoft.com/en-us/data/hh859577.aspx
    However, it is a scalar function, unfortunately, as far as I know, even entity framework 6 doesn't suport generating calls for scalar functions by default. The workaround is to write a custom method like this inside your DbContext class, for example, there
    is scalar function as:
    CREATE FUNCTION [dbo].[Function20150410]
    @param1 int,
    @param2 int
    RETURNS INT
    AS
    BEGIN
    RETURN @param1 + @param2
    END
    When we imported it to the model, it would generate code in SSDL as:
    <Function Name="Function20150410" Aggregate="false" BuiltIn="false" NiladicFunction="false" IsComposable="true" ParameterTypeSemantics="AllowImplicitConversion" Schema="dbo" ReturnType="int">
    <Parameter Name="param1" Type="int" Mode="In" />
    <Parameter Name="param2" Type="int" Mode="In" />
    </Function>
    While, it will not generate a call method as a store produce, for a workaround, we could write a custom function as:
    [DbFunction("DFDBModel.Store", "Function20150410")]
    public ObjectResult<int> GetContentByIdAndCul(int id, int culture)
    var objectContext = ((IObjectContextAdapter)this).ObjectContext;
    var parameters = new List<ObjectParameter>();
    parameters.Add(new ObjectParameter("Id", id));
    parameters.Add(new ObjectParameter("Culture", culture));
    return objectContext.CreateQuery<int>("DFDBModel.Store.Function20150410(@Id, @Culture)", parameters.ToArray()).Execute(MergeOption.NoTracking);
    I suggest that you write this custom method a separate cs file since if we update the model, the original context call would be reset.
    Calling it as:
    using (DFDBEntities db=new DFDBEntities())
    var result = db.GetContentByIdAndCul(1, 1).FirstOrDefault();
    }s
    Regards.
    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.

  • Error in User defined function for dynamic file naming

    Hi,
    While creating User Defined function with this following code for dynamic fieldname
    DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
    String ourSourceFileName = conf.get(key);
    return ourSourceFileName;
    which options should i select for cache Value, Context, Queue
    for Augument , what name shd i mention.
    Regards,
    Varun

    Hi Varun,
    I guess I have answered a similar question just a few minutes before on very similar post from you. Just pasting the same here .................
    Are you trying to access the ASMA values from the SOAP header of the XI message for the source file name?
    First of all you need to Set the Sender File Adapter for Set ASMA and then file name. So it will work fine when you actually run the scenario end to end.
    But in the mapping tool when you test the mapping - there is not message header updated with the actual source filename - and whenever you try to read the FileName attribute in the message header from the UDF - it cannot find the object and returns a NullPointerException.
    I would suuggest for your mapping tool testing to be successful, have a check in the java code for null values,
    DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
    String ourSourceFileName = conf.get(key);
    If (ourSourceFileName != null)
       Return ourSourceFileName;
    Return "NoFileName.txt";
    Let us know if this works.
    Regards,
    Suddha

Maybe you are looking for

  • How to make the default param work?

    Hi experts, When I define a default value for a parameter in a procedure or function, such as (p in     varchar2 default null), and when I call it without providing the parameter value, I am getting the "PLS-00306: wrong number or types of arguments

  • ABST2 - How to take the report for the previous fiscal year

    Hi, For FI-AA reconciliation, my scenario is this: The current fiscal year is 2009 and the system (server) date is 16-Apr-2009. My fiscal year period is: Mar-Apr. In ABST2, it does not accept Fiscal year. When I take the report, it displays for fisca

  • Linking between Material GR and Service Entry Sheets

    Hi!, We have two separate Quantity Contracts. One for supply of Material X and another for transportation service for transporting material X. Now the transportation vendor shall have to be paid as per the exact Goods Receipts quantity done for Mater

  • Using iframe

    I am sending the product id value to another jsp where it process the servlet operations and sends back the result... i am having the problem it shows undefined addpdt.jsp file <script language="JavaScript"> function getComboBoxValue(id){ var cbox=do

  • Font Rendering to thick

    It seems that Firefox is rendering fonts a bit too thick. font-weight is set to the right values, the problem is partially solved when decreasing the weight 100 (from 300 to 200) but is then displayed too thin on the other browsers. This image shows