应用场景
标准化代码中预留客制化部分,保证代码主体完整性,可以在预留增强位置预留两种类型的增强处理,其一为标准增强类型的,增强部分代码属于增加的逻辑,其二对于部分多样化的逻辑,使用优先执行默认逻辑,有增强实施则执行增强实施中的代码逻辑。
步骤
1. 创建增强点(Enhancement Spot)
2. Demo测试
DATA: lo_badi_test TYPE REF TO zbadi_demo_01_a.
TRY.
GET BADI lo_badi_test
FILTERS
mode = 'A'.
CATCH cx_badi_not_implemented.
ENDTRY.
CALL BADI lo_badi_test->check.
CALL BADI lo_badi_test->data_before_save.
CALL BADI lo_badi_test->data_after_save.
BADI实例创建属性-重用实例
DATA: lo_badi_test TYPE REF TO zbadi_demo_01_a.
TRY.
GET BADI lo_badi_test
FILTERS
mode = 'A'.
CATCH cx_badi_not_implemented.
ENDTRY.
CALL BADI lo_badi_test->check.
TRY.
GET BADI lo_badi_test
FILTERS
mode = 'A'.
CATCH cx_badi_not_implemented.
ENDTRY.
CALL BADI lo_badi_test->data_before_save.
CALL BADI lo_badi_test->data_after_save.