Skip to content

Lesson 18 Practice — Add Work Notes to the Support Issue BO ​

Your Support Issue application is currently a single-node draft-enabled RAP BO:

text
Issue

Extend it to:

text
Issue
└── Work Notes

A Work Note belongs to exactly one Issue.

The child must participate in:

text
managed behavior
draft
locking
authorization
DCL
projection
OData V4
Fiori Elements
EML

Practice information ​

TimeAbout 3 hours
PrerequisiteLesson 18 guided exercise
RootZR_ISSUE_###
Child active tableZISSNOTE_###
Child CDSZR_ISSUE_NOTE_###
Child draft tableZDISSNOTE_###
Child projectionZC_ISSUE_NOTE_###
EML classZCL_ISSUE_COMP_###

1. Target BO ​

Build:

text
Issue
└── Work Notes

Use:

text
Issue
→ root

Work Note
→ child

Cardinality:

text
Issue 1
→
0..* Work Notes

2. Create Child Persistence ​

Create:

text
ZISSNOTE_###

Required fields:

text
client
note_uuid
issue_uuid
note_no
note_text
note_category
local_last_changed_at

Recommended types:

text
client                → ABAP client type
note_uuid             → SYSUUID_X16
issue_uuid            → SYSUUID_X16
note_no               → NUMC(4)
note_text             → CHAR(255)
note_category         → CHAR(20)
local_last_changed_at → ABP_LOCINST_LASTCHANGE_TSTMPL

Technical key:

text
client + note_uuid

3. Create the Child CDS Entity ​

Create:

text
ZR_ISSUE_NOTE_###

Requirements:

text
define view entity
not root
select from ZISSNOTE_###
@AccessControl.authorizationCheck: #CHECK
association to parent ZR_ISSUE_###

Expose:

text
_Note parent association
NoteUuid
IssueUuid
NoteNo
NoteText
NoteCategory
LocalLastChangedAt

Use a sensible actual association name such as:

text
_Issue

4. Model the To-Parent Association ​

Use the child:

text
IssueUuid

to identify the root Issue key.

The ON condition must cover the complete root key.

Expose the association exactly once in the child select list.


5. Add Composition to the Issue Root ​

Modify:

text
ZR_ISSUE_###

Add:

text
composition [0..*]

to:

text
ZR_ISSUE_NOTE_###

Use an association name such as:

text
_Notes

Expose _Notes in the root select list.


6. Protect Child Reads ​

Create Access Control for:

text
ZR_ISSUE_NOTE_###

Use the parent Issue's:

text
ResponsibleUser

through the to-parent association.

Required read rule:

text
parent ResponsibleUser
=
current user

Do not hard-code a user ID.


Base Behavior ​

7. Create-Enable the Composition ​

In the Issue root behavior add:

text
association _Notes

with:

text
create
with draft

The child must be created through the parent.


8. Add Child Behavior ​

Add another define behavior block in the same base BDEF.

Requirements:

text
persistent table = ZISSNOTE_###
draft table = ZDISSNOTE_###
lock dependent by parent
authorization dependent by parent
ETag master = LocalLastChangedAt
update
delete
managed numbering for NoteUuid
IssueUuid read-only
NoteNo mandatory on create
NoteNo read-only on update
parent association with draft
complete persistence mapping

Do not add normal:

abap
create;

to the child.


9. Generate Child Draft Table ​

Place the cursor on:

text
ZDISSNOTE_###

Use:

text
Ctrl+1

Generate the draft table.

Activate it.

Do not manually maintain the draft administration fields.


10. Activate the Base Composition ​

Activate:

text
ZISSNOTE_###
ZR_ISSUE_NOTE_###
child Access Control
modified ZR_ISSUE_###
ZDISSNOTE_###
modified base BDEF
related behavior artifacts

Do not proceed until the base BO activates cleanly.


EML Composition Challenge ​

11. Create ZCL_ISSUE_COMP_### ​

Implement:

text
IF_OO_ADT_CLASSRUN

Rules:

text
external EML consumer
no IN LOCAL MODE
no direct SQL writes

12. Find an Owned Issue ​

Use a protected read against:

text
ZR_ISSUE_###

Find one Issue owned by the current user.

Use an existing practice Issue if available.

Store its:

text
Uuid

13. Create a Work Note by Association ​

Use:

text
CREATE BY \_Notes

Create:

text
NoteNo       = 0001
NoteText     = Initial troubleshooting note
NoteCategory = TECHNICAL

Do not supply:

text
NoteUuid
IssueUuid

Inspect:

text
MAPPED
FAILED
REPORTED

14. Prove Managed Child Numbering ​

From:

text
MAPPED

retrieve the generated:

text
NoteUuid

associated with your child %cid.

The consumer must not generate the UUID itself.


15. Commit the Child ​

Use:

text
COMMIT ENTITIES

with response handling.

Verify:

text
Work Note persisted
parent Issue unchanged except BO-wide change metadata

16. Read by Association ​

Use EML to read:

text
Issue
BY \_Notes

Request:

text
RESULT
LINK
FAILED

Output the returned Work Notes.


Use your runtime result to identify:

text
source Issue key
→
target Work Note key

Do not infer the relationship from internal-table ordering.


Deep Create Challenge ​

18. Create an Issue and Two Notes Together ​

Create:

text
one new Issue
two Work Notes

inside one:

text
MODIFY ENTITIES

Requirements:

text
root %cid
CREATE BY \_Notes
child %cid_ref
child %target
two child %cid values

Do not split the operation just to obtain the root UUID.


19. Deep Create Evidence ​

Before commit inspect:

text
MAPPED root component
MAPPED note component
FAILED
REPORTED

After commit verify:

text
one Issue
two related Work Notes

Projection Layer ​

20. Create Child Projection ​

Create:

text
ZC_ISSUE_NOTE_###

Requirements:

text
projection on ZR_ISSUE_NOTE_###
#CHECK
metadata extensions enabled
all Work Note fields projected
parent association redirected to ZC_ISSUE_###

Use:

text
redirected to parent

21. Redirect Root Composition ​

Modify:

text
ZC_ISSUE_###

Expose:

text
_Notes

and redirect it to:

text
ZC_ISSUE_NOTE_###

Use:

text
redirected to composition child

22. Protect Projection Child Reads ​

Create Access Control for:

text
ZC_ISSUE_NOTE_###

Inherit access conditions from:

text
ZR_ISSUE_NOTE_###

Do not repeat the same ownership expression manually.


Projection Behavior ​

23. Extend the Root Projection BDEF ​

Expose:

text
_Notes

with:

text
create
with draft

24. Add Child Projection Behavior ​

Add behavior for:

text
ZC_ISSUE_NOTE_###

Expose:

text
use etag
use update
use delete
use association parent with draft

Do not use:

text
use create

for the child.


Service and UI ​

25. Add Work Notes to the Service ​

Modify:

text
ZUI_ISSUE_###

Expose:

text
ZC_ISSUE_NOTE_###

with alias:

text
WorkNotes

Keep the existing OData V4 UI Service Binding.

Reload it after activation.


26. Add the Work Notes Facet ​

Modify the root Issue metadata.

Add a facet:

text
type = #LINEITEM_REFERENCE
targetElement = _Notes
label = Work Notes

Choose a sensible position after the main Issue details.


27. Create Child Metadata ​

Create Metadata Extension for:

text
ZC_ISSUE_NOTE_###

Add line-item metadata for:

text
NoteNo
NoteText
NoteCategory

Fiori Draft Runtime ​

28. Create a Draft Work Note ​

Open an owned Issue.

Choose:

text
Edit

Create one Work Note in the child facet.

Before Save verify:

text
ZISSNOTE_###
→ no new active row

ZDISSNOTE_###
→ draft Work Note exists

29. Save the Composition Tree ​

Choose:

text
Save

Expected:

text
Issue draft activates
Work Note draft activates
active Work Note appears
draft Work Note disappears

30. Discard a Child Modification ​

Edit the Issue again.

Change or delete the Work Note.

Before Save, inspect active and draft state.

Choose:

text
Cancel / Discard

Expected:

text
active Work Note unchanged
draft modification removed

31. Verify the Root Total ETag ​

Capture the Issue root:

text
LastChangedAt

Change and save only a Work Note.

Read:

text
LastChangedAt

again.

Expected:

text
root total ETag changed

Repair Tasks ​

32. Wrong Relationship Type ​

Temporarily reason about replacing:

text
composition

with:

text
association

Restore the composition.

Identify the whole–part semantics that would be lost.


33. Missing To-Parent Association ​

Break the child:

text
association to parent

Run syntax check.

Restore the direct parent relationship.


34. Incorrect Child Create ​

Try to reason about adding:

abap
create;

to the managed child.

Restore the correct model:

text
create through root association

35. Missing Lock Dependency ​

Break:

text
lock dependent by

Repair it.

Identify the actual lock master.


36. Missing Authorization Dependency ​

Break:

text
authorization dependent by

Repair it.

Identify the actual authorization master.


37. Missing Draft Association ​

Remove:

text
with draft

from one side of the behavior relationship.

Restore it.

Explain why active/draft navigation must remain state-consistent.


38. Projection Not Redirected ​

Remove one:

text
redirected to parent

or:

text
redirected to composition child

statement.

Repair the projection hierarchy.


39. Child Missing from Service ​

Remove:

text
WorkNotes

from the Service Definition.

Reload the service binding.

Restore the child exposure.


Submission Checklist ​

40. Checklist ​


41. End-of-Practice Model ​

You should now be able to implement:

text
Issue
  │
  │ composition
  ↓
Work Note

through all RAP layers:

text
persistence
CDS composition
to-parent association
base behavior
create by association
lock dependency
authorization dependency
draft
projection redirection
OData service
Fiori child facet
EML deep create

That is the core pattern for a managed multi-node RAP Business Object.