Modularization Part 7: Global Classes vs Local Classes
Preview · a free account unlocks the full lesson
Decide where a class belongs: local classes inside one program vs global classes in the class library (SE24/ADT) — reuse, visibility, testing, transport, naming, and how to promote a local class to a global one.
In this lessonShow sectionsHide sections
Visual overview
Explanation
Part 6 wrote a local class; this part answers the question of where classes should actually live. A local class lives inside a single program — a report, function group, or class include — and only that program can use it, which makes it perfect for structuring a report into pieces like lcl_report, lcl_alv_handler, or lcl_data_access.
Because it's confined to one program, a local class causes no naming pollution in the system, and changes to it affect only that program, but it also can't be reused by anything else.
A global class, by contrast, is created in SE24 (either the form-based or source-code editor) or in ADT, named something like ZCL_... or YCL_..., and lives in the class library, visible system-wide, with its own transport object, documentation, and where-used list — the right shape for a service meant to be used by many programs, such as ZCL_FLIGHT_SERVICE or ZCL_BOOKING_VALIDATOR.
A global class can itself contain local helper classes, in its local types include, and local test classes, in its test classes include.
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.