cancel
Showing results for 
Search instead for 
Did you mean: 

Concatenation UDF

Former Member
0 Kudos

Hi Expert,

I have requirement like, One Source System and Two Target System. In that source system I have input like First Name last Name and age department. In First target side I need a output like Name(FirstName+LastName), Age , Department but in my Secound Target System I need a outPut Only First Name , Age and Department. How Can I write a UDF for this. Anyone can help me out in this?

Thanks

Mary Durai

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi, I suggest to create two mappings, one for each target system. In the first mapping you can use the concat function to concatenate names.

Then you have to create two interface determinations in order to execute the appropriate mapping for each target system.

Martin

Former Member
0 Kudos

I am agree with Martin,

You can use 2 different mappings using CONCAT Function to concatenate FirstName & SurName strings (Standard Mapping Function is highly recommended rather than an UDF)

Former Member
0 Kudos

Hi

Yes I agree that I can create by using two different mapping. But I want to do only with UDF. Can you please advice me that how can I do?

Thanks

Mary Durai

Ryan-Crosby
Active Contributor
0 Kudos

Hi Mary,

You should be able to just use the mapping contexts and have one message mapping because you can differentiate context by using the constant for receiver. You then can feed that in as a parameter to a UDF or use regular graphical mapping logic to determine the concatenation output for the field.

Regards,

Ryan Crosby

Answers (2)

Answers (2)

Former Member
0 Kudos

HI Mary,

Let me give a simple solution!!!

Solution is simple If it is ok for you to hardcode the target system names in the UDF.

Also consider the multiple instances of ur Target System names (Dev, QA, Prod).

If you are using PI 7.1 and above then pass all parameters which you require for the UDF plus an EXTRA node called

"RECEIVER" to the UDF. This option is there in constants TAB in the mapping.

Inside, UDF write condition something like ,

if (RECEIVER = TargetSysADev || RECEIVER = TargetSysAQA || RECEIVER = TargetSysAProd )

{return Firstname+Lastname}

else

(if RECEIVER = TargetSysB)

{return Firstname}

Here, there is also an assumption that you are handling the other stuff to route the message to system A and B respectively.

Please let me know if this is complex!!!!!!!!!

Thanks,

VK

Former Member
0 Kudos

This UDF will give you the receiver component of your message


GlobalContainer globalContainer;
AbstractTrace trace;
String headerField;
java.util.Map map;
// Get trace using the container object 
// (which is passed by parameter u2018containeru2019 
//  to this user-defined function)
trace = container.getTrace();
// To get a global container, use method getGlobalContainer() 
// of the container object
globalContainer = container.getGlobalContainer();
// There are two ways of getting the runtime constant map now:
// a) by calling container.getTransformationParameters() or
// b) by calling globalContainer.getParameters().
map = globalContainer.getParameters();
// get the value for a header field
headerField = (String) map.get(
                StreamTransformationConstants.RECEIVER_SERVICE);
// output value to trace and return it
trace.addInfo("Receiver Component:" + headerField);
return headerField;

you can find more info about the constants here:

[http://help.sap.com/saphelp_nwpi71/helpdata/en/43/c3e1fa6c31599ee10000000a1553f6/frameset.htm]