Skip to Content

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

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.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Aug 24, 2011 at 01:54 PM
    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);

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 24, 2011 at 03:05 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 24, 2011 at 02:04 PM

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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.