cancel
Showing results for 
Search instead for 
Did you mean: 

Migrating Custom Java base UDF from SAP PO into Groovy Script for graphical Mapping in SAP CPI

04-28-2020 8:29 AM
2367 views 1 comments
0 Likes
SAP Managed Tags
Subscribe

We are presently working in SAP CPI webui. We want to migrate java based UDF from SAP PO into Groovy script of SAP CPI and used it for mapping.

Issue (1)

we can not include custom function using groovy script of the type void() into graphical mapping of SAP CPI.

issue (2)

UDF of SAP PO has input parameters like itemqueue, textqueue & Resultlist in its signature. Does SAP CPI support such kind of parameters of type String[] in graphical mapping ?

-In SAP CPI while saving groovy script in graphical map we get the message as ‘Script has no valid function’. Groovy script can’t contain parameters like itemqueue, textqueue, which are of the type String[].

-In SAP CPI We also can not save groovy script in graphical map which return Boolean value.

-In SAP CPI graphical map, we can use custom function of type String only.


if SAP CPI does not support what is equivalent feature as it is found in SAP PO?

  • Objects in SAP PO: Message mapping -> DELVRY03_to_LoadTenderMotor_EU_INTL in namespace -> urn:otc.i00011.loadtendermotor.psp.com_INTL ( from ESB)
  • (1)Graphical mapping in SAP PO
  • (2)Name of Local UDF à z_OnePerContext
  • (3)Target field in SAP PO à
  • /ns0:LoadTenderMotor/ns0:LoadTenderMotorBody/ns0:LoadTenderMotorDetails/ns0:LoadTenderMotorProductLineItem/ns0:HazardousGoods
  • (4)UDF in signature & its code in SAP PO
  • Signature
  • Code

public void z_OnePerContext(String[] inputQueue, ResultList result, Container container) throws StreamTransformationException{

//write your code here

//write your code here

//write your code here

boolean flag = false;

for(int i =0; i<inputQueue.length;i++)

{

if((inputQueue[i].equals(ResultList.CC)) ||(inputQueue[i].equals("SUPPRESS")))

{

if (flag)

{

result.addValue("constant");

flag = false;

}

result.addValue(ResultList.CC);

}

else if (inputQueue[i].equals("Constant"))

{

flag = true;

}

}

if (flag)

{

result.addValue("Constant");

}

Objects in SAP CPI as below:

Artefact - DELVRY03_to_LoadTenderMotor_EU_INTL_CPTest

Mapping:--> DELVRY03_to_LoadTenderMotor_EU_INTL_CPTest

Target fields :--> /ns1:LoadTenderMotor/ns0:LoadTenderMotorBody/ns0:LoadTenderMotorDetails/ns0:LoadTenderMotorProductLineItem/ns0:HazardousGoods

  • (1)Graphical mapping in SAP CPI
  • (2)Name of converted groovy script
  • (3)Target field in SAP CPI à
  • /ns1:LoadTenderMotor/ns0:LoadTenderMotorBody/ns0:LoadTenderMotorDetails/ns0:LoadTenderMotorProductLineItem/ns0:HazardousGoods
  • (4)Groovy script from SAP CPI: z_OnePerContext

import com.sap.it.api.mapping.*;

// def String customFunc(String arg1, String arg2, String arg3, MappingContext context)

def String z_OnePerContext(String[] inputQueue, ResultList result, Container container, Output output, MappingContext context)

{

boolean flag = false;

for(int i =0; i<inputQueue.length;i++)

{

if((inputQueue[i].equals(ResultList.CC)) ||(inputQueue[i].equals("SUPPRESS")))

{

if (flag)

{

output.addValue("constant");

flag = false;

}

output.addValue(ResultList.CC);

}

else if (inputQueue[i].equals("Constant"))

{

flag = true;

}

}

if (flag)

{

output.addValue("Constant");

}

return "";

}

0 Likes

Accepted Solutions (0)

Answers (1)

Answers (1)

neethuvgowda857
Discoverer
0 Likes

Hi Chveerrao,

Got any solutions for your issues?