cancel
Showing results for 
Search instead for 
Did you mean: 

What configurations needed to use user-defined function to read File Name?

former_member190543
Participant
0 Kudos

Hi,

I have a requirement (file to ERP) of picking a file from a directory, take a part of file name and use it in the mapping to populate it as a field. I got the following code from SDN and using it as it is.

public String AccessFileName(Container container){

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

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

String FILE_NAME = attrib.get(fileKey);

return FILE_NAME;

}

In File sender adapter, what are the configurations I have to make so that the above function in mapping gets the file name to work on?

I gave the AF_Modules/DynamicConfigurationBean and CallSapAdapter without giving any parameters. And also I ticked the Adapter-Specific Message Attributes and File Name check boxes.

I am getting an fatal mappping error.

Any more configurations to add?

Please help.

Accepted Solutions (1)

Accepted Solutions (1)

former_member854360
Active Contributor
0 Kudos
I gave the AF_Modules/DynamicConfigurationBean and CallSapAdapter without giving any parameters. And also I ticked the Adapter-Specific Message Attributes and File Name check boxes.

No need to use any module AF_Modules/DynamicConfigurationBean

Only ticked the Adapter-Specific Message Attributes and File Name check boxes is enough.

String  inputFileName;
		


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


DynamicConfigurationKey key1 = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
inputFileName= conf.get(key1);

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Ramesh,

>>> In File sender adapter, what are the configurations I have to make so that the above function in mapping gets the file name to work on?

All you need to do in File Sender Adapter is to check the Adapter-Specific Message Attributes and File Name check boxes in the "Advanced" tab of the File channel.

Please remember one thing that even after doing the above configuration and using the UDF that you mentioned, you will get a Fatal error when you test the mapping from the "Test" tab of your graphical mapping editor, however, this will work perfectly fine during runtime which you can easily test by running an end to end File-to-IDoc scenaro.

I hope this helps.

Regards, Gaurav

Shabarish_Nair
Active Contributor
0 Kudos

do go thru this - /people/shabarish.vijayakumar/blog/2009/03/26/dynamic-configuration-vs-variable-substitution--the-ultimate-battle-for-the-file-name