Mapping UDF

Hey folks
I have a mapping issue:
It is IDOC to file scenario
A segment in IDOC repeats multiple times. I want to take a field of the first repeating segment and map it to a target field.
And i want to take afield of the last repeating segment and map to a target field.
Eg : E1EDPL1  
            GSB     100
      E1EDPL1
           GSB      200
      E1EDPL1
           GSB     300
Mapping logic 1 :
Take the first GSB ( Value: 100) and map to a target field.
Mapping logic 2 :
Take the last GSB(Value : 300) and map to a target field.
Guess we need to have a context java function which takes as an input an array of GSB and extract first and last GSB.
Need help with the java udf.
Thnx

A small correction
Here a is the GSB values.
cache parameter - context
1st udf
public void add(String[] a,ResultList result,Container container)
   //write your code here
result.addValue(a[0]);
GSB ---> add -
> tgt1
2nd udf
public void add1(String[] a,ResultList result,Container container)
//write your code here
int len = a.length -1;
result.addValue(a[len]);
GSB---> add1 -
>tgt2

Similar Messages

  • Container Element in the Mapping UDF

    Is there any way that to access the BPM container Element in the Mapping UDF. Can some one share the UDF code for this

    Hi,
    Refer BPM Container Element and Container in UDF Relation
    BPM Container Element and Container in UDF Relation
    Creating the container Object In Java Mapping
    Thanks
    swarup

  • RuntimeError in mapping.......package com.itc.xi.mapping.udf does not exist

    while testing a maaping, one of the UDFs threw the following runtime error...
    Error: package com.xxx.xi.mapping.udf does not exist...
    moreover, whats the CLASSPATH of the java package com.itc.xi.mapping.*
    Message was edited by:
            sudeep dhar

    Hi,
    You seem to be referring to some extrenal class in your UDF and this class is not available under imported archives.
    Please check what is the class being refefferd and make sure it is in the imported archives,.
    Regards
    Bhavesh

  • Java Mapping/UDF/ABAP mapping to capture payload

    Hi,
    could you please provide me Java mapping code samples (or UDF code) to save payloads of a message based on Message ID
    i have a synchronous scenario where i have payloads in sxmb_moni for request and response with different message IDs. So pelase let me know how to save those request and response payloads to a file.
    it would be great if you provide the stpes to implement and java code samples....if it is possible with ABAP mapping also please let me know te steps.
    Best Regards....SARAN

    Try with this code
    import com.sap.mw.jco.IFunctionTemplate;
    import com.sap.mw.jco.IRepository;
    import com.sap.mw.jco.JCO;
    public class PayloadExtractor {
        // The MySAP.com system we gonna be using
        static final String SID = "SID";
        // The repository we will be using
       IRepository repository;
        JCO.Field msgkeyField;
        public PayloadExtractor() {
            try {
                System.out.println("*** Creating the Pool... ***");
                JCO.addClientPool(SID, 10, "001", "user", "pwd", "EN", "host", "00");
                repository = JCO.createRepository("RecoverRepository", SID);
            } catch (JCO.Exception ex) {
                System.out.println("RecoverXI Caught an exception: \n" + ex);
        // Retrieves and prints information about the remote system
        public void getPayload() {
            // A messageID from your XI/PI
            String key = "48CD01EB3D27021BE1008000C0A8477D";
            final String pipelineID = "CENTRAL";
            byte[] msgkey = key.getBytes();
            try {
                IFunctionTemplate ftemplate = repository.getFunctionTemplate("SXMB_READ_MESSAGE_VERSION_RAW");
                if (ftemplate != null) {
                    System.out.println("*** Creating client and function... ***");
                    JCO.Function function = ftemplate.getFunction();
                    JCO.Client client = JCO.getClient(SID);
                    JCO.Structure struct = function.getImportParameterList().getStructure("MESSAGEKEY");
                    struct.setValue(key, "MSGID");
                    struct.setValue(pipelineID, "PID");
                    // SELECTION must be like this!
                    function.getImportParameterList().getField("SELECTION").setValue("2");
                    // This is the msg version number, where 000 is the first (Inbound); the last can be caught from the function output (see below).
                    // Setting this strongly depends on what you want to get: basically before or after the mapping...
                    function.getImportParameterList().getField("VERSION_REQUEST").setValue("000");
                    System.out.println("*** Calling... ***");
                    client.execute(function);
                    JCO.Table tb = function.getExportParameterList().getTable("MESSAGEPAYLOAD");
                    if (tb.getNumRows() > 0) {
                        // There could be multiple payloads (even if usually it's only one)
                        do {
                            String plstr = new String(tb.getField("PAYLOAD").getByteArray());
                            System.out.println(
                                "*** Payload found *** " + tb.getField("NAME").getString() + " *** BEGIN ***");
                            System.out.println(
                                "Message Last Version: "
                                    + function.getExportParameterList().getField("MAXVERSION").getString());
                            System.out.println(plstr);
                            System.out.println(
                                "*** Payload found *** " + tb.getField("NAME").getString() + " ***  END  ***");
                        } while (tb.nextRow());
                    } else {
                        System.out.println("*** No payload found! ***");
                    // Release the client into the pool
                    JCO.releaseClient(client);
                } else {
                    System.out.println("Function SXMB_READ_MESSAGE_VERSION_RAW not found in backend system.");
            } catch (Exception ex) {
                System.out.println("Caught an exception: \n" + ex);
        protected void cleanUp() {
            System.out.println("*** Cleaning... ***");
            JCO.removeClientPool(SID);
        public static void main(String[] argv) {
            PayloadExtractor e = new PayloadExtractor();
            e.getPayload();
            e.cleanUp();
    -Madhu

  • Need help with mapping( UDF)

    Hi,
      I had a mapping requirement where i need to transfer data with double quotes
          suppose data is
    sap-labs
    i need to send as "sap-labs".
    The main problem is when ever there is '-'(it can be any where in the string) I need to modify as above, otherwise data can be sent directly.
    I know how to do this requirement using Standard Functions.But, I am trying to use UDF so try to help me out with the code.
    and also what i have to import for this UDF. and why i have to import them?
    Thanks in advance,
    Siva.

    Hi Siva Bonthala,
    Note: - quote ("), apostrophe ('), ampersand (&), less than (<), greater than (>) are special characters in XML. They should not be present in data. [Link1|http://www.w3.org/TR/REC-xml/] [Link2|Re: Special Character Handling (&) in the payload content in PI 7.1]
    When you writing Java code to insert these special characters, you should use escape scequence characters.
    Test it for your self, in graphical mapping, use 'concat' function and type Delimiter String as ". Then check output XML, it will contain &quot ;.
    If you have to replace sap-labs with "sap-labs" for many element, I recomand you to use Java Mapping instead of UDF's for every field.
    Regards,
    Raghu_Vamsee

  • Message Mapping UDF for lookuping of a value inside field's list of values

    Hey everyone,
    For a FI mapping I'm working on, I was wondering if somebody has some Java UDF which lookups for a value inside the whole list of values which the mapping gathered for a specific field?
    Thanks,
    Ben

    source code --
    //write your code here
    JCO.Repository myRepository;
    // Change the logon information to your own system/user
    JCO.Client myConnection = JCO.createClient(
    // all the client information namely client ,user id pwd etc
    myConnection.connect();
    // create repository
    myRepository = new JCO.Repository( "SAPLookup", myConnection );
    // Create function
    JCO.Function function = null;
    IFunctionTemplate ft = mRepository.getFunctionTemplate("xxxxx"); //Name of RFC
    function = ft.getFunction();
    // Obtain parameter list for function
    JCO.ParameterList input = function.getImportParameterList();
    // Pass function parameters
    input.setValue( a , "xxxxx" ); //import parameter of RFC, a is input argument.
    myConnection.execute( function );
    String ret = function.getExportParameterList().getString( "XXXX" ); //export param
    myConnection.disconnect();
    return ret;
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/a03e7b02-eea4-2910-089f-8214c6d1b439
    File Lookup in UDF
    https://www.sdn.sap.com/irj/sdn/wiki?path=/display/xi/file%2blookup%2bin%2budf
    Lookupu2019s in XI made simpler
    /people/siva.maranani/blog/2005/08/23/lookup146s-in-xi-made-simpler
    SAP XI Lookup API: the Killer
    /people/alessandro.guarneri/blog/2006/03/27/sap-xi-lookup-api-the-killer
    Webservice Calls From a User Defined Function.
    /people/bhavesh.kantilal/blog/2006/11/20/webservice-calls-from-a-user-defined-function

  • 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

    Hi Guys,
    For the UDF functions for messagemapping,Its a pain to code it using the dataflow editor provided in the repository.
    We are having the XI version 3.0(SP 20).
    So I decided to use eclipse for coding and debugging the functions and then copy it to the UDF editor for usage.
    Have downloaded the Eclipse-SDK 3.0.02 Version and is going to use the the JDK version(1.4.12)
    Is that Okay?(I mean is it compatible with the XI version).
    I have the aii_map_api.jar already with me.
    What is the above ".jar" for and what do they contain?
    Have read somewhere that I need the aii_mt_rt.jar and aii_utilxi_misc.jar as well.
    What are they for and what do they contain?
    If I need the above said jars,Is there any java plug-in available.
    Thanks
    P

    Hi P,
    For writing UDF's you dont need all these jar file!!!! they are required either for java mapping or module creation..
    BTW you can use any java ide to write this simple piece of java codes (even notepad will do )
    Regards
    Suraj

  • 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

  • Mapping UDF Question.

    All,
    We have the following structure from the input XML... We want to extract the PSTLZ node value into the target structure where PARVW = "WE" - Im trying to use a UDF but - im getting an error because the PSTLZ is an optional node under E1EDKA1 and not all the E1EDKA1 segments have this field. i was trying to UDF to take 2 parameters - PARVW (context at IDOC level) and PSTLZ (context at IDOC level).
    Any help would be appreciated...
    <IDOC>
          <E1EDKA1 SEGMENT="1">
             <PARVW>AG</PARVW>
             <PARTN>1</PARTN>
             <TELFX>XXXXX1</TELFX>
             <BNAME>Mike</BNAME>
             <PAORG>100</PAORG>
             <ORGTX>US Purchasing</ORGTX>
             <PAGRU>UG1</PAGRU>
          </E1EDKA1>
          <E1EDKA1 SEGMENT="1">
             <PARVW>RE</PARVW>
             <NAME1>SomeName</NAME1>
             <STRAS>Street 1</STRAS>
             <ORT01>City1</ORT01>
             <PSTLZ> 12345</PSTLZ>
             <REGIO>NY</REGIO>
          </E1EDKA1>
          <E1EDKA1 SEGMENT="1">
             <PARVW>LF</PARVW>
             <PARTN>2</PARTN>
             <SPRAS>E</SPRAS>
             <SPRAS_ISO>EN</SPRAS_ISO>
          </E1EDKA1>
          <E1EDKA1 SEGMENT="1">
             <PARVW>WE</PARVW>
             <LIFNR>XYZ</LIFNR>
             <NAME1>NAME1</NAME1>
             <NAME4>Name4</NAME4>
             <STRAS>some street</STRAS>
             <ORT01>BUFFALO</ORT01>
             <PSTLZ>12345</PSTLZ>
             <LAND1>US</LAND1>
             <ABLAD>YYY</ABLAD>
             <PARNR>YYY</PARNR>
             <SPRAS>E</SPRAS>
             <REGIO>US</REGIO>
          </E1EDKA1>
    </IDOC>

    rkk,
    Try this
    Parvw[Change Context to IDOC] --->UDF
    PSTLZ[Don't Change Context] --->Map With Default[] -->Remove Context---> UDF
    If there are no values from PSTLZ what u want to do? According to the above logic, it will give blank value are u ok with it?
    raj.

  • Message mapping : UDF parameter string type versus default UTF-8 encoding

    Hi,
    I'm facing an issue with character encoding when using an UDF to transform into base64 encoding.
    While thinking about the subject, I'm not 100% sure if it's possible to get it to work corerctly :
    Given :
    -The input XML is encoded UTF-8 ( with a special characeter )
    -The UDF is generated with java parameter type 'string' ( = set of 16bit unicode characters )
    Doubts :
    -What is supposed to happen when a node content ( of message encoded in UTF-8 ) is used as input for the UDF string type parameter  ? Is the node content decoded/encoded correctly by PI automatically ( at input/output versus the internal 16bit unicode character string ) ?
    ( I would assume yes )
    -Is the default charset of the underlying JVM relevant ? Or does pi always use explicit charsets when encoding/decoding ?
    ( I would assume it's not relevant )
    The UDF java code considers the string as a array of chars while processing them. It uses methods .length and .charat on the input string.
    The result is that I have a ISO-8859 encoded string ! ( after decoding it back from the base64 ) 
    What could cause this ?
    regards
    Dirk
    PS If I simply use default functions ( concat etc..) then the resulting xml stays correctly encoded...

    Hi,
    But that would mean that an UTF-8 encoded byte array would be passed unconverted to the UTF-16 unicode string parameter ?
    Shouldn't that trigger an exception ?
    I'm going to make some tests and see if it enlights my knowledge ( empirical )
    Keep you updated,
    thanks
    dirk

  • Graphical mapping/UDF

    Hi all,
    I am using PAYEXT IDOC.
    My requirement is that when E1IDT01 does not exist then E1EDp02->Belnr should be populated to my target field--OBI_1......0 to unbounded->
                                                            Instructions
    if it exist TXT02 should be populated .
    The Logic is
    E1IDt01->exists->createif
                                                              or     OB1_1->
    E1IDt01->exists->createif
    I do not see OB1_1 created in the Target.
    Thanks,
    Srinivasa

    Hi Srini,
    I am not sure if I got what I need correctly. More over I could not find the PAYEXT idoc.
    What I understand is, if E1IDT01 does not exit ("the node itself"), you require to set the value E1EDp02->Belnr to OBI_1.
    If the above is true, use if (if .> then -> else)
    E1IDt01->exists->if > then > E1IDt01 > else > E1EDp02->Belnr to OBI_1
    hope it helps.
    Regards
    Unni

  • How to debug global values in UDF in a graphical mapping

    Hi Every one,
    I  got a situation in PI where i have to use global values in graphical mapping UDF.
    I can't able to get the values in "Display Queue " option.
    Can you please tell me what is the best way of debugging global variable in graphical mapping UDF.
    1. I declare one array list in the global values
    2. store some values using another UDF to the arraylist.
    3. I am traversing the values in the arraylist, but the values are not showing in "Display Queue".
    What is the solution to this.

    Did you try with trace.addInfo?
    https://help.sap.com/javadocs/NW04/current/pi/com/sap/aii/mapping/api/AbstractTrace.html
    Sample code for the setMail UDF (Carrier B2B) - Business Process Expert - SCN Wiki

  • Cannot resovle the Symbol error in UDF - Java mapping - RFC Lookup ?

    Hi Friends ,
    We are working on Java mapping  -  UDF for RFC Lookup . It is giving the Cannot resolve Symbol for all imported archive java class files even if we give again all imported files in import section of UDF we are still getting the same cannot resolve error  .
    We are using SP 12 of XI 3.0 . What could be the reason ?
    Thanks.,
    V.Rangarajan

    Hi,
    Can you try to open imported archive in IR and check if the path(folder structure like com.abc.xyz.etc) for classes is same as in import statement in UDF.Since we had experienced the same problem.
    Thanks.
    Regards,
    Shweta

  • Refresh GTC to map new UDF?

    Using OIM 11.1.1.5
    I have an existing GTC with FULL trusted source reconciliation in order to pull in users from our sql server database into OIM. Works fine.
    After the GTC was created, I have added a new UDF in OIM and want to map to the new UDF within the GTC. The new UDF does not show up in Step 3 of the Modify Connector Configuration. What are my options to "refresh" the connector besides a complete connector rebuild?
    Thanks!

    I am strictly talking about the OIM column on the mapping page. I know I can add fields in the Source and Reconciliation Staging columns. When I click the arrow button on the User table in the OIM column to show all the fields available for mapping, the newly created UDFs still do not show up.
    Has anyone been successful mapping UDFs that were created after the connector? If so, did you use the Design Console, MDS, or both? Or is it even possible to "refresh" a connector?
    Thanks

Maybe you are looking for