Skip to Content
0

Java Mapping

Apr 05, 2017 at 06:11 AM

69

avatar image

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)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

6 Answers

Best Answer
Evgeniy Kolmakov Apr 06, 2017 at 10:50 AM
0

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.

Share
10 |10000 characters needed characters left characters exceeded
Andrzej Filusz Apr 05, 2017 at 07:22 AM
1

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

Share
10 |10000 characters needed characters left characters exceeded
Renjith M Chandran Apr 06, 2017 at 08:06 AM
0
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();
       }
   }
}
Share
10 |10000 characters needed characters left characters exceeded
Renjith M Chandran Apr 06, 2017 at 08:08 AM
0

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

Share
10 |10000 characters needed characters left characters exceeded
Muni M Apr 06, 2017 at 09:04 AM
0

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


mapping.jpg (277.1 kB)
Share
10 |10000 characters needed characters left characters exceeded
Evgeniy Kolmakov Apr 06, 2017 at 10:45 AM
0

Hi Renjith!

You should implement transform() method in your class.

Regards, Evgeniy.

Share
10 |10000 characters needed characters left characters exceeded