RAP Basics Part 9: Behavior Implementation — Handler and Saver Classes
Preview · a free account unlocks the full lesson
Implement RAP business logic in the behavior pool: the ZBP global class, local handler classes (cl abap behavior handler) with FOR VALIDATE, FOR DETERMINE, FOR MODIFY and FOR INSTANCE FEATURES methods, the saver class (cl abap behavior saver), derived types, %tky, failed and reported, and IN LOCAL MODE.
In this lessonShow sectionsHide sections
Visual overview
Explanation
Part 7 declared validations, determinations, and actions; now we implement them. The behavior pool is a global class, such as ZBP_I_TRAVEL, created from the BDEF's quick fix — it's empty by itself, with the actual logic living in local classes under the "Local Types" tab.
One handler class per entity (lhc_travel, inheriting from cl_abap_behavior_handler) holds the validations, determinations, actions, features, and authorization methods, while a single saver class for the business object (lsc_zi_travel, inheriting from cl_abap_behavior_saver) holds the save sequence methods: finalize, check_before_save, save or save_modified, and cleanup. The method signatures here are generated, not typed by hand.
Handler methods come in a few kinds: FOR VALIDATE ON SAVE for validations, which fill failed and reported; FOR DETERMINE ON MODIFY or ON SAVE for determinations, which call MODIFY ENTITIES IN LOCAL MODE; FOR MODIFY ... FOR ACTION for actions, which return a result; and FOR INSTANCE FEATURES or FOR INSTANCE AUTHORIZATION for feature control and authorization checks.
Inside the business object you should always call MODIFY ENTITIES IN LOCAL MODE — without LOCAL MODE, your own internal logic gets subjected to the same feature control and authorization checks that are meant for external consumers, which blocks it.
These methods work with derived types and a set of standard %-components: TABLE FOR READ RESULT zi_travel\travel and TABLE FOR UPDATE are typical derived types, while %tky is the transactional key (including %is_draft), %key is the key alone, %control marks which fields are set, %msg carries a message, and %element identifies which field a message should highlight.
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
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.