Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
gagandeep_batra
Active Contributor

Hello Friends,

Today I got a Chance to learn in the following requirement hope this will help to you also.

Requirement is like that we 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:

http://scn.sap.com/community/pi-and-soa-middleware/blog/2013/02/12/another-way-to-get-the-libraries-...

                                                 

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.*;

import java.text.*;

import java.util.*;

public class Dynamic_Directory implements StreamTransformation {

    private Map param;

    public void setParameter(Map map1) {

        this.param = map1;

    }

    public void 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 = new byte[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

  1. Operation Mapping and
  2. 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:

Part 2: Part2: Step By Step Approach to Use of Picking the file from multiple folders, PGP encryption, Java ...

Regards

GB

2 Comments
Labels in this area