VALIDATION
校验(VALIDATION)
DATA:
lt_rot TYPE ztca90_i_work_orders,
lt_messages TYPE zers_tt_msg,
ls_msg TYPE symsg,
lv_msg_lifetime TYPE i.
IF eo_message IS NOT BOUND.
eo_message = /bobf/cl_frw_factory=>get_message( ).
ENDIF.
io_read->retrieve(
EXPORTING
iv_node = is_ctx-node_key
it_key = it_key
IMPORTING
et_data = lt_rot ).
LOOP AT lt_rot INTO DATA(ls_rot).
"业务分组
IF ls_rot-business_group IS INITIAL.
DATA(lv_error) = 'X'.
APPEND VALUE #( refkey = ls_rot-key
msgty = /bobf/cm_frw=>co_severity_error
msgid = 'ZERS_MSG'
msgno = '001'
msgv1 = '业务分组'
attribute = 'BUSINESS_GROUP' ) TO lt_messages.
ENDIF.
ENDLOOP.
*消息的显示方式
IF is_ctx-val_time = 'CHECK'.
"Validation fired during any action(Check, Save).
lv_msg_lifetime = /bobf/cm_frw=>co_lifetime_transition.
ELSE.
"Validation fired during any updation.
lv_msg_lifetime = /bobf/cm_frw=>co_lifetime_state.
ENDIF.
LOOP AT lt_messages INTO DATA(ls_message).
MOVE-CORRESPONDING ls_message TO ls_msg.
IF ls_message-attribute IS NOT INITIAL.
eo_message->add_message(
EXPORTING
is_msg = ls_msg
iv_node = is_ctx-node_key
iv_key = ls_message-refkey
iv_attribute = ls_message-attribute
iv_lifetime = lv_msg_lifetime ).
ELSE.
eo_message->add_message(
EXPORTING
is_msg = ls_msg
iv_node = is_ctx-node_key
iv_key = ls_message-refkey
iv_lifetime = lv_msg_lifetime ).
ENDIF.
ENDLOOP.
*--Return the failed draft key
IF line_exists( lt_messages[ msgty = /bobf/cm_frw=>co_severity_error ] ).
et_failed_key = it_key.
ENDIF.
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Hblog!