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?


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

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 "";
}
Request clarification before answering.
Hi Chveerrao,
Got any solutions for your issues?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 7 | |
| 5 | |
| 5 | |
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 1 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.