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

Similar Messages

  • UDF  for this mapping rule

    Hi Friends,
         I have one difficult issue which have one mapping rule to write user defined function. I am sending mapping rule Please give me java coding to create udf for this mapping rule which is following below:
    CRFT.COSTR = M_ORD_01 and
    CRFT.CRID = CRHE.CRID and
    CRFV.FTNO = CRFT.FTNO and
    CRFV.ATNAM = ZPPI_ORDER_SCHED_EN_DATE
    And
    CRFT.COSTR = M_ORD_01 and
    CRFT.CRID = CRHE.CRID and
    CRFV.FTNO = CRFT.FTNO and
    CRFV.ATNAM = ZPPI_ORDER_SCHED_EN_TIME
    From ATWRT of ZPPI_ORDER_SCHED_EN DATE+ ATWRT of ZPPIORDER_SCHED_EN_TIME
    In format yyyy-MM-ddTHH:mm:ss
    using this mapping rule, ATWART field can map with target field "End Time" i think.
    Actually source field is CALCULATE but this field is not in Source structure
    target field is "End Time"  this field is in Target Structure.
    I will wait for ur response
    Thanks adn regards
    Sai

    Hi Jagadish,
    This RFC is CONTROL_RECIPE_DOWNLOAD
    in this RFC, i want to map ATWRT field to Target field "End Time" with mapping rule which i had already given.
    In Graphical mapping, i am doing . but i can not get it because mapping condition is difficult. if you have any idea in graphical mapping give me early
    before that i have to give explantion about this is  date value and time value passed through this ATWRT field as different records.
    i am doing as a condition ie  first i have taken date condition. from that condition, first two fields  CRFT.COSTER and M_ORD_01 has given to "equals" funtion     like that have done remaining fileds then the output of those "equals" functions given to "and" functions finally i get one output of "and" function.  while sending DATE values from RFC this output  of "and " function.
    Like this, for Time condtion i have done mapping same way and giving a TIME values from RFC as Second record then output of this "and" function while sending second record with time value.
    here mainly i am getting problem is .....
    here i am taking source field ATWRT( in this field i am sending date format adn time format as different records) with the outputs of the mapping conditons as input vaules of another function. i dont have any idea for another function why because is first date record should be wait until the time record comes in this function.after then both vaules should concat .
    now here whenever you send date value through this field ATWRT as first record and after satishfy the date condition form mapping rule,  The date value of ATWRT should go to input of concat function. next i will send time value like date value through ATWRT as second record . It should go to another input of concat function. Then here both date value and time value concat with T  and should be come output in the format  yyyy-MM-ddTHH:mm:ss and this will go to Target field "End Time".
    I will be wait for ur possitive reply
    thanks for giving response
    Thanks adn regards
    sai

  • 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

  • Help needed for Graphical mapping.Tag only once produces

    Hello experts,
    I have a problem in my graphical mapping.This is the example:
    from each segment A in IDOC has to be made Tag A or Tag B in output XML.
    Segment A has a field USER_STATUS and if it is X than Tag B has to be made otherwise Tag A.
    Segment A is 0..9999999. occurence
    Tag A  0..unbounded
    Tag B 0..unbounded.
    I made a mapping
    mapping for Tag A:
    USER_STATUS -> mapwith default(empty)->length->EqualsA (with Constant =0)-> createif->Tag A
    for Tag B as following:
    USER_STATUS -> mapwith default(empty)->EqualsS (with Constant =X)-> createif->Tag B
    The problem is that in output XML, I have only one Tag A or B (depending on field USER_STATUS in first occurence of the segment) while in inbound IDOC 5 segments are with different value of the field: USER_STATUS.
    Does anyone idea to solve this problem!
    Thank you very much for your effort.
    King regards,
    Danijela Zivanovic

    HI,
    CAn you try this way,
    Use Maping Node UseOneAsMany for Tag B
    and pass 3 inputs as
    Constant[]----
    >
    USER_STATUS -> mapwith default(empty)->EqualsS (with Constant =X)----
    >
    USER_STATUS -> mapwith default(empty)->EqualsS (with Constant =X)----
    >
    Same way try for Tag A also.
    Thanks
    Swarup

  • Java code for Graphical Mapping

    Hi,
    I am new to the XI world.I read that when we do graphical mapping a java code is generated in the background.
    Can any one tell me how to access that code ?
    Any help would be appreciated.
    Thnx.

    hi,
    you can find it in the XI server folders
    have a look at my previous response:
    Re: Access to Java mapping code?
    Regards,
    michal
    <a href="/people/michal.krawczyk2/blog/2005/06/28/xipi-faq-frequently-asked-questions"><b>XI / PI FAQ - Frequently Asked Questions</b></a>

  • 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

  • Global java-library for graphical mapping?

    we hava a global .jar-java library we want to use in all software components (and not import them into all software comonents)
    in xi2.0 there was a procedure to update library.txt and reference.txt:
    reference library:XILookup library:jco
    (The XILookup class needs access to JCO)
    reference IntegrationServices library:XILookup
    (make XILookup visible to mapping runtime)
    reference ExchangeRepository library:XILookup
    (make XILookup visible to design-time)
    now in xi 3.0 we deployed the library as a j2ee library using nwds
    but how can i create the referenze to the exchangerepository and mapping runtime?
    thanks for any help
    joerg

    Hello
    I have the same problem. I want deploy also a jar library on xi system and after use this library for a messages mapping.
    I won't use the external Archives, i must use the library for different names spaces.
    I use for the deploying a library module in the NetWeaver developer studio. The deploying is working. But the mapping never found the jar library.
    Thanks for help.
    Regards Tom

  • UDF for sorting date

    Hi Guys,
    I am doing scenario File to Idoc, i have to sort date in acending order, the date format will be in either 22.10.2007 or 22/10/2007 . can any one send UDF for this.
    Regards,
    venu gopal

    Hi Venu
    You can execute this without UDF. Use " Transform" function in the Date functions.
    When you are using the UDF....you keep the strucure as "yyyMMddhhmmss" for that clickon Trnasform function and there you can see ShowAdvancedProperties...there u can find the format of the source which you are expecting and also change the strucutre of you target expected format.
    You please try this and check the mapping it will get execute.
    Use Standard Date Function DATATRANS. It have the property for format and input is the source date field. It will convert the date format to required specified format which you menstion in the DARTATRANS function
    for UDF
    Re: UDF  for this mapping rule
    Re: Problem in UDF please Help?
    Thanks!

  • 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.

  • 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

  • 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

  • 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>);

  • 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

  • Use RFC Lookup in Graphical Mapping for Database Update

    Hello,
    I am wondering whether the RFC Lookup function in graphical mapping provides the same functionality as a general RFC function call.
    In detail I would like to update a database table using a RFC which just takes some input parameters but does not use any output parameters. Would this work too as the name "lookup" implies that it might just be possible to read something?

    HI,
    Refer these links:
    RFC Lookup by michal
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/a03e7b02-eea4-2910-089f-8214c6d1b439
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/8e7daa90-0201-0010-9499-cd347ffbbf72
    http://help.sap.com/saphelp_nw04/helpdata/en/cf/406642ea59c753e10000000a1550b0/content.htm
    DB lookup - /people/siva.maranani/blog/2005/08/23/lookup146s-in-xi-made-simpler
    Regards,
    Nithiyanandam

