可以实现弹出一个对话框,提供选择数据的功能……
栗子1:
CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'
TYPE-POOLS slis. DATA: selec TYPE slis_selfield, l_exit TYPE c. DATA: lv_repid TYPE sy-repid. lv_repid = sy-repid. CONCATENATE sy-title '檢查異動類型+異動指示碼+特殊庫存是否與ZCO011相同' INTO gv_title. REFRESH gt_msg. CLEAR: gs_msg,gt_msg. SELECT * INTO TABLE @gt_matdoc FROM matdoc WHERE budat BETWEEN @gv_start_date AND @gv_end_date AND bukrs EQ @p_bukrs AND mjahr = @gv_start_date+0(4) AND werks IN @s_werks AND matnr IN @s_matnr AND lgort IN @s_lgort. SELECT * FROM zco011 INTO TABLE gt_zco011. SORT gt_zco011 BY kokrs bwart kzbew sobkz. LOOP AT gt_matdoc. READ TABLE gt_zco011 INTO DATA(ls_zco011) WITH KEY bwart = gt_matdoc-bwart kzbew = gt_matdoc-kzbew sobkz = gt_matdoc-sobkz BINARY SEARCH. IF sy-subrc <> 0. IF gt_matdoc-bwart = '561' OR gt_matdoc-bwart = '562'. "開帳MVT不納入 ELSE. CONCATENATE '異動類型:' gt_matdoc-bwart ',異動指示碼:' gt_matdoc-kzbew ',特殊庫存指示碼:' gt_matdoc-sobkz ',不存在設定檔中' INTO gs_msg-msg. COLLECT gs_msg INTO gt_msg. CLEAR gs_msg. ENDIF. ENDIF. ENDLOOP. LOOP AT gt_msg ASSIGNING FIELD-SYMBOL(<lf_msg>). <lf_msg>-num = sy-tabix. ENDLOOP. IF gt_msg[] IS NOT INITIAL. CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT' EXPORTING i_title = gv_title "'SELECT MATERIAL' i_tabname = 'GT_MSG' i_structure_name = 'SLS_MSGS' i_callback_program = lv_repid **i_callback_user_command = 'USER_COMMAND' IMPORTING es_selfield = selec e_exit = l_exit TABLES t_outtab = gt_msg. * CALL FUNCTION 'SLS_MISC_SHOW_MESSAGE_TAB' * TABLES * p_messages = gt_msg[] * EXCEPTIONS * no_messages_provided = 1 * OTHERS = 2. ELSE. MESSAGE i001(00) WITH '本期:異動類型+異動指示碼+特殊庫存與ZCO011設定一致.'. LEAVE LIST-PROCESSING. ENDIF.
展示效果:
可以实现
栗子2:
CALL FUNCTION 'SLS_MISC_SHOW_MESSAGE_TAB'