Skip to Content

Java Mapping

Dear Experts,

I am doing a simple file to file Scenario using Java mapping . In operation Mapping i am getting the error in Snap Shot. Please guide me if i am in wrong path.

Thanks in Advance.

Renjtihcapture.jpg

capture.jpg (31.4 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

6 Answers

  • Best Answer
    Apr 06, 2017 at 10:50 AM

    Also I can't catch the idea to implement static methods in transformation class. The better way is to put these methods in separate class and use it further in your mapping classes.

    Regards, Evgeniy.

    Add comment
    10|10000 characters needed characters exceeded

  • Apr 05, 2017 at 07:22 AM

    Hi Renjtih,

    Look at the error message please. Are you sure that your java mapping class implements StreamTransformation interface or extends AbstractTransformation class?

    Regards,

    Andrzej

    Add comment
    10|10000 characters needed characters exceeded

  • Apr 06, 2017 at 08:06 AM
    import java.io.*;
    import java.security.MessageDigest;
    import com.sap.aii.mapping.api.AbstractTransformation;
    import java.io.FileReader;
    import java.io.IOException;
    public class MD5Checksum extends  AbstractTransformation {
       public static byte[] createChecksum(String filename) throws Exception {
           InputStream fis =  new FileInputStream(filename);
           byte[] buffer = new byte[1024];
           MessageDigest complete = MessageDigest.getInstance("MD5");
           int numRead;
           do {
               numRead = fis.read(buffer);
               if (numRead > 0) {
                   complete.update(buffer, 0, numRead);
               }
           } while (numRead != -1);
           fis.close();
           return complete.digest();
       }
       public static String getMD5Checksum(String filename) throws Exception {
           byte[] b = createChecksum(filename);
           String result = "";
           for (int i=0; i < b.length; i++) {
               result += Integer.toString( ( b[i] & 0xff ) + 0x100, 16).substring( 1 );
           }
           return result;
       }
       public static void main(String args[]) {
           try {
    
           /********my code*********/
    
               String md5=getMD5Checksum("Path");
    
               BufferedReader reader = new BufferedReader(new FileReader("path "));
                   /*int character;
                   while ((character = reader.read()) != -1) {
                       System.out.print((char) character);
                   }
                   reader.close();*/
               String line;
               while((line=reader.readLine()) != null){
              if(line.contains("checksum")){
             line=line.replace("\"\"", "\""+md5+"\"");
              }
              System.out.println(line);
               }
           }
           catch (Exception e) {
               e.printStackTrace();
           }
       }
    }
    Add comment
    10|10000 characters needed characters exceeded

  • Apr 06, 2017 at 08:08 AM

    Hai Andrzej,

    Please refer the java mapping i am using and correct me if it is wrong as per the error snap shot.

    Thanks in Advance,

    Renjith

    Add comment
    10|10000 characters needed characters exceeded

  • Apr 06, 2017 at 09:04 AM

    I did not go through detailed. But I can see the issue with overriding.

    Did you override the method transform()?

    Please check

    https://help.sap.com/doc/2fmapping.jpg39047ed6b141cb83658041d2d4e029/7.5.7/en-US/PI/index.html

    Add comment
    10|10000 characters needed characters exceeded

  • Apr 06, 2017 at 10:45 AM

    Hi Renjith!

    You should implement transform() method in your class.

    Regards, Evgeniy.

    Add comment
    10|10000 characters needed characters exceeded