Java mapping is one of the commonly used mapping types in SAP Process Orchestration.
Essentially, a Java mapping is a special Java class that implements the Java Mapping API (Package com.sap.aii.mapping.api), to process XML documents, use Java API for XML Processing (JAXP), for example. The JAXP supports the Document Object Model (DOM) and the Simple API for XML (SAX). This gives you great flexibility for mapping-programming with Java.
The diagram below depicts how Java mapping works in SAP Process Orchestration.
In SAP Cloud Integration, which is a core capability of SAP Integration Suite, a Java mapping cannot run inside an integration flow directly. The most similar integration flow step (artifact) is a transformation script, either JavaScript or Groovy script.
Unlike the Java mapping in SAP Process Orchestration, the Groovy script can be directly assigned to the SAP Cloud Integration flow, without explicitly compiling to other formats or embedding into other artifacts.
The diagram below depicts how Groovy script works in SAP Cloud Integration.
For example, you can:
In the blog, we will try from a new perspective: Leverage the emerging generative AI to migrate SAP Process Orchestration Java mapping to SAP Cloud Integration Groovy script.
The core of the idea is: Provide the Java mapping code as the raw input, plus integration domain-specific prompts as instruction, to guide the generative AI to produce Groovy code by "translating" existing Java code.
The diagram below depicts the main steps of the solution.
Let us dig into these steps one by one.
Before the generation, you should collect the following artifacts from the SAP Process Orchestration system:
Note: Normally, the Java mapping developer can provide the Java mapping source code directly.
If this is not true for your case, you can export the Java mapping archive from your Process Orchestration system. The exported archive is a Java archive (with extension .jar). This Java archive contains the compiled Java class (with extension .class). You can use a Java decompiler tool such as jd-gui to decompile the Java class file to Java source code
In the context of generative AI, a well-crafted prompt is crucial for obtaining accurate and useful results from the language model.
In our case, the prompts should be crafted with SAP Process Orchestration, Cloud Integration relevant domain knowledge.
For example, the following prompt contains integration relevant context and very specific requirements:
With the Java mapping source code and relevant prompt being prepared, the next step is to send the complete prompt text to the Large Language Model (LLM).
You can do this:
Depending on the AI provider you chose, the quality of the prompt, and the complexity of Java mapping, the quality of the generated Groovy code may vary significantly.
Note: The LLM we used is described in the Disclaimer section.
How can you evaluate the quality of generated Groovy code? Is it correct, both syntactically and logically?
There are different options/aspects to do the evaluation.
For example, you can:
However, a very straightforward way is to run the generated Groovy script into a real integration flow:
Sometimes, the generated code just works perfectly, you don't have to change anything. Sometimes, the generated code has small syntax or logical issues, you need to verify and fix them manually.
Nevertheless, in general, the generated code can be used as a very good starting point for the migration.
The generative AI can help accelerate the migration of SAP Process Orchestration Java mappings.
You can use it as your copilot of the migration.
In the part 2 of this blog series, we will try the idea with a sample Java mapping scenario.
In the blog, we use the terms generative AI and LLM interchangeably.
In theory, the idea is LLM-independent, but at the time of this blog, we only tried the idea with OpenAI's GPT-3.5 and GPT-4 models.
When you invoke the generative AI, you have to send your source code to the AI provider. This implies the business logic is completely exposed to the AI provider, this can lead to security/IP-related issues if the AI provider is not reliable.
So please always keep this in mind, and only use the AI provider you TRUST.
This idea described in the blog is not an SAP officially released feature, SAP will not formally support any implementation of this idea.
The AI-generated content is not predictable, you may get a different response every time even you feed it with the same input, and there is no chance to debug why the response is different.
Generative AI is incredibly good at generating code, but AI-generated code is not always correct, sometimes the generated code has syntax issues, sometimes it has logical issues.
So you cannot use the generated code for production use directly.
Depending on the size of your Java mapping code, the AI token consumption could go beyond the token limitation, this cloud lead to higher costs, and even worse, a low-quality code (the generated code might be truncated due to token limitation).
The most suitable scenario for this idea is: The Java mapping does not have too many dependencies.
If the Java mapping class (which implements the Java Mapping API) itself has too many dependency Java classes, you will have to do the generation not only for the main Java mapping class, but also for its dependency Java classes as well.
This will increase not only the cost of AI token consumption but also the complexity of code integration (combining different codes together).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
12 | |
11 | |
10 | |
9 | |
8 | |
6 | |
6 | |
6 | |
5 | |
5 |