Access Message ID in graphical mapping

Hi,
I could not find a solution: How do I access the Message ID in the graphical mapping?
During Runtime, I need to get the Message ID in graphical mapping and map it to a field in the target rfc.
Can I do this either direct in mapping or is there a parameter in UDF?
thx
holger

search in sdn before posting...
http://wiki.sdn.sap.com/wiki/display/Snippets/UDFtoReadMessageIDofaPIMessage
Regards,
Raj

Similar Messages

  • Set adapter specific message attribute in graphical mapping

    Hi,
    I'm trying to set the mail reply to field in email messages sent by mail receiver adapter.
    To do this, I use the ASMA and developped my own UDF
    public String setMailFrom(String mailFrom, Container container) throws StreamTransformationException{
    DynamicConfiguration conf = (DynamicConfiguration) container
        .getTransformationParameters()
        .get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey key = DynamicConfigurationKey.create(
        "http://sap.com/xi/XI/System/Mail",
        "THeaderREPLY-TO");
    String valueOld = conf.get(key);
    if (valueOld != null) {
        String valueNew = mailFrom;
        conf.put(key, valueNew);
    return mailFrom;
    This works but I needed to asign the result of the udf to a node of my target message in order for the udf to be called.
    Is there a way to call a UDF without assigning the result to anything in the target message....
    Is there a better way to modify the ASMA than using a UDF in a mapping.
    Thanks.

    assign it to the root node of the target message.
    Also use exceptions in your code so that you can do independent testing.
    Additional ref:
    /people/shabarish.vijayakumar/blog/2009/03/26/dynamic-configuration-vs-variable-substitution--the-ultimate-battle-for-the-file-name

  • Fetching the business system name during graphical mapping

    Hi,
    After the receiver determination is done and in interface determination, while executing the interface mapping, i need the business system name for which the
    mapping is under progress. This i need during mapping.
    Also, i need the configuration scenario name during mapping.
    Is there any XI internal variable/system variables which hold these values so that using user defined function they can be accessed and used in graphical mapping ?
    In appreciate your input in this regard.
    Regards
    Ganesh

    Hi,
      For the configuration name you can map it with a constant and for the sender,receiver services and interfaces you nee to use the UDF as one mentioned below.
    Imports   com.racs.gpt.*;
    public String getMapValue(String a,String b,Container container)
    //String a denotes incoming data string |data1|data2|data3|...|dataN.
    //String b = lookupID.
    //container contains runtime parameters.
    AbstractTrace trace;
    String headerField;
    java.util.Map map;
    String  result;
    trace = container.getTrace();
    // get constant map
    map = container.getTransformationParameters();
    CrossReferenceAPI maprule1 = new CrossReferenceAPI();
    result  =   maprule1.getData(a,b,map);
    trace.addWarning("result = " + result);
    if (result.equals("$NULL$"))
    trace.addWarning("XREF Error.  Mapped data for " + a + " not found");
    ErrorHandler errHandler = new ErrorHandler();
    int lookupID = Integer.parseInt(b);
    errHandler.logSQLError(map, lookupID, a, "");
    result = "?";
    return result;
    Regards
    Madhu

  • Accessing SAP:HopList element in message header from JAVA-mapping

    Dear Experts,
    Is it possible to access the SAP:HopList element from message header in JAVA-mapping? 
    I need this to get the list off all receivers of current message (I have a ReceiverDetermination with two receivers, without any conditions, so both receivers are receiving each message and in InterfaceDetermination to one of the receivers I have a JAVA-mapping, in which I need to know the name of another receiver. And the SAP:HopList is containing this information).
    Or maybe where is some other solution?
    Best Regards,
    Artsiom Anichenka

    That's tricky, since the proper way of doing it would be through BPM.
    Anyway, if you expose your XI interface as a WebService (Soap sender cc) you could access it through Mapping Lookup (lookup works for RFC, DB and Soap lookups). Check https://help.sap.com/javadocs/NW04S/current/pi/index.html
    But be aware that Mapping Lookup API is not intended for inserts/updates (since it doesn't contain any transacational handling), just mere lookups (selects in tables), so I'm not sure it is the best approach for your case.
    Regards,
    Henrique.

  • Copy of source message to an element with graphical mapping

    Hi all,
    Is there a way to copy the complete source message of a mapping to an element of the destination message (with CDATA) with the graphical mapping (or UDF, but I want to avoid XSL) ?
    For example, from this message:
    <source>
      <element>test</element>
      <element2>test2</element2>
    </source>
    I expect the following result:
    <dest>
      <data><![CDATA[<source><element>test</element><element2>test2</element2></source>]]>
      </data>
    </dest>
    Thanks for your help.
    Greg

    Hi,
    Use this Simple Concept
    XML node into a string with graphical mapping
    /people/michal.krawczyk2/blog/2005/11/01/xi-xml-node-into-a-string-with-graphical-mapping
    Regards
    Seshagiri

  • Should we avoid Graphical mapping and stick with Java mapping?

    After developing mappings in XI for a month, I just don't see any good reasons to use Graphical mappings over Java mappings. Maybe some experienced users here can give me some valid reasons why we should choose Graphical mappings. Here is what I think:
    Disadvantages of Graphical mappings:
    1. No way to perform automated unit testings. This is probably the biggest reason I hate it. You can do some tests manually when you work in Integration Builder. But there is no way you can write some unit testing utilities to automate the task.
    2. Complexity. Even for some simple requirements, your Graphical mappings can become complicated and hard to understand. A lot of times, I find myself staring at several dozens of graphical nodes and try to understand what it does.
    3. Impossible to reuse. This is totally against the DRY (Don't repeat yourself) principle. For example, to generate messages for JDBC adapter, it is common to have two identical fields for primary keys: one in the access node and another in the key node. If you change the mapping logic in one, you have to remember to change the other.
    Advantage with Java mappings:
    1. Fully automated unit testing. You can create JUnit tests along with your Java mapping classes and use Maven or other build tools to perform automated unit testing.
    2. Your choice of XML parsing and binding. With Java mapping, you can choose any open source framework for XML parsing and binding. For example, with XMLBeans, I can convert XML input message to a Java object, transform to another Java object and write to output message. And each Java object is generated from its corresponding XML schema.
    3. Highly reusable. We can use fundamental object-oriented designs to create highly reusable mapping components.
    4. Better version control. Since the mappings are just Java classes, we can use CVS or SVN to track code changes.
    5. Better build tools. We can fully utilize build tools like Ant and Maven to automate the build, unit tests, or even generate documents and mapping web sites.
    So do you guys agree? Maybe I am still new to XI or I am missing some important things. But at this point, I just don't see why I should use Graphical mappings. Is there anyone developing XI interfaces completely with Java mappings?
    Thanks in advance for any comments!
    Kenny Cheang

    Hi Suraj,
    > Since its graphical the blocks will take space, but
    > there is always an adavntage of processing time.
    > Ebven though it may appear bigger, it will take less
    > time as compared with Java code (for the same
    > mapping).
    Could you explain more why the graphical mapping has better performance? I thought the graphical mapping is compiled into a Java class in the runtime anyway.
    > Yes thats there, but same goes with Java mapping too
    > right (if you haven't mentioned it as constants)
    I mainly think about inheritance. If I have to build 10 interfaces and they all have some common behavior, I can create a base interface class to encapsulate the common logic. But with graphical mapping, you have to duplicate them in each interface.
    > Disadvantages of Java mapping:
    > 1. Performance
    Same as above. I just don't see why Java has worse performance. I actually think Java should have better performance. You can optimize the code anyway you want. In some cases, you have to use queue functions in graphical mapping but it's not necessary in Java.
    > 2. All might not be well versed with Java Code(though
    > everyone may know basic java) .
    I am not asking everyone to abandon graphical mapping. I am just wondering which one is better when you have skills for both.
    > 3. Lot of standard functions are available in GM
    > which you can choose, but you have to remember the
    > exact code for those in Java mapping.
    You can create functions in Java too. All you have to do is to remember the function name.
    Kenny

  • Taking a container element into a graphical mapping

    Hi experts,
    I need to take a simple container string value from a container step into a graphical mapping in my BPM.
    Does anybody knows how to do that?
    Regards
    Gonzalo

    Hi,
    Check the discussions
    Accessing container variable of BPM in Message Mapping function
    Re: How to use Container Variable across Maps
    Thanks!

  • Graphical Mapping Vs XSLT mapping Vs Java Mapping Vs ABAP Mapping

    Hi Experts,
              I have a question regarding different message mapping options available in XI namely
    Graphical Mapping
    XSLT mapping
    Java Mapping
    ABAP Mapping
    Q1: Which amoung the above mappings is the best and why?
    Q2: On what cases Graphical, XSLT, Java and ABAP Mapping should be used?
    Q3: Is it true that graphical and XSLT mappings are converted into Java class internally?
    Kindly help!
    Thanks
    Gopal
    Message was edited by:
            gopalkrishna baliga

    Hi,
    There is no hard and fast rule for using the mapping techniques.
    Graphical Mapping is used for simple mapping cases. When, the logic for your mapping is simple and straight forward and it does not involve mult hiearchical mapping requirement. and context handling.
    Java and XSLT mapping are used when graphical mapping cannot help you.
    When the choice is between Java And XSLT, XSLT is simpler than java mapping and easier. But, it has its drawbacks.  XSLT can lead to a bad perfrormance if the Source XML is huge.
    Java Mapping uses 2 types of parsers. DOM and SAX. DOM is easier to use with lots of classes to help you create nodes and elements, but , DOM is very processor intensive.
    SAX parser is something that parses your XML one after the other, and so is not processor intensive. But, it is not exaclty easy to develop either.
    For further info on each of the mapping, refer to these links,
    Graphical Mapping,
    http://help.sap.com/saphelp_nw04/helpdata/en/6d/aadd3e6ecb1f39e10000000a114084/content.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/43/c4cdfc334824478090739c04c4a249/content.htm
    XSLT Mapping
    http://help.sap.com/saphelp_nw04/helpdata/en/73/f61eea1741453eb8f794e150067930/content.htm
    http://www.w3.org/TR/xslt20/
    Java Mapping
    http://help.sap.com/saphelp_nw04/helpdata/en/e2/e13fcd80fe47768df001a558ed10b6/content.htm
    DOM parser API
    http://java.sun.com/j2se/1.4.2/docs/api/org/w3c/dom/package-frame.html
    Also, check this thread for more info,
    Different types of Mapping in XI
    Am not sure about XSLT , but , yes graphical mapping is converted into java classes internally and these classes use SAX parsing as well.
    Regards,
    Bhavesh

  • How to use  Advance java function in graphical mapping in XI 2.0?

    Hi,
    currently I am using a simple java function to make an RFC call to R3 system.
    I want to avoid making connection for each lookup. Instead I want to make a single connection for whole message queue and get the corresponding values in some array or container object.
    please suggest a solution.
    I think this is possible using Advance java function, but I am not able to find any example on using Advance java function at help.sap.com.
    thaks in advance.

    Hi!!!
    I'm not sure if I understood you well.
    Do you want to preload some data into your structures in the memory and keep them there so you don't need to make a new connection during processing the whole message or every message?
    In my opinion you can cache some data during processing a message, but it's impossible to cache some data between processing messages.
    If you write your java mapping or you use graphical mapping (even with user-defined function), then you have a java class. The problem is that XI 2.0 reloads this class during processing every message, so even if you load some data from your data source into your structures in the memory, this data will be lost after reloading your mapping class.
    Regards,
    Andrzej Filusz

  • 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

  • Non-XML payload in graphical mapping

    Experts,
    I have a scenario where I need to trigger a graphical map which eventually populates an IDoc (custom) structure but the Idoc is not being populated with any of the source field.
    My source data is a flat file.
    1. I dont want the src file content to be transformed to XML.
    2. But need to trigger the map (graphical map) to populate the constant values in IDoc.
    However, even with a src message type with a single String type element (no sub-element), the mapping is failing giving XML parsing error.
    Question is:
    1. If it is possible to call a Graphical map without the XML conversion of the source? if yes.. how?
    2. Otherwise can I use Java / ABAP mapping? because since the input parameter for IF_MAPPING~EXECUTE - source is XSTRING type. So can I pass a flat file instead?
    - Shibaji

    HI Shibaji
    1. I dont want the src file content to be transformed to XML.
    2. But need to trigger the map (graphical map) to populate the constant values in IDoc.
    XI expects some XML if it is empty also it will work but you need to send dummy XML for triggering the mapping. You can pass just a blank field as source to trigger this.
    . If it is possible to call a Graphical map without the XML conversion of the source? if yes.. how?
    IE expects XML to process so you need to send some data to execute mapping. I don't think you can avoid XML conversion.
    Otherwise can I use Java / ABAP mapping? because since the input parameter for IF_MAPPING~EXECUTE - source is XSTRING type. So can I pass a flat file instead?
    Java or ABAP mapping also require some source and target to be formed and when you can meet the requirement for triggering the mapping from Graphical. It will complicate using Java/ABAP mapping
    I think if you have a source dummy message with single field with 0..1 occurrence then it should trigger your mapping without any error
    Thanks
    Gaurav

  • 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

    Hi,
       plz tell me about graphical-mapping.
    with warm regards.
    vikash

    Hi
    MAPPINGS STANDARD NODE FUNCTIONS:
    Remove Contexts:     We use it to remove Header Contexts from source side. If we donu2019t want header context to repeat in target structure, use this. It removes repeated header contexts and all the items come under the same contexts.
    Split by Value:     This is counter part of remove context. Use this to add the header context at the target side. Suppose if we wan to separate header contexts for every value of item at source use this.
    Copy Value: We can use this to copy the value of a position in the source structure and assign it to a target field for  frequently occurring source structure element. The value is copied each time the target field occurs in the target structure.
    Createif ():     Use it to create a tag in the target structure depending on the condition. Use it, if the nodes at the target side have to be created only after certain condition is true. If value type is u2018INTENALu2019 Internal request node is created and if value type is u2018EXTERNALu2019 external request node is created.
    Collapse Context:     We use it, if we have to create empty tags in target for every context change in the source.
    Exists: While mapping idoc structure to file structure, Lot of times we come across a scenario where the fields (occurrence=0) are not mandatory in the idoc. They are not populated in the source xml and they are required in the target xml (occurrence=1) which gives runtime exception that target element canu2019t be created.
    u can also refer the below links for further assitance
    /people/claus.wallacher/blog/2006/06/29/message-splitting-using-the-graphical-mapping-tool
    /people/claus.wallacher/blog/2006/04/17/replication-of-nodes-using-the-graphical-mapping-tool
    Different Node Functions in Graphical Mapping.
    : /people/sravya.talanki2/blog/2005/08/16/message-mapping-simplified--part-i
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/6658bd90-0201-0010-fbb6-afe25fb398d3
    cheers
    reward points if found useful

  • REG: Graphical Mapping

    Hi All,
                I have scenario where i need to split 1 input file( xml ) to n files based on one of the i/p values and post those n files in the  target directory. Is it possible in the graphical mapping and if not which mapping is preferable?
    Thanks in advance,
    Siva

    Hi Sivarama krishna,
                   we can use any mapping for splitting, basically we can do Splitting & Merging for the BPM Scenarios.
    We need to prefer Graphical mapping ,it is very easy for splitting the message. we need to design BPM
    BPM Steps are required for Splitting
    1) RECEIVE Step: it can receive the message from sender.
    2) TRANSFORMATION Step: it can split the message Or it can merge the messages.
    3) FORK Step: it can dispacthes the multiple senders and multiple receivers.
    4)RECEIVER DETERMINATION Step: Association of Outbound message interfaces and it can processed by single or multiple receivers.
    Note: Here we can take two Receiver Determination steps.One for Sender1 and antother for Sender2
    5) SEND Step: Take the two SENDER steps one for Send1 and Send2.
    Regards,
    Sateesh N.

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

Maybe you are looking for