Error in User defined function for jdbc lookup
I am getting th error as follows "Method TestJDBCAPI$ with 2 arguments not found in class com.sap.xi.tf._JLU_MM_" when i a m testing in message mapping
//write your code here
String Query = " ";
Channel channel = null;
DataBaseAccessor accessor = null;
DataBaseResult resultSet = null;
//Build the Query String
Query = "Select role from login where username = " + username[0] + " and password = " + password[0] ;
try{
//Determine a channel as created in the configuration
channel = LookupService.getChannel("JLU_BUSS","JLU_chan");
// Get a system accessor for a channel.As the call is being made to the database an database accessor is obtained.
accessor = LookupService.getDataBaseAccessor(channel);
// Execute the Query and get the values in the resultSet.
resultSet = accessor.execute(Query);
for(Iterator rows = resultSet.getRows();rows.hasNext();)
Map rowMap = (Map)rows.next();
result.addValue((String)rowMap.get("role"));
catch(Exception ex){
result.addValue(ex.getMessage());
Above is my udf.My logic is that for the given username and password it should select the corresponding role from the database.
Similar Messages
-
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,
VarunHi 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 -
Need user define function for the message mapping structure
Hi All
I am new to XI.I need the java code for Udf for the following structure.
i have two input and one out put as error.
order_nos----
user define function-------error message
order_details----
num of orders---- i.e. 10
order_details------ i.e. whole order records details
1.i have to compare the 1st input with 2nd one means if the ist input contain 10 means there are 10 orders in 2nd input.if not then i have to give error message .
2.then i have to check the fields in 2nd input has no null values.if no values the output will be error message.
Edited by: Rohit Kumar on Dec 18, 2008 4:43 PMHi Sudhir
thanks for your continues help.i need some help so that i can fulfill my requirmrnt
this is my message mapping xml.
<?xml version="1.0" encoding="UTF-8" ?>
- <ns0:methodCall_MT xmlns:ns0="http://www.dfdsf">
<num_orders>10</num_orders>
<test_mode />
- <order_x> ( which is order details)
<order_id>t78tyu8t</order_id>
<order_date />
<mfg_id />
<catalog_id />
<first_name />
<last_name />
<recipient />
<message />
<address1 />
<address2 />
<address3 />
<city />
<state />
<zip />
<country />
<country_code />
<phone />
<subtotal />
<tax />
<shipping />
<total />
<shopatron_total />
<fulfiller_total />
<shipment_id />
- <additional_info>
<in_store_pickup />
- <express_shipping>
<express_shipping_flag />
<express_shipping_text />
<express_shipping_arrival />
</express_shipping>
</additional_info>
- <discount>
<discount_description />
<discount_percentage />
<discount_total />
</discount>
<lang_id />
<currency_id />
<packing_list />
<num_items />
- <items>
<item_id />
<quantity />
<price />
<part_number />
<fulfiller_total />
<shopatron_total />
- <options>
<option_x />
</options>
</items>
</order_x>
</ns0:methodCall_MT>
this my mapping where under one element number elements are there.when i am excuting the code to check the null value its always giving the there is null val but i have filled evrything.its due to first its checking the order_x and which will be always null.uder this all data will be filled.please suggest what to change in the udf.the code given by u is working fine but its failing in this scenario because it getting the parent filed is null. -
User defined function for getting last string in the line
Hi Experts,
I am not java expert, can anyone give me user defined function for getting last string in the line.
for example if the source field is "NEW ARBOUR SQUARE" i want to pass to target field only last string that is "SQUARE"
please help me out of this.
Kind Regards.
Praveen.You don't even need a UDF for this. In the graphical editor look for the standard functions and once you do a scroll over on 'text functions; you will find what you are looking for.
Just a piece of advice, try keeping UDF's to minimum unless really required or it is complicated without it.
regards -
Error in User defined function
I have created a user defined function to make a call to SAP using JCo.
But I am getting an error "package com.sap.mw.jco does not exist"
Do we need to install JCo on our server?
Thanks in advanceHallo Vijaya Kumari,
if you use XI3.0 then you should check csn note 753294:
Symptom
A message mapping contains a user-defined function that uses a class
from the "com.sap.mw.jco", "sapxmltoolkit" or "com.sap.tc.Logging"
library. An error stating that the source code contains syntax errors
occurs when you test or activate the message mapping. When you use a
class from "com.sap.mw.jco", the system reports, for example, "package
com.sap.mw.jco does not exist".
This error only occurs in systems containing a Support Package lower
than 5.
Solution
Import Support Package 5 or higher.
You can use the following workaround as a short-term solution: Upload
the library that is referenced in the message mapping into the software
component of the message mapping as an "imported archive". Do not
activate the "imported archive" with the library since it is not needed
for the runtime. The only purpose of the archive is to allow the message
mapping to be compiled. To avoid version conflicts with newer libraries,
you should delete the archive again after you import Support Package 5
or higher.
In your case you will find the relevant jar file in the path
[sap_j2ee_engine_installaltion_path]\cluster\server0\bin\ext\com.sap.mw.jco\jrfc.jar
Regards Franz -
UDF(user defined function) for standard date transformate function,
Hi All,
Hope you are doing good !!!
I have a requirement where i need to write an UDF(user defined function). Please help me in writing the code for below logic-
I am getting my Input as 111213 where 11 denotes HH 12 denotes mm 13 denotes ss. I need ti insert : between hh:mm:ss
Please help me achieving a code for below logic
I have used standard date transformate function, there i am getting spaces as separator in my input resulting an errors i am sending without spaces.
Regards,
Vijay Kumar.Hello,
I am getting my Input as 111213 where 11 denotes HH 12 denotes mm 13 denotes ss. I need ti insert : between hh:mm:ss
Please help me achieving a code for below logic
I have used standard date transformate function, there i am getting spaces as separator in my input resulting an errors i am sending without spaces.
What do you mean by spaces? Can you try the mapping below?
inputDate -> replaceString -> dateTrans(inputDateFormat: HHmmss outputDateFormat: HH:mm:ss) -> target
Constant: -> /
Constant:-> /
Hope this helps,
Mark -
Making a User Defined Function for Mapping in XI
Hi folks..
I knw how to make User defined Function in XI,
i was wondering about can we have any room for making a function for Initializing Purpose, which intializes few fields in source Message to some Global variables, and later we can use these Global Variables to set the the Target field
My Doubt is this...
i have Source & target Structure like this Structure like this....
SOURCE TEST DATA IS...
Parentsrc
child1src a
child2src b
child3src c
child4src hi
child4src hello
child4src hey
(On the basis of instances of child4src the istance of the Parentdst will be generated)
TARGET DATA SHUD BE LIKE THIS....
Parentdst
child1dst a
child2dst b
child3dst c
child4dst hi
Parentdst
child1dst a
child2dst b
child3dst c
child4dst hello
Parentdst
child1dst a
child2dst b
child3dst c
child4dst heyHi
You have to modify your target structure:
<b>Source</b>
Parentsrc
child1src a
child2src b
child3src c
child4src hi
child4src hello
child4src hey
<b>Target</b>
<b>root</b>
Parentdst
child1dst a
child2dst b
child3dst c
child4dst hi
Parentdst
child1dst a
child2dst b
child3dst c
child4dst hello
Parentdst
child1dst a
child2dst b
child3dst c
child4dst hey
<b></root></b>
Now map like this:
child4src -
Parentdst
child1src--|
child4src--| UseOneAsMany -- Splitbyvalue --- child1dst
child4src--|
child2src--|
child4src--|UseOneAsMany --Splitbyvalue --- child2dst
child4src--|
child3src--|
child4src--| UseOneAsMany -- Splitbyvalue --- child3dst
child4src--|
child4src -- SplitbyValue -- child4src.
Regards
Suraj -
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 -
SQL User Defined Functions for performing statistical calculations
Hi!
I hope you can help. I just wasn’t sure where to go with this question, so I’m hoping you can at least point me in the right direction.
I’m writing a SQL Server stored procedure that returns information for a facility-wide scorecard-type report. The row and columns are going to be displayed in a SQL Server Reporting Services report.
Each row of information contains “Current Month” and “Previous Month” numbers and a variance column. Some rows may compare percentages, others whole numbers, others ratios, depending on the metric they’re measuring. For each row/metric the company has specified whether they want to see a t-test or a chi-squared statistical test to determine whether or not there was a statistically significant difference between the current month and the previous month.
My question is this: Do you know where I can find a set of already-written user defined functions to perform statistical calculations beyond the basic ones provided in SQL Server 2005? I’m not using Analysis Services, so what I’m looking for are real SQL User Defined Functions where I can just pass my data to the function and have it return the result within a stored procedure.
I’m aware that there may be some third-party statistical packages out there we could purchase, but that’s not what I’m looking for. And I’m not able to do anything like call Excel’s analysis pack functions from within my stored procedure. I’ve asked. They won’t let me do that. I just need to perform the calculation within the stored procedure and return the result.
Any suggestions? Is there a site where people are posting their SQL Server UDF’s to perform statistical functions? Or are you perhaps aware of something like a free add-in for SQL that will add statistical functions to those available in SQL? I just don’t want to have to write my own t-test function or my own chi-squared function if someone has already done it.
Thanks for your help in advance! Oh, and please let me know if this should have been posted in the TSQL forum instead. I wasn't entirely sure.
Karen GrubeSTATS_T_TEST_
docs.oracle.com/cd/B19306_01/server.102/b14200/functions157.htm
STATS_T_TEST_ONE: A one-sample t-test
STATS_T_TEST_PAIRED: A two-sample, paired t-test (also known as a crossed t-test)
STATS_T_TEST_INDEP: A t-test of two independent groups with the same variance (pooled variances)
STATS_T_TEST_INDEPU: A t-test of two independent groups with unequal variance (unpooled variances) -
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 -
User defined function for removing wrong data ... !!!
Hi Experts,
I'm having a source data like this
1001 545 6895895 1584 654 5478
1002 525 6895895 5084 654 5472
1003 535 6895895 0584 654 5478
1004 545 6895895 5184 654 5478 4XXX &^%% 1004 545
1005 555 6895895 5824 654 5478 8547 0000 522# ##00
1006 565 6895895 5844 654 5478
1007 575 6895895 5845 654 5478
1008 585 6895895 5846 654 5478
Some times I get a wrong data in my source file (above 4 and 5 th rows) .
My requirement is to remove these kind of wrong lines(entire lines to be removed) whenever XI reads the data. For this what is the standard function i can use in mapping. I thought I can create my own function to remove such kind of false data lines. It would be helpful for me if some body provide me the java code.
Thanks very much.Hi Swarna,
1001 545 6895895 1584 654 5478
1002 525 6895895 5084 654 5472
1003 535 6895895 0584 654 5478
1004 545 6895895 5184 654 5478 4XXX &^%% 1004 545
1005 555 6895895 5824 654 5478 8547 0000 522# ##00
1006 565 6895895 5844 654 5478
1007 575 6895895 5845 654 5478
1008 585 6895895 5846 654 5478
is it the .txt file you are keeping. Or the input in your mapping.
You just Tell your requirement properly.
If it is input in Mapping. Map like this
input ----->subtring( starting position 0 andNumber of characters 30) ---->Output
substring is a standard Text function.
Thanks. -
User define function for SQL Server
Hi all,
it's possible to write an UDF for SQL Server in Java?
I know that it is possible with DB2 and Oracle.
My main goal is to write an UDF that works well with all of these DB.
Thank'sHi all,
it's possible to write an UDF for SQL Server in
Java?Okay, JDBC can talk to any database (given you have a driver implementation). Also, JDBC is like a conduit. So the real question is likely, will your database let you do this?
I know that it is possible with DB2 and Oracle.
My main goal is to write an UDF that works well with
all of these DB.I also don't know what a UDF is, but if you ARE talking about stored procedures, then no, it's not possible. All databases are different. On that note, I typically recommend NEVER using stored procedures unless absolutely necessary.
But it also sounds like you want to do this at runtime. I've seen systems that do this (bind stored procs at runtime dynamically) and it's a freakin nightmare! So be careful. -
Hi All,
I was trying to create user defined function for raising exception if any mapping error occur according to the blog
"Throwing Smart Exceptions in XI Graphical Mapping" by Alessandro Guarneri
i have create the jar file and imported the classes but my udf is not able to resolve the method defined in the class.
Please help me in how should i import the jar correctly?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.
-
User-defined function in message mappings
Hi experts,
I'm a senior c++ programmer, but I never write program by abap/java.
I want to create a user-defined function for mapping. Who can give me some instruction?
Many thanks.SDN can. A simple search on SDN could provide you the steps and code as well. Try a search and come up with more specific doubts. I am sure most of the doubts would be gone.
Regards,
Prateek
Maybe you are looking for
-
Problem with final variables and inner classes (JDK1.1.8)
When using JDK1.1.8, I came up with following: public class Outer protected final int i; protected Inner inner = null; public Outer(int value) i = value; inner = new Inner(); inner.foo(); protected class Inner
-
CD/DVD drive it's not supported by Windows XP and Bios
I've bought a new cd/dvd drive Mat****a Panasonic. It only work on Windows 2000, it's not supported by Windows XP and Bios, so i can't boot with.
-
Reverse reset of Clearing Restriction
Dear All, I have a requirement where I need to block a clearing of an invoice until customer signs an agreement. I have set a clearing restriction on the invoice. And I made an entry in modifiable clearing restriction in IMG. This allows manual reset
-
RH_COST_CENTER_RESPONSIBLE Evaluation Path
Hi, I am working on an organizational structure change and want to ensure that changes are reflected correctly in various workflows. I found that the central function module for determining approvers is RH_COST_CENTER_RESPONSIBLE . The problem is tha
-
How do I stop unwanted and too many friend request...
I started receiving way too many contact requests from unknown men, usually all military, Which I have been consistently blocking, but I want to know if my account has been jacked or what is going on and how to stop this, please. Anyone???