UDF in mesage mapping.

Hi
I am trying to create a message mapping where the input and output messages are as follows.
Input:
<MT_Request >(1..1)
   <ItemData>(1..1)
      <Item>(0..unbounded)
         <Invoice/>(1..1)
         <TaxCode/>(1..1)
      </Item>
   </ItemData>
   <TaxData>(0..1)
      <Tax>(0..unbounded)
         <TaxCode/>(1..1)
         <TaxIndetifier/>(1..1)
         <TaxAmt/>(1..1)
      </Tax>
   </TaxData>
</MT_Request>
Output:
<MT_Response>(1..1)
   <Response>(1..1)
      <ResponseData>(0..unbounded)
         <Invoice/>(1..1)
         <ServiceTax/>(1..1)
       </ResponseData>
   </Response>
</MT_Response>
The mapping as follows
Invoice --> Invoice
If {(TaxCode in Item = TaxCode in TaxData) and
TaxIndetifier = constant value like A}
ServiceTax = TaxAmt
Here the Item Tag in request message is repeated as well as Tax Tag. So for each TaxCode under Item Tag, the programme should go and check all theTaxTag for the same Taxcode. If the values are same, then Taxfinder check will be done and then the TaxAmt value will be put in ServiceTax.Is there any way to do this by UDF???
Also please tell me when we are taking a parent node with child nodes (like TAX) and giving that as an argument to the UDF as a string array, what values will come inside the array???
regards,
Biranchi

Hi Biranchi,
You can try like this
input to UDF will be Item tag,Tax Code, Tax Data , Tax_Identifier and Tax_amt and create three arguments in UDF in context mode with same names,the UDF will look like
for(int i=0;i<item.length;i++)
  if( Tax_Code<i>.equals(Tax_Data<i>) && Tax_Identifier<i>.equals("A"))
result.addValue(""+Tax_amt<i>);
Correct if there is any context problem.Target will be Service Tax.
Thanks!

