cancel
Showing results for 
Search instead for 
Did you mean: 

Same source file name with a different extension

0 Kudos

Hi All,

I have a source file which is dynamic all the time. Can I create a target file which has the same name as the source file but with a different extension.

Scenaio is file to file.

test. xml is the source file name and the target file name should be as test.csv

Regards,

Amar

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Amareshwar,

you can write a java code (either in UDF or import in imported archive and use in imterface mapping).

The piece of code is..

DynamicConfiguration conf = (DynamicConfiguration) myParam.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

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

String OriginalFileName = conf.get(Filekey);

if (OriginalFileName != null)

{

NewFileName=OriginalFileName.replaceAll(".csv",".txt");

conf.put(Filekey,NewFileName);

}

And in Integration Directory>Configuration Scenario>your communication channels (both sender and receiver) just select

Adapter specific message attributes- File name

This would solve your problem.....

Regards,

Vishal Gupta

Plz reward points if you are satisfied with the solution.

justin_santhanam
Active Contributor
0 Kudos

Amar,

As i said follow the Dynamic configuration. Follow the Vishal implementation code to achieve the same.

Best regards,

Raj.

Message was edited by:

Raj

Answers (2)

Answers (2)

Former Member
0 Kudos

Nemalikanti,

Yes you can create. Get the filename using this weblog. Then you use the variale substitution for the filename. In your receiver file adapter then put the filename as <b>%var1%.csv</b> where var1 is the variable substitution for the filename.

/people/michal.krawczyk2/blog/2005/11/10/xi-the-same-filename-from-a-sender-to-a-receiver-file-adapter--sp14

---Satish

0 Kudos

Do I need to create this UDF function too or just set the adapter specific message attributes. Also please let me know what I should enter in variable substitution table against %vari%.

Regards,

Amar

Former Member
0 Kudos

Hi,

You should create the UDF function and pass this value to the last field in your target. Also you dont use this field in your content conversion.

Then you use this field in your variable susbtituion. Check this weblog on this:

/people/sravya.talanki2/blog/2005/08/11/solution-to-the-problem-encountered-using-variable-substitution-with-xi-sp12

---Satish

justin_santhanam
Active Contributor
0 Kudos

Amar,

I would suggest you to go for Dynamic configuration using UDF to acheive the same.

Get the filename from the container and set the same filename in the container with your extensions.

Reply back if you r not clear with that. It's much easier.

Best regards,

raj.

justin_santhanam
Active Contributor
0 Kudos

Amar,

<i> I have a source file which is dynamic all the time</i>

What does it mean, could you please explain. Is it the source structure is always dynamic or the data.

0 Kudos

Source file name is dynamic. It can change and can have any name. How can I use the source file name and create a target file name but with a different extension.

My source files are in xml format and my target files should be in CSV format.

Regards,

Amar

henrique_pinto
Active Contributor
0 Kudos

Assuming your scenario is file-2-file, you have 2 preferable options:

1. use dynamic configuration in mapping to change the file extension to .csv (make sure to check ASMA+filename in the receiver adapter). Check Michal's blog for reference: /people/michal.krawczyk2/blog/2005/11/10/xi-the-same-filename-from-a-sender-to-a-receiver-file-adapter--sp14 (but you don't need to do the filename in payload part, just the UDF + ASMA options in adapters);

2. use dynamic configuration module (with a dummy header field holding your filename) + variable substitution to read this header field into the file name. Check Jin Shin's blog for further information: /people/jin.shin/blog/2007/04/27/sap-netweaver-xi-variable-substitution-with-adapter-specific-message-attributes-via-dynamicconfigurationbean

Option 1 is preferable if you already have a message mapping in your scenario. If you don't have any mapping programs, use option 2.

Regards,

Henrique.