webdynpro MESSGAE

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

webdynpro MESSGAE

时间: 2024-11-15 16:46:42

webdynpro MESSGAE的相关文章

webdynpro 下拉列表控件

现在界面上添加下拉列表的控件DropDownByKey 在context中创建新的node,和属性DP 返回界面,绑定DP到控件DropDownByKey的SelectedKey 初始方法中代码如下: *下拉菜单 DATA lo_nd_drop TYPE REF TO if_wd_context_node. DATA lo_el_drop TYPE REF TO if_wd_context_element. DATA ls_drop TYPE wd_this->Element_drop. dat

SAP配置webdynpro完全手册

在sap下进行webdynpro开发的需要进行的配置有如下: 1.Internet Communication Manager 确认ICM中提供的HTTP/HTTPS运行正常. Tcode: SMICM -> Display service. ICM在SAP系统中应用中起着很重要的角色,HTTP请求到达ICM后,由ICM将HTTP请求转发到相应的Work process中,它还可以控制HTTP 对象的缓存等. 2. Internet Communication Framework (ICF) I

webdynpro的select_option示例

需求,输入航线代码和航线编号区间,查询记录存在表中显示,并不是alv显示 1.使用组件WDR_SELECT_OPTIONS. 2.在组件控制器中加入以下组件 3.在视图属性中也添加该组件 4.创建节点 5.控件设计 6.窗口下的视图中嵌套这个视图 7.设计视图初始化方法WDDOINIT method WDDOINIT . DATA lo_cmp_usage TYPE REF TO if_wd_component_usage. lo_cmp_usage = wd_this->wd_cpuse_se

To upload an excel file using WebDynpro Application.

Scenario:To upload an excel file using WebDynpro Application. Procedure: 1.       Go to transaction SE80. 2.        Select "WebDynpro Comp./Intf" from the list. 3.       Create a new WebDynpro component by the name ZEXCEL_UPLOAD. 4.       Double

ABAP webdynpro的view navigation和WebUI的view navigation

虽然ABAP webdynpro已经不是SAP未来主流的UX技术,但是在很多老的模块里使用还是很广泛. 在[SAP help]里有关于这个应用的详细介绍: 而ABAP webdynpro的技术很多地方实现都和WebUI非常类似. 下图是ABAP webdynpro的navigate方法,实际操作是delegate到view的view manager: WebUI类似: Webdynprode navigate方法是把和navigation相关的数据填到一个line structure里,再ins

使用Mybatis-Generator自动生成Dao、Model、Mapping相关文件

Mybatis属于半自动ORM,在使用这个框架中,工作量最大的就是书写Mapping的映射文件,由于手动书写很容易出错,我们可以利用Mybatis-Generator来帮我们自动生成文件. 1.相关文件 1.在G盘新建一个文件夹,命名:generator(或者其他盘其他名字也可以,之所以用这个,是为了copy下面代码后,不用再做修改路径) 2.准备需要的jar包:mybatis-generator-core-1.3.2.jar.MySQL-connector-Java-5.1.34.jar(忽略

Log4J使用

Log4J是Apache的一个开放源码的项目.通过使用Log4J.程序猿能够控制日志信息输送的目的地.包含控制台.文件.GUI组件和NT事件记录器,也能够控制每一条日志的输出格式,或通过定义每一条日志信息的级别,更加仔细地控制日志的生成过程.以下的代码是一个样例: //Log4J public void log4jDemo() { Logger logger = Logger.getLogger(Test.class); FileReader fr = null; try { fr = new

使用Mybatis-Generator自动生成Dao、Model、Mapping相关文件(转)

出处:http://www.cnblogs.com/lichenwei/p/4145696.html Mybatis属于半自动ORM,在使用这个框架中,工作量最大的就是书写Mapping的映射文件,由于手动书写很容易出错,我们可以利用Mybatis-Generator来帮我们自动生成文件. 1.相关文件 关于Mybatis-Generator的下载可以到这个地址:https://github.com/mybatis/generator/releases 由于我使用的是Mysql数据库,这里需要在

Android中的Handler

当我们在处理下载或是其他需要长时间执行的任务时,如果直接把处理函数放在Activity的OnCreate或是OnStart中,会导致执行过程中整个Activity无响应,如果时间过长,程序就会挂掉.Handler就是把这些功能放到一个当初的线程里执行,与Activity互不影响. 一.Handler的定义:  Handler主要接收子线程发送的数据, 并用此数据配合主线程更新UI,用来跟UI主线程交互用.比如可以用handler发送一个message,然后在handler的线程中来接收.处理该消