webdynpro MESSGAE

1、  添加辅助类CL_WDR_DEMO_MESSAGES

环境,设计的控件有:输入控件,按钮,每个按钮对应一个事件。分别是下面,然后报消息

TEXT:

SUCCESS:

webdynpro MESSGAE
method ONACTIONSUCCESS .
* get message manager
data lo_api_controller     type ref to if_wd_controller.
data lo_message_manager    type ref to if_wd_message_manager.
data: l_text type string.
l_text = wd_Assist->get_text( wd_assist->text1 ).

lo_api_controller ?= wd_This->Wd_Get_Api( ).

CALL METHOD lo_api_controller->GET_MESSAGE_MANAGER
  RECEIVING
    MESSAGE_MANAGER = lo_message_manager
    .

* report message
CALL METHOD lo_message_manager->REPORT_SUCCESS
  EXPORTING
    MESSAGE_TEXT              = l_text   .


endmethod.
webdynpro MESSGAE

WARNING:

webdynpro MESSGAE
method ONACTIONWARNING .
    data: l_text type string.

*   get message manager
  l_text = wd_assist->get_text( wd_assist->text1 ).
  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
      .

*   report message
  CALL METHOD lo_message_manager->REPORT_WARNING
    EXPORTING
      MESSAGE_TEXT              =  l_text.
endmethod.
webdynpro MESSGAE

ERROR:

webdynpro MESSGAE
method ONACTIONERROR .
    data: l_text type string.

*   get message manager
  l_text = wd_assist->get_text( wd_assist->text1 ).
  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
      .

*   report message
  CALL METHOD lo_message_manager->REPORT_ERROR_MESSAGE
    EXPORTING
      MESSAGE_TEXT              = l_text
endmethod.
webdynpro MESSGAE

ERROR关联元素中的数据

webdynpro MESSGAE
method ONACTIONERROR_PAR .
  data: l_text type string,
      l_value type I,
      l_params type wdr_name_value_list,
      l_param type wdr_name_value.

  wd_context->get_attribute( exporting name = INTEGER importing value = l_value ).

  l_text = wd_Assist->get_text( wd_Assist->text2 ).

  l_param-name = P1.
  l_param-value = l_value.
  append l_param to l_params.

* 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
    .

* report message
CALL METHOD lo_message_manager->REPORT_ERROR_MESSAGE
  EXPORTING
    MESSAGE_TEXT              =  l_text
    PARAMS                    =  l_params.
endmethod.
webdynpro MESSGAE

ERROR关联元素

webdynpro MESSGAE
method ONACTIONERROR_LT_1000 .
  data: l_value type I,
        l_text type string.
  DATA lo_el_context TYPE REF TO if_wd_context_element.
  DATA ls_context TYPE wd_this->Element_context.


wd_context->get_attribute( exporting name = INTEGER importing value = l_value ).
IF l_value < 1000.
  lo_el_context = wd_context->get_element( ).
   l_text = wd_Assist->get_text( wd_Assist->text1 ).
*    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
       .

*    report message
   CALL METHOD lo_message_manager->REPORT_ATTRIBUTE_ERROR_MESSAGE
     EXPORTING
       MESSAGE_TEXT              = l_text
       ELEMENT                   = lo_el_context
       ATTRIBUTE_NAME            = INTEGER
       .



ENDIF.
endmethod.
webdynpro MESSGAE

异常消息:

EXCEPTION

 

webdynpro MESSGAE
method ONACTIONERROR_EXCEPTION .
    data: l_exc type ref to cx_wdr_demo_messages.
  create object l_exc.
*   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
      .

*   report message
  CALL METHOD lo_message_manager->REPORT_EXCEPTION
    EXPORTING
      MESSAGE_OBJECT            = l_exc
endmethod.
webdynpro MESSGAE

 

异常关联元素

webdynpro MESSGAE
method ONACTIONATTR_WARN_EXCEPTION .
    data: l_exc     type ref to cx_wdr_demo_messages,
        l_value   type I,
        l_element type ref to if_wd_context_element.
      wd_context->get_attribute( exporting name = INTEGER importing value = l_value ).
  TRY.
     wd_assist->CHECK_VALUE_LT_1000( l_value ).

  CATCH cx_wdr_demo_messages into l_exc.
    l_element = wd_context->get_element( ).
*     get message manager
* 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
    .

* report message
CALL METHOD lo_message_manager->REPORT_ATTRIBUTE_EXCEPTION
  EXPORTING
    MESSAGE_OBJECT            = l_exc
    ELEMENT                   = l_element
    ATTRIBUTE_NAME            =  INTEGER
*    MSG_USER_DATA             =
    MESSAGE_TYPE             = lo_message_manager->CO_TYPE_WARNING
  ENDTRY.
endmethod.
webdynpro MESSGAE

 

webdynpro MESSGAE,布布扣,bubuko.com

webdynpro MESSGAE

上一篇:js选择器 querySelector


下一篇:Raspberry Pi(树莓派)国内软件源