Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
fatihpense
Active Contributor
Both SAP Process Orchestration(PO) and Cloud Integration have the same Graphical Message Mapping runtime. Your knowledge of UDF will transfer to CPI for the most part.

If you already know SAP PI/PO, this post aims to jumpstart writing UDFs in Cloud integration.

Differences



  • It is written Groovy instead of Java

  • You can write all functions in a single script file.

  • Editors and importing classes are different, and I like the developer experience of Cloud Integration more here.


The biggest difference is the missing execution mode.

While SAP PI/PO supports these 3 execution modes:

  1. All values of queue

  2. All values of context

  3. Single value


Cloud Integration(CPI) doesn't support number 1: "All values of queue"


Since you can't get all values in the queue there will be no "context change" in the input.

Examples


Single values


For each field you want to include, add it to the signature of the function like field1 and field2 below.

You can just return the result value.
import com.sap.it.api.mapping.*

def String exampleSingleValue(String field1, String field2, MappingContext context) {
//Your code here

return result;
}

All values of context


For each field you want to include, add it to the signature of the function like field1Array and field2Array below.

You can add values and "suppress" using the output parameter. There is no "return".
import com.sap.it.api.mapping.*

def void exampleAllValuesInContext(String[] field1Array, String[] field2Array, Output output, MappingContext
context) {
//Your code here

output.addValue(result1);
output.addSuppress();
output.addValue(result1);
}

 

 

Checking for context change and suppress


For Cloud Integration(CPI), you can use output.isSuppress(input[index]) for checking suppress.

There is a method for "context change" in the Javadoc documentation. However, since you can't get context changes in the input, it is not useful.
isContextChange(Object value)

Help page SDK API > Script API
Package: com.sap.it.api.mapping
Interface: Output

https://help.sap.com/doc/d47441d304c14a0ab9d3986c1b553a1e/Cloud/en-US/index.html

***

In SAP PI/PO, you would achieve checking context changes like below:
"com.sap.aii.mappingtool.tf7.rt" under "ResultList" Interface
You can use the CC to find context changes in the input array that the function was transferred to, for example: a[index].equals(ResultList.CC)

https://help.sap.com/doc/javadocs_nw75_sps04/7.5.4/en-US/PI/com/sap/aii/mappingtool/tf7/rt/ResultLis...

 

Is "all values of queue" really not supported?


I couldn't find the answer in the online documentation but in the PDF document "Developer's Guide: Managing Integration Content" dated 2015-10-28

It is very clear under "2.3.6.1 Guidelines for Creating Mapping Scripts using Custom Functions"



https://help.sap.com/doc/dd250f2e3c2645a8ae327e935071281e/latest/en-US/DevGuide_ManageIntContent_Ext...

***

There are also related questions in the community:

https://answers.sap.com/questions/13025382/sap-cpi-udf-execution-type-all-values-of-queues.html

https://answers.sap.com/questions/12688576/cpi---custom-udf-for-manage-queues--context-change.html

I conclude that it is not supported.

Still, if there is a way to use "All values of queue" that I'm missing, or if there are any plans to support it in the future, I think friendly colleagues from SAP will let us know.

More useful references


Great posts by Vikas containing reimplementation of UDFNodePool functions and step by step explanation of creating a custom function. If you need to transport UDFs from PI to CPI it can be useful: https://blogs.sap.com/2021/04/25/udfnodepool-functions-for-sap-cpi-with-groovy-scripting/

Examples in the official documentation:
https://help.sap.com/viewer/368c481cd6954bdfa5d0435479fd4eaf/Cloud/en-US/4f2a8c9c588947d7bde463b5959...

Let me know if I missed any good resources.

Thanks for reading!
1 Comment
Labels in this area