UDF or Graphical Mapping

Hello All
I have a requirement like below:
Source fields              
TXT                                 
AddTXT
Target Field
Node
I want to create Node as many times as AddTXT comes with value Concatinate(TXT+AddTXT). This I have achieved not a issue.
Now I want concatinate should happen only for 1st Node other nodes should contain only value of AddTXT.
e.g.
TXT = 001
AddTXT = James
AddTXT = Dheeraj
AddTXT = Rajesh
Result should be
Node = 001-James
Node = Dheeraj
Node = Rajesh
I believe using Graphical mapping this is not possible so how can I achieve this using UDF.
Thanks
Dheeraj Kumar

Hi Dheeraj
Please use the below code.
In the UDF
TXT = var1
AddTXT = var2
Regards
Osman

Similar Messages

  • Java lookup udf in graphical mapping

    Hi experts,
    I have java look up udf where it will look material number and display UOM but I dont want all UOM to get display. I want only one UOM to get display suppose if I have material 1 and UOM is EA and material 2 UOM is CR(as we are in milk business we use CR as UOM) I want to only CR if not IDOC should not get created. Below is the code which was already written
    String TAG_IV_GTIN = "GTIN";
    Hashtable hash = new Hashtable();
    String[] rfcInputParameters = ;
    String[] rfcInputValues = {inputParamValue1[0]};
    Map inputParam = container.getTransformationParameters();
        for (int i = 0, n = rfcInputParameters.length; i < n; i++) {
          hash.put(rfcInputParameters<i>, new String(rfcInputValues<i>));
    RFCLookup rfc = new RFCLookup();
    List rfcResults =  rfc.executeGMT(functionModule[0],hash, businessService[0],communicationChannel[0],resultXPathExpr[0],inputParam);
    String rfcOutput = null;
    Iterator iterator = rfcResults.iterator();
    while (iterator.hasNext()) {
        Node resultNode = (Node) iterator.next();
        Node firstChild = resultNode.getFirstChild();
         if (firstChild == null) rfcOutput = null;
        else rfcOutput  = firstChild.getNodeValue();
    if (rfcOutput != null)  {
         result.addValue(rfcOutput);
    } else {
        // throw error if material lookup fails
        ExceptionThrower.fire("Error : Material " + inputParamValue1[0] + " does not exist in SAP.");
    Can anyone please help me how I can look only particluar UOM and display that one only.

    MappingLookupAPI is the answer to your question.
    Refer
    http://help.sap.com/saphelp_nw2004s/helpdata/en/cf/406642ea59c753e10000000a1550b0/frameset.htm
    and the blog link specified by Vijaya for more details.
    Regards,
    Amol

  • UDF for graphical mapping

    Hi,
    The following is my source structure :
    Recordset 1..1 -> Idoc 1..unbounded -> Segment 1..1
    <Recordset>
    <Idoc>
    <segment>abcdefgh</segment>
    </Idoc>
    <Idoc>
    <segment>klmno</segment>
    </Idoc>
    </Recordset>
    I have a requirement where in I have to pass the data from the various segments as an input to the RFC.Is there any UDF which I can use to concatenate the values from the different segments and map it to the input for the RFC.There can be many idocs under one Recordset and each idoc has one segment.
    Appreciate if you could help.
    Thanks in advance.
    Induja

    Hi,
    Please use below TestUDF code
    Here pass the input parameter as Segment ---> TestUDF ---> Target field
    And select the cache parameter as queue
    String temp = new String("");
    for(int i = 0; i<a.length;i++)
    temp = a<i> + temp;
    result.addValue(temp);
    Thanks
    Swarup

  • 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

  • Create Attachment within Graphical Mapping using UDF

    Hi!
    We want to create an attachment witihn a graphical mapping using an UDF function.
    I use that function:
    public String addAttachment(String filename, String mimeType, String content, Container container) throws StreamTransformationException{
         BASE64Decoder decoder=new BASE64Decoder();
         try {
              GlobalContainer globalContainer = container.getGlobalContainer();
              OutputAttachments outputAttachments = globalContainer.getOutputAttachments();
              Attachment attachments = outputAttachments.create(filename, mimeType,decoder.decodeBuffer(content));
              outputAttachments.setAttachment(attachments);
              return "Adde1: "+filename;
         } catch (Exception e) {
              return e.toString();
    (SDN helped me much in creating that
    This function has no compiling errors, anything workes fine:
    It takes 3 input-parameters, see also: http://help.sap.com/javadocs/pi/SP3/xpi/com/sap/aii/mapping/api/OutputAttachments.html
    filename (ok, more or less contentID)
    mimeType (more or less contentType)
    content: Base64-encoded String which should be set as content
    In my sample I use the following constants for that function:
    filename = "fn1.txt"
    mimeType="application/xml"
    content = "UG9seWZvbiB6d2l0c2NoZXJuZCBhw59lbiBNw6R4Y2hlbnMgVsO2Z2VsIFLDvGJlbiwgSm9naHVydCB1bmQgUXVhcms=" --> cames directly from http://de.wikipedia.org/wiki/Base64
    When using the message, I got this error within SXMB_MONI:
    <SAP:AdditionalText>com.sap.engine.interfaces.messaging.api.exception.MessagingException: Could not queue receive for
    message 0022642d-b106-02df-8e8c-f41c243bd112(INBOUND). Reason: java.lang.NullPointerException: while trying to
    invoke the method com.sap.aii.af.sdk.xi.lang.Binary.getBytes() of an object returned from
    com.sap.aii.af.sdk.xi.mo.xmb.XMBPayload.getContent()</SAP:AdditionalText>
    This looks pretty much the same as Add Attachment from ABAP Mapping but this tread is also not answered.
    Adding attachment from PI level looks also in that direction, again, no answer.
    So, I was wondering if someone has solved such problem?

    Hi Divyesh!
    We did it that way:
    1. Choosing the XML-Mailstructure as Destination as described in Configuring the Receiver Mail Adapter - Advanced Adapter Engine - SAP Library -  Example (XI payload with mail package)
    2. now we have created a UDF for creating the "content"
    public void getContent(String[] text, String[] attFname, String[] attType, String[] attContent, ResultList result, Container container) throws StreamTransformationException{
    // vergleich ob alle att-Arrays selbe anzahl haben
    if (attFname.length!=attType.length || attFname.length!=attContent.length) {
        result.addValue(Integer.parseInt("Fehler: alle Attachment-Eingänge müssen die selbe Anzahl an Elementen haben!"));
        String CRLF = "\r\n";
        String output="This is a multi-part message in MIME format."+CRLF+CRLF+
        "--"+getBoundary(container)+CRLF+
        "Content-Type: text/plain; charset=UTF-8"+CRLF+
        "Content-Disposition: inline" + CRLF + CRLF +
        text[0]+CRLF;
    for (int i=0;i<attFname.length;i++) {
        output+="--"+getBoundary(container)+CRLF+
        "Content-Type: "+attType[i]+"; name="+((char)34)+attFname[i]+((char)34)+CRLF+
        "Content-Disposition: attachment; filename="+((char)34)+attFname[i]+((char)34)+CRLF+
        "Content-Transfer-Encoding: Base64"+CRLF+CRLF+attContent[i]+CRLF;
    output+="--"+getBoundary(container)+CRLF;
    result.addValue(output);
    This UDF is configured as "QUEUE"
    We have configured this input-structure
    The Content itself is allready base64.
    So we can call this mapping and it creates a Multipart-Mail for us.

  • Graphical mapping or UDF

    Hi,
    In my mapping i have a requirement where the input can be any of three values or not existing. (lets just call them V0, V1, V2 and V3, where V0 is the not existing tag)
    If the input is V0, or V1 or V2 i need output an Empty Constant, If the input is V3 i need to pass the value.
    I've worked this out with a graphical mapping, but it involves a lot of boxes. It works though.
    I'm still wondering if i can do it with a UDF though. Only problem is that my JAVA knowledge is not nearly as good as it should be, so maybe one of you out there can give me some ideas/code.
    The thing that give the most headache is the fact that the tag might not exist at all in the source message. How do I deal with that in JAVA code?
    Any ideas are welcome.
    Kind regards
    Robert

    Hi Robert,
    below is the Jave code, below code is w.r.t exection type as CONTEXT/QUEUE
    public void calculate(String[] var1, String[] var2, String[] var3, String[] var4, ResultList result, Container container) throws StreamTransformationException{
    if(var1.length != 0 || var2.length != 0 || var3.length != 0)
             result.addvalue(" ");
    else if(var4.length != 0)
         result.addValue(<passthe value>);

  • Performance of an UDF v/s standard graphical mapping functions

    Hello Experts,
    I would like to get your opinion/comments on the performance issues with respect to speed of execution when using graphical functions for doing the date conversion requirement given below:
    Requirement is to convert input date u20182008-12-03u2019 from the source side to u201820081203u2019 on the target side.
    We have used the standard graphical mapping functions 'substring' & 'replacestring' for doing this conversion as explained here: The u2018substringu2018 function is used to capture the part of the string from the source. A u2018constantu2019 with value u2018u2013u2018 is replaced by u2018constantu2019 (empty value) by using the standard text function u2018replaceStringu2019 in the target side.
    We did the same using the following UDF too:
    public String convertDate(String dateStringInOriginalFormat) {
                SimpleDateFormat originalFormatter = new SimpleDateFormat("yyyy-MM-dd");
                SimpleDateFormat newFormatter = new SimpleDateFormat("yyyyMMdd");
                ParsePosition pos = new ParsePosition(0);
                Date dateFromString = originalFormatter.parse(
                            dateStringInOriginalFormat, pos);
                String dateStringInNewFormat = newFormatter.format(dateFromString);
                return dateStringInNewFormat;
    From a critical performance point of view, which approach will fare better?
    Thanks in Advance,
    Earnest A Thomas
    Edited by: Earnest Thomas on Dec 4, 2008 6:54 AM

    Hi,
    Not only in this case but in general it is always better to use the functions available in MM and only if your requirement is not satisfied with the standard mapping functions then go for UDF.
    Also for your requirement no need of going for substring....you can directly use the DateTransform function available.
    Source --> DateTransform --> Target
    Regards,
    Abhishek.
    Edited by: abhishek salvi on Dec 4, 2008 11:25 AM

  • Do we any tool to test the UDF other than Graphical Mapping

    Hi Experts,
    in graphical mapping we come across UDF i just want to is there any seperate tool in market to test the UDF
    Thanks
    Metha

    Hi,
    Here you have the Effective Tool to Test Our Mappings
    The specified item was not found.
    Regards
    Seshagiri

  • Bug in exists() function of XI Graphical Mapping Tool?

    Hi!
    If I connect a source field with the exists() function in XI Graphical Mapping Tool and the tag exists it returns TRUE, otherwise it returns FALSE, so everything works as expected.
    But I have to connect a user-defined function with exists(). The user-defined function will either calculate a value or set Resultset.SUPPRESS.
    If there is a value the exits() function returns TRUE, however if Resultset.SUPPRESS is set it does also return TRUE! This looks to me like a bug in exists() function. Shouldn't it always return FALSE if the input is Resultset.SUPPRESS?
    Regards, Tanja

    Hi Stefan!
    > The exists() function checks, if a queue is empty.
    > An empty queue is <b>not</b> represented by the
    > SUPPRESS value.
    > If inside a queue there is a SUPPRESS value, the
    > queue is <b>not</b> empty.
    Ok, so it's not a bug and the exists() function is working as expected.
    > If you want the exist() function after a UDF, provide
    > an empty queue, or easier: return the values "true"
    > or "false" directly from the UDF.
    Yes, that's how I actually solved the problem. The UDF was used at several places where the ResultList.SUPPRESS output was needed. So I copied the UDF and changed it so that the output was TRUE or FALSE instead.
    Regards, Tanja

  • 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

  • Graphic Mapping:IDOC to File-Avoid Error in Adapter Engine

    Hi all,
    I'm using Graphic Mapping in my IDOC to File scenario in which each segment in source IDOC will generate a ROW in target File with the condition: DATBI >= currentdate (and some other conditions)
    I have a UDF and use the mapping function CREATEIF for this purpose:
                                 DATBI -> UDF -> CREATEIF -> ROW
    Problem scenario: In the source IDOC if all the segments have DATBI < currentdate then there is no ROW created, and I get the error in Adapter Engine
    Exception in XML Parser (format problem?):'java.lang.Exception: Message processing failed in XML parser: 'Conversion configuration error: Unknown structure ...
    How can I avoid this?
    I've tried to put this condition using XPATH in Interface Determination and got the error.
    There is a way to use function current-date() in XPATH condition?
    Thanks for your help,
    Elaine

    Hi all,
    How can I "suppress the row node if condition fails"? I'm new in PI, so please give more details.
    My FCC as follows:
    Record Structure: Record, Row
    Row.addHeaderLine 0
    Row.fieldSeparator ,
    Record.fieldSeparator 'nl'
    Row.endSeparator ; 'nl'
    It works fine if the condition satisfied.
    In Message Mapping, I've use Test to double check my mapping, and in the scenario that conditions fails, there is no Row in the target message.
    Please advise.
    Thanks,
    Elaine

  • How to delete target field in graphical mapping

    Hi all,
            i have a field called failedsubject in my target my requirement is if their is no value in this field then it has to be deleted means it should not be shown iam using graphical mapping. please help me
    thanks in advance

    Hi,
               Please try with the below logic.
    public String failedSubject(String sub1, String sub2, String sub3, Container container) throws StreamTransformationException{
    if (Integer.parseInt(sub1) >= 40)          //assuming 40 as passmark
              if (Integer.parseInt(sub2) >= 40)
         if (Integer.parseInt(sub3) >= 40)
               return false;
                          else
                                return true;
              else
                      return true;
    else
           return true;
    failedSubject---->ifWithoutElse-->failedSubject
    pass all subjects as input to the UDF.
    Regards
    Priyanka
    Edited by: priyanka.anagani on Sep 16, 2011 3:26 PM

  • Problem in  Graphical Mapping

    Hi all,
         i have a Graphical mapping logic here
    Source Structure:
    GS
    GP[1]
      F1-     QI
      SDQ
        F2-     2
    GP[2]
      F1-     QD
      SDQ
        F2-     3
    GP[3]
      F1-     PC
      CTP
        F2- 5.3
    GP[4]
      F1-     AI
      SDQ
        F2-     4
    GS
    Target structure:
          MT
         Material[1]
           Qty
         Material[2]
           Qty
         Material[3]
           Qty
         Material[4]
           Price
          MT
    Here the Material node  occurences is 0 to Unb.
    For values QI,QD and AI should be a seperate mapping ie) three nodes will be created.
    For values 'PC' seperate mapping ie. last node will be created only if F1 receives 'PC' beacause i need to implement the separate mapping logic for a value 'PC'.
    If i send the data sequence QI,QD,AI and PC  my mapping is working correctly.
          MT
         Material[1]
           Qty 2
         Material[2]
           Qty 3
         Material[3]
           Qty 4
         Material[4]
           Price 5.3
           MT
    But if i send the the data sequence QI,QD,PC and AI my mapping is not working properly for 'AI'. But for QI,QD and PC mapped correctly.
    Output:
          MT
         Material[1]
           Qty 2
         Material[2]
           Qty 3
         Material[4]
              Price 5.3
          MT
    Note: For Value 'AI' , target node Material[3] is completly ignored/not coming.
    We used createif function to create the target node in the target structure based on the value 'PC'.
    we think that once if mapping executed the value for 'PC', mapping for 'AI' is not executed i.e. it doesn't go back and execute the mapping for 'AI'.
    Can you please help me to solve this problem,
    Thanks and Regards
    Kamal

    Hi Kamal,
    I understand that your src is
    GS
    GP
    F1
    SDQ/CTP
    F2
    and depending on the value of F1 the target nodes has to be created.
    here, by using the createif, u can generate the nodes properly, but the problem arises when u have to get the corressponding values in the feild QTY of your target.
    in such a situation, writing a UDF would be better a better option.
    Thanks
    Hari.

  • XSLT using Java function from graphical mapping (RFClookup)

    Hi,
    I was wondering if it is possible to use the standard Java functions of the graphical mapping (RFCLookup, Datetrans, ...) or from my own UDF inside an xslt mapping. Does anyone have every tried this or is an example available ?
    Regards Bernd

    Hi Bernd,
    here you can find an example how to use RFC lookup from an XSLT Mapping:
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/05a3d62e-0a01-0010-14bc-adc8efd4ee14?quicklink=index&overridelayout=true
    Is this what you're looking for?
    Regards,
    Gábor

  • Graphical mapping qsn

    Hi All,
    I have a requirement in graphical mapping that i have a two nodes in source side both are identical. Each node has corresponding sub elements. Target side i have node with subelements. Based on certain conditions like if one condition satisfies i need to map first node and its corresponding sub elements in source side to target side node and its subelemts. If second condition satisfies then i need to map second node in source and its subelements to the target node and its sub elements. If both conditions not satisfy then target node should not be populated.
    Please let me know how to acheive this in graphical mapping.
    Thanks in advance.
    Regards,
    Rajesh

    otherwise go for udf which takes the input as your values and checks the condition in the udf and based on that value map the result to target node
    string empty=;
    if ( NODEAelement.equals("A"))
       return A;
    else if (NODEBelement.equals("B"))
       return B
    else
         return empty;
    I just provided the logic, you can procced with this...
    HTH
    Rajesh

Maybe you are looking for

  • Can i transfer my music from my iphone to my macbook

    isthere a way to transfer my music from my iphone to my macbook?

  • Best Practice for Initial Load

    Hello, what is the best way of doing the initial load? is there a best practice somwhere that tells you what should be imported first? I want to understand the order ex, 1. load Lookups, 2. Hierarchies, 3. taxonomy and attributes last the main table

  • Reducing video file/picture size

    I just upgraded to the 5 from the 4g and while the bump in quality is nice, a few MB a second when recording video is pretty staggering. I know it's suggested to convert the mov file to mp4 but is there any way to set the ipod to record in just 720 f

  • Why does my maximised app window appear a different size to the screen resolution?

    First: I'm a beginner with windows programming, fumbling my way through visual studio and C# (my background is C with console applications)... sorry if this is a naive question! Short story: When I create a window of the same size as the screen resol

  • How to make selection on JComboBox.

    Dear all, I want to make condition on basis of selection of JComboBox. Any one have code of such scenrio. Thanks in advance.