cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic Configuration-File to File in scenario

Former Member
0 Kudos

Hi Experts,

As per the requirement needs to supress the numeric extensions of the files and transfer to the receiver.

Example: file name is XXX123.txt , but after picking up by sender communication channel in XI that file needs to converts XXX.txt and transfer to the receiver. Finally in the receiver end the file name should be Mahesh.txt only.

Please share the inputs how to do dynamic configuration in XI in File to File scenario.

Accepted Solutions (0)

Answers (4)

Answers (4)

naveen_chichili
Active Contributor
0 Kudos

Hi Mahesh,

Take a look in the link :[ASMA|http://www.saptechnical.com/Tips/XI/ASMA/Index.htm]

Regards,

Naveen

anupam_ghosh2
Active Contributor
0 Kudos

Hi,

First you need to have a UDF as shown below. No need to put any arguments in the UDF.

 

public String getFileName(Container container){ 
DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION); 

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

//get file name in string s 

String s = conf.get(key); 
//remove all numeric values 

int i,l; 
l=s.length(); 
String a=""; 
for(i=0;i<l;++i) 
{ 
if(s.charAt(i)>='0' && s.charAt(i)<='9') 
{ 
continue; 
} 
a=a+s.charAt(i); 
} 
s=a; 

conf.put(key, s); 
return s; 
} 

Now you need to map this UDF to any root element or dummy element of the target XML structure.

Ensure that

1. Sender Comm Channel has ASMA and file name ticked

2. Receiver Comm Channel has ASMA and file name and "fail if ASMA missing" ticked

3. in receiver communication channel -> File access parameters-> File name scheme -


> put any value say "*". This step is not compulsory.

Hope this solves your problem.

regards

Anupam

Former Member
0 Kudos

Hi,

I have a scenario where I need to take the month and year from the file name and map it to suitable fields in the target. Ex - filename_apr2014 from this i should be able to read the month and year and map it. How to do this? I tried the udf -

public String getFileName(Container container){

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

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;

got this error while testing the mapping -

Runtime exception when processing target-field mapping /ns0:MT_Aries_RmngRsrvs_Output/Impairment_Details; root message: Exception:[java.lang.NullPointerException: while trying to invoke the method com.sap.aii.mapping.api.DynamicConfiguration.get(com.sap.aii.mapping.api.DynamicConfigurationKey) of a null object loaded from a local variable at slot 2] in class com.smenergy.https_.common.ZSMART method getSourceFileName[com.sap.aii.mappingtool.tf7.rt.Context@5b04fc0f]

See error logs for details    

Former Member
0 Kudos

Hi,

1. You have check the Adapter Specific Parameter in Sender File comm. channel.

This link will help for your step 1: /people/michal.krawczyk2/blog/2005/11/10/xi-the-same-filename-from-a-sender-to-a-receiver-file-adapter--sp14

2. In UDF mentioned in the above blog suppress the numbers in the file name.

That's all

Regards

Ramesh

Former Member
0 Kudos

Set ASMA settings as described in this blog.

Now create an UDF with one argument let's say 'a', could be something like this:

DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
 
DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
 
String SourceFileName = a;

        for (int d=0; d<nameLen;d++)
            {
            Character check = (SourceFileName.charAt(d));
            removeChar = check.toString();
            if (Character.isDigit(check))
                {
                SourceFileName = SourceFileName.replace(removeChar, "");
            }

return  SourceFileName;

UDF---->Some RootNode.

Take a look here:

/people/michal.krawczyk2/blog/2005/11/10/xi-the-same-filename-from-a-sender-to-a-receiver-file-adapter--sp14