zoukankan      html  css  js  c++  java
  • web dynpro message(备忘用)

     1     DATA lo_api_controller     TYPE REF TO if_wd_controller.
     2     DATA lo_message_manager    TYPE REF TO if_wd_message_manager.
     3 
     4     lo_api_controller ?= wd_this->wd_get_api( ).
     5     CALL METHOD lo_api_controller->get_message_manager
     6       RECEIVING
     7         message_manager = lo_message_manager.
     8 
     9     DATA lv_ebeln TYPE ebeln.
    10     lv_ebeln = WD_COMP_CONTROLLER->cust_get_if( ).
    11 
    12 
    13     IF lv_ebeln is INITIAL.
    14 
    15 * report message
    16 
    17       CALL METHOD lo_message_manager->REPORT_ERROR_MESSAGE
    18         EXPORTING
    19           message_text              = '请输入必要的字段!'
    20           show_as_popup             = 'X'
    21           cancel_navigation         = 'X'
    22 *        enable_message_navigation = 'X'
    23           .
    24     ENDIF.

    SUCCESS:

    复制代码
    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.
    复制代码

    WARNING:

    复制代码
    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.
    复制代码

    ERROR:

    复制代码
    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.
    复制代码

    ERROR关联元素中的数据

    复制代码
    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.
    复制代码

    ERROR关联元素

    复制代码
    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.
    复制代码

    异常消息:

    EXCEPTION

    复制代码
    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.
    复制代码

    异常关联元素

    复制代码
    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.
    复制代码
  • 相关阅读:
    [哈希][倍增] Jzoj P5856 01串
    [exgcd] Jzoj P5855 吃蛋糕
    [折半搜索][分治][二分] Jzoj P5851 f
    [lca][主席树] Jzoj P5850 e
    [二分][树状数组] Jzoj P5849 d
    [容斥] Jzoj P5843 b
    [前缀和][枚举] Jzoj P5842 a
    [平衡规划][模拟][前缀和] Jzoj P4724 斐波那契
    [spfa] Jzoj P4722 跳楼机
    [模拟] Jzoj P2499 东风谷早苗
  • 原文地址:https://www.cnblogs.com/mingdashu/p/4861527.html
Copyright © 2011-2022 走看看