Courseiva

C_CPI Integration Suite Development Practice Question

Refer to the exhibit.

```groovy

import com.sap.gateway.ip.core.customdev.util.Message;
import groovy.json.JsonSlurper;
import groovy.json.JsonBuilder;

def Message processData(Message message) {
    def body = message.getBody(java.lang.String as Class);
    def jsonSlurper = new JsonSlurper();
    def data = jsonSlurper.parseText(body);

data.status = "PROCESSED";

def jsonBuilder = new JsonBuilder(data);

message.setBody(jsonBuilder.toString());

return message;
}

```

A Groovy script shown in the exhibit is executed within an integration flow to update an incoming JSON payload. What is the primary execution behavior and potential runtime risk associated with this script?

⚠ Common exam trap

Candidates often overlook the memory overhead of parsing large JSON strings into memory-resident maps. They assume Groovy scripts are always efficient, failing to account for heap space limits on large payloads.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

The script modifies the payload in-memory by parsing the JSON text, updating a property, and serializing it back to the message body.

The script parses an incoming JSON string into an in-memory map structure, modifies an attribute, and serializes it back into a string using standard Groovy JSON libraries. The primary runtime risk involves handling extremely large JSON payloads, which can cause excessive memory consumption and trigger OutOfMemoryError exceptions on the worker node.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    The script streams the JSON content incrementally using a pull parser, ensuring minimal memory overhead for payloads exceeding 100 megabytes.

    Why it's wrong here

    JsonSlurper.parseText reads the whole body into memory as a map; it is not a streaming pull parser, so large payloads risk heap exhaustion rather than minimal overhead. It tempts because Groovy offers streaming parsers such as JsonSlurper's INDEX_OVERLAY, but this script uses the default in-memory parseText.

  • ✓

    The script modifies the payload in-memory by parsing the JSON text, updating a property, and serializing it back to the message body.

    Why this is correct

    The script correctly reads the message body as a string, instantiates a JsonSlurper to parse the text into a navigable data structure, modifies the status field, and uses JsonBuilder to serialize the updated map back into the outgoing message body.

  • ✗

    The script fails at runtime because the com.sap.gateway.ip.core.customdev.util.Message class does not support the getBody method with a Class parameter.

    Why it's wrong here

    The Message object in SAP Integration Suite fully supports retrieving the body as a specific data type by passing the desired Class parameter. This is a standard and widely utilized pattern for reading message bodies as Strings or InputStreams.

  • ✗

    The script throws a ClassCastException because JsonBuilder cannot serialize modified Groovy maps back into valid JSON string formats.

    Why it's wrong here

    JsonBuilder serialises Groovy maps and lists to JSON strings without error, so no ClassCastException arises from writing the modified map back. It tempts because type mismatches do occur when parsing non-JSON input, but the actual risk here is memory exhaustion from loading the entire payload into a JsonSlurper object.

About these practice questions

One of 218 original C_CPI practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official SAP exam blueprint

This C_CPI practice question is part of Courseiva's free SAP certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the C_CPI exam.