cancel
Showing results for 
Search instead for 
Did you mean: 

Error in User defined function for dynamic file naming

Former Member
0 Kudos

Hi,

While creating User Defined function with this following code for dynamic fieldname

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;

which options should i select for cache Value, Context, Queue

for Augument , what name shd i mention.

Regards,

Varun

Accepted Solutions (1)

Accepted Solutions (1)

sunilchandra007
Active Contributor
0 Kudos

Hi,

U can't test the mapping having the udf which dynamically access the adapter specific settings directly. U need to configure the whole scenario first , then only u can test it.

Regards,

Chandra

Answers (3)

Answers (3)

former_member238007
Contributor
0 Kudos

Hi.

In Sender Communicatioin Channel. Give the File name as *.xml, so that it can pick any file irrespective of the Name.

In Advanced mode check the check box Set Adapter-Specific Message Attributes & File

In Receiver Communication Channel also do the same setting of Advanced Mode Check box for Set Adapter Specific Messag Attribure and for the File

Define the UDF as cache type ..

regards,

Kishore

santhosh_kumarv
Active Contributor
0 Kudos

Hi,

1. You have to create a UDF of Cache type Value.

2. Do not pass any value to it.

3. Make sure that the option Set Adapter-Specific Message Attribute and Filename is checked in the sender file adapter.

Also check my reply to this [thread|;.

Thanks

SaNv...

Former Member
0 Kudos

Hi Varun,

I guess I have answered a similar question just a few minutes before on very similar post from you. Just pasting the same here .................

Are you trying to access the ASMA values from the SOAP header of the XI message for the source file name?

First of all you need to Set the Sender File Adapter for Set ASMA and then file name. So it will work fine when you actually run the scenario end to end.

But in the mapping tool when you test the mapping - there is not message header updated with the actual source filename - and whenever you try to read the FileName attribute in the message header from the UDF - it cannot find the object and returns a NullPointerException.

I would suuggest for your mapping tool testing to be successful, have a check in the java code for null values,

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);

If (ourSourceFileName != null)

{

Return ourSourceFileName;

}

Return "NoFileName.txt";

Let us know if this works.

Regards,

Suddha