Open SQL Part 10: Open SQL in Real Reports and Interfaces
Preview · a free account unlocks the full lesson
Put it all together: a complete classic report and an interface extract with selection screen, authorization, efficient reads, joins, FOR ALL ENTRIES, totals, locking-aware updates and a review checklist.
In this lessonShow sectionsHide sections
Visual overview
Explanation
Parts 1 through 9 of this series covered the individual tools; this final part puts them together into a realistic flight occupancy report and a booking extract destined for an external system. A real program follows one consistent flow: selection, authorization, reading (in as few statements as possible), processing in memory, and then output or update.
The read flow looks like this: a selection screen with ranges and validation, as covered in ABAP Core Part 5; an AUTHORITY-CHECK on organizational values, such as the airline, before any reading happens; reading header data with explicit field lists and WHERE conditions; reading dependent data once, using either a JOIN or FOR ALL ENTRIES (with an emptiness check and de-duplication on the driver table); loading lookup and master data into HASHED tables; processing everything in memory using sorted or hashed tables, with no SQL left inside any loop; and finally outputting the result through ALV or a file.
Writing data applies only to custom tables — standard SAP data is always changed through BAPIs or released APIs, never directly. INSERT ztab FROM TABLE gt_new. performs a mass insert, where duplicates either raise an exception or set sy-subrc to 4, depending on whether ACCEPTING DUPLICATE KEYS is used. UPDATE ztab FROM TABLE gt_changed. updates by primary key.
MODIFY ztab FROM TABLE gt_rows. inserts or updates as needed. DELETE ztab FROM TABLE gt_del. or DELETE FROM ztab WHERE …. removes rows. Concurrent changes should be protected with lock objects, using the ENQUEUE_/DEQUEUE_ function modules generated from SE11, and COMMIT WORK should be issued at a consistent point, with ROLLBACK WORK used on error.
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
Interview questions on this topic
Related SAP topics
Referenced SAP objects
Reviewed reference pages for the objects this page mentions.
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.