ERPClimb logoERPClimb
EML
RAP / CDS / ODataintermediate 9 min read

EML Part 2: %cid, %cid_ref, MAPPED, FAILED and REPORTED

Preview · a free account unlocks the full lesson

Key takeaway

Master the correlation and response side of EML: %cid and %cid ref for linking new instances, deep creates, MAPPED for final keys, FAILED with %fail-cause, and REPORTED messages — and how to evaluate them correctly.

In this lessonShow sections

Visual overview

EML Part 2: %cid, %cid_ref, MAPPED, FAILED and REPORTED — learning sheetFlow: Run the code example: deep create with two items plus an action on the new request → Print MAPPED to see the keys, then force a failure (omit the description) and print FAILED and REPORTED after COMMIT → Write a reusable method that converts FAILED/REPORTED into a readable log. Key ideas: MAPPED — THE KEYS YOU DID NOT KNOW; FAILED — WHAT DID NOT WORK; REPORTED — WHY; EVALUATE AT THE RIGHT TIME. Watch out: Evaluate responses after MODIFY and after COMMIT.ERPClimb.com / RAP / LESSON 2/5 / LEARNING SHEETEML Part 2: %cid, %cid_ref, MAPPED, FAILED and REPORTED1 · HOW IT FLOWS1Run the code exampledeep create with two items plus anaction on the new request2Print MAPPED to see thekeys, then force afailure (omit the…3Write a reusable methodthat convertsFAILED/REPORTED into a…2 · KEY IDEAS EXPLAINEDMapped — The Keys You Did Not KnowAfter the MODIFY, MAPPED contains one line percreated instance per entity:mapped-purchaserequest (with %cid and the key /…Failed — What Did Not WorkOne component per entity: failed-purchaserequest,failed-item.Each line identifies the instance (%tky, or %cidfor creates) and %fail-cause: not_found,unauthorized, locked, conflict (e.g. ETag)…Reported — WhyMessages per entity (reported-purchaserequest with%tky / %cid and %msg), plus reported-%other forunbound messages.%msg is an object implementingif_abap_behv_message; get the text with%msg->if_message~get_text( ) and the severity…Evaluate At The Right TimeAfter MODIFY: interaction-phase results —authorization, feature control, prechecks, actionfailures, determinations on modify.After COMMIT ENTITIES RESPONSE: save-phase results— validations and on-save determinations. Arequest that passed MODIFY can still fail at…3 · REMEMBER · WATCH OUTRemember%cid names a new instance; %cid_ref refers to it.MAPPED returns new keys; FAILED has %fail-cause; REPORTED hasmessages.Deep create: header + items in one MODIFY.!Watch outEvaluate responses after MODIFY andafter COMMIT.4 · IN A REAL PROJECTA data migration program created purchase request headers in one MODIFY, committed, then tried to find the newheaders by selecting the latest rows from the table to attach items. Under parallel load it attached items tothe wrong headers. Rewriting it as a deep create — header with %cid, items with %cid_ref in the same MODIFY —…Original ERPClimb learning sheet • Verify against your SAP release and edition

Explanation

%cid names a new instance before it has a real key, while %cid_ref is used to refer back to that instance elsewhere in the same statement. After a MODIFY, MAPPED returns the new keys, FAILED carries a %fail-cause for anything that didn't work, and REPORTED carries the messages explaining why. A deep create lets you create a header together with its items in one MODIFY, and responses need to be evaluated both after MODIFY and after COMMIT.

Part 1 introduced the EML statements themselves. When you create several related instances at once, you need a way to refer to things that don't have keys yet, and afterward you need to know exactly what happened to each instance — that's the job of content IDs and the response parameters.

%cid gives a name to something that has no key yet. When you create an instance, its key may be assigned later by the business object — a UUID, a number range, or late numbering — so you can't refer to it by key within the same request. Instead you assign it a content ID, such as %cid = 'REQ1'. The value is your own choice, must be unique within that one request, and only lives for the duration of that request.

%cid_ref lets other operations in the same MODIFY refer back to that new instance. You might write CREATE BY \_Item … %cid_ref = 'REQ1' to create items for the request being created in the same statement — a deep create — or EXECUTE submit FROM VALUE #( ( %cid_ref = 'REQ1' ) ) to run an action on it, or UPDATE … %cid_ref = 'REQ1' to change it again. Each item inside %target also gets its own %cid so its key can later be found in MAPPED.

Free account

Create a free account to keep reading

You have read the opening of this lesson. A free ERPClimb account unlocks the rest of it, every other lesson and topic, and your learning history, so you can pick up exactly where you stopped. No card needed.

  • Full explanation
  • Code example
  • Real project scenario
  • Common mistakes
  • Best practices
  • Interview angle

One tap with Google works too. Every topic keeps its first lesson open to everyone.

Keep exploring

Check before use: lesson examples are educational, not a guarantee of correctness for your SAP edition or release. Sample code has not been executed on your SAP system. Confirm API availability, syntax, authorizations and business impact in an approved development or test environment.