Maybe you are looking for

  • Issues in using the GLMAST01 idoc type

    Hi there,            I am using the LSMW to upload the GL master records using the IDOC method. I am using the IDoc type as GLMAST01. I am passing the following data. I am not able to post the IDoc with following data. Please tell me, is there anythi

  • Complaint re: Customer Care

    I purchased a V560 with Windows 7 64 bit in March of 2011. Shortly after purchasing the laptop, I noticed that there was a screw cover missing on the inside of the lid so that the screw is exposed. It is a minor cosmetic issue, but I decided to call

  • IU Elim. "No data found for processing using current selection conditions""

    Dear Experts, While Executing task of Interunit elimination  in Consolidation Montior  I am getting Message "No data found for processing using current selection conditions" Ex. is A) In Unit X GL (399999) Account     Dr. 65000 (Customer Recon. Ac.) 

  • Parameter for report title

    Hello, I have a report with many pages and I need the same title on every page. To do so, I would like to use a parameter which could be defined by the user through a VBS inputbox and then reused on each page. I tried something with scalar parameters

  • Hiding wireless messages on boot [Solved]

    After clearing the systemd startup sequence on my laptop, the system displays several messages regarding what I can only assume to be the kernel's wireless drivers, such as [ <some value, perhaps a timestamp?>] ieee80211 phy0: brcmsmac: brcms_ops_bss