cancel
Showing results for 
Search instead for 
Did you mean: 

Dinamic content conversion in Java Mapping

AntonioSanz
Active Participant
0 Kudos

Hi all,

I need to set the name of the file I generate in my integration scenario dinamically. I am using a Java mapping.

I have search in forum and I have seent that in graphical mapping I can use a UDF like:

   DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
   DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
   String SourceFileName = "nameoffile.txt";
   String TargetFileName = SourceFileName;
   conf.put(key, TargetFileName);  

I have tried this in my java mapping but I get a compilation error on container.

getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

Does anyone know how to do this inside in a java mapping?

Thanks.

Accepted Solutions (1)

Accepted Solutions (1)

former_member184681
Active Contributor
0 Kudos

Hi,

The code to be used inside the Java mapping is a little bit different. Use the following:

DynamicConfiguration conf = input.getDynamicConfiguration();

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

String filename = "some_file_name.txt"; //use your own name here

conf.put(key, filename);

Hope this helps,

Greg

AntonioSanz
Active Participant
0 Kudos

Greg, I have tried that

but I get an error with input.getDynamicConfiguration();


I havent defined "input"

My method is:

public void execute (InputStream in, OutputStream out)

    throws com.sap.aii.mapping.api.StreamTransformationException

but "in" hasnt got that method

Any further help?

former_member184681
Active Contributor
0 Kudos

This input variable should be of type TransformationInput. See a complete example here, maybe this will help you: http://pastebin.com/F82wRPcf

Regards,

Greg

AntonioSanz
Active Participant
0 Kudos

thanks greg. This java code is very usefull.

I have implemented, but now I get this error on my communication FTP channel:

Message processing failed. Cause: com.sap.engine.interfaces.messaging.api.exception.MessagingException: Error occurred while connecting to the FTP server "192.168.40.83:21": java.lang.Exception: Exception in XML Parser (format problem?):'org.xml.sax.SAXParseException: The processing instruction target matching "[xX][mM][lL]" is not allowed.'

I have configured the Receiver FTP channel in Advanced-->Adapter-Specific Message Atrributes and I have checked:

- Use Adapter-Specific message attributes

- Fail if adapter-specific attribute is missing

- File Name

Any idea?

AntonioSanz
Active Participant
0 Kudos

That was an error on my content conversion in FTP channel.

Thanks for all

Answers (0)