Courseiva

C_CPI Integration Suite Development Practice Question

An integration developer is using a Groovy script step in an integration flow to modify the message body. The script needs to read a header named 'CustomerID' and set a new header named 'CustomerType' based on its value. Which code snippet correctly accomplishes this in SAP Cloud Integration?

⚠ Common exam trap

The trap here is mixing up headers and properties in the message API, as both have similar getter and setter methods but serve different purposes in the integration flow.

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

✓

def customerId = message.getHeaders().get("CustomerID"); message.setHeader("CustomerType", customerId == "VIP" ? "Premium" : "Standard");

In a Groovy script step, message headers are accessed via message.getHeaders() and set via message.setHeader(). The correct snippet reads the CustomerID header and sets the CustomerType header using a conditional expression. Using properties or the message body would not meet the requirement of reading a header and setting a header.

Answer analysis

Option-by-option breakdown

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

  • ✗

    def customerId = message.getBody(String.class); message.setHeader("CustomerType", customerId == "VIP" ? "Premium" : "Standard");

    Why it's wrong here

    This snippet reads the message body as a String, not the CustomerID header. It then sets the CustomerType header based on the body content, which is unrelated to the header value and would produce incorrect results for the intended logic.

  • ✗

    def customerId = message.getProperty("CustomerID"); message.setProperty("CustomerType", customerId == "VIP" ? "Premium" : "Standard");

    Why it's wrong here

    This snippet uses getProperty and setProperty, which operate on exchange properties, not message headers. The requirement is to read a header and set a header, so using properties would not achieve the desired outcome and would likely result in null values.

  • ✗

    def customerId = message.getHeaders().get("CustomerID"); message.setProperty("CustomerType", customerId == "VIP" ? "Premium" : "Standard");

    Why it's wrong here

    This snippet correctly reads the CustomerID header but then sets a property instead of a header. The requirement is to set a header named CustomerType, so using setProperty would place the value in the exchange properties, not the headers, failing the requirement.

  • ✓

    def customerId = message.getHeaders().get("CustomerID"); message.setHeader("CustomerType", customerId == "VIP" ? "Premium" : "Standard");

    Why this is correct

    This snippet uses the message API to retrieve the CustomerID header and then sets a new CustomerType header based on a conditional expression. It correctly accesses the headers and modifies the message headers, which is the intended way to manipulate headers in a Groovy script step.

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.