ERPClimb logoERPClimb
Modularization
ABAP Developmentintermediate 9 min read

Modularization Part 7: Global Classes vs Local Classes

Preview · a free account unlocks the full lesson

Key takeaway

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 sections

Visual overview

Modularization Part 7: Global Classes vs Local Classes — learning sheetIn one line: 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.ERPClimb.com / ABAP / LESSON 7/10 / LEARNING SHEETModularization Part 7: Global Classes vs Local Classes1 · IN ONE LINEDecide where a class belongs: local classes inside one program vs global classes in theclass library (SE24/ADT) — reuse, visibility, testing, transport, naming, and how to promotea local class to a global one.2 · KEY IDEAS EXPLAINEDLocal ClassesDefined in the program (or its includes).Perfect for structuring a report: lcl_report,lcl_alv_handler, lcl_data_access.Global ClassesCreated in SE24 (form-based or source-code editor)or ADT; name ZCL_… / YCL_….Visible system-wide, have their own transportobject, documentation and where-used list.When To Go GlobalA second program needs the same logic.The logic is a stable service (validation,calculation, data access for a business object).Naming And OrganizationGlobal: ZCL_<AREA>_<PURPOSE>,interfaces ZIF_…, exceptions ZCX_….Local: lcl_, lif_, lcx_, test classes ltc_.3 · DO · AVOIDBest practice!Common mistakeLocal classes for program structure; globalclasses for reusable services.Promote to global when a second consumerappears.Keep global interfaces small and stable;document them.✕Copying local classes between programs insteadof creating a global one.✕Making every helper global without a realsecond consumer.✕No unit tests in global classes.4 · IN A REAL PROJECTThree reports each had a local class with nearly identical "booking validation" logic. A newvalidation rule was added to two of them; the third kept accepting invalid bookings, which surfaced only in anaudit. The team promoted the logic to a global class ZCL_BOOKING_VALIDATOR with unit tests and replaced the…Original ERPClimb learning sheet • Verify against your SAP release and edition

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.

Free account

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

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.