Webdynproforabap入门教程
- 格式:ppt
- 大小:934.00 KB
- 文档页数:25
WebDynpro for ABAP 简单ALV实例创建一个简单的ALV实例。
先看一下效果。
下面是创建步骤:先创建一个Web Dynpro组件。
添加ALV组件在COMPONENTCONTROLLER 的Properties中添加ALV组件。
在View中添加两个控件,一个Button一个ViewContainerUIElement。
设置VCU_ALV设置Button的Text和事件onAction。
添加Context页面加载时绑定ALV控件DATA: dyn_node TYPE REF TO if_wd_context_node.dyn_node = wd_context->get_child_node( name = 'LT_MARA' ). DATA: lo_interfacecontroller type ref to iwci_salv_wd_table.lo_interfacecontroller = wd_this->wd_cpifc_alv( ).lo_interfacecontroller->set_data( dyn_node ).点击Search按钮时显示数据。
DATA lo_nd_lt_mara TYPE REF TO if_wd_context_node.DATA lt_lt_mara TYPE wd_this->Elements_lt_mara.* navigate from <CONTEXT> to <LT_MARA> via lead selectionlo_nd_lt_mara = wd_context->get_child_node( name = wd_this->wdctx_lt_mara ).* @TODO handle non existant child* IF lo_nd_lt_mara IS INITIAL.* ENDIF.** @TODO compute values** e.g. call a model function*SELECT * INTO TABLE lt_lt_mara FROM MARA UP TO 50 ROWS.lo_nd_lt_mara->bind_table( new_items = lt_lt_mara set_initial_elements = abap_true ). 然后保存激活各项。
WEB DYNPRO FOR ABAP01 1. 创建第一个web dynpro for abap的程序,效果如下:在界面上输出VIEW1
2. 创建一个web dynpro component(组件)
输入名称和描述等信息,这里定义窗口为MAIN、第一个试图为VIEW1
3. 创建完成之后可以看到对应的组件和接口,双击VIEW1点击“修改”按钮进行编辑
可以使用拖拽方法在界面上创建元素,这里使用INSERT ELEMENT方法
在界面上创建一个TEXT_VIEW元素
修改property中的text,改为view1
4. 创建一个web dynpro application
输入application名称和描述
创建完成之后保存,我们可以获得一个url地址
5. 打开游览器,输入刚才的url地址,输入gui的账号、密码和客户端
登陆后就可以看到我们创建的web页面了。
一、需求Tabtrip每一个tab上有关闭按纽.点击其,可以隐掉该tab。
结果如图1所示:图1二、实现1,在view中画出来控件tabstrip,然后点右键insert tab 四次出现四个tab。
2,在context中定义四个wdy_boolean 变量,分别为t1,t2,t3,t4.3,对四个tab控件的属性进行填写.4,点击tab属性visible的binding按钮,让其分别于context的变量进行绑定。
5,填写tabstrip属性,其中事件onClose的栏位中写一个on_close方法,6,双击on_close,进入代码编辑器,代码如下:method ONACTIONON_CLOSE .data: lo_Node type ref to If_Wd_Context_Node,lo_Elem type ref to If_Wd_Context_Element,ls_context type wd_this->element_ENABLE,lw_name type string.lw_name = wdevent->GET_string( 'TAB' ).* nodelo_Node = wd_Context->get_Child_Node( Name = 'ENABLE' ).* get attributelo_Node->get_Static_Attributes( importing Static_Attributes = ls_context ).IF lw_name cs'TAB '.clear:ls_context-T1.ELSEIF lw_name cs'TAB_1'.clear:ls_context-T2.ELSEIF lw_name cs'TAB_2'.clear:ls_context-T3.ELSEIF lw_name cs'TAB_3'.clear:ls_context-T4.ENDIF.* bind structurelo_Node->bind_structure( new_item = ls_context SET_INITIAL_ELEMENTS = abap_true ).endmethod.method WDDOINIT .data: lo_Node type ref to If_Wd_Context_Node,lo_Elem type ref to If_Wd_Context_Element,ls_context type wd_this->element_ENABLE.* nodelo_Node = wd_Context->get_Child_Node( Name = 'ENABLE' ).* get attributelo_Node->get_Static_Attributes( importing Static_Attributes = ls_co ntext ).ls_context-T1 = abap_true.ls_context-T2 = abap_true.ls_context-T3 = abap_true.ls_context-T4 = abap_true.* bind structurelo_Node->bind_structure( new_item = ls_context SET_INITIAL_ELEMENTS = abap_true ).endmethod.8,激活程序。
Getting started with web dynpro for abap一功能:初始界面点continue按钮到如下界面点back返回二.实现:1.创建web dynpro名字叫做zlh_tutorial.2.创建start view。
3.在start view 的layout表中添加label 和input。
4.在label的属性中添加如下:5.添加一个按钮,text属性设置为continue,添加onaction事件。
6.在inbound plugs表中添加如下:7.创建main node如下:8.创建name attribute。
9.将input值和name绑定:10.创建result view ,添加text1 类型为textview,button text属性为back。
11.在result view的context中添加如下node 和attribute:12将text1的text属性和name绑定13.在button中添加事件back。
14.在inbound plugs中添加如下:15在COMPONENTCONTROLLER中添加main node和name attribute,将start view中的main 和COMPONENTCONTROLLER中的main绑定。
16.在result的WDDOMODIFYVIEW中添加以下代码:method WDDOMODIFYVIEW.DATA lo_nd_main TYPE REF TO if_wd_context_node.DATA lo_el_main TYPE REF TO if_wd_context_element.DATA ls_main TYPE wd_this->Element_main.DATA lv_name TYPE wd_this->Element_main-name.* navigate from <CONTEXT> to <MAIN> via lead selectionlo_nd_main = wd_context->get_child_node( name = wd_this->wdctx_main ).* @TODO handle non existant child* IF lo_nd_main IS INITIAL.* ENDIF.* get element via lead selectionlo_el_main = lo_nd_main->get_element( ).* @TODO handle not set lead selectionIF lo_el_main IS INITIAL.ENDIF.* get single attributelo_el_main->get_attribute(EXPORTINGname = `NAME`IMPORTINGvalue = lv_name ).concatenate'welcome to wda,' lv_name into lv_nameseparated by space.lo_el_main->set_attribute(exportingname = 'Name'value = lv_name).endmethod.17.在ONACTIONBACK 中添加以下代码:method ONACTIONBACK .DATA lo_nd_main TYPE REF TO if_wd_context_node.DATA lo_el_main TYPE REF TO if_wd_context_element.DATA ls_main TYPE wd_this->Element_main.DATA lv_name TYPE wd_this->Element_main-name.* navigate from <CONTEXT> to <MAIN> via lead selectionlo_nd_main = wd_context->get_child_node( name = wd_this->wdctx_ma in ).* @TODO handle non existant child* IF lo_nd_main IS INITIAL.* ENDIF.* get element via lead selectionlo_el_main = lo_nd_main->get_element( ). * @TODO handle not set lead selection IF lo_el_main IS INITIAL.ENDIF.* get single attributelo_el_main->get_attribute(EXPORTINGname = `NAME`IMPORTINGvalue = lv_name ).CLEAR LV_NAME.lo_el_main->set_attribute(exportingname = 'Name'value = lv_name).wd_this->fire_tostart_plg().endmethod.18. 将result和start view拖到窗口。
一、WebDynpro For ABAP 基础
本节中主要记录WebDynpro For ABAP的基础操作.如各种UI Elment的使用,Context的使用等.
本节所涉及知识,主要集中于标准教材NET310.
案例一:WebDynpro环境准备
一:需求
如果我们的SAP没有与Portal进行集成,那么需要我们进行相关的配置,这样才能访问我们的WD Application.
特别是我们自己随便找了一个SAP开发机,我们又无法通过WD自动生成的URL进行访问写成的WD,这时候,我们就需要配置WebDynpro浏览环境
如下面的例子:
使用该URL进行访问:
当我们配置完成后,我们可以访问该WD Application了.
二.实现
1. 原理
SAP Notes: 1088717
https://websmp230.sap-
ag.de/sap(bD16aCZjPTAwMQ==)/bc/bsp/spn/sapnotes/index2.htm?numm=1088717
2. 操作: 激活Service
Transaction Code:SICF
默认,执行F8:
然后对应上的原理,进行激活相关的service:星号表示激活该节点下的所有服务。
2. 操作: 添加local hosts
文件路径: C:\WINDOWS\system32\drivers\etc
对上面的文件以notepad打开:
追加一行: 9.121.12.117
Note
# 上面一行中,前面的IP是你的SAP服务器的IP,如果是本机,可以试成127.0.0.1 ; 这里我的系统是:
# 后面一行,是你假想的一个域名格式。
ABAP-BSP调用Webdynpro页面
1、BSP调用WebDynpro页面实例
目的:在BSP(BUSINESS SERVER PAGES)程序中调用WebDynpro页面。
说明:在实现该实例前,需先熟悉WebDynpro 程序的开发。
涉及内容:
1.1 SE80 BSP程序调用WebDynpro页面
1.1.1 BSP页面添加按钮元素
1、T-CODE:SE80进入“对象导航“界面,程序类型选择“业务服务器页面应用程序”(英文:BusinessServerPages Application),然后在程序名处输入程序名,找到业务功能对应的视图,如图1.1.1-1:
图1.1.1-1
说明:
a、本练习对采购订单进行更改。
2、找到要添加WebDynpro页面的BSP视图页面,然后双击进入页面代码中,并将代码更改为可编辑状态,如图1.1.1-2:
图1.1.1-2
3、在BSP页面需要添加按钮的位置处添加按钮代码,如图1.1.1-3:
图1.1.1-3
说明:
a、代码如下:。