cancel
Showing results for 
Search instead for 
Did you mean: 

Vaildating File name with the data in the file using sender file adapter

Former Member
0 Kudos

Hi,

Below is the scenario

1) Pick up files from a FTP server, the file name is dynamic, how do I put dynamic name in sender file adapter?

2) Determine if the user correctly named the file based on data in the file.

a. File naming structure that we will be concerned with is <company_code><accounting_time_period>.<extension>

b. The company code and the time period in the file name have to match the data in the file.

i. For example. If the file name is 1001_200712.csv and the data in the file is for company code 1005, time period 200712, the file is incorrectly named. Both values must be correct.

How do we do this?

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Sachin,

As Rightly said by Krishna, You can not put Dynamic name in sender File Adapter .You have to provide the name of the file like "*.txt" in Sender Adapter and at runtime you can access this file name by using following UDF:

DynamicConfiguration conf = (DynamicConfiguration) container

.getTransformationParameters()

.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

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

String valueOld = conf.get(key);

return (valueOld);

As now you have picked up the file name at runtime.

Now concatenate source file fields Company_code and Accounting_timeperiod using "_" as delimiter in properties.Also concat the extension .Now you have required file name.

So using EQUALS standard function ,compare it with File Name fetched at runtime using above given UDF, and pass result as you desire to process further or not or to raise Alert to resend the file.

Thanks & Regards,

Anurag Garg

You can validate this file name in Mapping itself.

moorthy
Active Contributor
0 Kudos

Hi,

Quick tips:

1) Pick up files from a FTP server, the file name is dynamic, how do I put dynamic name in sender file adapter?

>>>You can not have dynamic file naming in the sender adapter. However, you can achieve this in the following way. :-Provide the source file name as . so that it will pick up all the files from the source directory.

2) Determine if the user correctly named the file based on data in the file.

>>>This validation can be done at different places:

1. At Adapter Module

2. At Mapping - Using java functions and also set the "Adapter specific Attributes" so that you can get the file name in the message payload.

2nd option here is good probably.

Hope this helps,

Rgds,

Moorthy