Skip to Content

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

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.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • May 01 at 05:52 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

    • 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

  • May 02 at 08:14 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • May 02 at 01:15 PM

    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.

    Add comment
    10|10000 characters needed characters exceeded