cancel
Showing results for 
Search instead for 
Did you mean: 

Changing the file name dynamicallly in file Adapter

former_member181928
Participant
0 Kudos

Hi i want to change the file name directly from Java Mapping in the file adapter

for this i have written this code

DynamicConfiguration dynamicConfiguration = (DynamicConfiguration)map.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

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

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

dynamicConfiguration.put(keyFile,fileName);

dynamicConfiguration.put(keyDir,outputpath);

but it gives a null pointer exception at dynamicConfiguration.put(keyFile,fileName);

please suggest.

regards

Nilesh Taunk.

Accepted Solutions (1)

Accepted Solutions (1)

bhavesh_kantilal
Active Contributor
0 Kudos

Hi Nilesh,

If your requirement is to create , the file name dynamically for your receiver file adapter, you can do so using your <b>FILE ADAPTER CONFIGURATION</b> itself, and need not go for any JAVA Mappping / Java Code at all.

The dynamic filename generation concept is as follows.

In your filename field in the receiver file adapter, just give a variable with <b>%</b> symbols. (eg: %file% ).

Now, under the option <b>Variable Name Substitution</b>, you can give how the value has to be created.

<b>It can be your interface name, sender service name, etc or it can be some value dynamically from your payload.</b>

For the former, your give

<b>message:interface_name</b> ,etc

and for the payload part you give,

<b>Payload: "your element root which u wanna acecss"</b>

Just check this link out,

http://help.sap.com/saphelp_nw04/helpdata/en/bc/bb79d6061007419a081e58cbeaaf28/content.htm

And read the contents under variable substitution and it will help you understand the concepts better.

Also, in your FILE Adapter under the option FILE CREATION MODE, you have options like,

1.Add Counter,

2. Append

3. Create

4. Add Time Stamp

If you have any clarifications on this approach, do get back.

Regards,

Bhavesh

former_member181928
Participant
0 Kudos

I appreciate your alternative way,but ill like to know as to why an object of dynamicConfiguration is not being created and giving me a null pointer excep....

Is it that i cannot create an object of dynamicConfiguration in my Java mapping like this

regards

Nilesh Taunk.

MichalKrawczyk
Active Contributor
0 Kudos

Hi,

>>>>Is it that i cannot create an object of dynamicConfiguration in my Java mapping like this

you can use it with java mapping;

http://help.sap.com/saphelp_nw04/helpdata/en/43/09b16006526e72e10000000a422035/content.htm

Regards,

michal

Answers (1)

Answers (1)

MichalKrawczyk
Active Contributor
0 Kudos

hi,

>>>>dynamicConfiguration.put(keyFile,fileName);

dynamicConfiguration.put(keyDir,outputpath);

are you sure fileName has any value ?

maybe check if it's not null

Regards,

michal