ABAP Webdynpro Interface View的用法

简介: ABAP Webdynpro Interface View的用法

If the component usage is not defined at design time, it is not possible to embed an interface view of this component usage into a ViewUIElementContainer of another view. It is also not possible to define a navigation link connecting any outbound plug of an existing view to an inbound plug of this interface view at design time. In this case methods of the Web Dynpro API have to be applied.


I will use the example in the following two blogs to demonstrate the trick.


(1) Step by Step to create UI elements and context node attribute in the runtime

(2) Step by step to use Component usage clone


after you specify the number of rows you want to generate and click the create button, all UI elements and context node attribute will be generated in the runtime. The UI elements marked in blue come from the interface view of another component, and this view embedding logic is also done dynamically in the runtime.

image.pngimage.pngimage.png

Step3

In method GET_VALUE_BY_INDEX, store the component usage of both static and dynamic one into the attribute GT_USAGE_NAME created in step 2.

DATA(lo_static_com_usage) = wd_this->wd_cpuse_zclone_example( ).

 DATA: lo_generic_usage TYPE REF TO if_wd_component_usage,

       lo_interface_control TYPE REF TO ZIWCI_DYNAMICUSAGE.

 READ TABLE wd_this->gt_cmp_usages ASSIGNING FIELD-SYMBOL() INDEX iv_index.

 CASE iv_index.

   WHEN 1.

     IF lo_static_com_usage->has_active_component( ) IS INITIAL.

        lo_static_com_usage->create_component( ).

     ENDIF.

APPEND 'ZCLONE_EXAMPLE' TO wd_this->gt_usage_name.

     lo_generic_usage = lo_static_com_usage.

   WHEN OTHERS.

     READ TABLE wd_this->gt_cmp_usages ASSIGNING FIELD-SYMBOL() INDEX iv_index.

     IF sy-subrc <> 0.

        DATA(lv_usage_name) = 'DYNAMIC_USAGE' && sy-index.

        data(lo_dyn_usage) = lo_static_com_usage->create_comp_usage_of_same_type( name = lv_usage_name ).

        APPEND lo_dyn_usage TO wd_this->gt_cmp_usages.

 APPEND lv_usage_name TO wd_this->gt_usage_name.

     ENDIF.

     IF lo_dyn_usage->has_active_component( ) IS INITIAL.

        lo_dyn_usage->create_component( ).

     ENDIF.

     lo_generic_usage = lo_dyn_usage.

  ENDCASE.

  lo_interface_control ?= lo_generic_usage->get_interface_controller( ).

  rv_output = lo_interface_control->get_field_value( iv_index ).

endmethod.Step4

In method ONACTIONCREATE, now also create separate view container UIElement instance for each component usage. That view container will be used to embed

the interface view exposed by component ZDYNAMICUSAGE. Then we use API prepare_dynamic_navigation to create a navigation link dynamically, from host view in component ZDYNAMIC to the interface view of component ZDYNAMICUSAGE. The component usage name stored in attribute gt_usage_name in step 3 will be used during API call. Finally fire the outbound plug of MAIN view to make the embedded view displayed in UI.

method ONACTIONCREATE .

CONSTANTS: cv_label TYPE string VALUE 'LABEL',

cv_field TYPE string VALUE 'FIELD',

   cv_container TYPE string VALUE 'EMBEDDED',

cv_bind_text TYPE string VALUE 'DYNAMIC.VALUE'.

DATA: lv_count type i,

lo_container type ref to cl_Wd_uielement_container.

wd_context->get_attribute( EXPORTING name = 'NUMBER' IMPORTING value = lv_count ).

CHECK lv_count > 0.

create_context( lv_count ).

DATA(lo_root) = wd_this->mr_view->get_element( 'DYNAMICUI' ).

lo_container ?= lo_root.

lo_container->remove_all_children( ).

DO lv_count TIMES.

data(lv_field_id) = cv_field && sy-index.

data(lv_label_id) = cv_label && sy-index.

data(lv_bind_path) = cv_bind_text && sy-index.

DATA(lo_text_view) = cl_wd_text_view=>new_text_view( id = lv_field_id bind_text = lv_bind_path ).

