Skip to Content
0
Dec 13, 2022 at 10:48 AM

Groovy array split and extract multiple values SAP CPI

402 Views

Hi Experts,

I am working on the below requirement to split a string multiple times based on \\| & # to extract the multiple values for each each # first position.

Input : [<Action[0bbah]#111#true#01#INR#false>|<DV<Action[f53]#289#true#215.01#USD#false>VD>]|[<Action[a175]#500.0#true#190#INR#false>VD>]

Expected output should be

111- Field1

289-Field2

500-Field3 ....... Field10 max

{

def Input2 = Input1.split("\\|")

def outpt = ""

for (i=0; i<Input2.length; i++)

{

def internalInput = Input2[i].split("#")

for (j=0; j<internalInput.length; j++)

{

if(j==1)

{

return outpt = outpt+""+internalInput[1]

}

}

}

please suggest on how to acheive this.