ERPClimb logoERPClimb

SAP ABAP Modularization Interview Questions

Modularization comes up in SAP ABAP interviews because it is one of the few areas where an interviewer can tell, in two questions, whether you have worked with the process or only read about it.

Learn how to structure ABAP code using FORM routines, function modules, methods, includes, classes and reusable service design.

This page carries 17 reviewed SAP ABAP modularization interview questions, each with a complete written answer and no sign-in required. The set breaks down into 3 foundational, 10 mid-level and 4 advanced questions, so you can start at the top for a first interview or skip ahead to the scenario-based items for a senior round.

The fastest way to use this page is to read the question, answer it yourself, and only then read the answer. The gap between your version and the written one is your actual revision list for modularization.

17 Modularization questions with answers

easyModularization

1. What is a Function Module and when is it required?

A Function Module is a reusable procedure in a function group with typed parameters. It is required for RFC/BAPI calls, tRFC/qRFC integration and update task processing. For pure in-system logic prefer global classes.
easyModularization

2. A customer validation rule was written as a local class in one report. Now two other programs need it. What do you do?

A local class is visible only in its program, so reusing it means copying it — which leads to divergent versions. I would move it to a global class in SE24 (for example ZCL_CUSTOMER_VALIDATOR) with a clear public method, typed parameters and a class-based exception for failures. The steps: create the global class, move the code and its tests (local test classes), adapt the original report to call the global class, verify with the same test data, then have the other two programs use it. I keep only the public API public and everything else private so the class can evolve. Local classes remain fine for helpers that are truly specific to one report, such as the report's output handling.
easyModularization

3. When should you use a subroutine (FORM), a function module, and a method?

Subroutines (FORM/PERFORM) are legacy, local to the program, and should be avoided in new code. Function modules are RFC-capable, remotely callable, part of a function group with shared global data, good for stable public APIs and remote enablement. Methods on classes/interfaces are the modern default – strongly typed, testable, support inheritance and interfaces.
mediumModularization

4. Report crashes because a FORM reads an uninitialised global variable. How do you prevent it?

