1.15 WDA PLG,Application跳转传参
本实例Outbound Plugs页面跳转传参,URL跳转Application传参。
1.创建Component:Z_TEST_WDA_L6;
2.创建Main View;
Context页签:
创建Context Node:NODE_PARAM;
创建Attribute:CARRID,类型spfli-carrid;
创建Attribute:CONNID,类型spfli-connid;
Layout页签:
创建Toolbar组件,创建Button组件,open new application window,绑定Action:OPEN_NEW;
创建两个INPUT组件,分别绑定NODE_PARAM.CARRID,NODE_PARAM.CONNID;
创建Button组件,search,绑定Action: SEARCH;
Outbound Plugs页签:
创建TO_DETAIL,设置传递参数CARRID,CONNID;
3.Methods页签,Action及Method代码实现;
代码实例:ONACTIONSEARCH,获取页面输入Carrid,Connid,跳转到Detail页面查询数据并显示;
DATA:lo_node TYPE REF TO if_wd_context_node.DATA:lo_element TYPE REF TO if_wd_context_element.DATA:lt_node_param TYPE wd_this->elements_node_param.DATA:ls_node_param TYPE wd_this->element_node_param."获取节点lo_node = wd_context->get_child_node( wd_this->wdctx_node_param ).lo_element = lo_node->get_element( ).lo_element->get_static_attributes(IMPORTINGstatic_attributes = ls_node_param).wd_this->fire_to_detail_plg(carrid = ls_node_param-carridconnid = ls_node_param-connid).
代码实例:ONACTIONOPEN_NEW,通过URL打开新的Application,并传递参数Carrid,Connid;
DATA:lo_node TYPE REF TO if_wd_context_node.DATA:lo_element TYPE REF TO if_wd_context_element.DATA:lt_node_param TYPE wd_this->elements_node_param.DATA:ls_node_param TYPE wd_this->element_node_param.DATA:lv_url TYPE string.DATA:lv_parameter TYPE string.DATA:lo_component TYPE REF TO if_wd_component.DATA:lo_window_manager TYPE REF TO if_wd_window_manager.DATA:lo_window TYPE REF TO if_wd_window."获取节点lo_node = wd_context->get_child_node( wd_this->wdctx_node_param ).lo_element = lo_node->get_element( ).lo_element->get_static_attributes( IMPORTING static_attributes = ls_node_param )."获取application urlcl_wd_utilities=>construct_wd_url(EXPORTINGapplication_name = 'Z_TEST_WDA_L7'IMPORTINGout_absolute_url = lv_url)."添加parameterlv_parameter = ls_node_param-carrid.cl_http_server=>if_http_server~append_field_url(EXPORTINGname = 'CARRID'value = lv_parameterCHANGINGurl = lv_url)."设置参数CLEAR lv_parameter.lv_parameter = ls_node_param-connid.cl_http_server=>if_http_server~append_field_url(EXPORTINGname = 'CONNID'value = lv_parameterCHANGINGurl = lv_url).lo_component = wd_comp_controller->wd_get_api( ).lo_window_manager = lo_component->get_window_manager( ).lo_window = lo_window_manager->create_external_window( url = lv_url ).lo_window->open( ).
4.创建Detail View,显示查询到信息;
Context页签,创建节点NODE_SPFLI,结构和Spfli一致;
Layout页签,创建Table组件,绑定节点NODE_SPFLI;
Inbound Plugs页签:
代码实例:实现通过传入参数获取数据绑定NODE_SPFLI节点;
DATA:lo_node TYPE REF TO if_wd_context_node.DATA:lo_element TYPE REF TO if_wd_context_element.DATA:lt_spfli TYPE wd_this->elements_node_spfli.DATA:ls_spfli TYPE wd_this->element_node_spfli.SELECT * INTO CORRESPONDING FIELDS OF TABLE lt_spfliFROM spfliWHERE carrid = carridAND connid = connid."获取节点lo_node = wd_context->get_child_node( wd_this->wdctx_node_spfli ).lo_node->bind_table( new_items = lt_spfli set_initial_elements = abap_true ).
5.创建Component: Z_TEST_WDA_L7;
创建Main View;
Context页签:创建NODE_SFLIGHT,结构和Sflight一致;
Layout页签:创建Table组件,绑定NODE_SFLIGHT,显示信息;
Methods页签:创建Method,INIT_SFLIGHT;
在View的WDDOINIT方法中调用INIT_SFLIGHT方法;
代码实例:INIT_SFLIGHT,通过Application URL传递参数获取对弈Sflight信息;
主要通过wdr_task=>client_window->
if_wdr_client_info_object~get_parameter方法获取URL中传递参数;
DATA:lo_node TYPE REF TO if_wd_context_node.DATA:lo_element TYPE REF TO if_wd_context_element.DATA:lv_string TYPE string.DATA:lv_carrid TYPE spfli-carrid.DATA:lv_connid TYPE spfli-connid."获取数据DATA:lt_sflight TYPE wd_this->elements_node_sflight.DATA:ls_sflight TYPE wd_this->element_node_sflight."获取节点lo_node = wd_context->get_child_node( wd_this->wdctx_node_sflight )."获取carridlv_string = wdr_task=>client_window->if_wdr_client_info_object~get_parameter( 'CARRID' ).lv_carrid = lv_string."获取connidCLEAR lv_string.lv_string = wdr_task=>client_window->if_wdr_client_info_object~get_parameter( 'CONNID' ).lv_connid = lv_string."查询数据SELECT * INTO CORRESPONDING FIELDS OF TABLE lt_sflightFROM sflightWHERE carrid = lv_carridAND connid = lv_connid."获取节点lo_node->bind_table( new_items = lt_sflight set_initial_elements = abap_true ).