Skip to Content
0
Jun 21, 2021 at 09:26 AM

Generate JSON string using Groovy UDF in SAP CPI Mapping

858 Views Last edit Jun 21, 2021 at 04:48 AM 6 rev

Hi Guys,

I am struggling to write a UDF in CPI mapping. My requirement is to get the 3 fields from source xml , combine them in a json string and pass it to the target xml field in JSON

The source xml is as below

<root><job_info><department>IT</department><role>casual</role><title>developer</title></job_info></root>

these fields have to pass as JSON string into customrole_info field

[{“OrgUnit”: “<department1>”, “JobCode”: “<role1>”, “JobTitle”: “<title1>”, }, {“OrgUnit”: “<department2>”, “JobCode”: “<role2>”, “JobTitle”: “<title2>”, }]

Target xml is ,

<role_info><customrole_info></customrole_info></role_info>

any input is much appriciated.

Thanks,

Vijay