Skip to content

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 timeAbout 3 hours
EnvironmentSAP BTP ABAP Trial
Existing tableZISSUE_###
New classZCL_ISSUE_SQL_###
Rows usedTwo
Final table stateCleaned up

Part 1 — Verify yesterday's table ​

Open:

text
ZISSUE_###

Confirm it is active.

Open Data Preview:

text
Alt + F8

If 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_CLASSRUN

Do not copy the Companion solution before attempting the task.


Part 3 — Generate two UUIDs ​

Create:

text
uuid_a
uuid_b

Both must use the X16 UUID API from the guided lesson.

Handle the UUID exception.

If UUID generation fails:

text
output the error
return

Part 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:       EUR

Do not fill:

text
client
RAP administrative fields

Part 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:       EUR

Part 6 — Insert both rows ​

Insert Issue A.

Immediately capture:

text
sy-dbcnt

Insert Issue B.

Immediately capture:

text
sy-dbcnt

Expected:

text
A → 1
B → 1

Output both counts.


Part 7 — Read both rows back ​

Read the two UUIDs.

Display at least:

text
IssueNo
Title
Priority
Status

Prove that two distinct rows exist.


Part 8 — Update only Issue A ​

Change:

text
Issue A Status
O → I

Use:

text
uuid_a

in the WHERE condition.

Immediately capture the updated row count.

Expected:

text
1

Part 9 — Prove Issue B was not changed ​

Read Issue A.

Read Issue B.

Expected:

text
A Status = I
B Status = O

This 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 A

using:

text
uuid_a

Expected row count:

text
1

Part 11 — Prove Issue B still exists ​

Read:

text
uuid_b

after deleting A.

Expected:

text
Issue B still exists
Status = O

If B disappeared, your delete logic was unsafe.


Part 12 — Clean up Issue B ​

Delete only:

text
uuid_b

Capture:

text
sy-dbcnt

Expected:

text
1

Part 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:

OperationExpectedActual
Insert A1
Insert B1
Update A1
Delete A1
Delete B1

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 abstraction

Part 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: 0

Give at least three plausible explanations that do not require changing the SQL syntax.


Optional challenge — Zero-row test ​

Generate a third UUID:

text
uuid_missing

Do not insert it.

Run a targeted update using that UUID.

Expected:

text
sy-dbcnt = 0

Explain 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 ​

ActionShortcut
Open objectCtrl + Shift + A
Content assistCtrl + Space
Quick FixCtrl + 1
Syntax checkCtrl + F2
ActivateCtrl + F3
Run classF9
Database table Data PreviewAlt + F8