ERPClimb logoERPClimb
Modularization
ABAP Developmentbeginner 7 min read

Modularization Part 2: FORM Routines — Legacy but Still Important

Preview · a free account unlocks the full lesson

Key takeaway

Read and maintain FORM routines in existing programs: PERFORM and FORM, USING and CHANGING, pass by value vs reference, TABLES parameters, global data side effects — and how to refactor them safely.

In this lessonShow sections

Visual overview

Modularization Part 2: FORM Routines — Legacy but Still Important — learning sheetIn one line: Read and maintain FORM routines in existing programs: PERFORM and FORM, USING and CHANGING, pass by value vs reference, TABLES parameters, global data side effects — and how to refactor them safely.ERPClimb.com / ABAP / LESSON 2/10 / LEARNING SHEETModularization Part 2: FORM Routines — Legacy but StillImportant1 · IN ONE LINERead and maintain FORM routines in existing programs: PERFORM and FORM, USING and CHANGING,pass by value vs reference, TABLES parameters, global data side effects — and how torefactor them safely.2 · KEY IDEAS EXPLAINEDSyntaxParameters are matched by position.Typed parameters (TYPE …) give syntax checks;untyped ones (old code) accept anything — risky.Passing MechanismsUSING p — intended as input, but passed byreference: changing it inside the FORM changes thecaller's variable.USING VALUE(p) — copy; changes stay local.Local DataDATA inside a FORM is local (created at eachcall). STATICS keep their value between calls.External PerformPERFORM form_name IN PROGRAM zother IF FOUND. —calls a FORM of another program. Common in userexits and SAPscript; fragile (no interface check).3 · DO · AVOIDBest practice!Common mistakeType all FORM parameters.Use VALUE( ) for inputs that must not change.Avoid new FORMs; wrap logic in methods.✕Assuming USING parameters are read-onlycopies.✕Untyped FORM parameters.✕TABLES parameters with header lines.4 · IN A REAL PROJECTIn a pricing user exit, a FORM received the net price via USING and "temporarily" multiplied it fora calculation. Because USING passes by reference, the caller's net price was changed too, and some orders werepriced 10% too high until a user noticed a pattern. The fix declared the parameter USING VALUE( ), and the…Original ERPClimb learning sheet • Verify against your SAP release and edition

Explanation

Part 1 of this series introduced modularization units in general; FORM routines are the oldest of these processing units, and even though they're obsolete for new code, you'll still maintain thousands of them across reports, user exits, and print programs, so you need to be able to read, debug, and carefully change them.

The basic syntax is PERFORM calc_free_seats USING gs_flight CHANGING gv_free. to call a routine, matched against FORM calc_free_seats USING us_flight TYPE sflight CHANGING cv_free TYPE i. … ENDFORM. to define it; parameters are matched purely by position. Typed parameters (declared with TYPE …) get checked at syntax time, while untyped parameters, common in older code, accept anything at all, which is risky.

The passing mechanisms matter a great deal here. USING p is intended as input, but is actually passed by reference by default, so changing it inside the FORM also changes the caller's variable. USING VALUE(p) passes a copy instead, so changes stay local to the FORM. CHANGING p is passed by reference and intended for output.

CHANGING VALUE(p) is a copy that gets written back to the caller only when the FORM reaches a normal ENDFORM. TABLES itab is the obsolete way of passing internal tables, using a header line; USING or CHANGING with proper table types should be used instead in any code you touch.

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

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.