cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic File Name depending on the Source File name

Former Member
0 Kudos

Hi Experts,

I have a problem like Dynamic File name depending on the Source File Name. I will explain with example as follwos

Source File name Targer Folder/Filename

NK01.VR59.L2007030 VR59/Rec.l200

NK01.VR71.L2017030 VR71/Rec.l201

NK01.VR77.L2027030 VR77/Rec.l202

See above the exaple, Depending on the Source file name, I am deciding where i need to place my file and what name i need to name it.

So please suggest me the solution and How can i do this with a single communication channel ? Do i need to create multiple CC for each folder??

Points will be rewarded for Valuable anwer.

Thanks in Advance,

Best Regads,

Vijay

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

check this one out tooo

/people/william.li/blog/2006/04/18/dynamic-configuration-of-some-communication-channel-parameters-using-message-mapping

<b>Cheers,

*Raj*

Answers (2)

Answers (2)

justin_santhanam
Active Contributor
0 Kudos

Vijay,

Check the Adapter Specific Message attributes Filename & Directory in sender/receiver comm.channel.

DynamicConfiguration conf = (DynamicConfiguration) container

.getTransformationParameters()

.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

DynamicConfigurationKey key = DynamicConfigurationKey.create(

"http://sap.com/xi/XI/System/File",

"FileName");

DynamicConfigurationKey key1 = DynamicConfigurationKey.create(

"http://sap.com/xi/XI/System/File",

"Directory");

String source = conf.get(key);

String tar_fname =source.substring(5,9);

String tar_dirname =source..substring(10,14);

conf.put(key, tar_fname);

conf.put(key1, tar_dirname);

Create the above UDF[with no input ] and map it to the target node.

Best regards,

raj.

Former Member
0 Kudos

Hi Raj,

What you told here , I did the same. But i am getting Fatal error saying as follows

- <!-- Request Message Mapping

-->

- <SAP:Error xmlns:SAP="http://sap.com/xi/XI/Message/30" xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" SOAP:mustUnderstand="">

<SAP:Category>Application</SAP:Category>

<SAP:Code area="MAPPING">EXCEPTION_DURING_EXECUTE</SAP:Code>

<SAP:P1>com/sap/xi/tf/_MM_Target_File_determined_</SAP:P1>

<SAP:P2>com.sap.aii.utilxi.misc.api.BaseRuntimeException</SAP:P2>

<SAP:P3>Fatal Error: com.sap.engine.lib.xml.parser.Parser~</SAP:P3>

<SAP:P4 />

<SAP:AdditionalText />

<SAP:ApplicationFaultMessage namespace="" />

<SAP:Stack>During the application mapping com/sap/xi/tf/_MM_Target_File_determined_ a com.sap.aii.utilxi.misc.api.BaseRuntimeException was thrown: Fatal Error: com.sap.engine.lib.xml.parser.Parser~</SAP:Stack>

<SAP:Retry>M</SAP:Retry>

</SAP:Error>

Please give me any suggestios about that.

Warm Regards,

Vijay

former_member192892
Active Contributor
0 Kudos

Which SP are you using??

former_member192892
Active Contributor
0 Kudos

>>>>>>>>>>String tar_dirname =source..substring(10,14);

Also please note, there is an extra dot in the code provided by raj.

Its source.substring(10,14);

justin_santhanam
Active Contributor
0 Kudos

Vijay,

Did u checked the ASMA checkbox in both the channels. Also as noted by varun ,please remove the one more dot "." in the above code.

Best regards,

raj.

Former Member
0 Kudos

Yes I already done both what you are suggested. I don't what is the problem.Is there any wrong in mapping. Do i need to give any Import packages for the UDF. Currently there is no Package improted explicitly.

Warm Regards,

Vijay

justin_santhanam
Active Contributor
0 Kudos

Vijay,

Could you please summarise the steps u did? There is no need to import anything. Also please note that there is no input needed for this UDF, map the UDF to the root node of the target element.

Best regards,

raj.

Former Member
0 Kudos

Hi Raj,

I sent you all my screenshots to your Gmail . Please do the needful.

Thanks in Advance,

Best Regards,

Vijay

justin_santhanam
Active Contributor
0 Kudos

Vijay,

Sent the reply, do the necessary changes and run the scenario again.

Best regards,

raj.

Former Member
0 Kudos

Hi Raj,

I have done the configuration according to your mail. But still it is showing same FATAL Error. This error is comming from the UDF. I think there is some problem in UDF. Can you please trace the problem.

<b>My UDF As follows:</b>

  //write your code here
 DynamicConfiguration conf = (DynamicConfiguration) container
.getTransformationParameters()
.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

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

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

String source = conf.get(key);