DATA(lo_label) = cl_wd_label=>new_label( id = lv_label_id label_for = lo_text_view->id text = lv_label_id ).

CL_WD_ROW_HEAD_DATA=>new_row_head_data( element = lo_label ).

cl_wd_row_data=>new_row_data( element = lo_text_view ).

DATA(lv_container_id) = cv_container && sy-index.

data(lo_view_cont) = CL_WD_VIEW_CONTAINER_UIELEMENT=>new_view_container_uielement( id = lv_container_id ).

   CL_WD_ROW_HEAD_DATA=>new_row_head_data( element = lo_view_cont ).

lo_container->add_child( the_child = lo_label ).

lo_container->add_child( the_child = lo_text_view ).

   lo_container->add_child( the_child = lo_view_cont ).

ENDDO.

DATA: lr_api_main_view TYPE REF TO if_wD_view_controller.

lr_api_main_view = wd_this->wd_get_api( ).

DO lv_count TIMES.

 READ TABLE wd_this->gt_usage_name ASSIGNING FIELD-SYMBOL() INDEX sy-index.

DATA(lv_position) = 'MAIN/' && cv_container && sy-index.

lr_api_main_view->prepare_dynamic_navigation(

      source_window_name = 'ZDYNAMIC'

      source_vusage_name = 'MAIN_USAGE_0'

      source_plug_name   = 'VIEW_TO_USAGE'

      target_component_name = 'ZDYNAMICUSAGE'

      target_component_usage =

      target_view_name       = 'ZDYNAMICUSAGE'

      target_plug_name       = 'DEFAULT'

      target_embedding_position = lv_position ).

   wd_this->fire_view_to_usage_plg( ).

ENDDO.

endmethod.

image.png

目录
相关文章
|
19天前
|
数据处理 开发者
ABAP AT NEW 关键字的用法
ABAP AT NEW 关键字的用法
20 0
|
1月前
|
UED
在 ABAP Webdynpro 的 FPM 中控制单独的 UIBB 可编辑性
在 ABAP Webdynpro 的 FPM 中控制单独的 UIBB 可编辑性
30 0
|
1月前
|
存储 自然语言处理 BI
ABAP 关键字 READ TEXTPOOL 的用法介绍
ABAP 关键字 READ TEXTPOOL 的用法介绍
24 0
|
2月前
|
JavaScript 前端开发 数据库
如何在 SAP CRM 里通过 navigation framework 跳转到 ABAP Webdynpro 页面
如何在 SAP CRM 里通过 navigation framework 跳转到 ABAP Webdynpro 页面
21 0
|
7月前
|
SQL 关系型数据库 Unix
SAP ABAP FOR ALL ENTRIES 的用法
SAP ABAP FOR ALL ENTRIES 的用法
48 0
|
6月前
|
数据库
什么是 SAP ABAP CDS view 的 Filtered association?
什么是 SAP ABAP CDS view 的 Filtered association?
33 0
|
23天前
|
数据库 存储 BI
SAP ABAP CDS View 源代码存储的数据库表揭秘和其他相关数据库表介绍试读版
SAP ABAP CDS View 源代码存储的数据库表揭秘和其他相关数据库表介绍试读版
12 0
SAP ABAP CDS View 源代码存储的数据库表揭秘和其他相关数据库表介绍试读版
|
23天前
|
数据库
迈入 SAP CDS View 世界的前置知识 - SAP ABAP 数据库视图介绍试读版
迈入 SAP CDS View 世界的前置知识 - SAP ABAP 数据库视图介绍试读版
10 0
迈入 SAP CDS View 世界的前置知识 - SAP ABAP 数据库视图介绍试读版
|
23天前
|
数据库 SQL 应用服务中间件
SAP ABAP CDS View 和 HANA CDS View 相同点和不同点辨析
SAP ABAP CDS View 和 HANA CDS View 相同点和不同点辨析
20 0
SAP ABAP CDS View 和 HANA CDS View 相同点和不同点辨析
|
1月前
|
SQL Java 数据库
ABAP 7.40 新语法介绍系列之四 - ABAP Table Expression 内表表达式的用法试读版
ABAP 7.40 新语法介绍系列之四 - ABAP Table Expression 内表表达式的用法试读版
18 0

热门文章

最新文章