cancel
Showing results for 
Search instead for 
Did you mean: 

User defined function during Mapping.

Former Member
0 Kudos

Hi,

I am trying to retrieve filename using user defined function.

The payload is simple.

<?xml version="1.0" encoding="UTF-8"?>

<ns0:FTPTOFTP_MT_OB xmlns:ns0="urn://ftptoftp.com">

<RECORD>

<ROW>

<EMPNO>723</EMPNO>

<NAME>Jack</NAME>

</ROW>

</RECORD>

</ns0:FTPTOFTP_MT_OB>

the code for user defined function is

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;

now during message mapping ...

do I have to have extra xml tag in the destination

message which is now having

<?xml version="1.0" encoding="UTF-8"?>

<ns0:FTPTOFTP_MT_IB xmlns:ns0="urn://ftptoftp.com">

<RECORD>

<ROW>

<EMPNO>723</EMPNO>

<NAME>Jack</NAME>

</ROW>

</RECORD>

</ns0:FTPTOFTP_MT_IB>.

If yes ...

Then how to graphically map this extra xml tag.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Deepak,

If u want to display the source file name in ur output, then ur output XML structure there should be an extra tag for displaying the file name.

In message mapping, select the user defined function which u have already created and map it to the tag for storing the file name in the target message XML format.

There is a editor present to write the user defined function on the bottom left corner of the message mapping screen.

For this function u need to select the Simple Function Tab.

Regards

Neetu

Former Member
0 Kudos

Hi,

Thanks for your prompt reply .

MY input interface is

having ytwo field name and rollno ...my output interface is having 3 fields now filename , empno, name.

Is this correct .Or the tag should be there in both inbound and outbound message.

When we create message mapping.

Created a user defined function called testudf.

during graphical mapping I am able to map filename tag to this to this function .

but ...the tag becomes as yellow....as there is nothing pointing top the other end of testudf function.

Former Member
0 Kudos

Hi Deepak,

No u dont need to have the filename tag in the input structure.

Ur mapping turns yellow because there must be some input parameter in the function.

When u create the user defined function make the arguments field as 0. In this case the function will not expect any in put and the mapping will be green without any tag from the input msg.

Regards

Neetu

Former Member
0 Kudos

Hi ,

Thanku. I deleted that argument before you reply .I think it will work now. Believe it or not I am on XI 7.0

SP06. So we don't get an option of simple and advance udf .We get to specify the type of arguments here...

context , queue et cetra. And it turns out there were arguments specified .. hence the problem during mapping.

Thank you .

again

Former Member
0 Kudos

Hi,

Is the problem not solved yet?

You need to use cache value as "value" and no inputs ( zero arguements).

Your UDF looks good.

Regards,

Jai Shankar

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Deepak,

You have to create an extra xml tag which stores the filename of the source file. Otherwise how will u get the filename? Map the output of the user defined function which you have written to this tag.

Regards,

Divija.

Shabarish_Nair
Active Contributor
0 Kudos

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

and yes you sud create an extra field and map it to UDF created.

At the receover side when you do content conversion you can use the NameA.fixedLengthTooShortHandling = cut option to remove tht field from the XML.

Message was edited by: Shabarish Vijayakumar