cancel
Showing results for 
Search instead for 
Did you mean: 

UDF for Reciver file name.

Former Member
0 Kudos

Hi Can any one provide me UDFfor following Requirement.

My source file name is like this XXXX081090001 and i want reciver file name as XXXXMT940.

Where MT940 is constant and XXXX is first 4 digits of Source file name.

Note that First four digits of Source file name can change.

Example :- Source file name ABC081090001 -


Target should be ABCMT940

and if Source file name is XYZ091100002 -


Target should be XYZMT940.

Thanks in advance....

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi,

try this code,

udf is context type,

single input i.e your source name

for(int i=0;i<sourceName.length;i++)

{

String store = "";

store = sourceName<i>.substring(0,4);

store = store + "MT940";

result.addValue(store);

}

Regards,

Rohit

Former Member
0 Kudos

Hi,

try this one...

DynamicConfiguration conf = (DynamicConfiguration)

container.getTransformationParameters().get

(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

DynamicConfigurationKey key = DynamicConfigurationKey.create

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

String input = conf.get(key);

String s1 = input.substring(0,4);

String s2 = "MT940";

String newfile = s1.concat(s2);

conf.put(key,newfile);

return (newfile);

Consider to set "Filename" in the Adapter Specific Message Attributes in FileAdapter.

Regards,

Ralph

Former Member
0 Kudos

Hi Ralf,

Thanks for ur Reply

this UDF not working

Error Description

RuntimeException in Message-Mapping transformation: Exception:[java.lang.NullPointerException] in class com.sap.xi.tf._MM_eSTATEMENT_SWIFT_ method Filename$[X1010810901100001, com.sap.aii.mappingtool.tf3.rt.Context@59ca59ca]

Thanks

Edited by: Dinesh on Apr 23, 2008 4:41 PM

Edited by: Dinesh on Apr 23, 2008 5:20 PM

Former Member
0 Kudos

Hi Dinesh,

I just tried the mapping and it works. If you use test functionality of message mapping you must deactivate lines 1 - 6 and line 10 of my solution because this is only filled on runtime. Instead of line 6 use the following: String input ="XXXX1081somewhat";

Ralph

Former Member
0 Kudos

Hi,

In my opinion this will help you..

Part-1

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

Part-2

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

Regards,

Sarvesh

Former Member
0 Kudos

Hi,

you could do it with the standard functions:

substring, concat and constant

Use the substring function for taking the first 4 chars and

then concat the result with constant (MT940).

Regards

Patrick

Former Member
0 Kudos

But how can i take File name in to Feilds to do those Functions.

Former Member
0 Kudos

Hi,

> But how can i take File name in to Feilds to do those Functions.

for this you could have a look at this thread:

Regards

Patrick