String tar_fname =source.substring(19,21);
String tar_dirname =source.substring(14,18);

conf.put(key, tar_fname);
conf.put(key1, tar_dirname);

return " ";

Thanks in Advance

Best Regards,

Vijay

Shabarish_Nair
Active Contributor
0 Kudos

note that when you test the same in mapping editor it will give you an error.

the test will work only in an end to end scenario and not in an independent mapping test.

Also remove the return " "; statement from your code and map the UDF to your top most node.

Former Member
0 Kudos

Hi VIjay,

Thanks for quick reply. But i am getting error in End to End Scenarios only. If i remove the Return " " statement from the UDF, while activating it is showing the error saying like missing return statement. I also mapped to the top most node to this UDF.

I am getting the following error in End to End error Scenarios:

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> 
- <!--  Request Message Mapping 
  --> 
- <SAP:Error xmlns:SAP="http://sap.com/xi/XI/Message/30" xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" SOAP:mustUnderstand="">
  <SAP:Category>Application</SAP:Category> 
  <SAP:Code area="MAPPING">EXCEPTION_DURING_EXECUTE</SAP:Code> 
  <SAP:P1>com/sap/xi/tf/_MM_Target_File_determined_</SAP:P1> 
  <SAP:P2>com.sap.aii.utilxi.misc.api.BaseRuntimeException</SAP:P2> 
  <SAP:P3>Fatal Error: com.sap.engine.lib.xml.parser.Parser~</SAP:P3> 
  <SAP:P4 /> 
  <SAP:AdditionalText /> 
  <SAP:ApplicationFaultMessage namespace="" /> 
  <SAP:Stack>During the application mapping com/sap/xi/tf/_MM_Target_File_determined_ a com.sap.aii.utilxi.misc.api.BaseRuntimeException was thrown: Fatal Error: com.sap.engine.lib.xml.parser.Parser~</SAP:Stack> 
  <SAP:Retry>M</SAP:Retry> 
  </SAP:Error> 

Former Member
0 Kudos

Hi VIjay,

Thanks for quick reply. But i am getting error in End to End Scenarios only. If i remove the Return " " statement from the UDF, while activating it is showing the error saying like missing return statement. I also mapped to the top most node to this UDF.

I am getting the following error in End to End error Scenarios:

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> 
- <!--  Request Message Mapping 
  --> 
- <SAP:Error xmlns:SAP="http://sap.com/xi/XI/Message/30" xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" SOAP:mustUnderstand="">
  <SAP:Category>Application</SAP:Category> 
  <SAP:Code area="MAPPING">EXCEPTION_DURING_EXECUTE</SAP:Code> 
  <SAP:P1>com/sap/xi/tf/_MM_Target_File_determined_</SAP:P1> 
  <SAP:P2>com.sap.aii.utilxi.misc.api.BaseRuntimeException</SAP:P2> 
  <SAP:P3>Fatal Error: com.sap.engine.lib.xml.parser.Parser~</SAP:P3> 
  <SAP:P4 /> 
  <SAP:AdditionalText /> 
  <SAP:ApplicationFaultMessage namespace="" /> 
  <SAP:Stack>During the application mapping com/sap/xi/tf/_MM_Target_File_determined_ a com.sap.aii.utilxi.misc.api.BaseRuntimeException was thrown: Fatal Error: com.sap.engine.lib.xml.parser.Parser~</SAP:Stack> 
  <SAP:Retry>M</SAP:Retry> 
  </SAP:Error> 

ravi_raman2
Active Contributor
0 Kudos

Seems to be an error in the xml that is being parsed....!!

re-check the code if needed, validate the xml again from an external tool then re-run..that is if its not been fixed yet

Regards

Ravi

Former Member
0 Kudos

Try using the following:

I used the following code in my scenario and it works.

<b>public String FileName(String VarName,String VarAddress,Container container){

String filename = null;

filename = VarName+VarAddress;

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

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

conf.put(key1,filename);

return "";</b>

Here VarName and VarAddress are the source fields.

I have pasted the code exactly the way I used it.

First try for file name and then we will go onto dir thingy.

Regards,

XIer

Message was edited by:

XIer

Former Member
0 Kudos

Hey,

This can be achevied through variable subsitution right.

Hope these blogs help you

Dynamic File Name Part 1

/people/jayakrishnan.nair/blog/2005/06/20/dynamic-file-name-using-xi-30-sp12-part--i

Dynamic File Name Part 2

/people/jayakrishnan.nair/blog/2005/06/28/dynamic-file-namexslt-mapping-with-java-enhancement-using-xi-30-sp12-part-ii

Another some one pasted a smilar blog in the morning.Please check that out too,

<b>Cheers,

*Raj*

*REWARD POINTS IF FOUND USEFULL*</b>