Appearance
Lesson 9 Practice — Prove Safe SQL Writes
In Lesson 8 Practice, you created:
text
ZISSUE_###Today you will prove that you can manipulate it safely from ABAP.
Create:
text
ZCL_ISSUE_SQL_###This is not just a "CRUD checklist."
Your main proof is:
Changing or deleting Issue A must not accidentally affect Issue B.
Practice information
| Expected time | About 3 hours |
| Environment | SAP BTP ABAP Trial |
| Existing table | ZISSUE_### |
| New class | ZCL_ISSUE_SQL_### |
| Rows used | Two |
| Final table state | Cleaned up |
Part 1 — Verify yesterday's table
Open:
text
ZISSUE_###Confirm it is active.
Open Data Preview:
text
Alt + F8If the table contains unrelated rows from earlier experiments, do not delete them.
Your class must operate only on UUIDs generated during its own run.
Part 2 — Create the class
Create:
text
ZCL_ISSUE_SQL_###Implement:
text
IF_OO_ADT_CLASSRUNDo not copy the Companion solution before attempting the task.
Part 3 — Generate two UUIDs
Create:
text
uuid_a
uuid_bBoth must use the X16 UUID API from the guided lesson.
Handle the UUID exception.
If UUID generation fails:
text
output the error
returnPart 4 — Create Issue A
Use VALUE zissue_###.
Required values:
text
IssueNo: 00000001
Title: Cannot publish service
RequesterEmail: student@example.com
Priority: H
Status: O
ReportedOn: current date
EstimatedCost: 75.00
Currency: EURDo not fill:
text
client
RAP administrative fieldsPart 5 — Create Issue B
Use a different UUID.
Suggested values:
text
IssueNo: 00000002
Title: Data preview mismatch
RequesterEmail: student@example.com
Priority: M
Status: O
ReportedOn: current date
EstimatedCost: 40.00
Currency: EURPart 6 — Insert both rows
Insert Issue A.
Immediately capture:
text
sy-dbcntInsert Issue B.
Immediately capture:
text
sy-dbcntExpected:
text
A → 1
B → 1Output both counts.
Part 7 — Read both rows back
Read the two UUIDs.
Display at least:
text
IssueNo
Title
Priority
StatusProve that two distinct rows exist.
Part 8 — Update only Issue A
Change:
text
Issue A Status
O → IUse:
text
uuid_ain the WHERE condition.
Immediately capture the updated row count.
Expected:
text
1Part 9 — Prove Issue B was not changed
Read Issue A.
Read Issue B.
Expected:
text
A Status = I
B Status = OThis is one of the most important outputs in the Practice.
It proves your WHERE condition was selective.
Part 10 — Delete only Issue A
Delete:
text
Issue Ausing:
text
uuid_aExpected row count:
text
1Part 11 — Prove Issue B still exists
Read:
text
uuid_bafter deleting A.
Expected:
text
Issue B still exists
Status = OIf B disappeared, your delete logic was unsafe.
Part 12 — Clean up Issue B
Delete only:
text
uuid_bCapture:
text
sy-dbcntExpected:
text
1Part 13 — Verify final cleanup
Open Data Preview again.
Your two test rows should be gone.
If unrelated rows existed before the exercise, they should still be there.
That distinction matters.
Part 14 — Safety audit
Copy the two statements from your class that can be most destructive:
text
UPDATE ...
DELETE ...For each, write:
text
Target condition:
Rows that can be affected:
Why this is safe:Part 15 — Row-count audit
Record the observed values:
| Operation | Expected | Actual |
|---|---|---|
| Insert A | 1 | |
| Insert B | 1 | |
| Update A | 1 | |
| Delete A | 1 | |
| Delete B | 1 |
If an actual value differs, explain why before submitting.
Part 16 — Client-handling reasoning
Answer:
Why did you not assign the client field?
Why did the WHERE conditions not include client = @sy-mandt?
Does implicit client handling mean every user is authorized to access every row in the client?
Part 17 — Admin-field reasoning
After the INSERT, inspect the RAP administrative fields if useful.
Answer:
Why should you not expect today's direct SQL class to behave like a managed RAP runtime?
Mention at least:
text
administrative fields
behavior rules
transactional abstractionPart 18 — Direct SQL vs future RAP
Complete:
text
Today:
Consumer → __________ → ZISSUE_###
Later:
Consumer → __________ → RAP BO → ZISSUE_###Then list at least four things a future RAP BO can protect or coordinate that direct SQL can bypass.
Part 19 — Certification-style debugging case
A class runs:
abap
UPDATE zissue_###
SET status = 'C'
WHERE uuid = @uuid.
DATA(updated_rows) = sy-dbcnt.Output:
text
Updated rows: 0Give at least three plausible explanations that do not require changing the SQL syntax.
Optional challenge — Zero-row test
Generate a third UUID:
text
uuid_missingDo not insert it.
Run a targeted update using that UUID.
Expected:
text
sy-dbcnt = 0Explain why this is a valid result rather than necessarily an error.
Optional challenge — Improve output
Make your console output clearly show the lifecycle:
text
=== CREATED ===
...
=== AFTER TARGETED UPDATE ===
...
=== AFTER DELETE A ===
...
=== CLEANUP COMPLETE ===Do not change the persistence logic.
Submission checklist
Useful ADT actions
| Action | Shortcut |
|---|---|
| Open object | Ctrl + Shift + A |
| Content assist | Ctrl + Space |
| Quick Fix | Ctrl + 1 |
| Syntax check | Ctrl + F2 |
| Activate | Ctrl + F3 |
| Run class | F9 |
| Database table Data Preview | Alt + F8 |