cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic configuration

Former Member
0 Kudos

Hi Experts,

I have a requirement to get a processID from the source structure and that name should be the name of the output file. I have written a code.. Could anyone please check the code and tell me if any changes need to be made for the code.

Here I need to add that field in the filename. I am mapping this field to the root node of the target structure.

public String Filename(String a,Container container)

{

String b; // Target file Name

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

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

b = "MN1234" + a +"12345.TXT";

conf.put(keyHeader1, b);

return "";

}

Quick reply is highly appreciated......

Edited by: Hareenkumar on Jul 14, 2010 11:03 AM

Accepted Solutions (0)

Answers (2)

Answers (2)

Shabarish_Nair
Active Contributor
0 Kudos

looks fine.

More info at - /people/shabarish.vijayakumar/blog/2009/03/26/dynamic-configuration-vs-variable-substitution--the-ultimate-battle-for-the-file-name

Former Member
0 Kudos

Hi Shabarish,

Could you please check the code given to ensure that changes I made to the code are fine..

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

DynamicConfigurationKey key = DynamicConfigurationKey.create(u201Chttp://sap.com/xi/XI/System/Fileu201D,u201CFileNameu201D);

String name = "OU2003" + a + "OSLORR" + b ".txt;

conf.put(key, name);

former_member200962
Active Contributor
0 Kudos
String name = "OU2003" + a + "OSLORR" + b ".txt;

Above statement is missing some parameters...it should be String name = "OU2003" + a + "OSLORR" + b + ".txt";

Have you declared a and b properly ..... are they input to the the UDF?

Former Member
0 Kudos

Yes, I have declared a and b. a would be the field value in the source and b will be the currentdate function.

former_member200962
Active Contributor
0 Kudos

It is fine then....di you test your scenario?

Former Member
0 Kudos

When I try to test the scenario, I am getting the below error:

Message processing failed. Cause: com.sap.aii.af.ra.ms.api.RecoverableException: The Adapter Message Property 'FileName' was configured as mandatory element, but there is no 'DynamicConfiguration' element in the XI Message header: com.sap.aii.adapter.file.configuration.DynamicConfigurationException: The Adapter Message Property 'FileName' was configured as mandatory element, but there is no 'DynamicConfiguration' element in the XI Message header

Could you please tell me what is the reason behind it...

former_member200962
Active Contributor
0 Kudos

1) Did you check the Adapter Specific Message Attribute and FileName checkboxes in the receiver FILE Channel?

2) Are you testing the scenario end-to-end?

Former Member
0 Kudos

Yes, I have checked the option filename in the receiver file adapter and doing end-to-end testing...

former_member200962
Active Contributor
0 Kudos

Can you post your UDF.....complete UDF with what the inputs are? The UDF is not getting executed.

what have you put in the FileName section of the receiver file channel.

Former Member
0 Kudos

I am able to execute the UDF and able to get the file in the Dynamic Configuration in moni. unable to process at the receiver side. The scenario is proxy to File.

My UDF is:

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

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

String name="MN1234" + a + "123456.TXT";

conf.put((keyHeader1, b);

return "";

former_member200962
Active Contributor
0 Kudos
DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

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

String name="MN1234" + a + "123456.TXT";

conf.put((keyHeader1, b);

return "";

UDF is wrong ......

1) what is b?

2) why are you using b in the conf.put statement?

3) conf.put((keyHeader1, b); ......why am i seeing two start brackets?

4) Is a defined properly?

Try with the below UDF:

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

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

String name="MN1234" + a + "123456.txt";

conf.put(keyHeader1, name);

return ""

Former Member
0 Kudos

Sorry abhi, unfortunately I have sent the wrong one.

The UDF what I have used is :

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

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

String final1;

final1 = "MN1234" + a + "123456.TXT";

conf.put(key,final1);

return "" ;

vkaushik82
Active Participant
0 Kudos

Is your payload empty.?

In my case i got this same error message but my reason was payload was empty.

Former Member
0 Kudos

I am able to get the Payload. I have resolved the issue by writing another UDF and that fixed the issue.

former_member200962
Active Contributor
0 Kudos
String b; 
b = "MN1234" + a +"12345.TXT";

Things look fine.....instead of having two statements you could combine it into one

String b = "MN1234" + a +"12345.txt";

Do not forget to check teh ASMA attribute, FileName, in the FILE channel and test it end-to-end

Regards,

Abhishek.