cancel
Showing results for 
Search instead for 
Did you mean: 

File copy with change of file type

Former Member
0 Kudos

I'm currently working on what seems like a simple file-to-file scenario. A file (without an extension) on server A has to be copied to server B. The name of the file on the target server should be the same as the file on the source system. Only change is that the file on the target system should get a .txt extension. After trying various options I'm stuck on the .txt extension.

I enabled File Name in Adapter Specific Message Properties on both the sender and receiver communication channels. With this option the file gets copied to the target server with the same name, but I cannot add the .txt extension. I also followed the instructions in this blog: https://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/2664. [original link is broken] [original link is broken] [original link is broken] Unfortunately, I don't see the file name in the payload of my message, which means I cannot use it in the Variable Substitution option of my receiver communication channel.

Does anyone know what I might be doing wrong here?

Edited by: Cheese2 on Jul 15, 2009 12:39 PM

Accepted Solutions (1)

Accepted Solutions (1)

former_member272911
Participant
0 Kudos

Hi,

U need to use mapping for it and use the UDf mentioned by Vijay

Thanks

kamath

Answers (3)

Answers (3)

Former Member
0 Kudos

Thank you all for your assistance. The extension is added to the file name. I accidentely forgot to check the file name option under adapter-specific message attributes in the receiver communication channel before my last reply.

Former Member
0 Kudos

create a UDF with the code specified by Shabarish

just add one line of code after you concatenate .txt extension with filename, as -

conf.put(key,ourSourceFileName);

Former Member
0 Kudos

Thank you all for your replies,

I applied the code from Vijay and Mughda to my message mapping and mapped the function to the root node of the receiving message type. The interface doesn't return any errors, but I still don't see the file name in the payload of the message. The .txt extension also isn't added to the file on the target system.

former_member200962
Active Contributor
0 Kudos
The interface doesn't return any errors, but I still don't see the file name in the payload of the message. The .txt extension 
also isn't added to the file on the target system.

You wont see the filename in your payload.....in Michal's blog he is using a return statement to get the filename in some node...however in your case since you are mapping UDF o/p to the root node you wont get the filename....basically return statement is not applicable in your case...remove the return statement and just use the conf.put statement given in earlier reply...

Former Member
0 Kudos
but I still don't see the file name in the payload of the message

this filename will not become part of payload but you can see it SOAP header --> DynamicConfiguration in MONI

have you checked adapter specific message attributes in sender and receiver file adapters as per the blog

other than this, nothing has to be done

Shabarish_Nair
Active Contributor
0 Kudos

use dynamic configuration. you can manipulate the file names very easily - /people/shabarish.vijayakumar/blog/2009/03/26/dynamic-configuration-vs-variable-substitution--the-ultimate-battle-for-the-file-name

/people/michal.krawczyk2/blog/2005/11/10/xi-the-same-filename-from-a-sender-to-a-receiver-file-adapter--sp14 - in your case as per this blog all you need to change in the code will be;

DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

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

String ourSourceFileName = conf.get(key);

ourSourceFileName = ourSourceFileName + ".txt";

return  ourSourceFileName;