cancel
Showing results for 
Search instead for 
Did you mean: 

To split the input string based on condition in mapping SAP PI 7.5

ramu_g4
Participant
0 Kudos

Hi Experts,

My requirement is to split the input string if it is more than 35 characters, then populate the first 35 to one target field & rest of characters to second target field. Else if length is less than 35 characters then populate the input string to first target field.

Please suggest whether we require UDF or can be done using functions in graphical mapping.

Thanks,

Ramu.

Accepted Solutions (0)

Answers (3)

Answers (3)

peter_karg
Explorer

Hi Ramu,

I would do the same mapping as Liz for the first part. For a longer string you need a second substring also. On our PO 7.4 the substring function works only if your string has same or more characters needed for the substring function. To avoid problems I add always a constant with blanks and add later a trim function.

Regards

Peter

Liz_
Product and Topic Expert
Product and Topic Expert

Hi Ramu,

You can simply use the function of If and substring("", 0, 35) to fulfill your requirement. I just tested in my local PI system, the result is as expected. Please check the following screen of the mapping design:

If anything unclear, get back to me.

Best Regards,

Liz

ramu_g4
Participant
0 Kudos

Hi Liz,

Thank you for your snippet:)

But what if the input field is NULL value? How to handle NULL values in input field here?

Thanks,

Nithin.

Liz_
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Nithin,

It depends on you. How do you want to treat this?

1. there must be error, if you input NULL by design.

2. but you also can do a check, if the input field is null, you set a constant value to it, and there will be no mapping error.

Best Regards,

Liz

dhivakar
Participant
0 Kudos

Hi Ramu,

Since you have to split the strings to two output fields if the length is greater than 35. you should go ahead with an UDF.

Because for the standard substring functions you need the length of the complete string.

eg: first target field will have 0..35 second target field should be passed with string starting from 36 till end. we don't know the complete length in this case.

Refer the attached Screenshots for the solution.

Mapwith Default function will avoid error in mapping as it will pass even the NULL value as empty field.targetfield1.jpgtargetfield2.jpgudf.jpg

Regards,

Dhivakar.