UDF in message mapping

Hi,
Why allways accepts the arguments as string types while UDF's are created, if i need to pass an integer is it possible or not..
if i need to pass an integer do i need to declare inside the coding or can i directly declare an ineger argument..
regards
reddy.

Hi SHS,
As with the UDF's is concerned you can only pass the arguments as STRING, if U need to manipulate with the integers you need to do codification to convert the integer values with in the code part using parse int.
and u may see string conversions for more information..
Example code:
int a = Integer.parseInt(String);  -- String is the input parameter where u supply..
String b = String.ValueOf(a); -- Where this statement is used to convert the integer varibale a to string b, and then delivers to the target as a string..
regards,
Kishore

Similar Messages

  • Web Service call from java UDF in message mapping

    Hi,
           Is it possible to call a web service from inside a java UDF in message mapping? The webservice can be any standard one. If this is possible please let me know how this can be done.
    Regards,
    Shiladitya

    Hi Shila,
                 Hope u remember me
    Here is the standard code used to call webservice from Java UDF
    public String setSoapAction(String SOAPAction,Container container){
    try{
    DynamicConfiguration conf = (DynamicConfiguration)container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey soapurl = DynamicConfigurationKey.create("http:/"+"/sap.com/xi/XI/System/SOAP" , "THeaderSOAPACTION");
    conf.put(soapurl, SOAPAction);
    return "";
    }catch(Exception e){
    e.getMessage();
    return "";
    Regards,
    Arijit

  • UDF in message mapping instead of Java Mapping. Pls advice urgent

    Hi All,
    My scenario
    CRM --- XI -- CRM
    In XI I have to open socket connection.
    Pls refer link:
    /people/saravanakumar.kuppusamy2/blog/2005/12/15/socket-integration-with-xi
    Can Java Mapping code given in above link for socket connection can be used in Message Mapping (CRM -- CRM)UDF?
    Pls advice urgent
    Regards

    Hi Henry,
    I understood your requirement.
    But as per the architecture of XI/PI some message has to trigger your scenario.
    In this case there is no adapter where you can directly communicate with CRM system.
    Do one thing configure a dummy scenario on the sender side.
    Use File adapter for simplicity. once it pools the file with some dummy data in the file it comes to Interface mapping(message mapping) of the PIPELINE steps. Now use the code as you mentioned above(within UDF) for opening socket to CRM system and implement you business logic within that program and write the response to target interface which will infact talk with CRM system.
    Dont forget to do the coding in an infinite loop with some delay (if required). Other wise every time you have to put a message for File Adapter for triggering purposes.
    You can also acheive the same if you use Java Mapping instead of Graphical mapping with UDF(code for Opening socket and business logic). I suggest you to use Java Mapping.
    I dont know how you will comunicate with CRM system on receiver side.?
    Thanks,
    Gujjeti

  • Message Mapping activation error-Source code has syntax errors in UDF

    Hi all,
    I wrote a small UDF for sum of 2 numbers:
    import
    udf.*
    public String getsum(String a, String b, Container container) throws StreamTransformationException{
    int c = Integer.parseInt(a);
    int d = Integer.parseInt(b);
    int e = packageDemo.getSum(c,d);
    return e+"";}
    In imported archives, i imported pack.jar
    In D:\udf , I have packageDemo.java, packageDemo.class, aii_map_api.jar, pack.jar(has the other 3)
    packageDemo.java :-
    package udf;
    public class packageDemo{   
        public static int getSum(int a,int b)
            int c= a+b;
            return c;
    Did i miss anything?? Icant activate message mapping for 2 errors:-
    1.package udf does not exist
    2.Function getsum, Line 3:
    cannot find symbol symbol : variable packageDemo location: class com.sap.xi.tf._xml_mm_int e = packageDemo.getSum(c,d); ^Note: /usr/sap/P7R/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Mapd4214d3099dc11dd9470001d090e4bbe/source/com/sap/xi/tf/_xml_mm_.java uses or overrides a deprecated API.Note: Recompile with -Xlint:deprecation for details.Note: /usr/sap/P7R/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Mapd4214d3099dc11dd9470001d090e4bbe/source/com/sap/xi/tf/_xml_mm_.java uses unchecked or unsafe operations.Note: Recompile with -Xlint:unchecked for details.2 errors
    Edited by: NagaDurga Nannapaneni on Oct 16, 2008 1:07 PM

    Hi ,
    Think the error is coming because the content in imported archive is not being taken into message mapping at all...so package, class, method ..nothing is identified.
    Can anyone suggest the solution..
    Thanks,
    Durga

  • Message Mapping error in UDF

    I am receiving errors when trying to activate my MM.  I believe the issues are in one of two UDF's.  These UDF's do work in another MM without error.  Below are the error's and UDF's.
    ERRORS:
    Activation of the change list canceled Check result for Message Mapping MM_WPDBBY_WPDBBY01_TO_POS_WAWAFILE | http://wawa.com/xi/erp/pos:  Starting compilation  Source code has syntax error:  /usr/sap/XID/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map5420e070cabe11dcab4b00306ef38da9/source/com/sap/xi/tf/_MM_WPDBBY_WPDBBY01_TO_POS_WAWAFILE_.java:3291: cannot resolve symbol symbol : variable container location: class com.sap.xi.tf._MM_WPDBBY_WPDBBY01_TO_POS_WAWAFILE_ map = container.getTransformationParameters(); ^ /usr/sap/XID/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map5420e070cabe11dcab4b00306ef38da9/source/com/sap/xi/tf/_MM_WPDBBY_WPDBBY01_TO_POS_WAWAFILE_.java:3293: cannot return a value from method whose result type is void return constant; ^ 2 errors
    UDF's:
    public String getSender(Container container){
    String constant;
    java.util.Map map;
    // get constant map
    map = container.getTransformationParameters();
    constant = (String) map.get (StreamTransformationConstants.SENDER_SERVICE);
    return constant;
    IMPORTS:  com.sap.xi.mapping.parse.dom.;javax.xml.parsers.;java.io.;com.sap.aii.mapping.lookup.;org.w3c.dom.*;
    public String getSeqNum(String fileType,String objNum,String Sender,Container container){
    String request = "<ns0:ZRFC_NUMBER_GET_NEXT xmlns:ns0=\"urn:sap-com:document:sap:rfc:functions\"><NR_RANGE_NR>" + fileType + "</NR_RANGE_NR><OBJECT>" + objNum + "</OBJECT><QUANTITY/></ns0:ZRFC_NUMBER_GET_NEXT>";
    InputStream isRequest = new ByteArrayInputStream(request.getBytes());
    SystemAccessor accessor = null;
    String num  = null;
    try{
         // 1. Determine a channel.
         Channel channel = LookupService.getChannel(Sender, "R_RFC_ERP");
         // 2. Get a system accessor for the channel.
         accessor = LookupService.getSystemAccessor(channel);
         // 3. Create a payload according to the data type which the adapter expects.
         //    Use service.getBinaryPayload() for binary payload,
         //    and service.getTextPayload() for text payloads.
         Payload payload = LookupService.getXmlPayload(isRequest);
         // 4. Execute lookup.
         Payload response = accessor.call(payload);
         //Parse response
         DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
         DocumentBuilder builder = factory.newDocumentBuilder();
         InputStream resStream = response.getContent();
         Document doc = builder.parse(resStream);
         Element sequence = doc.getDocumentElement();
         NodeList number = sequence.getElementsByTagName("NUMBER");
         //Extract Number
         num = DOMUtil.getSimpleElementText((Element) number.item(0));
    } catch (Exception e) {
         return e.getMessage();
    } finally {
         try {
              if (accessor != null) accessor.close();
         } catch (Exception e) {
              return e.getMessage();
    GlobalContainer gc = container.getGlobalContainer();
    gc.setParameter("Num", num);
    return num;
    Any help is appreciated.
    Regards,
    Darrell

    Fauver,
    Just to narrow down the problem first remove the first udf and only use the 2nd user defined function. Also in the 2nd udf you have to change this line:
    try{
    // 1. Determine a channel.
    Channel channel = LookupService.getChannel(Sender, "R_RFC_ERP");
    In the above line instead of Sender you use the business service or business system where R_RFC_ERP RFC communication channel is created in Integration Directory. So you are hardcoding it first.
    Once you have done this changes do save and test it once again. If this works then you can change back to original and your first udf needs to be checked.
    Regards,
    ---Satish

  • UDF for leading zero's in message mapping

    Dear team,
    I need UDF for leading zero's in my message mapping.
    Source and Target both structures contains matnr field.But we have to maintain total 18 chars at target matnr , because RFC in R/3 needed.So I want to add leading zero's when mapping. Can anybody provide the UDF code.
    Matnr[source]--->split by value(eachvalue) ->UDF->Matnr[Target]
    Ex::if source matnr conatains value "9846538" ; I need matnr value at target side like "000000000009846538"[total 18 chars].
    -Drumi

    Hi Ambrish,
    Good day...
    I have enterd what you said and I got below error... and I gave "input" in place of var1, 18 in place of filedlenght in below program...
    =================================
    int len = Integer.parseInt(18);
    int inputLength = input.length();
    try {
    Integer.parseInt(input);
    // If it is an integer, add 0 (len - inputLength) times
    for (int i=0; i< len-inputLength;i++)
        input = "0" + input;
    return input;
    } catch (NumberFormatException numForEx) {
    // return as it is, if alphanumeric
    return input;
    ====================================
    ERROR:
    Source text of object Message Mapping: Lubrisur_SHPMNT_SHPMNT05_TO_WMMBXY_WMMBID02_TransferPosting | urn:bp:xi:dwn:lu:common:Logistics:100 has syntax errors:
    Function LeadingZeros, Line 1:
    cannot find symbol symbol  : method parseInt(int) location: class java.lang.Integer int len = Integer.parseInt(18);                  ^ 1 error
    =======================
    Please suggest

  • UDF Problem in message mapping

    Hi,
    I have proxy to file scenario where i am getting mapping error
    Runtime exception during processing target field mapping /ns0:DataManagement/payrollArea. The message is: Exception:[java.lang.NullPointerException] in class com.sap.xi.tf._DataManagement_to_DataManagementM4_ method SetFileName$[, com.sap.aii.mappingtool.tf3.rt.Context@1861efad].
    There is one UDF Set file Namewhich t is throwing  error.
    UDF Setfilename
    DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File", "FileName");
    String targetFileName="DMS_" + a + ".dat";
    conf.put(key,targetFileName);
    return a;
    Please help me in this issue.
    Thanks in Advance

    Hi,
    This error will not come while actual run of scenario.
    During Testing Message mapping, this might be coming to you, but while actual run scenario will work fine.
    and one more thing ...
    please your code inside try .. catch block of java code
    try
    /* your actual code */
    catch(Exception e)
    String exception = e.toString();
    return exception;
    Hope this will help you.
    Regards
    Prabhat Sharma.

  • GlobalContainer object values acessed among UDF's  in message mapping ?

    hi
    i have scenario where i am using globalContainer variable functionality in my message mapping.
    in edit java section
    String usr;
    Container container ;
    GlobalContainer globalContainer ;
    intialize usr = "";
    in First UDF
    String inlogin_sess =  " ashutosh test value" ;
    globalContainer.setParameter(usr,inlogin_sess);
    return any value :
    now if i create another 2nd UDF and use :
    String  out =globalContainer.getParameter(usr);
    return out ;
    now 2nd UDF is giving null pointer exception...
    for testing the code functionality..
    IF i  use the  SET and GET in 1st UDF :
    globalContainer.getParameter(usr);   in 1st UDF than it is working sucessfully...
    globalContainer.setParameter(usr,inlogin_sess);
    String  out = globalContainer.getParameter(usr);
    return out ;
    in help.sap it is mentioned that Globalcontainer objects  values can be fetched   among UDF's in one message mapping....
    [http://help.sap.com/saphelp_nw04/helpdata/en/0f/80243b4a66ae0ce10000000a11402f/frameset.htm]
    i have gone a lot of thread in sdn where Global container are used like sequence no creation etc, but every where  the
    GET and SET are used in SAME UDF...
    any clue where is leak..
    Regards,
    ashutosh R

    Hi Abhishek
    Your point is legimate, but for my their is no such issue..
    even i try to use it as :see image..
    [http://www.screenshots.cc/show.php/14137_GlobalVariable.JPG.html]
    UDF1 :
    globalContainer.setParameter(usr,inlogin_sess);
    return any value :
    and in UDF2 
    String  out = globalContainer.getParameter(usr);
    return out ;
    mainting the sequence
    My concern is object globalContainer is local in UDF1, so it will through nullpointer ,if we try to access in UDF2.
    if we declare globalContainer   in edit jave -GlobalVariables also, still it is having the error..
    Regards
    AshutoshR

  • Message mapping problem / experts needed / UDF?

    Hello experts,
    I have the following problem in a message mapping:
    Source structure is as follows:
    - Node a (min 1, max 999)
      - Subnode b (min 0, max 999)
      - Each Subnode b has the element "number" (1,1)
    This structure must be mapped to the following target structure:
    - Node c (1,999)
       - Subnode d (0,999)
       - Each subnode d has the following elements:
           - e1
           - e2
           - e3
           - e11
    1 Source node a should create 1 target node c.
    All numbers in all subnodes b of one source node a should be mapped to the e1, e2,...e11 elements of the target structure. As one target node d can only contain up to eleven numbers, there must be several d nodes.
    I have already tried to create a UDF, but it does not work.
    Any experts who would like to share their knowledge?
    Thanks in advance.
    CHRISTOPH
    Edited by: Christoph G. on Apr 23, 2008 10:46 PM

    Hello again,
    meanwhile I have worked hard on it and I have found the solution (just one UDF (queue function) which gets the article numbers as well as constant(targetField). So the UDF covers the creation of the "groups" as well as the mapping of the article numbers.
    It was really interesting and it made me ambitious to find the solution myself I do not have access to the system today, but I will post my solution as far as I have access again. Maybe you still want to search for a solution? It really may be fun, just like some kind of a puzzle game.
    In order to make it more clear, here comes the source and target structure with an example. Let me once more explain it: In the source, there are positions, each with unlimited article numbers. Each position will create a targetPosition. The node "targetPosition" has the subNode "articlenrs" (unbounded). Articlenrs has 11 differnet elements, calles a1, a2, a3, ..., a11. That means, all article numbers from a source postion should be mapped to "groups of 11 target article numbers". Please be aware the there are 11 differnet target fields for article numbers: a1, a2, ... a11.
    I think that' why the solution of  Liang Ji and Rohit Kalugade will not work...
    SOURCE
    <position>
         <articlenr> 123   </articlenr>
         <articlenr> 456   </articlenr>
         <articlenr> 4783 </articlenr>
         <articlenr> 123   </articlenr>
         <articlenr> 456   </articlenr>
         <articlenr> 4783 </articlenr>
         <articlenr> 123   </articlenr>
         <articlenr> 456   </articlenr>
         <articlenr> 4783 </articlenr>
         <articlenr> 123   </articlenr>
         <articlenr> 496   </articlenr>
         <articlenr> 4783 </articlenr>
             . (unbounded)
    </positon>
    <position>
         <articlenr> 543  </articlenr>
         <articlenr> 865  </articlenr>
         <articlenr> 643  </articlenr>
    </positon>
    TARGET
    <targetPosition>
      <articlenrs>
           <a1> 123  </a1>
           <a2> 456  </a2>
           <a3> 4783 </a3>
           <a11> 496 </a11>
      <articlenrs>
      <articlenrs>
           <a1>4783 </a1>
      </articlenrs>
    </targetPosition>
    <targetPosition>
         <articlenrs>
         <a1> 543 </a1>
         <a2> 865 </a2>
         <a3> 643 </a3>
            </articlenrs>
    </targetPosition>
    Thanks,
    Christoph
    Edited by: Christoph G. on Apr 30, 2008 10:20 AM

  • UDF works in Message Mapping but not in Interface Mapping

    Hello,
    I have encountered a very strange problem. I use a simple UDF in a message mappings which imports a class that has been imported as "imported archive".
    This works perfectly fine when testing the message mapping itself.
    However when I execute the message mapping within a interface mapping I get a Java Error indicating that resources are missing (com.sap.aii.ib.core.mapping.ResourceNotFoundException) This error refers to a missing class.
    How can this be? Message mapping works but not when using it in a interface mapping.
    Do you have any idea?

    Hello,
    this is what I have already tried, with the same result. But now I have come to a conclusion. It is a little bit tricky, but maybe also helpful for others:
    A method of a class (part of the imported archived) itself calls a class which throws an exception. This exception however is handled by the method itself and does not affect the overall outcome.
    In the message mapping itself you do not see the error message, only in the interface mapping. Result however is the same.
    Maybe the trace level is set different for mesage and interface mapping.....

  • Export parameter in Message mapping UDF

    Hi, I use PI7.1.
    I defined an Export parameter in Message mapping "Signature" tab.
    And as http://help.sap.com/saphelp_nwpi71/helpdata/en/43/c3e1fa6c31599ee10000000a1553f6/frameset.htm,
    I wrote in my UDF as follows:
    public String myudf(int var1) {
    String str="test";
    if(exists("MY_PARA") == true) {
    getOutputParameters.setString("MY_PARA", str);
      return str;
    However when I ran the test, it said there is "syntax error".
    I guess the reason is not found the method exitst() or getOutputParameters. Anybody can help? thanks

    Here is a valid sample for a Java Mapping program working with Parameterized Mappings - taken from help.sap.com::
    import com.sap.aii.mapping.api.AbstractTransformation;
    import com.sap.aii.mapping.api.StreamTransformationException;
    import com.sap.aii.mapping.api.TransformationInput;
    import com.sap.aii.mapping.api.TransformationOutput;
    import com.sap.aii.mapping.lookup.Channel;
    public class Parametrization_Java
       extends AbstractTransformation {
          public void transform(
             TransformationInput in,
             TransformationOutput out)
          throws StreamTransformationException {
             try {
    // Read Import Parameters
                String paramS =
                   in.getInputParameters().getString(u201CPARAM_Su201D);
                int paramI =
                   in.getInputParameters().getInt(u201CPARAM_Iu201D);
                Channel paramC =
                   in.getInputParameters().getChannel(u201CPARAM_Cu201D);
    // Use Parameters during Mapping
    // Set Export Parameters
                   out.getOutputParameters()
                      .setString(u201CPARAM_ESu201D, [String-Wert]);
                   out.getOutputParameters()
                      .setInt(u201CPARAM_EIu201D, [Integer-Wert]);
                   out.getOutputParameters()
                      .setValue(u201CPARAM_ECu201D, [java.lang.Object]);
             } catch (Exception e) {
                // Exception Handling
    Regards,
    Volker

  • Message mapping/UDF help..

    Hi experts,
    Can someone let me know whether there is a chance to fulfill the below requirement:
    Input file:
    In the Input CSV file, there is a fixed length field with length 9 char and has leading zeroes (ex: 000000650)
    Output file:
    In the O/p XML file, the corresponding value should be displayed as "6.50" (Have to remove the leading zeroes, right justified and the last two digits should be allocated for decimals)
    Can anyone let me know if we can handle in Message mapping or should we write a UDF? If so can you please provide the code..
    Any help would be highly appreciated !!
    Thnx
    - Ravi

    Hi Ravi,
    UDF:
    Create a function zerosuppress and take the cache as value and take one argument input. Then put the code below:
    //Put this code
    String output = input.replaceFirst("^0+","");
    return output;
    With this function your leading zeros will remove.
    Then map like this:
    source field --> zerosuppress (udf) --> divide by 100 --> target field.
    This should solve your issue.
    Regards,
    ---Satish

  • Problem in Graphical message mapping.Need UDF to add array based on some co

    Hi All,
    I have been struck in message mapping.Below i am explaining it,
    I have two input array,
    one array lets call  X [24]
                                    [25]
                                     [26]
                                     [24]
                                    [25]
    other array is Y [10]
                           [11]
                           [12]
                           [13]
                           [14] .length of both the array will be same .
    Now I want the output as: if there is any same value in first array i.e array X then corresponding value of second array should be added.i.e in array X if 24 is coming as twice (1st and 4th) then 1st and 4th value of array Y will be added.So here there will be only three output as Z[23]
                                                      [25]
                                                      [12]
    Please guide me if posiible .I tried to use the for loop but  its not working as the value of X is repeating.
    Regards,
    Saurabh

    Hi,
    Tru this..
    public void test(String[] a,String[] b,ResultList result,Container container){
    int flaga,flagb;
    for(int i=0;i<a.length;i++)
         flaga =0;
         for(int j=i+1;j<a.length;j++)
              int p =  Integer.parseInt(a<i>);
              int q =  Integer.parseInt(a[j]);
              if(p==q)
                   flaga =1;
                   int c = Integer.parseInt(b<i>)+Integer.parseInt(b[j]);
                   String d = new Integer(c).toString();
                   result.addValue (d);
    if (flaga ==0)
    flagb=0;
    for(int q =i-1; q>=0;q--)
         if(Integer.parseInt(a<i>) == Integer.parseInt(a[q]))
              flagb = 1;
    if (flagb == 0) result.addValue((b<i>));
    I have tested with the same input... it is working for me
    http://www.flickr.com/photos/28929439@N06/2721471681/
    Thanks
    SaNv...

  • Use exported parameter from message mapping (via UDF) in next mapping prog

    Is there any chance to assign an exported parameter from one message mapping to another mapping program within an operation mapping?

    Hi,
    Try using  dynamic configuration
    1. Set value in message mapping and
    2. Get value in java mapping
    Refer this link http://help.sap.com/saphelp_nw04/helpdata/en/43/03612cdecc6e76e10000000a422035/content.htm
    Regards
    Suraj

  • How to use the variables used in the message mapping

    Hi ,
    In the message mapping we can declare variables in the JAVA section , these variables could be used across the mapping .
    I have tried using it but I am unable to retrieve the values assigned to the variables in one UDF into the another UDF .
    Please guide me how to use the variables declared in the JAVA section in the message mapping .
    Thanks
    Anita Yadav

    Anita,
    I have worked on the Global variables and i found no issues. Make sure that the variable is declared in the Declaration Section and then initlaized in the Initialization section.
    If you declare a variable in the Declaration Section ,
    int i;
    then in any udf you can use if directly. No need to re declare  the variable in the UDF. If you do this, then it becomes a local variable.
    Regards,
    Bhavesh

Maybe you are looking for