ERPClimb logoERPClimb
OOP ABAP
ABAP Developmentbeginner 8 min read

OOP ABAP Part 2: Local Classes vs Global Classes

Preview · a free account unlocks the full lesson

Key takeaway

Know when to write a local class inside a program and when to create a global class in SE24/ADT — visibility, reuse, where-used lists, transport, test classes and the typical classic report structure with a local class.

In this lessonShow sections

Visual overview

OOP ABAP Part 2: Local Classes vs Global Classes — learning sheetFlow: Create report ZOOP_LOCAL with lcl_report (code example) → Create global class ZCL_FLIGHT_UTIL in SE24 with a static method get_carrier_name → Call the global method from the local class and check the where-used list of ZCL_FLIGHT_UTIL. Key ideas: LOCAL CLASSES; GLOBAL CLASSES; HOW TO DECIDE; CLASSIC REPORT STRUCTURE WITH A LOCAL CLASS. Watch out: Copying a local class into several reports creates divergent copies.ERPClimb.com / ABAP / LESSON 2/10 / LEARNING SHEETOOP ABAP Part 2: Local Classes vs Global Classes1 · HOW IT FLOWS1Create report ZOOP_LOCALwith lcl_report (codeexample)2Create global classZCL_FLIGHT_UTIL in SE24with a static method…3Call the global methodfrom the local class andcheck the where-used list…2 · KEY IDEAS EXPLAINEDLocal ClassesDefined in the program source (often in an includelike ZREPORT_CLS).Visible only in that program; cannot be calledfrom outside.Global ClassesCreated in SE24 (form-based or source-codeeditor), SE80 or ADT, names ZCL_…Stored in a class pool; visible in all programs(subject to package rules).How To DecideUsed by more than one program, a BAdI, RFC wrapperor OData service → global.Only used by this report and specific to itsscreen/output → local.Classic Report Structure With A Local…Selection screen in the main program.lcl_report DEFINITION/IMPLEMENTATION in aninclude.3 · REMEMBER · WATCH OUTRememberLocal classes live inside one program (report, function group, classpool) and are visible only there.Global classes are repository objects (SE24 / SE80 / ADT) — reusablesystem-wide, with where-used list and own transport entry.Reusable business logic belongs in global classes; report-specifichelpers can stay local.!Watch outCopying a local class into severalreports creates divergent copies.4 · IN A REAL PROJECTThree reports each had a local class LCL_PRICE_CHECK copied from the first report. A tax rounding fix wasapplied in only one of them, and finance found different totals in month-end reports. The team created globalclass ZCL_PRICE_CHECK, moved the logic and tests into it, and replaced the three local copies with calls. The…Original ERPClimb learning sheet • Verify against your SAP release and edition

Explanation

Part 1 used a local class without dwelling on the choice. This part asks: when is local fine, and when does a class need to be global?

Local classes are defined directly in a program's source, often in an include such as ZREPORT_CLS, and they are visible only within that program — they cannot be called from outside it. Local classes live inside one program and are visible only there.

Typical uses include a report's own application class, often named lcl_report with methods like get_data, process and display, event handlers for ALV, and local test classes. Order matters when defining them: a class's DEFINITION must come before it is used, and CLASS lcl_x DEFINITION DEFERRED lets you reference a class that is only declared later in the source.

Global classes, by contrast, are repository objects created in SE24 (either the form-based editor or the source-code editor), SE80 or ADT, and their names follow the ZCL_… convention. Global classes are reusable system-wide, with their own where-used list and their own transport entry. They are stored in a class pool and are visible to all programs, subject to package visibility rules. They can still contain local helper types, local classes and local test classes within their own includes.

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.