Move the logic into a class method that only sees IMPORTING/EXPORTING parameters. If refactoring is not possible immediately, add explicit CLEAR statements at method entry and use pragma checks (##NEEDED, ##NO_TEXT) so unused globals are visible.
mediumModularization

5. Customer validation exists separately in three reports and one OData service. How do you move it into a class-based design?

I would design a class with a single responsibility — ZCL_CUSTOMER_VALIDATOR — with a public method VALIDATE( iv_kunnr ) that returns messages or raises ZCX_CUSTOMER_ERROR. Instance vs static: I prefer instance methods and a constructor that receives dependencies (a DAO for KNA1/KNVV reads), so tests can inject fakes. Then I compare the four copies to find differences and agree the correct rules with the business. I implement them once, write ABAP Unit tests for valid, blocked and missing customers, and replace each copy with a call. Errors are mapped per consumer: messages in a report, BAPIRET2 or exceptions for OData. Afterwards a where-used list of the class shows all consumers.
mediumModularization

6. The same delivery-block rule is coded separately in a report, a user exit and an OData service, and they now give different results. How do you fix this?

The root cause is duplicated business logic. I would create one reusable unit that owns the rule — a global service class such as ZCL_DELIVERY_BLOCK_SERVICE with a method like CHECK_BLOCK( is_order ) returning the block reason, or a function module in older systems. The three consumers then only call it. First I agree the correct rule with the functional team and document it, then implement it once with unit tests for the key cases. Database access sits behind a DAO interface so the rule can be tested. I replace the copies one by one, regression-testing each channel. After that, any change to the rule is done in one place, and a where-used list shows all consumers.
mediumModularization

7. A pricing routine uses several global variables and CHANGING parameters, and nobody knows which values it changes. How do you clean up its interface?

Hidden side effects through globals make code unpredictable and untestable. I would first list what the routine reads and writes. Then I define a clear interface: inputs as IMPORTING (passed by value if they are small or must not change), results as EXPORTING or, if there is one result, RETURNING in a functional method so it can be used in expressions. CHANGING only when a structure really must be both read and updated in place. I convert the routine into a method, pass everything it needs through parameters, and remove global access step by step. Regression tests compare prices before and after with the same data. The result is a routine whose signature documents its behaviour.
mediumModularization

8. A delivery user exit in MV50AFZ1 contains several FORM routines sharing global variables, and a change caused wrong values in another FORM. How do you work safely here?

MV50AFZ1 is an SAP include with predefined FORM exits (like USEREXIT_SAVE_DOCUMENT_PREPARE) and the program's global data such as LIKP and XLIPS. Since you cannot change their structure, I keep the code in the FORMs minimal: each exit calls one method or FM with the needed data as parameters and receives results explicitly. Custom global variables shared between FORMs should be avoided; if state is needed, it goes into a class with clear methods. I check which SAP globals each FORM reads and writes, remember that the exit runs for every delivery (so clear local data), and test all affected delivery scenarios. Changes need a modification key only if SAP marks the include as such; the user-exit FORMs themselves are customer-reserved.
mediumModularization

9. You need logic that a report uses, that an external system calls via RFC, and that runs in the update task. Would you use a FORM, a method or a function module?

Each technique has a place. FORM routines are obsolete for new code; they are local to one program and only acceptable for maintaining legacy reports. Methods in global classes are the default for new business logic: typed interfaces, class-based exceptions, visibility, unit tests. But some technical requirements still need function modules: RFC-enabled calls from external systems, update function modules (IN UPDATE TASK), and some framework hooks. So I would put the business logic in a global class and create thin function modules as adapters: an RFC FM that calls the class and maps errors to BAPIRET2, and an update FM for the database write. The report calls the class directly. This gives one implementation and the required technical entry points.
mediumModularization

10. A 6,000-line SD report with everything in START-OF-SELECTION is hard to change. How do you restructure it into maintainable modules?

I would not start with a big-bang rewrite. First I separate the program into its natural blocks: selection screen, data retrieval, processing and output. In a classic report I use TOP, SEL, F01 (FORMs) includes or, better, local classes: a data class (SELECTs), a logic class (rules) and an output routine (ALV). START-OF-SELECTION then only calls these in order. Includes alone only split the text — they do not create interfaces. Real modularization means each unit has typed parameters and no hidden global data. I move one block at a time, run the report with the same variants before and after, and compare the output (or write ABAP Unit tests for the logic class). Shared rules used by other programs go into a global class or function group.
mediumModularization

11. A custom RFC-enabled function module is called by several external systems. What must you consider when changing it?

An RFC FM is a published interface, so compatibility is the first concern. Callers depend on its parameter names, types and behaviour. I can add new optional IMPORTING parameters or new fields at the end of a structure only if the callers tolerate it; I must not rename, remove or retype existing parameters. For bigger changes I create a new version (Z_..._V2) and migrate callers gradually. RFC FMs must pass parameters by value, cannot use CHANGING of generic types or references, and should return errors in a RETURN table (BAPIRET2) rather than raise dumps. I also check the authorization (S_RFC and business authority checks inside the FM), COMMIT handling (the caller or the FM — documented clearly), and test with each consuming system or at least with SE37 test and captured payloads.
mediumModularization

12. A pricing rule was copied into five reports. A defect was fixed in one of them, and the others still produce wrong prices. How do you prevent this happening again?

The immediate fix is to correct the remaining four, but the real fix is structural: one reusable implementation of the rule (a global class method or FM) that all five reports call, so a future fix is made once. To make that safe I add regression protection: ABAP Unit tests for the pricing method covering the defect case, normal cases and edge cases (zero quantity, rounding, currency). The method gets its data through parameters or a DAO interface, so tests do not depend on database contents. I include the tests in the ATC check variant so they run before each transport. With the where-used list I can also find every consumer when the rule changes.
mediumModularization

13. Where would you put business logic that must be reused by a report, a Fiori app and a BAPI?

In a global class with clearly typed methods, so the report, OData service and BAPI wrapper all delegate to it. This preserves single responsibility and makes ABAP Unit testing possible.
hardModularization

14. How do you design a service layer for a large ABAP application?

Separate a domain layer (business rules), a persistence layer (DB reads/writes), an integration layer (BAPIs/RFCs) and a UI layer (reports/Fiori). Use interfaces so the domain depends only on abstractions; provide test doubles for the persistence layer.
hardModularization

15. What is the cost of many small function-module calls in a loop?

Each CALL FUNCTION carries context switching and parameter marshalling overhead. In tight loops, an inline method call is faster; RFC calls are much more expensive and should be batched. Move loop-invariant work outside the loop and pass tables rather than rows.
hardModularization

16. How do you evolve a legacy function group into a service class without breaking callers?

Create a wrapper class that delegates to the FG initially, migrate callers incrementally, add ABAP Unit tests for the class, then move logic into the class one method at a time. Finally reduce FMs to thin shims and delete when unused.
hardModularization

17. Users get a success message after saving a sales-related custom document, but the record is sometimes missing in the database. What could be wrong with the update logic?

This pattern points to asynchronous update processing. If the data is written by an update function module called IN UPDATE TASK, the success message appears when COMMIT WORK is issued, but the update runs later in the update work process. If it fails, the change is rolled back and the user already saw "success". I would check SM13 for terminated update records and ST22 for dumps in the update FM. Typical causes: a runtime error in the update FM, a duplicate key on INSERT, or a missing COMMIT WORK so the update never ran. The fix depends on the cause: correct the update FM, validate data before commit (checks belong before COMMIT, not in the update FM), and use COMMIT WORK AND WAIT when the program must know the result, checking sy-subrc. Update FMs must not issue COMMIT or MESSAGE type E themselves.

Related lesson

Modularization Part 8: Parameter Passing — IMPORTING, EXPORTING, CHANGING and RETURNING

Related topics

Next practice step

Go deeper on this topic