1、  添加辅助类CL_WDR_DEMO_MESSAGES

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

TEXT:

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

webdynpro MESSGAE的更多相关文章

  1. webdynpro

    -------------------------------------------------------------------------------------WebDynpro For A ...

  2. webdynpro 调用应用程序做跳转

    1.是调用指的是调用生成应用程序,非webdynpro组件程序, 如下: 1)调用页面,并传值 METHOD get_zgmtpage . DATA:lw_application_name TYPE ...

  3. Webdynpro ABAP 简单剖析

    众所周知,WEBDYNPRO是今天来SAP主推的一个面向WEB的MVC编程框架,接触过J2EE的朋友都不会对MVC这种设计模式陌生,WEBDYNPRO ABAP的基本设计思路和很多著名的面向互联网的M ...

  4. webdynpro 组件重用 传值问题

    组件zwd1,需要调用组件zwd2的时候,zwd2组件控制器中需要定义一个方法,定义所要传输的参数,并且该方法需要定义为interface方法. 组件zwd1可以通过代码向导调用组件zwd2,的该方法 ...

  5. 进阶:案例三: Upload File using WebDynpro

    1.节点创建,其中DATASOURCE存放uploadfile名称 2.layout布局 3.upload事件代码: method ONACTIONUPLOAD . DATA: lo_Node typ ...

  6. webdynpro 下拉列表控件

    现在界面上添加下拉列表的控件DropDownByKey 在context中创建新的node,和属性DP 返回界面,绑定DP到控件DropDownByKey的SelectedKey 初始方法中代码如下: ...

  7. webdynpro tree控件使用

    1.  首先创建一个TREE控件 2.  在Tree下面创建一个TREE  NODE  TYPE ,node type 是可以继续展开的,而Item type是无法展开的. 3. 创建node.,下面 ...

  8. webdynpro的select_option示例

    需求,输入航线代码和航线编号区间,查询记录存在表中显示,并不是alv显示 1.使用组件WDR_SELECT_OPTIONS. 2.在组件控制器中加入以下组件 3.在视图属性中也添加该组件 4.创建节点 ...

  9. 一个简单的webdynpro的ALV示例

    开发alv的时候需要1.在web dynpro组件下面 的已使用的组件中添加ALV组件 SALV_WD_TABLE 2.在组件控制器的属性下面创建ALV组件SALV_WD_TABLE 3.在视图界面的 ...

随机推荐

  1. [POJ 1521]--Entropy(哈夫曼树)

    题目链接:http://poj.org/problem?id=1521 Entropy Time Limit: 1000MS    Memory Limit: 10000K Description A ...

  2. [Swust OJ 188]--异面空间(读懂题意很重要)

    题目链接:http://acm.swust.edu.cn/problem/188/ Time limit(ms): 1000 Memory limit(kb): 65535   江鸟来到了一个很奇怪的 ...

  3. Javascript DOM 03 表格添加、删除 + 搜索

    获取 tBodies.tHead.tFoot.rows.cells   隔行变色 鼠标移入高亮   添加.删除一行 DOM方法的使用                                   ...

  4. Net FLow Template

    EK  Template : bool bfs(int src, int des){ memset(pre, -, sizeof(pre)); while(!que.empty()) que.pop( ...

  5. Ubuntu 12.04 安装JDK 8和Eclipse

    Ubuntu 12.04 下安装 JDK8 方法一:(缺点是安装时附加openjdk等大量程序并无法去除,长处是安装简单) $ sudo apt-get install eclipse 方法二:(长处 ...

  6. SimpleAdapter

    1.视图 1)主视图 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" x ...

  7. Eclispse 换主题、皮肤、配色,换黑色主题护眼

    链接地址:http://jingyan.baidu.com/article/6c67b1d68c03be2787bb1ed6.html Eclipse写android代码时,默认的文本和框架都是白色, ...

  8. iphone开发,模拟器生成文件路径

    原文链接:http://blog.csdn.net/gf771115/article/details/7722023 Finder---位置----apple(用户名)---application s ...

  9. Ibatis的分页机制的缺陷

    我们知道,Ibatis为我们提供了可以直接实现分页的方法 queryForList(String statementName, Object parameterObject, int skipResu ...

  10. Java之从控制台读入数据

    0 引言    从控制台中读取数据是一个比较常用的功能,在 JDK 5.0 以前的版本中的实现是比较复杂的,需要手工处理系统的输入流.有意思的是,从 JDK 5.0 版本开始,能从控制台中输入数据的方 ...