cancel
Showing results for 
Search instead for 
Did you mean: 

SAP PI mapping UDF for splitting Description field into multiple targets field

Former Member
0 Kudos

Hi SAP PI expert ,

  Need below help for UDF at Node Level And field level

SAP PI mapping UDF for splitting Description field into multiple targets field

-Description length is Dynamic it can below 60 Char or can be 240 at max target field can hold 70 Chars

1

Node –                                                                                                   - Node 1

Description (140 Char) based on the length – UDF            -              Target Des (70)

                                                                                                                -Node2

                                                                                                                               -Target Des (70)               

2

Node                                                                                                    – Node 1

Description (210 Char) based on the length – UDF            -                     - Target Des (70)

                                                                                                              -Node2

                                                                                                                                -Target Des (70)               

                                                                                                                - Node3

                                                                                                                                -Target Des (70)

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hello,

Check this UDF:

if(!var1[0].equals(""))

{

int len = var1[0].length();

int divide = len/70;

String out = "";

int temp = 0;

if(len%70 == 0)

{

for(int i=0;i<divide;i++)

{

temp = 70*i;

out = var1[0].substring (0+temp,70+temp);

result.addValue(out);

}

}

else

{

for(int j=0;j<divide;j++)

{

temp = 70*j;

out = var1[0].substring (0+temp,70+temp);

result.addValue(out);

}

result.addValue (var1[0].substring (divide*70, len));

}

}

else

result.addSuppress();

Thanks

Amit Srivastava

Former Member
0 Kudos

Hi Amit and Nabendu,

    Yes I used the same UDF its working fine.

Thanks for help

nabendu_sen
Active Contributor
0 Kudos

You are welcome Satnam.

Answers (3)

Answers (3)

nabendu_sen
Active Contributor
0 Kudos

Hi Satnam,

You can use like below code:

String result ="";

if(str.length > 70){

     result = str.subString(0,69);

}

return result;

former_member184789
Active Contributor
0 Kudos

Hi,

You want it such that the source field which contains say 140 characters has to be split into two such that first 70 go into field1 & rest into field 2. You can have a substring function as substring(0,69) for field1 & substring(70,139) for field 2. If the length is dynamic, then what is your criterion for splitting the fields. Suppose if it is 120, then are you dividing it by 2 i.e 60 each or 70 in first & 50 in second. In such cases you will need UDF.Could you please elaborate on the length for splitting.

Former Member
0 Kudos

Please check this:

http://scn.sap.com/thread/3175764

Regards,

Beena