cancel
Showing results for 
Search instead for 
Did you mean: 

message mapping

Former Member
0 Kudos

Hi,

Need to do a message mapping.

Client is sending the data in a single row which has diffrent fields as columns and has 2 material data in this row.

Now the requirement is to split this data into 2 rows, first row for one material and second for other material charecteristics.

Can we do this mapping ?

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

I do have the same scenario but the data is from table. wants to make into 2 rows in the same table at the output. Do i use the same code ?

Input data :

A_thick A_data A_length B_thick B_data B_length

Output data :

Thick Data Length

A

B

Is it possible to have this mapping ?

Former Member
0 Kudos

The Complete UDF is as follows:

public void sepDec(String[ ] instr,String[ ] delimiter,ResultList result1,ResultList result2,Container c)

{

String[] outstr = instr[0].split(delimiter[0]);

result1.addValue(outstr[0]);

result2.addValue(outstr[1]);

}

This UDF takes 2 inputs, the 1st input is the client data sent in a single row, the second input is the separator between the two material records sent in a single row( for eg say if the input is like "abcd,1234" where abcd is the first material characteristic and 1234 is the second material characteristic and they are separated by a comma(","), then the value for the second input of the UDF is a comma sent as a constant string(",").

This UDF has 2 outputs,namely result1 and result2.

result1 contains the first material characteristics while result2 contains the second one.

The line : String[] outstr =instr[0].split(delimiter[0]);

separates the instr[0], which is the input based on the delimiter(which in my eg is a comma) and stores the part before the delimiter in outstr[0] and the part after that in outstr[1].

Those 2 values are then taken out as the 2 outputs and needs to be mapped to the 2 target fields.

HOPE THIS HELPS YOU BUDDY.

THANKS

BISWAJIT

Edited by: 007biswa on Feb 10, 2011 4:39 PM

Former Member
0 Kudos

What is your scenario? You can use UDF to split the string into parts. If you know some kind of identifire in your file from where you wnat to split then you can use below UDF code to split it into parts.

Here instr is your input string and delimiter is the identifire value.

String[] outstr  = instr[0].split(delimiter[0]);

 for (int i = 0; i < outstr.length; i++)
    result.addValue(outstr<i>);

baskar_gopalakrishnan2
Active Contributor
0 Kudos

>> Can we do this mapping ?

Yes, It is possible. Read the entire row and will use Text function to split the row in to two and map it to two fields in the target.

Former Member
0 Kudos

Pls let me know the brief idea of using the text function u r saying.

Former Member
0 Kudos

Text functions are substring, concate, equalS etc.... just check in your mapping under Functions. You have to use UDF for this.

baskar_gopalakrishnan2
Active Contributor
0 Kudos

Yes, Sarvesh is right. I see some variations between graphical text functions and java string methods. In this situation, use string spit method and pass Regex or pattern or delimiter to the argument. Basically identify the delimiter that splits the row in to 2. pass it in the split method as argument.