Similar Messages

  • Run time exception while checking dynamic file name in mesage mapping

    Hi Experts,
    In my file to idoc scenario i need to know the file name dynamicalyy as i require this file name during mesage mapping.
    for that i have created UDF with the following code.
    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);
    but when i am testing this code in mesage mapping in IR i am getting runtime exception.why its giving so ?
    RuntimeException in Message-Mapping transformation: Runtime exception during processing target field mapping /ns0:Messages/ns0:Message1/ORDERS05/IDOC/EDI_DC40/MANDT. The message is: Exception:http://java.lang.NullPointerException in class com.sap.xi.tf._MM_EDI_HospitalsToORDERS05_ method filename$com.sap.aii.mappingtool.tf3.rt.Context@545f545f
    Can we test this in message mapping itself ?
    Best Regards,
    Rohit

    One more question - I hope you didn't forget return statement in your java code.
    this worx 4 sure:
    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;

  • UDF in XSLT Mapping.

    Hi,
    Can I use a UDF in XSLT mapping. If yes, can anyone please guide me in the issue. When I searched the forum there is a discussion related to the attachment of Java classes to the XSLT mapping. Does this replace the use of a UDF ? Instead, can we opt for a Java Mapping. Which will be of more help? Kindly suggest your opinions with relevant explanation.  Thank you very much for your time.
    Krishna.

    Hi krishna,
    check this links
    http://www.topxml.com/rbnews/XML/re-55178_Remove-empty-nodes-in-BizTalk-by-using-XSLT.aspx
    http://www.topxml.com/rbnews/XML/re-55176_XSLT-performance-when-mapping-large-documents-in-BizTalk.aspx
    http://help.sap.com/saphelp_nw04/helpdata/en/6b/4493404f673028e10000000a1550b0/frameset.htm
    XI: New features in SP14
    http://help.sap.com/saphelp_nw2004s/helpdata/en/d9/718e40496f6f1de10000000a1550b0/content.htm
    How to parse "XX/YY/ZZ;AA/BB/CC;11/22/33" in message mapping.
    What is UDF
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/be05e290-0201-0010-e997-b6e55f9548dd
    Java Mapping (Part I)
    Difference in using java,xslt,message mapping
    Java Mapping (Part I)
    Java Mapping (Part II)
    Java Mapping (Part III)
    Testing and Debugging Java Mapping in Developer Studio
    Using JAXP to both parse and emit XML in XI Java mapping programs
    "JAVA MAPPING", an alternate way of reading a CSV file
    Think objects when creating Java mappings
    Regards
    srinivas

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

  • How do i test split by value functionality in mesage mapping with multiple

    how do i test split by value functionality in mesage mapping with multiple values ?
    regards,
    venkat

    repeat your source node. in mapping editor you can view queues by right clicking to mapped element.. selecting Display Queues option.. this will show u your values .
    You can also select this Display Queue option for splitByValue option
    for example
    source--->splitByValue>target
    Try viewing your queues to each this step... for splitByValue in display Queue you will see context inserted(grey colour) accodingly

  • 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

  • UDF and Category mapping table name?

    Hi
    I have created UDF on the screen and categorized these UDF for the user convenient. Now i would like to know the table where the system store this mapping.
    Here i am attaching the mapping screen which table i needed. Kindly refer the screen shot it would help to understand my requirement.
    Regards
      Ashish

    Hi Ashish,
    Please check CUFD table.
    Please also check below link.
    SAP Business One 9 - Quick Copy Categories and Copy Methods
    Hope this help
    Regards::::
    Atul Chakraborty

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

  • 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

  • Regarding UDF's in Mapping

    Hi,
    I want to Know some Situations where a Developer is going to Use the UDF for the Requirement in the Mapping????
    I want Some Possible Casess and the COrresponding UDF's also..
    Regards
    Suman

    Hi,
    For business requirement and business logic we have to write UDFs.check some exaples.
    UDF
    http://flickr.com/photos/8764045@N06/
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/be05e290-0201-0010-e997-b6e55f9548dd
    Example 1
    http://www.flickr.com/photo_zoom.gne?id=544183191&size=o
    http://www.flickr.com/photo_zoom.gne?id=544183195&size=o
    http://www.flickr.com/photo_zoom.gne?id=544183225&size=o
    http://www.flickr.com/photo_zoom.gne?id=544183233&size=o
    Example 2
    http://www.flickr.com/photo_zoom.gne?id=545133789&size=o
    http://www.flickr.com/photo_zoom.gne?id=545133791&size=o
    http://www.flickr.com/photo_zoom.gne?id=545133801&size=o
    http://www.flickr.com/photo_zoom.gne?id=545133807&size=o
    http://www.flickr.com/photo_zoom.gne?id=545133811&size=o
    http://www.flickr.com/photo_zoom.gne?id=545138911&size=o
    http://www.flickr.com/photo_zoom.gne?id=545138913&size=o
    http://www.flickr.com/photo_zoom.gne?id=545138915&size=o
    http://www.flickr.com/photo_zoom.gne?id=545138917&size=o
    http://www.flickr.com/photo_zoom.gne?id=545138947&size=o
    http://www.flickr.com/photo_zoom.gne?id=545138951&size=o
    http://www.flickr.com/photo_zoom.gne?id=545005958&size=o
    Example 3
    http://www.flickr.com/photo_zoom.gne?id=549186611&size=o
    http://www.flickr.com/photo_zoom.gne?id=549186651&size=o
    http://java.sun.com/j2se/1.5.0/docs/api/
    /people/krishna.moorthyp/blog/2006/07/29/documentation-html-editor-in-xi
    /people/sap.user72/blog/2006/02/06/xi-mapping-tool-exports
    http://help.sap.com/saphelp_nw04/helpdata/en/43/c4cdfc334824478090739c04c4a249/content.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/22/e127f28b572243b4324879c6bf05a0/content.htm
    /people/stefan.grube/blog/2005/12/30/test-user-defined-functions-for-the-xi-graphical-mapping-tool-in-developer-studio
    http://help.sap.com/bp_bpmv130/Documentation/Operation/MappingXI30.pdf
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/d046c490-0201-0010-84b6-9df523cbca31
    Regards,
    Phani
    Reward points if Helpful

  • 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

  • File to IDOC: mesage mapping

    Hi!
    I am implementing File to Idoc scenario.
    I use in file a element "createdate". The same one does exist on Idoc side and hase type "xsd:string".
    Which type should have the element in data type?
    a) xsd:string
    b) xsd: date
    c) it does no matter
    Thank you!

    Hi!
    Thank you!
    Could you please explain why the option within message mapping "map the same structure..." is inactive in my case?
    Is that a bug?
    I am on SAP NetWeaver 7.0 SP 14 .
    Thank you!

  • UDF req for mapping

    Scenario IDoc to File:
    For one filed I get different values. As many as 20 values from sap and for that value I will have to set an error code. Each Number from SAP will have an error code respectively.
    Thanks
    Kiran

    Hi Kiran
    Yes, you are right we will need to import in archive folder as JAR
    Steps>
    >First Make a java class containing your method or any number of other method
    like
    public class TextOne {
         public static void main(String[] args) {
         public String yourMethodName(String parameter){
            String result = "your value"; // as for example
              return result;
    >step continue
    >go to command prompt
    > go to directory(package name like in above code) where u r java file is there
    >make jar by following command
    >jar -cvf nameofjarfile.jar yourjavafilename.java
    >nameofjarfile.jar will we created
    >go to archive folder in IR
    >import that jar file
    >go to UDF
    >write import packagename
    >now u can access function like class's object.method name
    Reward points if helpful

Maybe you are looking for

  • How to move iTunes from Mac to PC (via external drive)

    I would like to copy my iTunes library from my home iMac to a PC laptop (I know, don't ask, it's a work tool) - without clogging that work PC with all the music data, so I am thinking external drive. Here are my questions: first, how do I need to for

  • How do I get iTunes to recognize my iPod without losing all of my music?

    I keep all of my music on an external harddrive. My computer crashed and once I fixed everything and reloaded all of the software, I tried connecting my iPod. All of my music is on the external harddrive and on my iPod, but I can't get iTunes to sync

  • Dreamweaver CS4 critical installation error

    I have upgraded to a new PC (running windows 8.1) and when I run the Dreamweaver CS4 installer I get "Critical errors were found in setup".  I don't have any other CS4 products on my PC. What should I do?

  • Reading RH_STRUC_GET bottom to top

    Does anybody know if it is possible to read te orginization structure from the lowest level to the highest level, so starting at Pa0001-orgeh to the highest level in the tree??

  • Adding a Button a Servlet that calls a JSP

    How would one put a Button in a Servlet that directs to a JSP. ... I have created a servlet that displays records from a database, but I would like to add a button that returns to a JSP page. I thought something like this would help... out.println("<