- MIGO在前台点击校验、保存时校验数据,BADI增强:MB_MIGO_BADI,抬头的数据可以通过指针获取,也可以通过参考标准对象去调用方法获取;通过调用标准方法去获取在check_header里面可以获取所有行数据,在check_item里面可以获取单行数据。
- if_ex_mb_migo_badi~check_header 获取行项目数据
FIELD-SYMBOLS: <fs_kernel_class> TYPE any.
DATA: lv_ref_kernel TYPE REF TO object,
lt_item TYPE goitem_t.
ASSIGN ('(SAPLMIGO)LCL_MIGO_GLOBALS=>KERNEL') TO <fs_kernel_class>.
lv_ref_kernel ?= <fs_kernel_class>.
* 获取MIGO中的行项目数据
CALL METHOD lv_ref_kernel->('GET_PT_GOITEM')
IMPORTING
e_pt_goitem = lt_item.
IF lines( lt_item ) GT 400.
ls_bapiret-type = 'E'.
ls_bapiret-id = '00'.
ls_bapiret-number = '001'.
ls_bapiret-message_v1 = '采购订单直销库不允许超过400行入库!'.
APPEND ls_bapiret TO et_bapiret2.
ENDIF.
- if_ex_mb_migo_badi~check_item
获取抬头/行项目数据
DATA: lo_migo TYPE REF TO object.
DATA: ls_item TYPE goitem,
ls_head TYPE gohead,
lv_action TYPE goaction,
lv_refdoc TYPE refdoc.
DATA:ls_return TYPE bapiret2.
TRY.
ASSIGN ('(SAPLMIGO)LCL_MIGO_GLOBALS=>KERNEL') TO FIELD-SYMBOL(<fs_object>).
lo_migo ?= <fs_object>.
CALL METHOD lo_migo->('LINE_GET')
EXPORTING
i_line = CONV syst_tabix( i_line_id )
i_dependent_tables = abap_true
IMPORTING
es_goitem = ls_item.
CALL METHOD lo_migo->('HEADER_GET')
IMPORTING
e_gohead = ls_head.
lv_action = lo_migo->('S_CONTROL-ACTION').
lv_refdoc = lo_migo->('S_CONTROL-REFDOC').
CATCH cx_sy_dyn_call_error INTO DATA(lo_exc).
ENDTRY.