cancel
Showing results for 
Search instead for 
Did you mean: 

Message mapping logic

Former Member
0 Kudos
139

Hi All,

There is a message mapping logic which I need to find out for the below mentioned scenario.

Company name (Source Field) --> name 1 (target) (max 40 characters allowed)

Company name (Source Field) --> name 2 (target) (max 40 characters allowed)

If the Company name is more than 80 characters, set the invalid flag (TARGET FIELD) = 'X'.

If the Company name is less than 80, then check for the last space before 40 characters and pass the

value upto space to name1 and the remaining (if it is less than 40), pass it to name2.

If the remaining is more than 40, set the invalid flag (target field) to 'X'.

How can i accomodate this logic in message mapping? Do i need to use some java user defined function to achieve this? The requirement from the business is to do this strictly in message mapping itself. Appreciate a quick response. Thanks a lot.

-Anand

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Here you have to map one field at a time , so

First map the target field , with source field as

Company name -


> Put function length

check if the length is more than 80, if yes then put 'X' in Invalid Flag.

Now map the name1 field as follows

Check if the length of the Company Name is less than 80 (use ifWithoutElse), if yes

now use substring function (parameters ) start position as 0 and number of characters as 39----->

then use function lastIndexOf (input will be "output of the substring" and CONSTANT ' ')

-


> .......this returns the index of the last "space" before 40 characters,

output of this will give you the number of characters for the name1 -


now

here you will need to write a UDF with 3 input parameters ie 1 ) the source string, 2 )starting index and the 3) lastindexOf 'space'

this function will return the stirng starting from 0th position till the number of characters sent as input.

similarly map name2 now,

use logic for name 1 now here you can use the same logic until lastindex of,

but this time the output of the last index will be input to the UDF u written for name1

that will be the starting position of the name2 , and length of company name will be the end postion.

Hope this helps

Regards

Advait.

Former Member
0 Kudos

Hi Anand,

You have to use lenth function for the total lenth and decide upon that.

Then coming to the spliting the value into two field , use the substring with index.

Here if the lenth < 40 you will get the error,to aviod this you need to follow below logic.

first concatenate the some unused char like ( | ) to the existing value ( means to Company name) use substring after getting the 40 lenth value including | then use replace function for the replacing | to the space.

follow same logic to the name2 also.

Hope you got , pls give points.

If you want more on this pls give me your mail ID to my id, i will give you snapshots for this.

my ID rayapudi.ramarao@tcs.com

ok bye

Former Member
0 Kudos

Hey Deno,

You can do this by using Length,Format Number and subString Predefined functions in Message Mapping.

Steps:

1. First of all you need to check the length of the source field

2. Depending upon length you have to go with your requirements, in this process you can use some predefined functions in Message Mapping like Length and Format Number and Substring.

Cheers.,

Esha

Former Member
0 Kudos

Hi Esha,

<i>>>If the Company name is less than 80, then check for the last space before 40 characters and pass the

value upto space to name1 and the remaining (if it is less than 40), pass it to name2</i>

Is this also possible with standard functions? How do u check for the space?

cheers,

Prashanth

Former Member
0 Kudos

Hey Prashant,

We can check space by using standard text function - endsWith

By comparing value of Name ( source field ) ends with Constant ( space) then its true otherwise its giving false.

By this way we can test the sapce ... Please corrrect me If I'm wrong.

Cheers.,

Esha

Former Member
0 Kudos

Hi Esha,

Never tried these functions out that much :). Usually resort to writing a UDF.

Thanks a ton for the info.

cheers,

Prashanth

Former Member
0 Kudos

Hey Prashanth,

Never Mine, XI is a technology lot people coming from different backgrounds so if they really well in java, then UDF is the best way to approch this functionality otherwise do some Karate with standard functions.

Lastly, I've read some weblogs (like mail adapter etc.,) the way explains the concept is very impressive, New XI developers like me are waiting for more weblogs from people like you. So When can we Expect??!!

Cheers.,

Esha

Former Member
0 Kudos

Hi Esha,

Thanks a zillion for the appreciation.:). We really need it to keep going. :). You were talking about the mail adapter article right? Lets take the discussion offline. Could you please mail me at prashanth.azharuddin@wipro.com?

cheers,

Prashanth

Former Member
0 Kudos

Hey Esha,

Can you please show diagrammatically how it can be achieved for company name

less than 80 check using format num, substring and endswith, length.

Thanks

Former Member
0 Kudos

Hi Advait,

In this case, what will be the UDF and last index ( ) ?

If you can paste the code here, it would be good. And what are the parameters we need to specify inside lastindex( )?

Thanks a lot

Former Member
0 Kudos

Hi Deno,

You would require a UDF to do this.Write a UDF for the logic, and use if then else for your mapping.

cheers,

Prashanth