cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic File and Directory Name without Mapping

shweta_walaskar2
Contributor
0 Kudos

Hello Experts,

We have following requirement:

1) Files will be picked from R/3 AL11 directory and would be placed in corresponding folder in target system.

2) On source side ,there would be only one folder for all types of files(around 20),but on target side,there would be one folder for each kind of file(20 folders)

3) File name should be same on the target side but target directory should be selected based on file name.

I have gone through a number of posts related to similar requirements and hence,sorry for a new post but I am not yet able to find a solution to this.

I could understand,this can be achieved using DynamicConfiguration UDF .

But I have no possibility to have mapping in my scenario.It would just be a pass through scenario.

Can anyone please suggest a solution to this?

Thanks.

Regards,

Shweta

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi.

Wiithout mapping is difficult However you can make a module.

/people/rinku.gangwani/blog/2008/07/16/customized-adapter-module

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/02706f11-0d01-0010-e5ae-ac2...

Former Member
0 Kudos

Hi,

I think Module will be easy way to address this requirement.

If not then,

Try multiple receiver communication channels and conditional receiver determination based on file name.

Anand More

Answers (2)

Answers (2)

shweta_walaskar2
Contributor
0 Kudos

Hello,

Thanks a lot for suggesting solution to this problem.

I could achieve this using following Java mapping:

import com.sap.aii.mapping.api.*;

import java.io.*;

import java.text.*;

import java.util.*;

public class GetDynamicConfiguration 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;

// a) Set ouput File name

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 key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File", "FileName");

DynamicConfigurationKey key1 = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File", "Directory");

String filename =conf.get(key);

conf.put(key, filename);

trace.addInfo("File name is "+filename);

if(filename.equals("in.txt"))

directory = "/home/ftpxi/in";

if(filename.equals("test.txt"))

directory = "/home/ftpxi/in/test";

if(filename.equals("shweta27.txt"))

directory = "/home/ftpxi/in/test";

trace.addInfo("Directory name is "+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();

}

}

}

Thanks again.

Regards,

Shweta

henrique_pinto
Active Contributor
0 Kudos

Indeed, without a mapping, it would be hard to achieve this.

If you had the file type within the payload, you could do variable substitution, but it is unlikely you have it.

Since variable substitution parameters can only be read from the actual payload, I don't see many rooms here, without going for a module (which would be a more effort consuming task than the mapping itself).

Why do you want to avoid mapping? Due to efforts or performance of the scenario?

BR,

Henrique.

EDIT: Anand's sugestion is indeed possible, to create 20 fake receivers to simulate the same receiving system, and then creating manually 20 different communication channels, 1 for each receiver. It is indeed possible, but not at all desirable, both due to architecture and maintenance efforts going up. I'd go for the mapping instead. Notice that performance wise, executing a mapping OR having a conditional routing being evaluated are not so different (they both require the XML to be parsed anyhow).