Hello Friends,
Today I got a Chance to work in the following requirement hope this will help to you also.
Requirement is like that I have to Pick the file from multiple folders, encrypt them and put in the Encrypt folders under the same folder.
For that we have tried multiple options to do without ESR object but at not find any suitable options.
Like we tried to do this using Dynamic Configuration bean with variable substitution but problem with variable substitution is that it will automatic convert the special character like, : ;< >/ \ etc. with underscore(_). So it not work when you referring to the current directory in Variable substitution.
One other option that we didn’t try is Run OS command if you like that one you can try but this will not work when you talking about FTP/SFTP
Finally do this with JAVA mapping using...
I divided this blog with 2 Parts because the length of the blog:
Part1: JAVA mapping & ESR Part
Part2 : PGP configuration & ID part
.
Open NWDS->
File->New->Java Project
Give Name Like: Dynamic_Directory
Then Next
Click on Libraries then Add External Jar’s
Click on Libraries then Add External Jar’s
Select the Library files for mapping .
You can download the libaray files from server refer following blog for that:
Then Finish.
Now right click on src folder and select New file
Give Name Like Dynamic_Directory.java
And write the following code in this file
import com.sap.aii.mapping.api.*;
import java.io.*;
importjava.text.*;
import java.util.*;
publicclass Dynamic_Directory implementsStreamTransformation {
privateMapparam;
publicvoid setParameter(Map map1) {
this.param = map1;
}
publicvoid execute(InputStream inputstream, OutputStream outputstream) throws StreamTransformationException {
try {
AbstractTrace trace = null;
String directory=null;
trace = (AbstractTrace)param.get(StreamTransformationConstants.MAPPING_TRACE );
param.put(DynamicConfigurationKey.create("http://sap.com/xi/XI/Dynamic", StreamTransformationConstants.DYNAMIC_CONFIGURATION), "");
DynamicConfiguration conf = (DynamicConfiguration) param.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key1 = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File", "Directory");
String directory_name =conf.get(key1);
trace.addInfo("Directory is "+directory_name);
directory = directory_name+"/Ency";
trace.addInfo("Directory after update "+directory);
conf.put(key1, directory);
// b) Just copy input file to output file
byte[] b = newbyte[inputstream.available()];
inputstream.read(b);
outputstream.write(b);
} catch (Exception exception) {
exception.printStackTrace();
}
}}
Now Create Jar file for that Goto
File->Export->Java->jar File.
Select your project file you can also select java source file by click export java source file.
Following jar file will created on you Disk
It’s Time for ESR
In ESR we just need two objects
- Operation Mapping and
- Java Mapping
Create Name Space:
Create Imported Archive: IA_Dynamic_Directory
Import the Jar File
Create opetration Mapping with dummy interface name:
:OM_Dynamic_Directory
And refer the java mapping as below:
Regards
GB