侯志宇
2014/6/19
具体实现方法可参照WDR_TEST_POPUP_3_BUTTONS
需要特别说明的是:
对话框选择完成后执行的事件是:WDDOAFTERACTION
METHOD WDDOAFTERACTION .
DATA SET TYPE WDR_CONTEXT_ELEMENT_SET.
DATA LO_ND_USERNODE TYPE REF TO IF_WD_CONTEXT_NODE.
DATA LS_ND_USERNODE TYPE REF TO IF_WD_CONTEXT_ELEMENT.
DATA LS_USERNODE TYPE WD_THIS->ELEMENT_USERNODE.
DATA LT_USERNODE TYPE WD_THIS->ELEMENTS_USERNODE.
DATA: E_TYPE TYPE BAPI_MTYPE,
E_MESSG TYPE BAPI_MSG.
DATA: LT_ROLDIST TYPE TABLE OF ZYBT_ROLDIST,
LS_ROLDIST TYPE ZYBT_ROLDIST.
DATA LO_ND_POP TYPE REF TO IF_WD_CONTEXT_NODE.
DATA LO_EL_POP TYPE REF TO IF_WD_CONTEXT_ELEMENT.
DATA LS_POP TYPE WD_THIS->ELEMENT_POP.
***初始化消息
* get message manager
DATA LO_API_CONTROLLER TYPE REF TO IF_WD_CONTROLLER.
DATA LO_MESSAGE_MANAGER TYPE REF TO IF_WD_MESSAGE_MANAGER.
LO_API_CONTROLLER ?= WD_THIS->WD_GET_API( ).
CALL METHOD LO_API_CONTROLLER->GET_MESSAGE_MANAGER
RECEIVING
MESSAGE_MANAGER = LO_MESSAGE_MANAGER.
***取得对话框返回值******
* navigate from <CONTEXT> to <POP> via lead selection
LO_ND_POP = WD_CONTEXT->GET_CHILD_NODE( NAME = WD_THIS->WDCTX_POP ).
* get element via lead selection
LO_EL_POP = LO_ND_POP->GET_ELEMENT( ).
* @TODO handle not set lead selection
IF LO_EL_POP IS INITIAL.
ENDIF.
* get all declared attributes
LO_EL_POP->GET_STATIC_ATTRIBUTES(
IMPORTING
STATIC_ATTRIBUTES = LS_POP ).
******更新用户数据**************
IF LS_POP-BUTTON_PRESSED = 'OK'.
LO_ND_USERNODE = WD_CONTEXT->GET_CHILD_NODE( NAME = WD_THIS->WDCTX_USERNODE ).
*取得多选行项目
CALL METHOD LO_ND_USERNODE->GET_SELECTED_ELEMENTS
RECEIVING
SET = SET.
LOOP AT SET INTO LS_ND_USERNODE.
LS_ND_USERNODE->GET_STATIC_ATTRIBUTES(
IMPORTING
STATIC_ATTRIBUTES = LS_USERNODE ).
* 删除用户数据
MOVE-CORRESPONDING LS_USERNODE TO LS_ROLDIST .
APPEND LS_ROLDIST TO LT_ROLDIST. CLEAR LS_ROLDIST.
ENDLOOP.
CALL FUNCTION 'ZDMS_DELETE_USER'
IMPORTING
E_TYPE = E_TYPE
E_MESSG = E_MESSG
TABLES
LT_ROLDIST = LT_ROLDIST.
IF E_TYPE = 'S'.
****取得用户所以信息
LO_ND_USERNODE->GET_STATIC_ATTRIBUTES_TABLE( IMPORTING TABLE = LT_USERNODE ).
*删除用户
CLEAR LS_ROLDIST.
LOOP AT LT_ROLDIST INTO LS_ROLDIST.
DELETE LT_USERNODE WHERE USER_ID = LS_ROLDIST-USER_ID.
ENDLOOP.
****更新前台展示数据
LO_ND_USERNODE->BIND_TABLE( NEW_ITEMS = LT_USERNODE SET_INITIAL_ELEMENTS = ABAP_TRUE ).
* report message
CALL METHOD LO_MESSAGE_MANAGER->REPORT_SUCCESS
EXPORTING
MESSAGE_TEXT = E_MESSG.
ENDIF.
IF E_TYPE = 'E'.
* report message
CALL METHOD LO_MESSAGE_MANAGER->REPORT_ERROR_MESSAGE
EXPORTING
MESSAGE_TEXT = E_MESSG.
ENDIF.
**初始化确认对话框的值
LS_POP-BUTTON_PRESSED = ''.
* set all declared attributes
LO_EL_POP->SET_STATIC_ATTRIBUTES(
STATIC_ATTRIBUTES = LS_POP ).
ENDIF.