Read messageID without Java Mapping

Hello,
is there a simple way to read the messageID and assign it to a target element without using a Java Mapping?
Background is that I want to use a messageID as correlationID in a BPM send step. Maybe by using a UDF.
Thank you for your help.

Hi Florian,
You can get this by using a simple udf. MessageId is the attribute in which you can get your message id. Please see this help for the udf:
http://help.sap.com/saphelp_nw04/helpdata/en/43/03612cdecc6e76e10000000a422035/content.htm
Here he is getting file name which is in FileName attribute. You can use MessageId where you have filename which will get you the message id.
Also whle testing in test tab of mapping there is paramers tab there put some id in message id. Then your test wil run else it will throw error or you may need to run end to end to work.
Regards,
---Satish

Similar Messages

  • Read Attachments using Java Mapping API

    Hello,
    after investigating the Java Mapping API a little deeper I found some very interesting Interfaces "InputAttachments" and "Attachments" which could do exactly what is required:
    Reading attachments and convert them into base64 code.
    As I am not an experienced Java Programmer howeve, I am note sure how to use those interfaces.
    For example there is a method defined in interface "InputAttachments":
    Attachment getAttachment(String contentID)
    How do I use it? If I use it in a way like "InputAttachments.getAttachment("abc");" then I get the error that it is not a static method. However how do I instantiate "InputAttachments".? As it is an interface I am not sure how to do this.
    Any idea how to handle these methods?

    Hi,
    I am working on the similar. I am able to attach txt files and csv files but have trouble attaching xcel and pdf's. Any input is appreciated. Thanks

  • Java mapping - for reading the binary file contents and changing filename

    Hi,
    I have already gone through the various bolgs and threads and have not been able to find a solution to my problem.
    One blog did give some idea but did not help- "JAAPPING", an alternate way of reading a CSV file
    I am not very good in java but have been trying some out recently to fulfill the interface requirements.
    I would really appreciate if you could help am I am giving below the detailed scenario below.
    Part 1- working fine - The incoming file looks like:
    :20:STMEMU096868DUBE
    :25:001180256210
    :28C:00371/00001
    :60F:C090617AED742136,92
    :61:0906300630CD34,27FINTCREDIT INTEREST
    26MAY2009 TO 25JUN2009
    :62F:C090630AED742171,19
    :64:C090630AED742171,19
    The file name as received is:TCDE.BLQSAM.SAEA2682.C0084025.A9G24T58.20090724195908
    This file without any conversion is placed on XI server dircetory folder.
    Part 2 - need to develop
    The file should now be renamed according to the incoming value in 2nd line - specifically the 12 digit value 001180256210 and placed on the R/3 dircetory folder.
    The new file name in the above example should be:
    AC_NO_001180256210_datetime
    The module for the above was created and the last time I checked it was working.
    However, when I wanted to do final testing in Dev and move the changes further, the module has seemed to have stopped working so I need an alternate solution fast.
    I was thinking of doing the Java mapping as I will be more in control as to what is going on thereby reducing the dependency.
    There is no need to create any target xml structure as the file as it is needs to be placed in the target folder with a new name.
    I can get the file name in UDF which I have already created but i am not usre if it working.
    Can you please help?
    Any help will be greatly appreciated.
    Regards,
    Archana
    +44-7867636863

    Hi Stephen
    The xml must be getting added in the below part of the code. It is coming from arg[0]
    You can put a check and get it removed.
    while ((len = arg0.read(buffer)) != -1) {
      arg1.write(buffer, 0, len);
    Regards
    Osman

  • Read Filename form Adapter-Specific Message Attributes in Java Mapping

    Hi,
    I have scenario File to Mail adapter. How can i read filename from Adapter-Specific Message Attributes
    in java mapping.
    Thank you and Best regards
    Fernand

    Hello Fernand,
    Are u using DOM or SAX parser?
    In any case just put the Dynamic config code in the execute function or the other option is to define it as a private functionand call it in the execute,My personal advice would be the former.
    Just put this code in ur java mapping
    As fellow sdn ers have mentioned there is no need of the container method,just initialise the set param method and use it in the dynamice config code as follows
    public class YourClass implements StreamTransformation
         private Map map;
    public void setParameter(Map param)
         map = param;
    public void execute(InputStream in, OutputStream out) throws StreamTransformationException
                   DynamicConfiguration conf =(DynamicConfiguration) map.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
                   DynamicConfigurationKey KEY_FILENAME =DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
    // read value
    File = conf.get(KEY_FILENAME);
    Now just call File in the mapping program,
    Should help u out 
    Regards,
    Tauseef

  • Without BPM:Call RFC using JCO in interface mapping using java mapping

    Hi all
    I have a very small scenario where REQUEST from the customer comes via Web Service all i have to do is to read the request using SOAP adapter and call an interface mapping(lets say the name is IM_TEST) inside which there is a JAVA MAPPING program written which will call an RFC in CRM using JCO.
    Now this was really simple and i cud test the Interface mapping successfully, but the problem is when loading the scenario in integration directory i have certain things to do
    1. to set the SENDER AGREEMENT which i did correctly
    2. set the RECEIVER DETERMINATION, INTERFACE DETERMINATION AND RECEIVER AGREEMENT now here i am stuck because there is no receiver in my case as the RFC is called inside the mapping only.
    can i call one more message mapping in IM_TEST which will write file onto the XI directory and then in RECEIVER DETERMINATION, INTERFACE DETERMINATION AND RECEIVER AGREEMENT i can mention the reciever as FTP.
    I tried it but i gives the following error
    Runtime exception occurred during execution of application mapping program com/sap/xi/tf/_MM_TEST_WRITE_FILE: com.sap.aii.utilxi.misc.api.BaseRuntimeException; Parsing an empty source. Root element expected!
    Please help me how to complete the scenario so that customer can run it end to end.
    <REMOVED BY MODERATOR>
    Edited by: Prateek Raj Srivastava on May 12, 2010 1:44 PM

    Stefen
    What do i do then...actually this is the project requirement. They want a very fast response from PI and thats why they wnt us to omit BPM and the Graphical mapping from the scenario.
    I am able to test the interface mapping which calls the the Java mapping inside which there is an RFC call, but i cannot implement it end - to - end as there is no receiver business system in this case. The only business system i have is the SOAP sender.
    I am really troubled now, please help me with a solution.
    Is there any other possible way through which the process can become very fast whic hcan meet their requirement.
    Regards
    Naina

  • Read DataType Definition in a Java Mapping,

    Hi,
    Is there a way to load a DataType Definition and parse the fields and attribute of this data type from java code?
    I am in a custom Adapter Module (PI 7.1) and need to dynamically load the definition of a DataType to do some FCC.
    I would like to do the FCC based on the DataType definition rather then on the Communication Channel's adapter module configuration.
    Thanks,
    Martin

    Hi Martin Lavoie,
    I understand, you are getting a flat file and want to convert it into XML or the other way, converting XML to flat file in SAP PI 7.1 using File channel.
    First, why you are going for Adapter module? (I think even you don't like it) It is resource intensive to develop, running in production system, maintain. If already there is an adapter module, leave it as it is. Consider using Java mapping over adapter module. Java mapping is relatively less resource intensive to develop, running in production system, maintain. Java mapping can do the payload conversion what you are planning to do in adapter module. If you write adapter module (generic), you have to use it in interfaces (all channels) where you need to transform the payload. If you write java mapping (generic), you can use it in operational mapping in all interfaces where you need payload transformation, along with other graphical mappings.
    Second, as of now, there is no way to access Data type XSD (which are declared in ESR) using SAP PI. In PI 7.1 EHp1 payload validation using XSD can be done, by placing XSD file in folder on PI server. From PI 7.3, validation is based on Data type (XSD) defined in ESR. First place, you are interested in payload transformation not payload validation. So there is no way you can access XSD in ESR from Adapter module dynamically. I guess you can upload XSD along with adapter module, but maintenance in not all easy.
    Finally, I donu2019t recommend adapter module for you requirement. Try using FCC. You may say whenever there is change in XSD (change in field lengths), you have to change FCC (edit the channel), and I donu2019t see better option than this. If you think FCC will not be sufficient for your requirement, and then go for Java mapping. Writing generic java mapping will be a good challenge.  Java mapping should be uploaded with XSD (or parameter file) for every interface and should be edited if there is a change in XSD.
    Regards,
    K_Raghu_Vamsee
    Edited by: Raghu Vamsee on Jan 7, 2011 12:28 AM

  • Error while doing java mapping

    Hi,
    I have written a java mapping code .But i have a small doubt when i compile it it is showing errors that package com.sap.aii.mapping.api does not exist.How can i solve the problem.Please help me in this issue.
    Thanks,
    Bhargav

    Hi ,
    check this thread, it may help you.
    https://forums.sdn.sap.com/click.jspa?searchID=3558715&messageID=3229273
    Regards,
    Ramesh.

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

  • Java mapping for XSD Validation

    Hello,
    I have developed a Java mapping to validate an XML based on XSD.
    I works fine and generates a message with error details.
    I would like to create a report with all errors encountered during this Validation and to stop this message from being sent to the partner.
    But this Java mapping stops at first error encountered and generates an error message with first error only even though document has more errors further.
    Can anyone please let me know if there is an option to log all errors without allowing the message to go through?
    Thanks.
    Best Regards,
    Shweta

    Yes, as abhishek mentioned when you validate the instance document (XML) using standard parsers then they validate based on the spec provided in XSD and they stop at the first error. The link given using dom parser via java code will also stop at the first error.
    If you really want to validate the entire instance document then you might have to create a custom validator class which does validation for each and every fields and store it in an object like Vector or List or Map object.  Then when you throw exception you can retrieve that Map object  in the catch block and read all the individual error messages and display in log. This requires additional effort. In this case you dont rely on parser validation. Completely custom based.
    Example:
    Vector errorList = new Vector();
    if the field name is  SSN and if you see any alpha characters you add error for that field in the errorList
    If(SSN.matches("[a-zA-Z]")){
        do nothing
    }else{
        errorList.add("The fieldName SSN contains other than alpha characters");
    Like that you have to add error string mesg in the errorList object and return the errorList at the end.

  • Java mapping runtime issue

    Hi,
    I have currently created a java mapping which unzips files and transforms plain text/falt files to xml according to a specific structure... So far so good. This stuff works perfectly when testing interface mapping in the repository. However at runtime it does not work, and this is where you clever guys come into the picture:-)
    It should be mentioned that the zip-file is dropped on a MQ-queue and picked up in XI and passed on to a BPM - the only thing the BPM does is to perform the java mapping and afterwards send one of the messages to R/3 and the other to CRM.
    The concrete error given at runtime in the PE is:
    Error handling for work item 000000718016
    Work item 000000718016: Object CL_SWF_XI_MSG_BROKER method CALL_TRANSFORMATION cannot be executed
    Parsing error before mapping: unexpected end-of-file (line 1, column 1)
    Hope somone can help me on this matter,
    Best regards,
    Daniel
    PS: In case it is of interest/use the java code used is this:
    package dk.post.xi.unzipAndConvert;
    import java.io.*;
    import java.util.Map;
    import java.util.HashMap;
    import java.util.zip.ZipEntry;
    import java.util.zip.ZipInputStream;
    import com.sap.aii.mapping.api.MappingTrace;
    import com.sap.aii.mapping.api.StreamTransformation;
    import com.sap.aii.mapping.api.StreamTransformationConstants;
    import com.sap.aii.mapping.api.StreamTransformationException;
    public class UnzipMain implements StreamTransformation {
         private MappingTrace mappingTrace = null;
         private Map param = null;
         private StringBuffer currentXmlRecord = new StringBuffer();
        private StringBuffer currentPlainRecord = new StringBuffer();
        private int[][] dataRanges = null;
        private char[] charsInCurrentRange = new char[650];
         private String[] xmlTagNames = null;
         /* (non-Javadoc)
    @see com.sap.aii.mapping.api.StreamTransformation#setParameter(java.util.Map)
    Method must be implemented when class is implementing streamTransformation
           public void setParameter(Map param) {
            this.param = param;
            if (param == null) {
               this.param = new HashMap();
    (non-Javadoc)
    @see com.sap.aii.mapping.api.StreamTransformation#execute(java.io.InputStream, java.io.OutputStream)
    Main function -- called by XI to start execution of java mapping
           public final void execute(InputStream in, OutputStream out)
                throws StreamTransformationException
                //if no input, then cancel program execution
                if (in == null) {
                     throw new RuntimeException("Something wrong with input zip file - is null");
                //input <> null. Begin upzip operation
                try {
                     //test is only relevant outside of XI
                     if (param != null) {
                          mappingTrace = (MappingTrace) param.get(StreamTransformationConstants.MAPPING_TRACE );
                  ZipInputStream zip = null;
                     try {
                          zip = new ZipInputStream(in);
                          ZipEntry ze = null;
                          out.write("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><ns0:Messages xmlns:ns0=\"http://sap.com/xi/XI/SplitAndMerge\">".getBytes());
                          while ((ze = zip.getNextEntry()) != null) {
                               writeDebugInfo("File: " + ze.getName() + " with compressed size: " + ze.getCompressedSize());
                               scrutinize(zip,(ZipEntry) ze, out);
                          out.write("</ns0:Messages>".getBytes());
                     finally {
                          if (zip != null)
                               zip.close();
                          out.flush();
                          out.close();
                } catch (Exception e) {
                     throw new RuntimeException(e + "\nSomething went wrong...");
           //Unzip flat files and convert to xml
           private void scrutinize(ZipInputStream inStream,ZipEntry zipEntry, OutputStream outstream) throws Exception {
                long start = System.currentTimeMillis();
              InputStreamReader inStreamReader = null;
              BufferedReader buffReader = null;
              byte[] xmlBytes = null;
              try {
                   inStreamReader = new InputStreamReader(inStream);
                   buffReader = new BufferedReader(inStreamReader);
                 boolean masterData = zipEntry.getName().equals("PD-01-STAMDATA.DAT");
                 boolean creditData = zipEntry.getName().equals("PD-02-KREDITVURDERING.DAT");
                 String currentLine = null;
                 if (masterData) {
                      writeDebugInfo("- Begin reading and converting every line of MasterData...");     //out-comment this outside of XI, or compilation will fail (functionality is only available in XI)
                      outstream.write("<ns0:Message1><ns1:masterData_MT xmlns:ns1=\"http://pdk/xi/kob/importDataToSap\">".getBytes());
                        while ((currentLine = buffReader.readLine()) != null) {
                           //convert one line of credit data plain into an xml record structure
                           makeXmlRecord(currentLine,true);
                           //Write record XML to XI's outputstream (appends)
                           xmlBytes = currentXmlRecord.toString().getBytes();
                           outstream.write(xmlBytes);
                      outstream.write("</ns1:masterData_MT></ns0:Message1>".getBytes());
                      writeDebugInfo("- Finished reading and converting every line of MasterData...");     //out-comment this outside of XI, or compilation will fail (functionality is only available in XI)
                 if (creditData) {
                      writeDebugInfo("- Begin reading and converting every line of CreditData...");
                      outstream.write("<ns0:Message2><ns1:creditData_MT xmlns:ns1=\"http://pdk/xi/kob/importDataToSap\">".getBytes());
                      while ((currentLine = buffReader.readLine()) != null) {
                           //convert one line of credit data plain into an xml record structure
                           makeXmlRecord(currentLine,false);
                           //Write record XML to XI's outputstream (appends)
                           xmlBytes = currentXmlRecord.toString().getBytes();
                           outstream.write(xmlBytes);
                      outstream.write("</ns1:creditData_MT></ns0:Message2>".getBytes());
                      writeDebugInfo("- Finished reading and converting every line of CreditData...");
              } finally {
                   long timeUsed = System.currentTimeMillis() - start;
                   writeDebugInfo(zipEntry.getName() + "  - Write took: " + timeUsed + " ms");
                   writeDebugInfo("Final statement entered...\n");
           //check for invalid xml chars (plus a few other strange chars) in a plain text record and if any are found update the ranges of so they correspond to the new length of a record
           private int[][] checkRange(String currentPlainLine, boolean isMasterData) {
                int counter = 0;
                int beginRange = 0;
                int endRange = 0;
                //populate array with proper data ranges/intervals according to how data is to be split
                dataRanges = isMasterData ? new int[][] {{0,2},{2,12},{12,44},{44,47},{47,50},{50,295},{295,298},{298,356},{356,426},{426,496},{496,499},{499,506},{506,510},{510,518},{518,540},{540,546},{546,552},{552,558},{558,564},{564,570},{570,576},{576,582},{582,588},{588,594},{594,604}} : new int[][] {{0,2},{2,12},{12,20},{20,23},{23,26},{26,29},{29,44}};
                //ensure stringbuffer is empty
                currentPlainRecord.delete(0,currentPlainRecord.length());
                //insert the current plain text line into stringbuffer
                currentPlainRecord.append(currentPlainLine);
              //loop through outer array (array of ranges)
              for (int i = 0; i <= (dataRanges.length-1); i++) {
                   beginRange = dataRanges<i>[0];
                   counter = beginRange;
                   endRange = dataRanges<i>[1];
                   //loop through stringbuffer, based on the value-pairs of ranges/intervals in array of arrays
                   while (counter < endRange) {
                        switch (currentPlainRecord.charAt(counter)) {
                             case '&':
                                  currentPlainRecord.insert(counter+1,"amp;");          //insert 'amp;' after '&', so that syntax conforms to xml syntax requirements (&amp;)
                                  counter += 5;                                                   //increment counter so that it continues after insertet characters
                                  updateRange(counter,4);                                        //update the array of ranges so that is corresponds to the new range
                                  break;
                             case '\'':
                                  currentPlainRecord.replace(counter,counter+1,"&");     //replace '\'' with '&'
                                  currentPlainRecord.insert(counter+1,"apos;");          //insert 'apos;' after '\'', so that syntax conforms to xml syntax requirements (&apos;)
                                  counter += 6;                                                   //increment counter so that it continues after insertet characters
                                  updateRange(counter,5);                                        //update the array of ranges so that is corresponds to the new range
                                  break;
                             case '"':
                                  currentPlainRecord.replace(counter,counter+1,"&");     //replace '"' with '&'
                                  currentPlainRecord.insert(counter+1,"quot;");          //insert 'quot;' after '"', so that syntax conforms to xml syntax requirements (&quot;)
                                  counter += 6;                                                   //increment counter so that it continues after insertet characters
                                  updateRange(counter,5);                                        //update the array of ranges so that is corresponds to the new range
                                  break;
                             case '<':
                                  currentPlainRecord.replace(counter,counter+1,"&");     //replace '<' with '&'
                                  currentPlainRecord.insert(counter+1,"lt;");               //insert 'lt;' after '&', so that syntax conforms to xml syntax requirements (&lt;)
                                  counter += 4;                                                   //increment counter so that it continues after insertet characters
                                  updateRange(counter,3);                                        //update the array of ranges so that is corresponds to the new range
                                  break;
                             case '>':
                                  currentPlainRecord.replace(counter,counter+1,"&");     //replace '>' with '&'
                                  currentPlainRecord.insert(counter+1,"gt;");               //insert 'gt;' after '&', so that syntax conforms to xml syntax requirements (&gt;)
                                  counter += 4;                                                   //increment counter so that it continues after insertet characters
                                  updateRange(counter,3);                                        //update the array of ranges so that is corresponds to the new range
                                  break;
                             case 0x7F:
                                  currentPlainRecord.replace(counter,counter+1," ");     //replace 0x7F with ' '
                                  writeDebugInfo("-- Corrected the character 0x7F ('') to ' '");
                                  counter++;
                                  break;
                             case '‘':
                                  currentPlainRecord.replace(counter,counter+1," ");     //replace 0x91 ('‘') with ' '
                                  writeDebugInfo("-- Corrected the character '‘' to ' '");
                                  counter++;
                                  break;
                             case '›':
                                  currentPlainRecord.replace(counter,counter+1," ");     //replace 0x9B ('›') with ' '
                                  writeDebugInfo("-- Corrected the character 0x9B to ' '");                              counter++;
                                  break;
                             case '†':
                                  currentPlainRecord.replace(counter,counter+1," ");     //replace '†' with ' '
                                  writeDebugInfo("-- Corrected the character '†' to ' '");
                                  counter++;
                                  break;
                             default :
                                  counter++;
                                  break;
                return dataRanges;
           //update array of ranges so that is corresponds to the new range
           private void updateRange(int currentRange, int updateRangeBy) {
              for (int k = currentRange; k < dataRanges.length; k++) {
                   if (k != currentRange) {     //never update begin interval for the current range - only for the remaining intervals
                             dataRanges[k][0] += updateRangeBy;
                   dataRanges[k][1] += updateRangeBy;     //always update end intervals
           //convert one flat record line to a xml record structure
         private void makeXmlRecord(String currentPlainLine,boolean isMasterData) {
              dataRanges = checkRange(currentPlainLine,isMasterData);
              //clear StringBuffer
              currentXmlRecord.delete(0,currentXmlRecord.length());
              //get the correct set of xml tags to be used when performing mapping between plain text and xml
              if (isMasterData) {
                   xmlTagNames = new String[] {"dum1","kob_no","dum2","corp_status","legal_form","dum3","pr_protec_code","dum4","uri","email","emp_no_grp_code","exact_no_emp","dum5","founding_date","dum6","main_industry_code","industry_code1","industry_code2","industry_code3","industry_code4","industry_code5","industry_code6","industry_code7","industry_code8","dum7"};
              } else {
                   xmlTagNames = new String[] {"dum1","kob_no","rating_date","rating_value","risc_grp_code","currency","max_credit"};
              //copy all chars in stringBuffer to the specified char[]
              currentPlainRecord.getChars(0,currentPlainRecord.length(),charsInCurrentRange,0);
              //populate XML record structure
              currentXmlRecord.append("<record>");
              for (int i = 0; i < xmlTagNames.length; i++) {
                   currentXmlRecord.append("<" + xmlTagNames<i> + ">");
                   currentXmlRecord.append(charsInCurrentRange,dataRanges<i>[0],(dataRanges<i>[1])-(dataRanges<i>[0]));
                   currentXmlRecord.append("</" + xmlTagNames<i> + ">");
              currentXmlRecord.append("</record>");
         //write debug information to correct "place"
         private void writeDebugInfo(String debugInfo) {
              if (mappingTrace == null) {
                   System.out.println("Debug: " + debugInfo);
              } else {
                   mappingTrace.addInfo("Debug: " + debugInfo);

    Hi Alex,
    Thanks for your reply. First of all I was wondering if I missed something somewhere in my generel understanding of XI and BPM's!? - I kind of sense some irony/sarkasm in beginning of your reply:-) As far as I know BPM should have no trouble receing non-xml (in my case zip-files)!?
    Anyways here goes:
    1. Yes, this is also my impression that is should be possible somehow (we do currently run sp14). However, I havent yet figured out how to do it in this case. When trying to create interface mapping between the three involved software components, I get a 'MESS_MULTI_MAP_IF_WRONG_SWCV' three times. I've searched around without being able to find any information on the error. I does seem, though, like the problem is that all objects aren't in the same software component!! But this approach is of course the prefered one...
    2. Well - you got me there. Kind of expected someone to point that out:-) This is of course something to be looked into also in order to "improve"/"enhance" the program - though it, as already pointed out, works perfectly as is.
    3. This part I have also thought about - though quickly moved away from the idea, but that is only due to lacking insight/knowhow on the subject. Interesting weblog you have written, something so I will investigate further when  time allows for it:-)
    Best regards,
    Daniel

  • Null exception in Java mapping

    Hi Experts,
    I am getting "Exception in thread "main" java.lang.NoClassDefFoundError: com/sap/aii/utilxi/misc/api/BaseRuntimeException
    in line Container container = new Context(new FunctionWrapper(0)); " when trying to execute the java mapping inside my interface mapping.
    I am using the following code iside my java class in NWDS when I get the above error:
    //Get the message Header
              Container container = new Context(new FunctionWrapper(0));
              map = container.getTransformationParameters();
              strMessageID =  (String) map.get("MessageId"); // Get Message GUID
              strMessageID = strMessageID.trim();
              strMessageDate =  (String) map.get("TimeSent");
              strMessageTime = (String) map.get("TimeSent"); // Get Time Sent
    I have also imported aii_mt_rt.jar, aii_map_api.jar, aii_utilxi_misc.jar  into my class.
    Please can you help me solve this problem.
    Thanks and regards,
    Brendon

    I solved the problem by using
    strMessageID = (String)param.get(     
    StreamTransformationConstants.MESSAGE_ID);

  • Java mapping - Setting the name of the file dinamically

    Hi all,
    Problem: I know how to set the name of the file in an Idoc to file interface if I'm using a message mapping, but not if I'm using a Java mapping.
    I'm using this code inside a user-defined function of the message mapping so that I can set the name of the file dinamically:
    public String GetFileName(String  inboundParameter,String IdocNumber,Container container){
    String filename;
    java.text.SimpleDateFormat dateformat = new java.text.SimpleDateFormat( "yyyyMMdd" );
    filename = "cikk_" + dateformat.format( new java.util.Date() ) "_" IdocNumber + ".txt";
    DynamicConfiguration conf = (DynamicConfiguration) container
           .getTransformationParameters()
           .get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey key = DynamicConfigurationKey.create( "http://sap.com/xi/XI/System/File", "FileName");
    conf.put(key, filename);
    return inboundParameter;
    (See also: /people/michal.krawczyk2/blog/2005/11/10/xi-the-same-filename-from-a-sender-to-a-receiver-file-adapter--sp14)
    But how can I do that if I'm using a Java mapping??
    I don't have the class Container there. How can I retrieve the DynamicConfiguration object without that class?
    Thank you very much.

    Thank you Jin,
    I knew that it had to be related with the Map object got in setParameter, but in this link:
    http://help.sap.com/saphelp_nw04/helpdata/en/0f/80243b4a66ae0ce10000000a11402f/frameset.htm
    you can't find the constant DYNAMIC_CONFIGURATION.
    I think it's not up to date.

  • JAVA Mapping: Convert the InputStream in  to OutputStream out

    Hi everybody,
    I'd like to code my first JAVA Mapping. For this I would just like to convert the InputStream in  to OutputStream out.
    This does not work:
    out = new FileOutputStream(new File(in));
    How has the code look like?
    Thanks, regards
    Mario

    Hi Mario.
    Do you want to convert input into output directly without doing any transformation?
    The way I've always used is to load the input document first:
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    factory.setNamespaceAware(true);
    DocumentBuilder builder = factory.newDocumentBuilder();
    Document doc = builder.parse(inputStream);
    After loading the document you can parse it's content with DOM API.
    Finally you create the transformed document and return it through outputstream:
    Document resultDoc = builder.newDocument();
    TransformerFactory tFactory = TransformerFactory.newInstance();
    Transformer transformer = tFactory.newTransformer();
    transformer.setOutputProperty(OutputKeys.INDENT, "yes");
    DOMSource source = new DOMSource(resultDoc);
    StreamResult result = new StreamResult(outputStream);
    transformer.transform(source, result);
    If  you want to convert the input to output you can use:
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    factory.setNamespaceAware(true);
    DocumentBuilder builder = factory.newDocumentBuilder();
    Document doc = builder.parse(inputStream);
    TransformerFactory tFactory = TransformerFactory.newInstance();
    Transformer transformer = tFactory.newTransformer();
    transformer.setOutputProperty(OutputKeys.INDENT, "yes");
    DOMSource source = new DOMSource(doc);
    StreamResult result = new StreamResult(outputStream);
    transformer.transform(source, result);
    At this point, I think you will have the input into the output.
    Regards,
    Gari.

  • Get dynamic filename in a Java Mapping (NOT UDF)

    Hi,
    we are using a Java Mapping step in XI (not UDF). We need to have access to the filename. In the File Adapter we set the message attributes and can see the filename value in the SXMB_MONI.
    We use the following code fragment to have access to the filename:
    Container container = new Context(new FunctionWrapper(0));
    DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
    String sourceFileName = conf.get(key);
    This doesn't work. We think the declaration of the container class is wrong. Does anybody have some information about using the dynamic attributes in Java Mappings?
    Thanks in advance
    Michael

    import com.sap.aii.mapping.api.*;
    import java.io.InputStream;
    import java.io.OutputStream;
    import java.util.HashMap;
    import java.util.Map;
    public class JavaProgram
        implements StreamTransformation
        public JavaProgram()
        public void setParameter(Map map)
            param = map;
            if(param == null)
                param = new HashMap();
        public void execute(InputStream inputstream, OutputStream outputstream)
            try
                DynamicConfiguration dynamicconfiguration = (DynamicConfiguration)param.get("DynamicConfiguration");
                DynamicConfigurationKey dynamicconfigurationkey = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File", "FileName");
                String s = dynamicconfiguration.get(dynamicconfigurationkey);
             //Your logic
            catch(Throwable throwable)
                throwable.printStackTrace();
        private Map param;

  • PI Java Mapping NullPointerException

    Hi Gurus,
    I'm having some troubles doing the mapping through java mapping in PI.
    I've done the java class in the SAP NWDS and imported it on PI through the ESR.
    Now i'm trying to test through the SOAP and i've found the following error in the "Communication Channel Monitor":
    500   Internal Server Error  SAP NetWeaver Application Server/Java AS 
    java.lang.NullPointerException: while trying to invoke the method com.sap.aii.af.sdk.xi.lang.Binary.getBytes() of a null object returned from com.sap.aii.af.sdk.xi.mo.xmb.XMBPayload.getContent()
    And the following error in the SXMB_MONI:
    <SAP:Category>XIServer</SAP:Category>
      <SAP:Code area="INTERNAL">CLIENT_SEND_FAILED</SAP:Code>
      <SAP:P1>500</SAP:P1>
      <SAP:P2>Internal Server Error</SAP:P2>
      <SAP:P3>(See attachment HTMLError for details)</SAP:P3>
      <SAP:P4 />
      <SAP:AdditionalText />
      <SAP:Stack>Error while sending by HTTP (error code: 500 , error text: Internal Server Error) (See attachment HTMLError for details)</SAP:Stack>
    I've developed the code below:
    public class PI_Mapping_IF extends AbstractTransformation {
      public void transform(TransformationInput in, TransformationOutput out)    throws StreamTransformationException  {  
      this.execute(in.getInputPayload().getInputStream(), out.getOutputPayload().getOutputStream()); 
      public void execute(InputStream in, OutputStream out)  throws StreamTransformationException { 
      try  
      // Inicio do java mapping
      getTrace().addInfo("JAVA Mapping Iniciado"); //Log para o PI/XI
      // Declarações referentes ao XML de entrada
      DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
      DocumentBuilder db = dbf.newDocumentBuilder();
      Document xml_in = db.parse(in);
      // Declarações referentes ao XML de saída
      Document xml_out = db.newDocument();
      TransformerFactory transformerFactory = TransformerFactory.newInstance();
      Transformer transformer = transformerFactory.newTransformer();
      // Remove o standalone
      xml_in.setXmlStandalone(true);
      // Declara a estrutura que a RFC irá receber
      Element root = xml_out.createElement("ns1:ZFSD_VMOI_UPLOAD_CF_PG");
      root.setAttribute("xmlns:ns1","urn:sap-com:document:sap:rfc:functions");
      xml_out.appendChild(root);
      Element i_cenario = xml_out.createElement("I_CENARIO");
      root.appendChild(i_cenario);
      Element t_input = xml_out.createElement("T_INPUT");
      root.appendChild(t_input);
      Element item = xml_out.createElement("ITEM");
      t_input.appendChild(item);
      Element STRING = xml_out.createElement("STRING");
      item.appendChild(STRING);
      Element t_return = xml_out.createElement("T_RETURN");
      root.appendChild(t_return);
      Element item_r = xml_out.createElement("ITEM");
      t_return.appendChild(item_r);
      Element message = xml_out.createElement("MESSAGE");
      item_r.appendChild(message);
      // Verifica se existe algum filho no nó
      NodeList nodos = xml_in.getChildNodes(); 
      if (nodos.item(0) != null)
      getTrace().addInfo("O nó(XML) possui filhos"); //Log para o PI/XI
      // Declaração de variáveis
      String ident = ""; // <Ident>
      String buyer = ""; // <BuyerLineItemNum>
      String result = ""; // <Ident>;<BuyerLineItemNum>;<Date>;<QuantityValue>
      // Inicia a extração das informações do XML
      try{
      // Recupera o nó ShipToParty
      NodeList nodeShip = xml_in.getElementsByTagName("ns0:ShipToParty");
      Node node = nodeShip.item(0);
      Element elemXML = (Element) node;
      try{
      NodeList nodeIdent = elemXML.getElementsByTagName("ns0:Ident");
      Element nameElement = (Element) nodeIdent.item(0);
      nodeIdent = nameElement.getChildNodes();
      // Recupera o valor da chave <Ident>
      ident = PI_Mapping_IF.VerifyNull(((Node) nodeIdent.item(0)).getNodeValue());
      }catch(Exception e){
      result += "0.0;";
      // Recupera o nó ListOfMaterialGroupedPlanningDetail
      NodeList nodeBuyer  = xml_in.getElementsByTagName("ns0:MaterialGroupedPlanningDetail");
      for (int i = 0; i < nodeBuyer.getLength(); i++) {
      node = nodeBuyer.item(i);
      elemXML = (Element) node;
      try{
      // Preenche a chave BuyerLineItemNum
      NodeList nodeBuyerLine = elemXML.getElementsByTagName("ns0:BuyerLineItemNum");
      Element elemBuyerLine = (Element) nodeBuyerLine.item(0);
      nodeBuyerLine = elemBuyerLine.getChildNodes();
      buyer = PI_Mapping_IF.VerifyNull(((Node) nodeBuyerLine.item(0)).getNodeValue());
      }catch(Exception e){
      buyer += "0;";
      result = ident+";"+buyer+";";
      Node nodeDt_Qnt = nodeBuyer.item(i);
      Element elemDt_Qnt = (Element)nodeDt_Qnt;
      NodeList nodeValores = elemDt_Qnt.getElementsByTagName("ns0:ScheduleDetail");
      for (int j = 0; j < nodeValores.getLength(); j++) {
      node = nodeValores.item(j);
      elemXML = (Element) node;
      try{
      // Preenche a chave Date
      NodeList modelExtra = elemXML.getElementsByTagName("ns0:Date");
      Element extraElement = (Element) modelExtra.item(0);
      modelExtra = extraElement.getChildNodes();
      result += PI_Mapping_IF.VerifyNull(((Node) modelExtra.item(0)).getNodeValue())+";";
      }catch(Exception e){
      result += "//;";
      try {
      // Preenche a chave QuantityValue
      NodeList modelURL = elemXML.getElementsByTagName("ns0:QuantityValue");
      Element urlElement = (Element) modelURL.item(0);
      modelURL = urlElement.getChildNodes();
      result += PI_Mapping_IF.VerifyNull(((Node) modelURL.item(0)).getNodeValue())+";";
      } catch (Exception e) {
      result += "0.0;";
      // Marca o final do registro
      result += "||";
      // Preenche os nós itens
      Text srcxml = xml_out.createTextNode(result);
      STRING.appendChild(srcxml);
      result = "";
      buyer = "";
      }catch(Exception e){
      // Remove o standalone
      xml_out.setXmlStandalone(true);
      // Preenche o Cenario
      Text cenario = xml_out.createTextNode("P&G");
      i_cenario.appendChild(cenario);
      // Preenche mensagem de retorno
      Text msgxml = xml_out.createTextNode("XML lido com sucesso!");
      message.appendChild(msgxml);
      // Escreve a saida do XML            
      transformer.transform(new DOMSource(xml_out), new StreamResult(out));
      getTrace().addInfo("Fim da execução do Java Mapping");
      } catch (ParserConfigurationException e) {
      getTrace().addWarning(e.getMessage());
      throw new StreamTransformationException("Can not create DocumentBuilder.", e);
      } catch (SAXException e) {
      e.printStackTrace();
      } catch (IOException e) {
      e.printStackTrace();
      } catch (TransformerConfigurationException e) {
      e.printStackTrace();
      } catch (TransformerException e) {
      e.printStackTrace();
    Am i doing anything wrong in the code? Where can this nullpointerexception be triggered?
    Thanks.

    These three xml are the same:
    <?xml version="1.0"?><a:xml xmlns:a="urn:123">root</a:xml>
    <?xml version="1.0"?><xml xmlns="urn:123">root</xml>
    <?xml version="1.0"?><ns0:xml xmlns:ns0="urn:123">root</ns0:xml>
    But your code will work only with last one, because it doesn't bound namespace to prefix ns0.

Maybe you are looking for

  • How can I use the Time Capsule in only 802.11b/g?

    I think I am getting interferences on my 5GHz phone from the time capsule, which I have running in 802.11n mode with b/g compatitibility. I assume if the Time Capsule was running in 802.11b/g mode I would not get the intereferences? The Airport utili

  • Master/Master Matrix Report

    May I know is it possible to create a Master/Master matrix report? The example given in the Reports Documentation shows Master/Master Tabular reports only and I have been attempting to create a Matrix one but without success. Thank You. Cheers, Tan

  • VAT /CST% manually in the sales order,not getting copied to the Invoice

    Dear Friends, If I change the VAT /CST% manually in the sales order,its not getting copied to the Invoice Thanks Ivy

  • How to create a managed metadata column that allows terms from several term sets or groups ?

    My requirement is to create a a Managed Metadata column that allows terms that come from several term sets (or possibly from one group containing several term sets). Would it be possible ? Thanks.

  • HELP!!! NEED MY MODEL #

    I PURCHASED THIS SECOND HAND COMPUTER SYSTEM AND IT SEEMS THAT THE LABELS OF MODEL/SERIAL NUMBERS ARE REMOVED, I WAS NOT AWARE OF IT AT THE TIME OF PURCHASE.  I HAVE CONTACTED HP TO NO AVAIL, FIRST THING THEY WANT IS WHAT I DON'T HAVE, THEY TELL ME W