Now accepting guest editorial from SAP, Oracle, Workday and ServiceNow practitioners.Pitch a guide
The Sign-Off Table

Lesson 5 of 7

Worked example: adding a validation to ZR_CMC_CoreAgreement

11 min

Listen to this lesson

0:00 / 17:46

Maria, Contoso's order-to-cash key user, raised a ticket in SAP Cloud ALM: Great Lakes Fleet Services has two OPEN core return agreements with overlapping validity periods, and returns in the overlap were credited twice. The rule she wants: a customer may not have two OPEN agreements whose validity periods overlap. Kenji creates request CMDK900452 in CMD, adds a task for KENJI_AGT, and starts a Claude Code session on Route A. Every step below has the same shape: the agent proposes or acts, and a person checks the evidence.

The change loop: the agent iterates on edit, activation, tests and ATC; people own the plan, the review and the release.
The Sign-Off Table · thesignofftable.com/academy/sap-aid-203

1. Read before anything changes

Kenji starts in plan mode, so Claude can read but not edit. His prompt: "Read the behavior definition ZR_CMC_CoreAgreement, the behavior pool ZBP_R_CMC_COREAGREEMENT and its test classes. List the validations, determinations and actions with their triggers. Don't propose changes yet." Claude searches with abap_repository_search_object, reads with abap_read_file and answers: validations validateDates and validateCustomer on the agreement, validateDeposit on the item, determinations setInitialStatus and calcTotalDeposit, action closeAgreement, draft enabled, strict mode 2.

Kenji checks that summary against the source in ADT. This isn't ceremony: a summary that invents a validation, or misses one, tells you how much to trust the plan that follows. The read step costs a few minutes and catches most misunderstandings before they become code.

2. Plan, and surface the questions

The planning prompt states the rule, the constraints and the definition of done, and asks for questions rather than assumptions. Claude's plan has five parts: a new validation validateNoOverlap on save, triggered on create and on changes to Customer, ValidFrom and ValidTo; adding it to draft determine action Prepare so draft users see the message before activation, as SAP's draft guidance does for validations; one SELECT for all keys against the interface view ZI_CMC_CoreAgreement, not one SELECT per key; a message from class ZCMC_CORE bound to ValidFrom; and four tests. It also asks two questions: are the period boundaries inclusive, and should other customers' drafts count? Maria answers: inclusive, and only active agreements count.

3 and 4. Edit and activate

Kenji enables the edit file tool in the IDE for this session and leaves abap_edit_file under an ask rule, so he approves each edit after reading it. The first activation fails: Claude wrote CustomerID, a field name that doesn't exist in the BO; the field is Customer. Claude reads the activation error, fixes it and activates again. That is the loop working as designed: activation is a deterministic check, and the error message, not the model's confidence, is the signal.

The second problem doesn't show up in activation. Claude's first version declared the validation but didn't add it to draft determine action Prepare, although its own plan said it would. Activation succeeds either way. Kenji catches it by comparing the edit with the approved plan, line by line. Plans are useful precisely because they give you something to compare against.

5. ABAP Unit

Claude adds a local test class to the behavior pool's test include. For the BO it uses SAP's RAP BO test double framework (cl_botd_txbufdbl_bo_test_env, the transactional buffer double variant), and for the SELECT on ZI_CMC_CoreAgreement an Open SQL test double, so no test depends on data in CMD. Four tests: overlap_is_rejected, adjacent_periods_are_allowed, closed_agreement_is_ignored and same_day_boundary_is_rejected, the last one because Maria said boundaries are inclusive. All existing tests still pass.

Before trusting green bars, Kenji runs the oldest check in testing: he comments out the call inside validateNoOverlap, activates, and reruns the tests. Two tests must go red, and they do. A test that stays green when the behavior is gone proves nothing, and agent-written tests fail this check more often than people expect.

6. ATC

Claude calls abap_run_atc with variant ZCMC_CLOUD_DEV on the changed objects, then abap_atc_get_result. The first run reports a priority 2 performance finding: an earlier draft of the method had a SELECT inside the loop over keys. Claude replaces it with the single SELECT the plan described, reruns ATC, and the result shows no priority 1 or 2 findings. Exemption requests are denied in settings, so the shortcut isn't available even if the model reaches for it.

StepWhat Claude didWhat a person verified
ReadListed validations, determinations, actionsSummary matches the source in ADT
PlanProposed design, tests and two questionsMaria answered the business questions; Kenji approved the design
Edit and activateEdited, fixed CustomerID, reactivatedEach edit approved; plan compared with result (caught Prepare)
ABAP UnitFour new tests with test doubles; all greenTests go red when the validation is removed
ATCFixed SELECT in a loop; no P1/P2Rerun in ADT with ZCMC_CLOUD_DEV before release
DiffExplained every hunk of CMDK900452Diff contains only the BDEF, the pool and its test include
The agent's claims and the human checks, side by side: every row needs both columns.
The Sign-Off Table · thesignofftable.com/academy/sap-aid-203

7 and 8. Diff, pull request and release

Claude calls abap_transport_get_unified_diff for CMDK900452 and explains each hunk. Kenji reads the diff himself, then pushes the changed objects with abapGit to branch cmdk900452-overlap-check and opens a pull request against main using the template from sap-aid-204: ticket, what the agent was asked, what a person verified, ATC and ABAP Unit evidence, out-of-scope objects, session id. Two approvals later, one from the package owner, Kenji releases the request. Luis imports it into CMQ, and Priya's team tests the scenario there with Maria.

What would you do?

Claude reports: "validateNoOverlap added, 4 new tests green, ATC clean." Kenji opens the test class and sees that <code>overlap_is_rejected</code> creates two agreements for different customers and asserts that <code>failed</code> is initial. What should he do?

Key points
  • Read in plan mode and verify the summary; it calibrates your trust in the plan.
  • The plan names the design, the tests and open business questions; people answer them.
  • Activation errors and test results are the signals; compare the result with the approved plan.
  • Prove tests by breaking the behavior: they must go red.
  • Review the unified diff yourself, push to a branch, get two approvals, then a person releases.

Check your understanding · not graded

Lesson check

  1. 1. Why does Kenji start the session in plan mode?

  2. 2. The validation was declared but not added to draft determine action Prepare, and activation succeeded. What caught it?

  3. 3. What is the purpose of commenting out the validation logic and rerunning the tests?

  4. 4. ATC reports a priority 2 finding for a SELECT inside the loop over keys. What is the right agent behavior under Contoso's rules?