cancel
Showing results for 
Search instead for 
Did you mean: 

UDF to get the filename for File Sender Adapter

Former Member
0 Kudos

Hi,

I had an requirement to get the the Filename and map to the target payload.

I had configured the File Sender Adapter settings in the ID

This is the following UDF i got from SDN.

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

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

String ourSourceFileName = conf.get(key);

return ourSourceFileName;

But when iam using this UDF iam getting an error

RuntimeException in Message-Mapping transformation: Exception:[java.lang.NullPointerException] in class com.sap.xi.tf._MM_ORDER_CRS_OB_SAP_PROXY_IB_ method Filename$[com.sap.aii.mappingtool.tf3.rt.Context@54e154e1]

Please help me in correcting the error.

Thanks

Srinivas

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

did the error come from testing the real scenario or from the test using the Test tab in MM editor? The code only works in real scenario.

Jayson

Former Member
0 Kudos

Jayson,

Thanks for your Reply.I tested from the test tab in MM,I will try testing the scenario from end to end and will let you know if any errors.

Thanks

Srinivas

VijayKonam
Active Contributor
0 Kudos

You can only execute dynamic config used mappings from only interfacemapping test tab. Also do not forget to enbale dynamic config variables in the adapter..!!

VJ

henrique_pinto
Active Contributor
0 Kudos

Hi Jayson,

actually, it also works from Interface Mapping test tab (however in this case it'd retrieve just "null").

Regards,

Henrique.

Former Member
0 Kudos

Hi Henrique,

I think in the test tab, when you run the code, the DynamicConfiguration will be null, thus you would get nullpointerexception when you call the method of the DynamicConfiguration object.

Jayson

henrique_pinto
Active Contributor
0 Kudos

Hi Jayson,

actually, in the interface mapping, it doesn't give exception.

The DynamicConfiguration is a constant retrieved from the container object, so it will never be returned as null (given that the container object was instantiated).

Just the retrieved value will be null (since it was not previously set), but no exception occurs.

In the message mapping, the container object is never instantiated, and that's the reason for the NullPointerException.

Regards,

Henrique.

Former Member
0 Kudos

Oh, I see, didn't know that little difference between IM and MM. thanks

Answers (2)

Answers (2)

Former Member
0 Kudos

Thanks for all the Answers

Former Member
0 Kudos

Hi,

The code is fine. It would only work in the end to end scenario, bcos then only you will get the filename.

For this code to work you have to set Adapter Specific Identifier in the Adapter Channel.

So in the Communication Channel->Adapter-Specific Message Attributes-> File Name(Tick it).

Then only you will be able to access filename.

Regards

Arpil