PA教材提纲 TAW12-2

Unit1 Adjustment of SAP Standard Software(SAP标准软件修改)

1.1 Adjusting SAP Standard Software(如何修改SAP标准软件)

SAP标准应用的修改可分为三个级别:

  • Personalization: 个性化,通过配置不用开发
  1. Transaction Variants
  • Modification: 修改,可能影响升级
  1. Modification Assistant
  2. User Exit
  • Enhancement: 增强
  1. ABAP Dictionary: Tables, Data Elements, Domains
  2. Customer Exits
  3. Business Transaction Events
  4. Business Add-Ins( Classic )
  5. Business Add-Ins( New )
  6. Explicit Enhancements: Points, Sections
  7. Implicit Enhancements

 

几种修改方式的区别:

  • Customizing(定制配置): you can configure specific business processes and functions for your system based on the implementation Guide ( IMG )
  • Personalization(个性化): do not require development, but which allow field and screen properties to be adapted and simplified
  • Modification(修改): directly change SAP repository objects(可能影响升级,且需要Modification Assistant协助)
  • Enhancement(增强): adapt SAP repository objects without the need to modify them
  • Customer Development(定制开发): create new repository objects in the customer namespace

(注意: Modification、Enhancement、Customer Development会修改代码,所以会使用ABAP Workbench。)

 

只在以下情况下使用修改( modification ):

  • Customizing or personalization does not fulfill your requirements(无法配置)
  • A suitable enhancement option is not available(无法增强)
  • Copying the SAP object to the customer namespace cannot be considered as an option(无法复制标准对象再修改)

 

定制配置( customizing )提供以下功能:

  • A roadmap as a structure plan for implementing and enhancing the SAP System(提供增强的路线图)
  • Tools for making and documenting system settings(记录系统设置)
  • Recommendations for system settings(提供系统设置建议)
  • Customizing projects as a means for controlling the management, editing, and analysis processes of the implementation(控制管理、编辑、分析等实施工作)

 

个性化( personalization )包括以下功能:

  • Screen field properties can be controlled using(个性化屏幕字段): Variant transactions, SET/GET parameters, User-dependent or client-dependent table control settings
  • Personalized menus(个性化菜单)
  • Role-based menus(角色菜单)
  • Favorites(收藏夹)
  • Shortcuts on your desktop(快捷方式)

1.2 Describing Classic Enhancement Types(描述经典增强类型)

ABAP Workbench三级修改结构:

  • Modification: Modification assistant
  1. Executed with the help of user exits
  2. 'Hard-coded' at various points within SAP Repository objects
  • Enhancement: ABAP Dictionary, Program enhancements, Menu enhancements, Screen enhancements
  1. In ABAP programs by using program exits
  2. In a GUI status by using menu exits
  3. On screens, by using screen exits to insert a subscreen in an area that SAP provides
  4. In ABAP Dictionary tables or structures by using table enhancements
  • Customer Development: Calling/Not calling ABAP objects

 

Table Enhancements(表增强,有两种技术):

  • Append Structure: can only belong to one table
  • CL_Include: allowed to be used in multiple tables, the include statement must already exist in the SAP table/structure

 

Program Enhancements(程序增强,有四种技术):

  • Subroutine式的增强User Exit
  • Function module式的增强Customer Exit
  • Function module式的增强BTE ( Business Transaction Event )(事务代码FIBF)
  • Method式的增强BAdI

 

Menu Enhancements(菜单增强,有两种技术):

  • Customer exits
  • Business Add-Ins ( classic and new )

(通过增强获取的菜单,其对应的指令以+开头。)

 

Screen Enhancements(屏幕增强,需要五步实施):

  • Define the subscreen areas
  • Program the corresponding calls in the flow logic
  • Provide the framework for the data transport
  • Include the screen exit in an enhancement ( either a Customer Exit or a Business Add-In )
  • Maintain the documentation

 

New Enhancement Options Offered Through the Enhancement Framework as of SAP NetWeaver 7.0(第四代增强):

  • Implicit enhancement points and options(隐式增强点/项)
  • Explicit enhancement points(显式增强点)
  • Explicit enhancement sections(显式增强区)
  • New BAdIs(新BAdI)

 

Overview of Enhancement Options(隐式增强项概览,可以不通过修改实现以下目的):

  • Additional ( optional ) interface parameters in SAP function modules and SAP methods(额外参数)
  • Additional attributes and methods in SAP classes(额外属性)
  • Preparation and post-processing functions for global SAP methods(事先事后处理)
  • Replacements for global SAP methods(替换方法)

 

Modification(修改):

  • 修改就是直接改SAP的对象
  • 升级后你需要重新修改并适应新版本
  • Modification Assistant可以检修( overhauled )你的修改(4.5A版本以后)

Unit2 Enhancement of Dictionary Elements(字典元素增强)

2.1 Enhancement Tables Using Append Structures and Customizing Includes(用附加结构或定制Include增强表)

Options for Adding Extra Fields to SAP Tables(增加表字段的方法):

  • Append Structure
  1. 不需提前配置: Customers can create an append structure for an SAP table( without the need for SAP preparation )
  2. 多个结构用于同一个表: Multiple append structures can be used in a single SAP table
  3. 可以当普通结构用: Append structures can also be used like normal structures as types in programs
  • Customizing Include
  1. 增强位置已预置: Customizing includes are already integrated into SAP tables by SAP
  2. 可增加字段: Customers add the desired additional fields to the Customizing include
  3. 配合其它增强一起使用: Customizing includes often go hand-in-hand with program exits and screen exits for the processing of any additional fields added

 

使用Append Structures注意事项:

  • 注意表和结构的Enhancement Category属性

    (1) Not classified: 无规定

    (2) Cannot be enhanced: 不能增强

    (3) Can be enhanced( character-type ): 字符型增强

    (4) Can be enhanced( character-type or numeric type ): 支持除深度结构以外的增强

  • 不能给簇表和池表增加Append Structure,但BSEG表例外
  • 如果表内有长字段(即LCHAR或LRAW型字段),则不能使用Append Structure
  • 如果使用Append Structures,则字段命名必须以YY或ZZ开头
  • 系统升级后,数据库中的新增字段会在APPEND字段之后,不过在透明表中,它们在APPEND字段之前

 

使用Customizing Includes注意事项:

  • 所有Customizing Includes都以CI_开头
  • 有些Customizing Includes是SAP enhancement的一部分,需要通过Project Manager(事务代码CMOD)创建project
  • Customizing Includes的字段命名必须以YY或ZZ开头
  • 系统升级后,数据库中的新增字段会在INCLUDE字段之后,不过在透明表中,它们的顺序是正常的
  • 初次创建时,双击Include名称即可
  • Customizing Includes有利于保持数据一致性

2.2 Enhancing Texts of Data Elements(增强数据元素的文本)

定义(用户定制标签或文档):Text enhancements comprise(包含) customer-specific field labels and customer documentation for SAP data elements.

 

用户可以重写字段标签( field label ),比如定义屏幕字段。但要注意,可重写的屏幕字段的Dict. Modified属性值必须为F,该属性的值列表如下:

Value

Function

SPACE

Field label that best fits the field length

1

Short field label

2

Medium field label

3

Long field label

4

Field label for header

V

Variable text transfer from the dictionary ( as SPACE )

F

Fixed ( no text transfer from the dictionary )

 

修改SAP字段标签的步骤:

  1. 事务代码CMOD->Goto->Text Enhancements->Keywords->Change
  2. 如果升级后field label被还原,那么进入CMOD->Goto->Text Enhancements->keywords->Restore
  3. 如果想还原所有field label,请选择Restore SAP Version(注意: 如果还原的字段有BUKRS、MANDT这样的重要字段central fields,请不要在它们被修改时还原)

 

用户可以重写数据元素( data element )的文档( documentation ):

  • 重写的文档可以包含标准文档,故用户在字段上点击F1时,可以同时看到用户定制文档和标准文档
  • 要恢复标准文档,只需删除定制文档即可

 

创建定制文档的步骤:

  1. 事务代码CMOD->Goto->Text Enhancement->Data Elements->New DE Customer Document
  2. 如果选择Original text选项,则会在标准文档后追加定制文档
  3. 如果选择Template选项,则定制文档将覆盖标准文档

Unit3 Customer Exits(用户出口)

3.1 Describing Enhancement Projects(描述增强工程)

The characteristics of an application enhancement are as follows(增强的特性):

  • Each enhancement provides you with a set of preplanned, precisely defined functions预定义
  • The interface for these functions is clearly defined接口明确
  • Customers do not need in-depth knowledge of how to implement SAP applications简单易用
  • Customers do not need to adjust enhancements during an upgrade if SAP have developed new functions适应升级

 

常用事务代码:

  • 定义增强( Enhancements ): SAP通过事务代码SMOD定义出口(程序出口、菜单出口、屏幕出口);
  • 实现增强(Enhancements ): SAP通过事务代码CMOD实现出口;
  • 查找出口的路径Utility->Enhancements。

 

增强( Enhancements )、组件( Components )、出口( Exits )、工程( Projects )的映射关系:

  • 每个增强含有多个组件,每个组件只能属于一个增强,每个增强相当于一个函数组;
  • 每个组件对应某种出口,每个出口相当于一个函数模块( function module );
  • 每个工程可以实现多个增强,每个增强只能属于一个工程。

 

创建增强( Enhancements )的步骤:

  • SAP application programmers plan possible enhancements in an application and define the necessary components
  • The application programmer combines these components in SAP enhancements
  • The programmers document their enhancements in the best possible manner, so that customers can implement the enhancements without having to analyze the program source code or the screen source code
  • ( 注意: 教材课后习题中增加了最后一步Activate the enhancement project )

 

实现增强( Enhancements )的步骤:

  • Create an enhancement project
  1. Run the transaction code CMOD to start the Project Management function
  2. Name your enhancement project
  3. Go to the project attributes and enter a short text that describes the enhancement project
  • Choose the SAP enhancements that you want to use
  • Edit the individual components using the Project Management function
  • Document the entire enhancement project
  • Activate the enhancement project

3.2 Enhancing Programs Using Program Exits(通过程序出口增强程序)

程序出口: allows customers to implement additional logic in SAP standard applications.

程序出口( Program Exits )代码示例:

PROGRAM <program_name>

...

CALL CUSTOMER-FUNCTION '001'

EXPORTING

...

IMPORTING

... .

  1. 调用出口的关键字为CALL CUSTOMER-FUNCTION,出口函数的ID为三位数字
  2. 函数组(即每个Enhancement),名字必然以X开头
  3. 出口函数的名称格式为EXIT_<NAME_OF_CALLING_PROGRAM>_<NNN>

FUNCTION-POOL XAAA.

 

FUNCTION exit_<program_name>_001.

...

INCLUDE zxaaau01.

...

ENDFUNCTION.

 

寻找程序出口( Program Exits )的方法:

  • Search in the source code of the application program(搜索源代码关键字)

    When run a transaction, from the menu, choose System->Status. Double-click the program name to navigate to the source code. Use the Find button to search for the string CALL CUSTOMER-FUNCTION globally in the program.

  • Use global search tools(使用全局搜索工具)

    If you are using the Repository Information System to find suitable enhancements, you can restrict the search by the package, which the enhancement belongs to, by its technical name, and also by its description.

 

实现程序出口( Program Exits )的方法:

  1. Go to transaction CMOD.
  2. Create a Project.
  3. Assign an SAP Enhancement to your Project.
  4. From the initial screen of CMOD, select the Components radio button and then Change to navigate to the enhancement components.
  5. On the Components screen, there will be an entry for Function exit. Double-click the function module name listed next to it to navigate to the Function Builder, and go straight to the Source Code tab.
  6. Double-click the include program name, which is used in the source code.(如果出现警告信息,回车即可。)
  7. Enter the source code.

 

Normal Function Group Structure(普通函数组头文件结构):

SAPLABCD: Program name(注: 这里假设函数组名称为ABCD)

  1. LABCDTOP: Global data
  2. LABCDUXX: All function modules
    1.  
      1. LABCDU01: Function module #01
      2. LABCDU02: Function module #02
  3. LABCDF01: Subroutines

 

Exit Function Group(出口函数组头文件结构):

SAPLXAAA: Program name(注: 这里假设函数组名称为XAAA)

  1. LXAAATOP: Global data
    1. LXAAATAP: Global SAP data
    2. ZXAAATOP: Global customer data
  2. LXAAAUXX: All function modules
    1.  
      1. LXAAAU01: Function module #01

        (2.1.1) ZXAAAU01: Customer source code

      2. LXAAAU02: Function module #02

        (2.2.1) ZXAAAU02: Customer source code

  3. LXAAAF00: SAP source text proposal
  4. LXAAAF01: Subroutines
  5. LXAAAO01: PBO modules
  6. LXAAAI01: PAI modules
  7. LXAAAE01: ABAP events
  8. ZXAAAZZZ: Any other customer objects
    1.  
      1. ZXAAAF01: Subroutines
      2. ZXAAAO01: PBO modules
      3. ZXAAAI01: PAI modules
      4. ZXAAAE01: ABAP events

 

注意:

  • LXAAATOP包含了FUNCTION-POOL声明,不可修改
  • 你不能在LXAAATOP中定义default message class
  • 如果你需要使用message,可以在函数中使用MESSAGE关键字并指定message class
  • ZXAAAUNN头文件可以添加代码,但是不包括subroutines或modules,因为这类头文件都放在FUNCTION里
  • ZXAAAUNN中定义的变量都是局部变量
  • LXAAAFNN作为source text proposal时用于创建text symbols(我们可以在事务代码SMOD的增强中找到Sample Code)
  • 如果我们希望调用屏幕,可以遵循如下例子:
  1. 在ZXAAAU01中写CALL SCREEN 9000 STARTING AT 5 5.
  2. 在ZXAAAO01中写MODULE OUTPUT.
  3. 在ZXAAAI01中写MODULE INPUT.

3.3 Enhancing Menus Using Menu Exits(用菜单出口增强菜单)

菜单出口: allow you to attach additional custom functions to menu options in SAP menus.

  • 增强菜单的function code都以+开头
  • 除非增强被激活,否则这些菜单在GUI status中看不到

 

响应增强菜单的代码示例:

PROGRAM <program_name>.

DATA ok_code LIKE sy-ucomm.

 

*PAI-Module

CASE ok_code.

WHEN 'DISP'.

WHEN '+ABC'.

CALL CUSTOMER-FUNCTION '001'

EXPORTING

<i_variables>

IMPORTING

<e_variables>.

ENDCASE.

 

实现菜单增强的方法:

  • 进入Project Manager,事务代码CMOD
  • 在Components屏幕,双击菜单出口( Menu Exit ),分配菜单描述
  • 实现与之相连的函数出口( Function Exit )
  • 主调程序响应新的function code

3.4 Enhancing Screens Using Screen Exits(通过屏幕出口增强屏幕)

屏幕出口: allow you to use reserved sections of a main screen ( which a technically subscreen areas ) to display additional information or allow the user to enter additional data.

 

普通子屏幕的注意事项:

  • The function code can only be processed via the main screen
  • A subscreen may not have a named OK_CODE field
  • You cannot define GUI statuses for subscreens
  • You cannot control what the next screen will be in the flow logic of the subscreen( again this is done in the main screen )

 

调用普通子屏幕与出口子屏幕代码对比:

普通子屏幕

出口子屏幕

PBO:

PROCESS BEFORE OUTPUT.

MODULE ... .

CALL SUBSCREEN <SUBSCREEN_AREA >

INCLUDING <PRG> <DYNPRO_NO>.

MODULE ... .

PBO:

PROCESS BEFORE OUTPUT.

MODULE ... .

CALL CUSTOMER-SUBSCREEN <SUBSCREEN_AREA>

INCLUDING <PRG> <DYNPRO_NO>.

MODULE ... .

PAI:

PROCESS AFTER INPUT.

MODULE ... .

CALL SUBSCREEN <SUBSCREEN_AREA>.

MODULE user_command_<SCREEN_NO>.

PAI:

PROCESS AFTER INPUT.

MODULE ... .

CALL CUSTOMER-SUBSCREEN <SUBSCREEN_AREA>.

MODULE ... .

  1. 增强函数组的函数不能访问主调程序的全局变量,需要借助程序出口函数获取主屏幕的参数并传给函数组头文件的全局变量,这个函数需要在主调程序的PBO中被CALL
  2. 同样,如果要把出口子屏幕的值传回主调函数,需要另一个程序出口函数,这个函数需要在主调程序的PAI中被CALL
  3. 注意: 传入参数类型若与屏幕字段类型不匹配,则会读不到值,最好通过DDIC或Program导入字段,这样可以确保字段类型匹配

 

实施屏幕出口的过程:

  1. 进入Project Management(事务代码CMOD),在components界面可看到如下信息:
    1. The name of the calling program(主调程序)
    2. The four-digit screen number for the main screen(4位主屏幕编号)
    3. The name of the subscreen area(子屏幕区域名称,跟着函数组程序名、子屏幕编号)
  2. 进入components界面,创建子屏幕

Unit4 Classic Business Add-Ins(经典BAdI)

4.1 Describing an ABAP Objects Interface(描述ABAP对象的接口)

Business Add-Ins: are an object-oriented enhancement technique.

(其它类与接口知识点请参考前面的资料。第100页特别提到,接口不能通过CREATE OBJECT实例化。)

4.2 Describing Classic Business Add-Ins ( BAdIs )(描述经典BAdI)

经典BAdI: 需要至少一个接口( interface )以及一个BAdI adapter class实现接口。

  • 用户需要增强时可以实现接口
  • 一个BAdI可以被实现多次

 

The BAdI components are as follows(BAdI的组建包括):

  • Program enhancements: The interfaces for program enhancements are defined in the form of interface methods in a BAdI.
  • Menu enhancements: Function codes can be defined in a BAdI.
  • Screen enhancements: You can define and implement screen enhancements in a BAdI.

 

The components that must be created when a BAdI is defined are as follows(定义BAdI时需定义的组件):

  • Interface
  • Generated class ( the BAdI adaptor class ) that implements the interface(该类需执行下面的任务):
  1. Filtering: If implementations are created for a filter-dependent BAdI, the BAdI adapter class ensures that only the relevant implementations are called
  2. Control: The BAdI adaptor class calls the active implementations

 

代码示例:

REPORT <sap_program>.

DATA r_var TYPE REF TO <badi-interface>.

CALL METHOD cl_exithandler=>get_instance

CHANGING

Instance = r_var.

 

CALL METHOD r_var->meth_abc

EXPORTING

<i_variables>

IMPORTING

<e_variables>.

  1. Generate class会获取继承接口的类对象
  2. 然后类对象调用接口方法

 

搜索BAdI的方法:

  1. 在主程序搜索CL_EXITHANDLER字符串,找到BAdI定义后,可查看其documentation或实例
  2. 进入Repository Information System(事务代码SE84),选择Enhancements->Business Add-Ins搜索需要的程序
  3. 通过其它Customizing component进行关联搜索

4.3 Explaining Additional Details of Business Add-Ins ( BAdIs )(解释BAdI的细节)

Extendable Filter Types: Filter根据条件进入不同的实例,某些Filter允许增强。可增强的Filter有'Enhanceable'标志,它们可以使用域的value table以外的值进行过滤。

 

可增强Filter使用较为苛刻:

  • The domain is linked to a cross-client value table. The value table has exactly one key field, which has the data element of the filter type as its field type.
  • The domain has a text table with two key fields. A key field has the filter type as its field type, and a key field as a language field. To mark a field as a text field, the field must exist in a table that contains TEXT or TXT as a partial string. In the ABAP Dictionary, the text table must be assigned to the value table.
  • The delivery class of both tables must be E or S.

 

实现filter-dependent BAdI的过程:

  1. Create an implementation by referring to the corresponding Business Add-In definition.
  2. Assign a filter value for the implementation, or choose F4 and select a value from the list of possible entries displayed ( It is possible to define multiple filter values for each implementation ).
  3. Implement the BAdI method ( or methods ) as usual
  4. Activate your implementations

 

定义默认和样本代码( Default and Sample Code ):

  • 默认实例( Default Implementation ): 当没有其它激活的实例时执行,定义BAdI时可创建默认实例
  1. 查看默认实例的路径为Goto->Default Code
  2. 系统自动预创建了默认实例的类,用户可以实现类的方法,自定义默认行为
  • 样本实例( Sample Implementation ): 当实现BAdI方法时作为模板( tamplate )使用
  1. 查看样本实例的路径为Goto->Sample Code
  2. 用户创建实例时可以查看并使用样本代码作为模板

 

Exits、BTE、BAdI性能对比:

 

Customer Exits

Business Transaction Events

Business Add-Ins

Program Exit

YES

YES

YES

Menu Exit

YES

NO

YES

Screen Exit

YES

NO

YES

Append Fields on Screens

YES

NO

YES

Administration Level

YES

NO

YES

Multiple Implementations

NO

YES

YES

Filters

NO

YES

YES

 

Naming Conventions(命名规则):

  • BAdI Definition: <BADI>; Z<BADI>; /.../<BADI>
  • Interface: IF_EX_<BADI>; ZIF_EX_<BADI>; /.../IF_EX_<BADI>
  • Methods: choose any name
  • Generated BAdI class ( adapter class ): CL_EX_<BADI>; ZCL_EX_<BADI>; /.../CL_EX_<BADI>
  • BAdI Implementation: <IMPL>; Z<IMPL>; /.../<IMPL>
  • Implementing Class: CL_IM_<IMPL>; ZCL_IM_<IMPL>; /.../CL_IM_<IMPL>

Unit5 New Business Add-Ins(新BAdI)

5.1 Describing the Change from Classic BAdIs to New BAdIs(描述经典BAdI到新BAdI的变化)

Why SAP Introduced New BAdI Technology(引入新BAdI的原因):

  • To improve performance
  • To implement additional functions
  1. Enhanced filter concept
  2. Option to inherit attributes from sample implementation classes ( selective method redefinition )
  • To integrate into the new Enhancement Framework( together with enhancement points and enhancement sections )

 

SAP NetWeaver 7.0 Enhancement Framework(7.0版本增强架构):

  • Enhancement Spot不管理的:
  1. Implicit enhancement points/options
  • Enhancement Spot管理的:
  1. Explicit enhancement points/options
  2. New BAdIs

(总之,记住一句话: Unlike classic BAdIs, new BAdIs always belong to, and are managed by, enhancement spots.)

 

Classic BAdIs和New BAdIs的对比:

Classic BAdIs:

DATA r_exit TYPE REF TO <BAdI interface>.

 

CALL METHOD cl_exithandler=>get_instance

CHANGING

Instance = r_exit.

 

CALL METHOD r_exit->abc

EXPORTING

...

IMPORTING

... .

New BAdIs:

DATA r_exit TYPE REF TO <BAdI name>.

 

TRY.

GET BADI r_exit.

CATCH cx_badi_not_implemented. "若未找到实例则报此错

...

ENDTRY.

 

TRY.

CALL BADI r_exit->abc.

CATCH cx_badi_initial_reference. "若r_exit为空则报此错

...

ENDTRY.

Classic BAdIs到New BAdIs的转变目的如下:

  • BAdI performance is considerably enhanced by integrating BAdIs in the ABAP programming language through the new language elements GET BADI and CALL BADI.(新BAdI的关键字性能更好)
  • New BAdIs provide considerably more flexibility in the conversion of predefined enhancement options through new properties, such as contexts and more filtering options than BAdIs.(新BAdI支持context和更强的filter)

 

5.2 Using New Business Add-In ( BAdI ) Program Exits(使用新BAdI)

常用事务代码:

  • 事务代码SE18: BAdI definition in the enhancement spot
  • 事务代码SE19: BAdI implementations
  • 事务代码SE84: 可用于搜索BAdIs和enhancement spots

 

New BAdI与Classic BAdI的区别:

  • 不再创建adapter classes,也不需要主程序实例化BAdI,而是运行时系统会在kernel创建BAdI handle,功能与adapter class类似,且会更高效地调用实现的方法
  • reference variable的类型不再是BAdI的接口类型,而直接使用BAdI的类型(可参考上一节的代码)
  • 创建实例和调用方法的关键字不同,新BAdI为GET BADI和CALL BADI
  • New BAdI总是属于某个enhancement spot(事务代码SE84查看)

 

搜索新BAdI出口的方法:

  1. Perform a global search in the program you wish to enhance for GET BADI or CALL BADI(搜索关键字字符串)
  2. Double-click the reference variable used in the GET BADI or CALL BADI statement to navigate to the variable definition(双击引用类型找到BAdI定义)
  3. Double-click the BAdI name to navigate to the display for the corresponding enhancement spot(双击BAdI名称找到enhancement spot)

(另一种方法是在GET BADI处打断点,然后根据引用的类型获取BAdI的名称。)

 

两种特殊的BAdI implementation:

  • 回调类: A BAdI definition can be linked to a fallback class
  • 默认实现: A BAdI implementation can be defined as the default implementation

它们的运行原则如下:

  • 优先运行非默认实现: All non-default implementations are executed
  • 不存在非默认实现时,运行默认实现: The default implementation is only called if no other implementation is executed
  • 无任何实现时,运行回调类: The fallback class is used if nothing has been executed

 

实现New BAdI的方法:

  1. Display the corresponding enhancement spot
  2. Choose Implement Enhancement Spot and create the enhancement implementation.
  3. Specify a name for the enhancement implementation, the BAdI implementation, and the Implementing Class. ( If there is a Sample Class for the BAdI, you can choose to inherit from it or copy it. )
  4. In the Navigation area for the BAdI, double-click the implementing class, then, double-click the method or methods to implement or adjust them
  5. Activate the method and all other related objects, including the enhancement implementation

 

Filter-dependent BAdIs now allow the following(目前带过滤的BAdI允许以下功能):

  • Numeric filters(数字过滤)
  • Implementations with not only single filter values, but also filter conditions using the operators <>, >, <, >=, <=, CP and NP(公式过滤)
  • Multiple filters for one BAdI implementation(多重过滤)

5.3 Using New Business Add-In ( BAdI ) Menu Exits(使用新BAdI菜单增强)

BAdI菜单增强( BAdI Menu Exits ): provide customers with the option to implement additional menu entries on SAP screens, which trigger custom code.

  • Exits of this type can have only one active implementation(只能有一个激活实例);
  • BAdI Menu Exit,在被增强屏幕的GUI STATUS中含有预定义的+开头的function code,以及与function code关联的Program Exit,该Program Exit在屏幕PAI中被调用,只有Program Exit激活时,function code才会显示(故用户不需定义function code但需要实现Program Exit)。

 

代码示例:

DATA r_exit TYPE REF TO <BAdI name>.

 

TRY.

GET BADI r_exit.

CATCH cx_badi_not_implemented.

ENDTRY.

 

*PAI module

CASE ok_code.

WHEN 'DISP'. ...

WHEN 'EDIT'. ...

WHEN '+XXX'.

TRY.

CALL BADI r_exit->abc.

CATCH cx_badi_initial_reference.

ENDTRY.

ENDCASE.

 

5.4 Using New Business Add-In (BAdI) Screen Exits(使用新BAdI屏幕增强)

BAdI屏幕增强( BAdI Screen Exits ): provide customers with the option to display addtional fields or other screen elements on an SAP screen.

  • There can be only one active implementation of a screen exit(只能有一个激活实例);
  • BAdI Screen Exits,在被增强屏幕上预定义了subscreen area,并关联了特定的子屏幕。该子屏幕定义在一个定制函数组( customer function group )中,并在主屏幕的PBO中被指定了(用户看到的子屏幕的Program属性值,其实就是函数组对应的主程序名称)。

 

示例代码:

*PBO of the SAP container screen

GET BADI r_exit.

CALL BADI r_exit->put_data.

CALL METHOD cl_enh_badi_runtime_functions=>get_prog_and_dynp_for_subscr.

CALL SUBSCREEN ... INCLUDING ... .

 

*PAI of the SAP container screen

CALL SUBSCREEN ... .

CALL BADI r_exit->get_data.

 

搜索和使用BAdI屏幕增强的步骤:

  1. On the SAP standard screen, search for a subscreen area ( optional pre-search )(在被增强屏幕上搜索子屏幕区域)
  2. In the SAP standard program, search for the GET BADI command(用户也可以搜索GET_PROG_AND_DYNP_FOR_SUCSCR或CL_ENH_BADI_RUNTIME_FUNCTIONS)(搜索关键字)
  3. Double-click the reference variable used in the GET BADI statement to navigate to the definition of the reference variable(双击引用类型,查看BAdI定义)
  4. To navigate to the enhancement spot to which the BAdI belongs, double-click the BAdI used to type the reference variable(找到enhancement spot以及引用使用的BAdI)
  5. Read the BAdI documentation and perform the subsequent steps for the BAdI implementation(阅读说明文档)
  6. Create the function group, including the subscreen, the TABLES structure ( in the TOP include ), and the corresponding function modules(创建函数组,包括子屏幕和全局变量,以及逻辑函数)
  7. Create an implementation for the enhancement spot and for the BAdI(创建enhancement implementation)
  8. In the BAdI implementation, implement the available program exits ( the PUT and GET methods )(实现PUT和GET函数)
  9. In the BAdI implementation, double-click the available screen exit to implement it(实现屏幕出口)
  10. Specify the subscreen and the master program of the function group ( the name of the master program is the name of the function group with the prefix SAPL )(填写子屏幕名称和函数组主程序名称)
  11. Activate all objects(激活)

5.5 Using New Business Add-Ins ( BAdIs )(使用新BAdI)

定义和使用新BAdI的步骤:

  1. 进入BAdI Builder(事务代码SE18,或路径Tools->ABAP Workbench->Utilities->Business Add-Ins->Definition)
  2. 创建enhancement spot,再创建New BAdI
  3. 在New BAdI界面,点击Interface,定义接口名称、接口方法、方法参数
  4. 激活接口,再激活enhancement spot
  5. 在被增强程序中定义增强点( jump-points ),即跟GET BADI、CALL BADI有关的语句
  6. 如果有filter、菜单增强、屏幕增强,则需要额外的配置
    1. Filter需要定义名称和数据类型
    2. 如果包含菜单增强,则不可定义filter,也不可设置为multiple use,也不能用在switch语句中,但可以包含独立于菜单增强的方法
    3. 如果包含屏幕增强,则必须定义Instance Creation Mode为Reusing Instantiation,且不可设置为multiple use,但可以包含填写屏幕字段或计算屏幕字段的方法
    4. Instance Create Mode会影响GET BADI语句的性能,如果值为Newly Creating Instantiation,则每个BAdI handler都会创建自己的实例;如果值为Reusing Instantiation,则同一个internal session的BAdI handler会复用实例;如果值为Context-Specific Instantiation,则同一个internal session中Context值相同的BAdI handler会共用同一个plug-in object单件(只对context-dependent BAdI有效)
    5. 对于context-dependent BAdI,必须定义Context class,该类必须包含IF_BADI_CONTEXT接口
  7. 定义fallback BAdI implementation class(可选)

 

代码示例:

*Call in Program

DATA: badi_ref TYPE REF TO badi_name.

GET BADI badi_ref.

CALL BADI badi_ref->meth.

*BAdI with Filter

DATA: badi_ref TYPE REF TO badi_name.

GET BADI badi_ref

FILTERS

<filter> = <filter_value>.

CALL BADI badi_ref->meth.

*BAdI with Context

DATA: bd TYPE REF TO badi_ctx_badi,

ctx TYPE REF TO cl_badi_report_context. "指向当前程序特有的context class实例

ctx = cl_badi_report=>get_instance( repid = sy-repid ). "绑定plug-in和context class实例

GET BADI bd CONTEXT ctx.

CALL BADI bd->meth.

 

Unit6 Explicit Enhancement Options(显式增强)

6.1 Describing the Enhancement Framework(描述增强架构)

(SAP增强的总架构请参考1.1节的内容。Enhancement Spot与Explicit Enhancement、Implicit Enhancement的关系,请参考5.1节内容。)

 

Composite Enhancement Spot: 复合增强Spot,可以包含其它复合增强点或普通增强点

Simple Enhancement Spot: 普通增强Spot,可以包含Explicit Enhancement Points、Explicit Enhancement Sections、BAdIs(New BAdI需要Enhancement Spot的管理,所以New BAdI可以视为特殊的Explicit Enhancement)。

Enhancement Implementation: 增强实现,每个Enhancement Spot可以创建多个对应的Enhancement Implementations,每个实现可以用于实现增强点下的所有组件(用户可以为复合增强Spot创建复合实现,但是这不是必须的)。

 

To Search for an Enhancement Spot(搜索增强Spot的步骤):

  1. Start the Repository Information System ( transaction SE18 ).
  2. Choose Enhancements->Enhancement Spots.
  3. Specify the search criteria ( package or application component ) for the enhancement spots you are looking for and execute to display a list of results.
  4. Pick one of the results to display ( from the list of enhancement points and sections ).
  5. On the Enhancement Implementations tab pages, you can see any existing enhancement implementations of the spot. Choose the enhancement implementation that you want to display.
  6. The result shows all enhancement implementation elements related to the enhancement implementation name.
  7. Choose Source to see the implementation code at the bottom of the screen. Choose Editor to display the source code of the enhancement in-place in the program.

(另一个用户查看增强点和增强实现的工具是Enhancement Browser,事务代码SPAU_ENH。)

6.2 Using Explicit Enhancements(使用显式增强)

Explicit enhancement points are provided by SAP and allow you to enhance SAP source code by inserting your own logic, without making modifications.

  • Static: allow additional data declarations
  • Dynamic: allow additional executable code

 

Explicit enhancement section is an option provided by SAP that allow you to replace an SAP source code section without making modifications.

 

注意事项:

  • If there are multiple active implementations for an enhancement point, it is not possible to know in which order they will be executed.(Enhancement points可有多个实现,但执行顺序无法保证。)
  • For an enhancement section, only one active implementation can be executed. If there are several active implementations. there is no runtime error, only a syntax warning.(Enhancement Sections若有多个实现,不报错但会警告,运行时只会执行某一个激活的实现)
  • To use explicit enhancement points and enhancement sections, you must create an enhancement implementation(因为显式增强由enhancement spot管理,所以使用前需要创建enhancement implementation)

 

Define your own Explicit Enhancements(定义显式增强的步骤):

  1. Switch to Change mode(进入编辑模式);
  2. Use the menu Enhancement Operations->Create Option to create your own explicit enhancement(创建显式增强);
    1. 如果在增强(Enhancement Points或Enhancement Sections)增加STATIC关键字,那么该增强将用于变量声明( data declarations ),如果没有该关键字,则该增强将用于逻辑代码;
    2. 如果在增强(Enhancement Points或Enhancement Sections)增加INCLUDE BOUND关键字,则该增强的代码会在所有调用它的编译对象( compilation unit )中执行link动作(一般头文件才这样做,因为头文件会被多个主程序调用),如果没有该关键字,则增强中的代码只在本程序执行(在未指定编译对象时,用户需要从列表中手动选择编译对象)。头文件中INCLUDE BOUND增强和普通增强不能并存,若头文件被同一个主程序调用多次,则只能包含INCLUDE BOUND增强;
  3. Create an enhancement implementation(创建增强实现)
    1. Display the SAP object ( program, function module, method )(显示SAP对象)
    2. Search for the required enhancement point or section(搜索增强点和增强区)
    3. Choose Enhance(选择Enhance图标,是一个螺旋图标)
    4. Position your cursor on the enhancement spot that you want to create the implementation for, then choose Create Enhancement Implementation(选中增强点,创建增强实现)
    5. Specify the name of the enhancement implementation ( comply with customer namespace Y* or Z* )(命名增强实现)
    6. Enter the source code between ENHANCEMENT ... ENDENHANCEMENT.(增加逻辑代码)
    7. Choose Activate Enhancements(激活)

 

Risks of Multiple Implementations of Explicit Enhancement Sections(增强区有多个实现时的风险):

  • It is possible that more than one enhancement implementation may have been created and activated for an enhancement section.(增强区可以存在多个激活的增强实现)
  • However, only one implementation for an enhancement section can be executed at runtime. To control which specific implementation is executed in this case, it is necessary to use the Switch Framework.(每次只能执行一个实现,如果要指定执行哪个实现,则需要使用开关功能)
  • In the case where more than one active implementation exists, you need to resolve the conflict by creating a conflict switch. In the absence of this switch, you cannot know which implementation will be executed at runtime.(开关必须是互斥的,否则我们依然无法判断哪个实现被执行了)

 

Risks of Multiple Implementation for Explicit Enhancement Points(增强点有多个实现时的风险):

  • It is possible to have one or more implementations for an enhancement point, belonging to different enhancement implementations.(增强点可以有多个实现,且这些实现可以属于不同的增强实现)
  • You cannot know the order in which the implementations will be executed.(用户无法知道实现的执行顺序)
  • An enhancement point of one spot can be assigned to many enhancement implementations, and one enhancement implementation can be used for enhancement points of one or more spots(一个增强点可以有多个增强实现,一个增强实现可以用于多个增强点
  • You must avoid any dependencies or conflicts in the logic.(用户必须避免实现间有依赖关系或冲突)

Unit7 Implicit Enhancements(隐式增强)

7.1 Explaining Implicit Enhancements(解释隐式增强)

Implicit Enhancement Points: provide you with the option to insert additional source code at certain points in SAP programs, function modules, and methods, without making modifications and without explicit preparation by SAP developers.(隐式增强不需要修改或预准备工作)

 

SAP provides options to create the following without making modifications(使用隐式增强可实现下述功能):

  • Additional ( optional ) interface parameters in SAP function modules and SAP methods(额外的参数)
  • Additional attributes and methods in SAP classes(额外的属性和方法)
  • Preparation and postprocessing functions for global SAP methods(预处理和后续处理)
  • Replacements for global SAP methods(替换全局方法)

7.2 Implementing Implicit Enhancements in Function Modules(在函数模块中实现隐式增强)

The following implicit enhancements are available for SAP function modules(隐式增强可以为函数模块提供以下功能):

  • Implicit enhancement options(增强项): Additional optional parameters can be added to the function module interface.
  1. The parameters can be IMPORTING, EXPORTING, CHANGING, or TABLES parameters, but additional EXCEPTIONS cannot be defined.
  2. To use the implicit enhancement option to create additional parameters for an SAP function module, it is necessary to switch to Enhancement mode. This is done by using the usual button on the toolbar, and you will then be asked to create an enhancement implementation. Once this has been done, you will be able to define the new parameters with a suitable type under the appropriate tab page in the Function Builder.
  3. Once you have activated the enhancement implementation, its name will be display against each of the new parameters, so that it is easy to distinguish between standard parameters and parameters created using an enhancement.
  4. 若我们使用pattern插入FM,则增强的参数也会被带出,且它们必须为optional
  • Implicit enhancement points(增强点): An enhancement implementation can be created to allow you to add logic at the beginning or end of the function module source code.
  1. To do this, under the Source Code tab, in enhancement mode, it is necessary to use the appropriate menu entry to show where the available implicit enhancement points are located. ( This will be at the beginning and end of the function module. )
  2. 增加逻辑往往配合增加参数一起使用

(详细步骤请参考204页,Unit7 Solution10。)

7.3 Implementing Implicit Enhancements in Global SAP Classes(在全局类实现隐式增强)

Implicit Enhancement Points and Options in SAP Classes(SAP类中的隐式增强点/项):

  • Implicit enhancement options
  1. Adding optional parameters ( importing, exporting, changing but no returning parameters and exceptions ) to method interfaces
  2. Defining additional attributes and methods ( public, protected, private )
  3. Defining a pre-method or a post-method for an SAP method ( alternatively, defining an overwrite method )
  • Implicit enhancement points
  1. Adding additional logic ( possibly using additional interface parameters, methods, or attributes )
  2. Implementing additional methods

 

在全局类增加属性和方法的步骤如下:

  1. Display the class in the Class Builder
  2. Choose Class->Enhance and create an enhancement implementation
  3. Define new attributes ( must always be optional ) , new methods, and new parameters for existing methods
  4. To branch to the method editor so you can add the code, double-click the name of any additional methods you have created
  5. Choose Activate Enhancements

 

Pre-Methods, Post-Methods, and Overwrite Methods(预处理方法、后续处理方法、重写方法):

  • These methods are automatically called before, after, or instead of the SAP method to which they are linked.
  • When an overwrite method is created, it is not possible to have pre or post methods for the same original method.
  • 预处理方法、普通方法、后续处理方法按顺序执行,如果中途报错,则后续动作不再执行
  • 定义预处理、后续处理、重写方法后,系统会在原类里定义lcl_<enhancement_name>本地类,该类可以通过CORE_OBJECT类引用访问原类的组件。

    本地类构成如下:

  1. IPR_<enhancement_name> for pre-methods
  2. IPO_<enhancement_name> for post-methods
  3. IOW_<enhancement_name> for overwrite methods

 

Restrictions of Pre-, Post-, and Overwrite Methods(预处理方法、后续处理方法、重写方法使用限制):

  • Pre-methods do not have EXPORT parameters
  • Post-methods do not have EXPORT parameters; the EXPORT parameters of the original SAP method become CHANGING parameters in the post-method
  • The returning parameter of a functional method becomes a CHANGING parameter
  • Overwrite methods have the same signature as the original method
  • You cannot change the parameter definitions of pre, post. and overwrite methods

(注意: 主要有两点,EXPORT和RETURNING参数变成CHANGING参数,重写时signature不能改变)

 

定义预处理方法、后续处理方法、重写方法:

  1. Display the class in the Class Builder.
  2. Choose Class->Enhance to create an enhancement implementation.
  3. Use the cursor to mark the required SAP method.
  4. Choose Edit->Enhancement Operations and choose Insert Pre-Method, Insert Post-Method, or Add Overwrite Method.
  5. Choose the button in the Pre-/Post-/Overwrite-Exit column to implement the corresponding method. To access components of the global class in the method, you have to use the reference variable core_object, which is filled in the local constructor.
  6. Save the method.
  7. Choose the Activate Enhancements button.

(详细步骤请参考214页Unit7 Solution11。)

 

通过隐式增强实现预处理、后续处理的优点:

  • Higher abstraction level due to a separate address space
  • Less adjustment effort than source code enhancements during upgrade ( only necessary when parameters are changed )
  • All pre- and post- methods are stored in a local enhancement class which has its own attributes to exchange data between methods

7.4 Using Other Implicit Enhancements(使用其它隐式增强)

Local SAP Class: Implicit Enhancements Options and Points(本地类隐式增强项/点):

  • Implicit Enhancements Options:
  1. Adding optional parameters ( importing, exporting, and changing, but no returning parameters and exceptions ) to method interfaces
  2. Defining additional attributes and methods ( public, protected, and private )
  • Implicit Enhancements Points:
  1. At the beginning and end of methods to add logic ( possibly using additional interface parameters, attributes, or methods )
  2. At the end of the IMPLEMENTATION block ( to implement any additional methods )

(注意: 本地类要使用隐式增强,需建立enhancement implementation。)

 

To Enhance a Local SAP Class(增强本地类的步骤):

  1. Display the source code of the local class
  2. Choose Enhance(为一螺旋状图标)
  3. Choose Edit->Enhancement Operations->Show Implicit Enhancement Options to show the implicit enhancement options
  4. In the editor, use the context menu of one of the implicit enhancement options or displayed points to create an enhancement implementation
  5. Insert the source code
  6. Choose Activate Enhancement

(详细步骤请参考224页Unit7 Solution12。)

 

Other Enhancement Points(其它隐式增强点):

  • At the end of a structure ( type ) declaration ( before "END OF ..." ) ( to include additional fields )
  • At the beginning and end of subroutines ( to add more functionality )
  • At the end of includes ( to implement additional functions and subroutines )

(但SAP Basis Object没有隐式增强点。)

(注意: 增强structure时,需要用DATA关键字定义额外字段,否则会报错。)

 

升级的影响: 尽管隐式增强没有修改标准代码,但是升级后依然需要手动调整。后面的Adjustment of Enhancement Implementation章节会有介绍。

 

To Use Other Implicit Enhancement Points(使用其它隐式增强的步骤):

  1. Display the source code of the corresponding SAP object.
  2. Choose the Enhance.(一个螺旋状图标)
  3. Choose Edit->Enhancement Operations->Show Implicit Enhancement Options.
  4. In the editor, use the context menu of one of the implicit enhancement points displayed to create an enhancement implementation.
  5. Insert the source code.
  6. Choose the Activate Enhancement pushbutton.

 

已有增强的实施( Enhancement Implementations )中也有隐式增强:

路径为Edit->Enhancement Operations->Show Implicit Enhancement Options

在ENHANCEMENT <num> <name>. ... ENDENHANCEMENT.的开头和结束位置就能看到隐式增强点。

7.5 Using Composite Enhancements(使用复合增强)

Enhancement Spots: are Repository objects that contain one or more enhancements ( either explicit enhancements or new BAdIs ).

Composite Enhancement Spots: are used to semantically group simple enhancement spots. They contain one or more simple enhancement spots or one or more composite enhancement spots of the relevant type as described in the figure. ( Composite Enhancement Spots are therefore used to combine simple enhancement spots into meaningful units. )

Enhancement Implementations: are repository objects that serve as containers for enhancement implementation elements.

Simple Enhancement Implementation: can contain one or more enhancement implementation elements, which relate to elements of the same enhancement spot.

New Enhancement Implementation: for something that belongs to a different enhancement spot, or implementation for an implicit enhancement.

Composite Enhancement Implementation: are used for the semantic grouping of simple enhancement implementations. ( either one or more simple enhancement implementations or one or more composite enhancement implementations of the relevant type )

 

注意:

Composite Enhancement Implementation和Composite Enhancement Spots并没有必然联系,一个Composite Enhancement Spot可以包含多个Simple Enhancement Implementations,一个Simple Enhancement Spot也可以包含多个Composite Enhancement Implementations。

Unit8 Modifications of the SAP Standard Application(修改SAP标准应用)

8.1 Modifying SAP Standard Software(修改SAP标准软件)

A repository object is original in only one system. In the case of objects delivered by SAP, the original system belongs to SAP. In customer systems, these objects are only available as copies. This applies to your development system and all other systems that follow on from it.(SAP架构中,原始版本SAP对象只存在于SAP公司,用户系统使用的是复制版SAP对象。)

 

If you create your own applications and repository objects, the objects that you create are original in your development system. You assign your developments to a change request of the type Development/Correction. When released, this change request can be used to transport objects from the development system to subsequent systems.(如果开发机创建原始版本Customer对象,则生成修改请求,然后从开发机传往下游系统。)

 

Correction and Repairs(更正与修正):

  • Corrections: changes to an original repository object. Corrections are also recorded in a change request. The tasks of the change request are of the type Development/Correction.
  • Repair: changes to a copy, and recorded in a task of repair.
  • Modifications: change to SAP objects.

总之,不管是SAP对象还是用户对象,修改原始版本的为correction,修改复制版本的为repair,而修改SAP对象还可称为modification。

  • 用户对象( customer objects ): 用户需要从original system(即开发机)修改( change ),然后传入下游系统,以保证数据一致性。
  • SAP对象( SAP objects ): 用户不能像修改用户对象那样修改( change )SAP对象,因为SAP对象的原始版本在SAP,剩下系统都是复制版本,只有在必要时才进行修改( modification )。

 

Modification and Upgrades(修改与升级):

  • When you upgrade your system or apply a Support Package, conflicts can occur with modified objects.
  • Conflicts occur when you have changed any SAP object and SAP also delivers a new version of it, which then becomes active in the repository.
  • If you want to keep the changes you previously made, you must perform a modification adjustment for these objects.
  • To ensure consistency between your development system and subsequent systems, you should only perform modification adjustments in your development system.

 

SSCR ( SAP Software Change Registration ): The developer who will change the SAP standard objects must register those changes using SAP Software Change Registration ( SSCR ).(注册一次之后,后续修改就不用再注册了。

Benefits of SSCR:

  • Quick error resolution and high availability of modified system
  • Dependable operation
  • Simplification of upgrades

If you want to change an SAP repository object, you must provide:

  • SSCR key(每个Key只能用于修改一个对象)
  • Change request(包括Change lock,Import lock,Version creation)

(版本控制逻辑如下,以前传入的版本为Full version,当修改后的版本传入后,新的版本为Full version,但是系统的version database会保存新版本和旧版本的区别,作为备份backward delta。Modification Adjustment就是利用这个。)

 

Critical Success Factors for Modifications(修改成功的注意事项):

  • Encapsulation instead of insertion(用封装代码代替散代码)
  • Use narrow interfaces during encapsulation(封装的代码越孤立越好)
  • Use standardized in line documentation(阅读在线文档)
  • Do not delete any SAP source code(勿删除标准源代码)
  • Keep a modification logbook(保存日志,事务代码SE95)
  • Do not modify any central Basis Dictionary objects(不修改核心对象)
  • Release all requests that contain repairs before upgrade/support package installation(升级或打补丁前释放所有修正请求)

 

日志基本内容:

  • Object type, such as program, screen, GUI status, and so on
  • Object name
  • Routine ( if applicable )
  • Subject area ( according to process design blueprint or technical design )
  • Change request number for the repair
  • Change date
  • Changed by
  • Preliminary correction - Yes or No
  • SAP Note number, valid until Release X.Y ( if applicable )
  • Estimated time to restore the modification during an adjustment

8.2 Modifying Applications Using the Modification Assistant(用修改助手修改应用)

老版修改助手( Modification Assistant )和新版修改助手的区别:

THEN

NOW

Granularity(颗粒度): Include program

Modification adjustment: Line by line

Each modification had to be included in the new SAP version manually ( cut and paste )

Granularity: Module ( for example, subroutine )

Modification adjustment: At module level

 

Tools Supported(可使用工具):

Tool

Use of Modification Assistant

ABAP Editor

Modification mode

Screen Painter

Layout, Flow logic

Menu Painter

 

Text Elements

 

Class Builder

 

Function Builder

Adding function modules, Compatible interface enhancements

ABAP Dictionary

Append structures are registered, Data elements: field labels can be changed

Documentation

Substituting documentation objects

 

修改SAP对象需要提交:

  • SSCR key
  • Change request

 

Modification Assistant Functions(修改助手提供的功能):

  • Insert: When you choose this function, the system generates two comment lines, between which you can enter your source code.
  • Replace: When you position the cursor on a line and choose Replace, the system comments out the corresponding line and another line appears in which you can enter the code. If you want to replace several lines, mark them as a block first.
  • Delete: By selecting a line or block of source code, and then choosing the Delete function, the lines will be commented out.
  • Undo modification: Choose this function to undo the selected modification that has been made to an object.
  • Display modification overview: Choose this function to display an overview of all the modifications that belong to this object.

 

Modification Browser(修改浏览器,事务代码SE95): 提供了所有被修改的对象,并将使用修改助手和不使用修改助手的修改区分开。其树状图的两层分别提供下述信息:

  • Modification type ( with or without Assistant )
  • Object type ( PROG, DOMA, DTEL, TABL )

8.3 Implementing User Exits(实现使用者出口)

使用者出口( User Exits ):

  • 第一代增强
  • 它们是主程序预定义的特殊头文件(Include Programs),并不以Z开头
  • 它们不受升级影响( these implementation will not be overwritten by SAP )
  • 不需要调整( adjustment )

 

使用者出口代码示例:

*Includes

PERFORM userexit_abc.

PERFORM userexit_xyz.

 

*Include MV45AFZB

FORM userexit_abc.

ENDFORM.

 

FORM userexit_xyz.

ENDFORM.

  1. Blank Subprograms(空白子程序)
  2. Includes delivered only once(Includes文件只传输一次)
  3. Mainly in SD(主要分布在SD模块,即sales and distribution分销发运模块)
  4. Technically: Modification(技术上属于修改)
  5. 子例程名称规则为USEREXIT_<NAME>
  6. 这些Include programs不会被系统修改,如果有新版本需要增加出口,则会增加新的头文件
  7. 头文件名称与主程序名称有对应关系,比如主程序为SAPMV45A,则Include文件名称为MV45AFZB
  8. 使用User Exit可以避免Modification并保证升级顺利( smooth upgrades )

 

搜索使用者出口( User Exit )的方法:

  • Search by Program
  1. System->Status, Double-click Program Name
  2. Search by Character String, Perform Userexit, Global in Program
  3. Double-click to navigate to the subprogram and Read the inline documentation
  • Search in the SAP Reference IMG
  1. S&D->System adjustment->User Exits

8.4 Adjusting Modifications(调整修改)

最初SAP系统有工具检查升级后增加了哪些对象,后来该工具演化出调整工具。当SAP升级( upgrade )或打补丁( Support Package )时,我们需要检查新增和修改的对象,并进行调整。(升级的事务代码为SPAM)

 

两种调整工具:

  • SPDD: 用于比较和调整ABAP Dictionary Objects
  1. Domains
  2. Data elements
  3. Tables ( this includes structures, transparent tables, pooled, and cluster tables, together with their technical settings )
  • SPAU: 用于调整其它类型的Repository Objects
  1. ABAP Programs
  2. Interfaces ( menus )
  3. Screens
  4. Search Helps
  5. Views
  6. Lock Objects

 

不需要使用SPDD的情况:

  • You did not make any changes to SAP standard objects in the Dictionary(未修改字典对象)
  • You have only added customer dictionary objects to your system(只增加了定制的字典对象)

 

每次升级( Update/Upgrade )后,用户有14天的时间可以不借助SSCR Key使用SPAU,且只能在开发机使用。SPAU可以检查用户修改的对象,以及版本升级修改的对象,调整修改( Adjusting Modifications )可以把修改传入升级后的系统。

 

调整的传输过程: 用户在开发机进行调整,系统将为SPDD调整和SPAU调整分别创建transport requests,然后传入下游的SAP系统。

 

调整时几种图标的含义:

  • Automatic adjustment: 绿灯,表示自动调整
  • Semiautomatic adjustment: 黄灯,表示半自动调整(有辅助工具)
  • Manual adjustment: 红灯,表示手动调整
  • Object adjusted: 对勾,调整成功
  • Original restored: 两个方块,恢复初始设置

Unit9 Introduction to Web Dynpro(Web Dynpro介绍)

9.1 Outlining the Benefits of Web Dynpro(概括Web Dynpro的优点)

A Web Dynpro application is developed using a declarative programming approach(申明式开发).

  • The necessary source code is then generated automatically
  • The Web Dynpro framework allows you to place the custom source code at predefined positions within the generated code

 

A Web Dynpro ABAP application can address all kinds of reuse components directly(可复用组件):

  • Methods of global classes defined in your system
  • Function modules defined in your system or ( through RFC ) in back-end system
  • Web services through a Web service client object

 

Benefits of Web Dynpro(优点):

  • Minimizes code and design(编码量最小化)
  • Separates layout and logic(分离显示和逻辑)
  • Supports reuse of components(组件可复用)
  • Supports data binding(支持数据绑定)
  • Compatible with multiple platforms(兼容多种平台)
  • Browser based, zero footprint(基于浏览器,无访问痕迹)
  • Support 508 accessibility(支持残疾人功能)

 

Web Dynpro设计理念:

  • Web Dynpro uses a declarative meta model for defining UIs.(申明式开发)
  • Web Dynpro provides technical features, such as support for internationalization, flicker-free interaction, and a clean separation of the business logic and the UI.(辅助技术)
  • Web Dynpro provides wizards that support the definition of forms and tables in the UI and source code in the controller methods.(安装向导)

9.2 Displaying Web Dynpro Component Architecture(显示Web Dynpro组件架构)

Web Dynpro Components: are containers for other entities related to a UI and Web Dynpro Program.

View: is the rectangular part of a page displayed by the client, the view contains UI elements, such as input fields and buttons.

Window: contains views and flow between views.(注意: Window可以包含多个View,View也可以用于多个Window。)

Web Dynpro Controllers: contains Web Dynpro Source Code.

Controller Attributes: Global Variables.

Context: Global Data related to the UI which are stored in a hierarchical storage area.

 

Web Dynpro components can be addressed in the following ways(访问Web Dynpro components的方法):

  • By using a Web Dynpro application, you can link a Web Dynpro component to a URL, which you can call from a web browser or another Web Dynpro client.
  • When reusing a Web Dynpro component as a subcomponent, you can combine the visual interface of a Web Dynpro component with the visual entities of the main component to form the UI.
  • When reusing a Web Dynpro component as a subcomponent, the main component can access all methods and the data defined in the programming interface.

 

Context and Data Binding(上下文与数据绑定):

  • Data Binding: View的界面元素(或元素的某个属性)与View Controller的上下文( context )节点或属性绑定(用于自动从界面输入输出数据)
  • Context Mapping: Component Controller和View Controller(或其它Component Controller)的上下文绑定(用于controllers间传数)

Mapping的使用规则:

  • A node must exist in the context of the controller acting as the mapping origin. This node may also have child nodes or attributes.(必须存在源节点)
  • The mapping origin controller must not be a view controller.(源节点不能在view controller中)
  • The controller containing the mapped node must declare the use of the mapping origin controller as a used controller.(目标节点所在的controller需要申明源节点所在的controller为已使用controller)

Data Binding的使用限制:

  • You may not bind the UI elements to the context nodes or attributes defined in another controller.(UI元素不能与本controller以外的controller绑定)
  • UI elements are private to the view controller in which they are declared.(UI元素在本controller是私有的)

Data Binding时Web Dynpro Framework执行的动作:

  • It transports data from the context attribute to the UI element during the screen rendering process.(将上下文属性传入UI元素)
  • It repopulates the context attribute from the UI element after data has been entered and the next server round trip is initiated. The values entered are automatically converted and checked for type conformity. If an error occurs, an appropriate message is displayed.(UI元素输入后,重新生成上下文属性,输入时自动进行格式转换和检查)

9.3 Navigating Between Views(视图间的跳转)

Outbound Plugs(出站接头): 触发视图间跳转( navigation )的控件,该控件以触发动作命名而非以视图名称命名。

Navigation Events(跳转事件): 出站接头抛出( raises )的异步事件( asynchronous events )。

Navigation Queue(跳转队列): 存放跳转事件的数据结构,一个视图可以有多个出站接头指向不同的界面( UI )。

Navigation Stack(跳转栈): 存放跳转队列的内存区,有新的出站接头活动时,该内存扩展,所有跳转执行完毕时,该内存区释放。

Inbound Plugs(入站接头):接收跳转的控件,拥有特殊的event handler,该控件以视图命名。出站接头和event handler可以用于传递视图输入的参数。

Navigation Links(跳转链接): 每个出站接头需要指向一个入站接头,以确定跳转顺序,该链接定义在Window中。

Action(动作): 动作可以连接event handler method(在View Controller中)和client-side event

(详细操作步骤请参考315页,Unit9 Solution18。)

9.4 Creating View Assemblies(创建嵌套视图)

Windows and Views(窗口与视图):

  • A window is the set of all possible views that can make up a visible screen.(窗口是一个由视图组成的屏幕)
  • A window defines which views are displayed in what combination and how the view combination changes by firing outbound plugs.(窗口定义了视图如何显示如何跳转)
  • A view can have container areas defined by the ViewContainerUIElement. This allows nesting of views within a window.(视图可以嵌套)
  • A ViewContainerUIElement can only display one view at a time.(视图容器控件一次只显示一个视图)

 

When you create a window, remember the following points(创建窗口的注意事项):

  • You must embed all the possible views that can exist in the visual interface of the component in the window(要包含所有可能显示的视图)
  • To display multiple views in parallel, define the layout and position of these views in a special view containing ViewContainerUIElement in its layout.(用视图容器定义视图的显示属性和位置)
  • Define the navigation links between the different views.(定义视图间的跳转链接)

注意:

  • 因为一个容器一次只能显示一个视图,所以切换视图就需要跳转链接;
  • 如果容器为空( blanked ),则嵌入名为EMPTYVIEW的视图,该视图为控件自动创建的且入站接头会响应合适的跳转事件。

 

View Assembly(嵌套视图):

  1. 出站接头( Outbound plugs )触发容器( view container area )显示特定视图的工作
  2. 所有候选的视图都需要嵌套在容器中,用户通过跳转链接决定显示哪个视图
  3. 任意时刻,可见视图的组合( subset of views visible )被称为嵌套视图( a view assembly )
  4. 跳转可用于更换容器里的视图,也可用于更换窗口中的视图组合( view combinations )

 

(详细操作步骤请参考324页,Unit9 Solution19。)

9.5 Indentifying Web Dynpro Entities and Relationships(识别Web Dynpro实体与关系)

SAP's Web Dynpro is built on the foundation of the MVC design paradigm(SAP Web Dynpro基于MVC范型。).

The architecture of a Web Dynpro component can be divided into two parts - external and internal visibility.(Web Dynpro组件可分为外部可见型和内部可见型。)

The internally visible parts can be further divided into visual entities and programming entities.(内部可见型组件可分为可视化实体和编程实体。注: 可视化实体与UI关联。)

The internally visible entities consist of windows and views.(可视化实体可分为窗口和视图。)

A view consists of a view layout and the corresponding view controller. The view controller can contain navigation plugs, methods, and a context.(视图可分为视图显示属性和视图控制器,视图控制器包括跳转接头、方法和上下文。)

A window embeds one or more views and has a corresponding window controller. A window controller can contain navigation plugs, methods, and a context.(窗口包含了一组视图和窗口控制器,窗口控制器包括跳转接头、方法和上下文。)

 

MVC架构:

  • Business Interaction Layer(业务交互层): Model(取数据)
  • User Interaction Layer(用户交互层): View(前端展示)
  • Binding Layer(绑定层): Controller(中间管理者)

 

窗口和视图的跳转规则:

  • The outbound plug of a window can be connected to any inbound plug of embedded views.(窗口可以跳转到嵌入的视图)
  • The outbound plug of a view can be connected to any inbound plug of the embedding window.(视图可以跳转到被嵌入的窗口)
  • Navigation between windows of the same component is not possible.(同一组件的窗口之间不能跳转)

 

组件控制器( component controllers )的知识点:

  • Component controller works as a component-wide controller. (组件控制器用于在组件范围内进行控制)
  • Program logic related only to a certain view which is coded in the related view controller.(程序逻辑只跟对应视图有关,就写在视图控制器中)
  • Usage declarations between the controllers allow you to access the context data, the public attributes, and the methods of the declared controller ( used controller ).(使用申明可以让用户访问已使用控制的上下文、公共属性、方法,请参考9.2章跟Mapping有关的部分)
  • A view controller cannot be declared as a used controller for other controllers because this violates good programming practice ( MVC programming paradigm ).(视图控制器不能作为已使用控制,即不能作为数据源,这是为了保证代码质量)
  • Business logic should not be part of the Web Dynpro component, but should be defined outside the component to ensure high reusability.(业务逻辑不应放入Web Dynpro组件,因为要保证复用性)

 

用户控制器( custom controllers )的知识点:

  • Custom controllers are optional controllers defined by the developer.(用户控制器是开发者自定义的可选控制器)
  • These controllers are used to modularize component content. For example, custom controllers can act as local controllers for some views, or they can be used to encapsulate the logic related to a certain model class ( business logic ).(用户控制器用于模块化管理组件,比如管理一组视图或者管理跟业务逻辑有关的代码)
  • The use of custom controllers allows you to reduce the content of the component controller by populating subfunctions.(用户控制器的使用可以减少组件控制器的代码)

 

接口控制器( interface controllers )的知识点:

  • 父组件与子组件( parent component and child component ):
  1. 如果一个Web Dynpro组件访问另一个Web Dynpro组件,则访问者为父组件,被访问者为子组件
  2. 父组件需要申明对子组件的访问,此时子组件会创建组件使用实例( component usage instance ),父组件会通过自己组件接口控制器( component interface controller )访问子组件的实例
  • 接口控制器的组成:
  1. Interface controller: All Web Dynpro components have only interface controller. Through the interface controller, data, methods, and event handlers can be made accessible to other components.(一个Web Dynpro结构最多只有一个接口控制器)
  2. Interface views: Interface views represent the visual interface of a Web Dynpro component. There is a one-to-one relationship between a window and an interface view.(每个窗口有且只有一个接口视图)
  • If a component has no views, there is no need to have windows. In this case, the component does not implement an interface view. Components without any visual interface are called faceless components.(不含视图的组件也不需要包含窗口,不含窗口的组件也不用包含接口视图,这类组件称为*面组件)

 

Web Dynpro Application知识点:

  • A Web Dynpro application is the entry point into a Web Dynpro component and is the only Web Dynpro entry that can be addressed through a URL.(Web Dynpro Application是唯一可通过URL访问的入口)
  • There is often a one-to-one relationship between an interface view and an application.(通常每个接口视图对应一个Web Dynpro Application)
  • The functions of a single Web Dynpro component can be accessed by defining multiple applications. Each application addresses a different interface view and/or a different inbound plug of the interface view.(每个Web Dynpro可以有多个Applications,每个Application可对应不同的接口视图或接口视图的入站接头)

 

To define a Web Dynpro application, specify the following elements(定义Web Dynpro Application需要设置如下元素):

  • The component to be instantiated. It is then known as the root component.(根组件,即用于实例化的组件)
  • The interface view of the root component to be used. The default view in this interface view defines the default view assembly.(根组件的接口视图)
  • The inbound plug that acts as an entry point for the nominated interface view ( this inbound plug must be of type Startup ).(被使用的接口视图需要定义入站接头作为进入点,且类型必须为Startup)
  • 如果是SAP NetWeaver AS for ABAP 7.5,创建Web Dynpro ABAP Application时,参数值自动设置为WDUIGUIDELINE = FIORI,WDPREFERREDRENDERING = STAND_ONLY,不过用户可以手动更改。
  • 新版本有以下主题( theme ):
  1. DEFAULT: 即根据GUIDELINE设置的值选择主题
  2. SAP_BLUECRYSTAL: GUIDELINE值为FIORI时的主题(该主题只支持RENDERING值为STANDARD)
  3. CORBU: GUIDELINE值为GL11或GL20时的主题(例如: 设置参数WDTHEMEROOT = SAP_CORBU)

Unit10 Web Dynpro Controllers(Web Dynpro控制器)

10.1 Outlining Controller Types and Entities(描绘控制器的类型和实体)

Types of Components in a Web Dynpro Component:

Controller Types

Description

Component controller

There is only one component controller in each Web Dynpro component. This is a global controller, visible to all other controllers.

Custom controllers

Custom controllers are optional. They are defined at design time and can be used to encapsulate subfunctions of the component controller. The coding in a custom controller should not depend on the existence of any other custom controller.

Configuration controllers

This is a special custom controller. It is only necessary if the corresponding component implements special configuration and personalization functions. Only one configuration controller may exist in any component.

View controllers

Each view consists of the layout part and one view controller. This controller handles the view-specific flow logic.

Windows controllers

Each window has exactly one window controller. You can use this controller to handle the data passed through the inbound plugs when it is reused as a child controller.

 

(Interface controller用于对外,所以此处未列出)

 

其它跟controller有关的知识点:

  • 控制器的实例( controller instances )相对于它们的父组件都是单件( singletons ),故同一个视图( view )不能多次嵌入一个嵌套视图( view assembly )。
  • 控制器的上下文( context )和方法( methods )都是私有的,除非有其它控制器显式申明使用了该控制器。不过,视图控制器不能被定义为已使用控制器,也就意味着视图控制器的上下文和方法恒为私有。

 

The following list describes the lifetimes of the different controller instances, depending on the controller type(不同控制器的生命周期):

  • Component controller: The lifetime of the component controller is the lifetime of the component. When you start a Web Dynpro application, the components controller is instantiated by the Web Dynpro runtime.
  • Custom controllers: The instantiation of a custom controller is delayed until the first method of the controller is called. Custom controller instances cannot be deleted explicitly.
  • Configuration controller: A configuration controller is instantiated as the first controller of the component. It lives as long as the component lives.
  • View controllers: The instantiation of a view controller is delayed until the first method of the controller is called. To delete the view instance with the component, the developer selects the framework controller option. To delete the view instance as soon as the view no longer belongs to the view assembly, the developer selects the when visible option.(不过后一种方式会在重新放入视图时再次实例化)
  • Window controllers: The instantiation of a window controller is delayed until the first the first method of this controller is called. This is done by starting a Web Dynpro application, by embedding the related interface view in the parent component's window, or by displaying the window in a dialog box. Window controller instances cannot be delete explicitly.

 

Common Controller Entities(通用控制器实体):

  • 上下文( context ): 每个控制器都有自己的上下文,其中根节点默认存在,而字节点和属性需要在运行时动态( dynamically )或静态( statically )加载
  • 引导方法( hook methods ): 由Web Dynpro framework按固定顺序调用的预定义方法,不同类型的控制器拥有的引导方法不同
  1. 所有控制器都有两个基本的引导方法,即创建实例的方法wddoinit(),和删除实例的方法wddoexit()。
  2. 每个控制器实例的生命周期( lifetime )中,这些引导方法只执行一次。
  • 自定义方法( additional methods ): 定义在Method页签
  • 属性( attributes ): 有些属性不与UI元素属性绑定,需要在Attribute页签定义
  1. 有两个预定义属性,即自指针WD_THIS,上下文WD_CONTEXT
  2. 控制器的所有方法都可以调用这些属性

 

Implications of one Controller C1 Using another Controller C2(控制器C1使用控制器C2时可以执行的动作):

  • Controller C1 can map context nodes of controller C2.(C1可以映射C2的上下文)
  • Controller C1 can call methods of controller C2.(C1可以调用C2的方法)
  • Controller C1 can access public attributes of controller C2.(C1可以访问C2的公共属性)
  • Controller C1 can handle events of controller C2.(C1可以响应C2的事件)
  • All controllers use the component controller by default. This usage can be deleted.(默认使用的控制器,可删除显式申明)
  • A view controller cannot be used.(视图控制器不能被使用)

 

Special Entities of Component/Custom Controllers(组件控制器与用户控制器的特殊实体):

  • 事件( events ): 可在参数中定义事件,而视图控制器和窗口控制器的方法则可以定义成event handler method来响应这些事件
  • 特殊引导方法( additional hook methods ) : 包括wddobeforenavigation(),wddopostprocessing(),wddoapplicationstatechange()

 

Special Entities of View Controllers(视图控制器的特殊实体):

  • 界面 ( UI )
  • 跳转接头( navigation plugs ): 包括了跳转事件和跳转事件响应函数
  1. 跳转事件( navigation event ): 触发出站接头( outbound plug )时抛出的事件,对应的方法为FIRE_<Outbound plug>_PLG
  2. 跳转事件响应函数( navigation event handlers ): 即入站接头( inbound plug ),对应的方法为HANDLE<Inbound plug>_PLG
  3. 跳转链接( navigation link ): 注册的链接入站接头和出站接头的静态属性。但该属性并不是视图控制器的一部分,而是注册于视图所在的窗口中,故每个窗口的注册事件可以不同。
  • 特殊引导方法( special hook methods ): 包括wddobeforeaction()事先检查函数,wddoafteraction()事后操作函数,wddomodifyview()渲染前修改屏幕函数,wddooncontextmenu()右键菜单修改
  • 特殊属性( additional attributes ): 组件控制器指针WD_COMP_CONTROLLER

 

Special Entities of Window Controllers(窗口控制器的特殊实体):

  • 嵌入视图( embed views ): 窗口需要把待显示的视图都包含进来
  • 出站接头( outbound plug )和入站接头( inbound plug ): 与视图类似,但是可以用于跨组件( cross-component )跳转,此时需勾选Interface属性
  • 特殊属性( additional attributes ): 组件控制器指针WD_COMP_CONTROLLER
  • 特殊引导方法( special hook methods ): 包括wddoonopen(),wddoonclose()

(窗口控制器的特殊实体与视图控制器的特殊实体类似,但是没有UI)

Unit11 Web Dynpro Context(Web Dynpro上下文)

11.1 Creating Context Nodes(创建上下文节点)

上下文节点( context ): Every Web Dynpro controller has exactly one hierarchical data storage structure, known as the context.

  • The data held in the context exists only for the life span of the controller. Once the controller instance has been terminated, all data held within its context is lost.(上下文数据的寿命与控制器实例相同)
  • The metadata of the context is typically defined at design time. At runtime you can modify the contents of the context and can also dynamically modify the structure.(上下文的元数据是非运行时定义的,但用户可以在运行时进行动态的修改)
  • All controller contexts are constructed from a hierarchical arrangement of entities known as nodes and attributes. A context always has a parent node known as the context root node. This context root node has fixed properties and it cannot be deleted.(上下文必然有一个根节点,其下方为子节点和属性,根节点不可删除)
  • A context node is the main abstraction class used for runtime data storage within the Web Dynpro framework.(上下文节点是个抽象类,可在运行时存放Web Dynpro框架下的数据)
  • All the child entities of a node are aggregated into a unit known as an element. A node can be thought of as a collection of such elements in the same way as a table is a collection of rows.(节点就是一个表,而表内每行数据称为element)
  • The name of a context node must be unique within the complete structure of a controller's context.(同一个控制器的节点名称是唯一的)
  • A structure is generated at runtime for the context attributes related to the context root. The reference to this structure is stored in the attribute STATIC_ATTRIBUTES of the element.(root element的STATIC_ATTRIBUTES属性,可存放上下文节点的属性)
  • A node object is created automatically for each subnode of the context root. The references are stored in the attribute CHILD_NODES of the context root element.(root element的CHILD_NODES属性可存放上下文节点的子节点对象)

 

节点( context node )和属性( context attribute )的区别:

节点:

  1. Arranged hierarchically(树状结构)
  2. Permitted to have children ( nodes or attributes )(可有子节点)
  3. Metadata description declared manually or derived from a DDIC structure(元数据为手动定义或从DDIC中定义)

属性:

  1. Stores runtime data or references to runtime data(存储或指向运行时的数据)
  2. Based on DDIC types(基于DDIC类型)

 

11.2 Setting Context Node Properties(设置上下文节点属性)

Possible Cardinality Values and Permissions(基数与含义):

Cardinality Values

Description

备注

0 .. 1

Zero or one element permitted

 

0 .. n

Zero or more elements permitted

 

1 .. 1

Exactly one element permitted

根节点的Cardinality为1 .. 1,此时将自动创建index 1节点

1 .. n

One or more elements permitted

 

基数( cardinality )知识点

  • At runtime the context root node is instantiated automatically. The reference to this node is provided by the framework though the controller attribute WD_CONTEXT.(控制器属性WD_CONTEXT存放运行时根节点的引用)
  • The existence of nodes that are not defined as direct children of the context root node is not guaranteed.(不在根节点下的子节点无法被定义)

( 注意: context node的默认基数cardinality为1 .. 1,默认选择基数 selection cardinality为0 .. 1 )

 

主选择(Lead Selection )知识点:

  • Each context node contains the attribute LEAD_SELECTION_INDEX. This attributes is of type integer, and is used to simplify access to the node's collection.(每个上下文节点都有属性LEAD_SELECTION_INDEX,该属性为整数,用于访问节点数据集)
  • The lead selection index is set automatically by the Web Dynpro framework if the context node property Initialize Lead Selection is set to true.(若把上下文节点属性Initialize Lead Selection设为true,则自动获取lead selection index)

 

主选择的使用场合( Lead selection index is important in the following situations ):

  • If a single row is selected in a table, the lead selection index automatically adjusts according to the selected row. The related context element can be accessed without having to find out the element index explicitly. On the other side, the marked row can be manipulated programmatically by changing the lead selection index.(主选择索引自动寻找到选中的一行数据而不需显式申明,且用户可用编程方式设置主选择索引值)
  • Form fields may be bound to attributes of a context node with the cardinality 0:n or 1:n. In this case, the form data originates from the element related to the node's lead selection index. The data set displayed by the form can be manipulated programmatically by changing the lead selection index.(当基数为0:n或1:n,选择哪个数据由主选择索引决定,且用户可用编程方式设置主选择索引值)
  • Special methods ( supply functions ) can be assigned to context nodes. The framework may call a supply function automatically if the lead selection in the parent node changes.(如果有supply functions指向上下文节点,那么在主选择索引被修改时,系统会自动调用supply function)

 

单件( Singleton )知识点:

  • 假设有某个context node N1,其子节点为context node N2
  1. 若Singleton为false,则N1的每行数据都会有一个N2节点的实例
  2. 若Singleton为true,则N1的每行数据指向同一个N2节点的实例

11.3 Sharing Data Between Controllers with Context Mapping(通过上下文映射在控制器间共享数据)

Context Mapping: 即所有上下文指向同一个内存区

Mapping Origin Node: 源节点

Mapped Node: 目标节点

Fully Established Mapping: 源节点的所有节点都映射到了目标节点

Partially Established Mapping: 源节点的节点多于目标节点,故只有部分节点映射到了目标节点

Internal Mapping: 源节点与目标节点在同一个component里

Unit12 Web Dynpro User Interface(Web Dynpro用户接口)

12.1 Defining the View Layout(定义视图显示属性)

UI element: is any graphical entity that occupies a position within a view layout. (屏幕元素: 图形化实体)

  • Certain UI elements, such as TransparentContainer, ViewContainerUIElement, or InvisibleElement, are not visible on the screen.(特定的UI元素或设定为不可见的UI元素在屏幕上是不可见的)
  • 常见屏幕元素类型:
  1. Text Category: 这类元素用于显示或输入文本
  2. Action Category: 这类元素用于触发跳转( trigger navigation )或返回( round trip )
  3. Selection Category: 这类元素允许用户从多个值中选择显示单个值或若干值
  4. Complex Category: 这类元素可以包含子元素
  5. Layout Category: 这类元素定义了子元素的显示顺序和规则
  6. Graphics Category: 这类元素用于渲染图片
  7. Integration Category: 这类元素可以嵌入non-ABAP技术
  • 一些特殊的屏幕元素:
  1. RootUIElementContainer: 该元素类型为TransparentContainer,该元素的ID不可修改但属性可以修改
  2. Context_Menus: 允许用户创建上下文菜单,系统在运行时将上下文菜单实例化且指向屏幕元素

 

Available Container Elements(可选的容器元素):

  • Group
  • Panel
  • TransparentContainer
  • Tray

(容器是一些方形屏幕区域,可将其它屏幕元素作为子节点,并通过layout的属性设置子节点的显示格式。)

 

Layout Property Possible Values(显示格式可选值):

  • FlowLayout: 默认值,即子节点按顺序排列,不能显式换行( line break )
  • RowLayout: 子节点按行排列,设置为RowHeadData时换行,设置为RowData时不换行
  • MatrixLayout: 子节点按网格排列(不仅行对齐、也会列对齐),设置为MatrixHeadData时换行,设置为MatrixData时不换行
  • FormLayout: 将子节点放入不同的块( section ),不同的块列数可以不同,其子节点可以有三种值:
  1. FormTopData: 块定义,通过colCount值设定每块的列数(一般是Group元素作为FormTopData)
  2. FormHeadData: 换行,如果colSpan等于-1,则元素宽度根据列数增加而扩展
  3. FormData: 不换行
  • GridLayout: 与网格排列类似,但是每行的列数为指定值,该值由colCount属性设置,仅在各行列数相同时使用
  • FormLayoutAdvanced: 与FormLayout类似,但是允许屏幕元素不局限于事先划分的屏幕区域里
  • TileLayout: 随着拖拉窗口,每行可显示指定的屏幕元素数量,默认值为2, 3, 5

12.2 Controlling UI Element Behavior with Data Binding(通过数据绑定控制屏幕元素行为)

数据绑定( data binding )的知识点:

  • 要控制屏幕元素的行为,就需要将屏幕元素的属性( properties )与上下文的节点和属性( attributes )绑定(屏幕元素属性也可以是写死的值,即hard-coded)
  • 一旦绑定,上下文就会向屏幕元素的属性赋值
  • 数据绑定是双向的,上下文可以向屏幕元素属性赋值,屏幕元素也可以把值返回给上下文的节点和属性

 

数据绑定( data binding )的步骤:

  1. Create a node or attribute in the context of the view controller that contains the data.(创建节点或属性)
  2. Create the UI element in your view layout.(创建屏幕元素)
  3. For all properties that require data binding, a button with a yellow icon and an empty circle is displayed on the right side of the property. Define the required binding by choosing this button. A dialog box displays the context of the view controller. All nodes or attributes, which have the correct type for binding to the UI element property, are displayed.(绑定需要的屏幕元素属性和上下文节点/属性)
  4. Select an appropriate node or attribute.(选定合适的节点或属性,因为绑定双方的数据格式必须匹配)

 

通过数据绑定控制屏幕元素行为的步骤:

  1. 定义跟屏幕元素属性格式一致的上下文属性(比如屏幕元素的readOnly属性,需要的上下文属性是boolean型)
  2. 绑定屏幕元素属性和上下文属性
  3. 通过引导方法( hook methods )或自定义方法( additionally defined methods )控制上下文属性的值

 

在SAP NetWeaver 7.0 SAP_ABAP Support Package Stack 12以后的版本,有两种绑定方式:

  • Bind Directly to the Selected Attribute: 直接通过名称( Key Property )绑定
  • Bind to the Property of the Selected Attribute Property: 手动选择合适的属性绑定

 

绑定文本元素和ABAP字典的方法:

  • 直接将文本元素绑定数据元素、结构字段或表字段
  • 若文本元素与别的元素有关,且别的元素与上下文的元素绑定,则该文本元素可以直接获取值且其Text属性需要为空(比如Label与InputField有关,且Label的Text属性为空,则InputField获取值时也会根据数据元素给Label赋值)

12.3 Using Composite UI Elements(使用组合屏幕元素)

Composite Element: is any UI element that requires child UI elements.(组合屏幕元素就是需要子屏幕元素的屏幕元素)

如果是Group或Tray型的组合元素,它们有默认子节点Caption(标题),其它子节点需要用户定义。

如果是Table或Tree型的组合元素,它们需要更复杂的子节点设置。

 

Table UI Element(表屏幕元素):

  • 其子节点为TableColumn UI Elements,且至少要有一行该节点
  • TableColumn UI Elements的子节点为Header(类型为Caption,即标题)和Cell Editor(默认类型为TextView,但可以被修改为InputField, DropDownByKey, Checkbox, Button)
  • Table由一个可选的Header,若干Rows,一个Footer Area组成,而Lead Selection Index指定的行会高亮显示
  • Table及其子节点可以通过Web Dynpro Code Wizard创建
  • 我们可以定义Web Dynpro Action并绑定onLeadSelect事件,该事件在用户选择某行时会触发wddobeforeaction()和wddoafteraction()引导方法
  • 如果希望在Table中一次选择多行,则需要把上下文根节点Nodes的cardinality属性设置为0 .. N或1 .. N(默认为0 .. 1),这样就可以通过SHIFT或CTRL选择多行
  • Table的selectionMode可以控制选择的模式
  1. auto: One or multiple rows, depending on context node property: Selection(根据上下文节点属性判定单选还是多选)
  2. multi: Multiple rows if the context node property, Selection, is set to {0, 1} .. n as well. Lead selection will be set.(允许多选,但是上下文节点属性必需也设置成允许多选,且需要设置主选择)
  3. multiNoLead: Like multi, lead selection will not be set.(与多选类似,但是不需要设置主选择)
  4. none: Selection column is not displayed. Row related to lead selection is not highlighted.(选择不会显示,主选择也不会高亮显示)
  5. single: One row, independent of context node property: Selection. Lead selection will be set.(单选,与上下文节点属性无关,但是需要设置主选择)
  6. singleNoLead: Like single, lead selection will not be set.(与单选类似,但是不需要设置主选择)

 

CTable(ClientTable,客户端表):

  • 默认情况下,只显示client端允许显示的行数
  • 如果想使用经典模式,需要把HeightMode属性设置为UseVisibleRowCount,此时可通过VisibleRows设置显示的行数
  • CTable允许滚动,且纵向滚动是在滚动时才加载数据,这样性能更好
  • CTable对象通过CTable元素创建,但是没有Web Dynpro Layout Wizard可以使用

 

Web Dynpro中有标准程序WDR_TEST_UI_ELEMENTS,允许用户测试各种屏幕元素。

Unit13 Controller and Context Programming(控制器与上下文编程)

13.1 Outlining Controller Methods and Attributes(描绘控制器方法和属性)

控制器的知识点:

  • Web Dynpro组件为全局类,控制器为其中的本地类,且定义控制器时自动申明本地类。
  • 实现控制器的代码是自动产生的,同时产生的还有引导方法( hook methods ),在运行时这些引导方法将按预定顺序执行。
  • 控制器方法内部本身为空,用户可以添加自己的代码于其中。
  • 除了引导方法( Hook Methods ),用户还可以定义其它方法: 常规方法( Ordinary Methods ),事件响应方法( Event Handler Methods ),供应函数 ( Supply Functions )。(但不包括静态方法)控制器激活时,引导方法和自定义方法都将创建。
  • ABAP Workbench中,控制器方法是不可访问的,用户只能在控制器方法中添加代码。
  • 如果我们希望访问上下文的元素或属性,则我们需要定义引用( reference to related context node )

 

标准引导方法( Standard Hook Methods ):

控制器类型

引导方法名称

含义

所有控制器

( All Controllers )

Wddoinit()

最先执行的方法,在控制器实例化时调用,且只调用一次。

Wddoexit()

最后执行的方法,通常用于清空内存( cleanup )

组件控制器

( Component Controller )

Wddobeforenaviation()

在执行动作( action method )后,抛出事件( event )前执行

Wddopostprocessing()

是显示界面( UI )前最后一个执行的引用方法

Wddoapplicationstatechange()

在应用挂起( suspended )或恢复( resume )时执行,挂起可能是因为抛出了挂起接头( suspend plug )或有新应用运行,恢复可能是因为抛出了恢复接头( resume plug )或者新应用运行结束

视图控制器

( View Controller )

Wddobeforeaction()

通常用于输入检查,抛出与动作( action )关联的事件( event )时首先执行

Wddoafteraction()

通常用于将事件响应( action handling )有关代码模块化,在视图控制器执行完事件响应方法( action handler method )后执行

Wddomodifyview()

通常用于动态更改视图层级( UI element hierarchy ),唯一允许访问视图层级的方法,其接口参数VIEW是指向视图层级的引用,FIRST_TIME参数可以识别是否已经在控制器生命周期中执行过该方法

Wddooncontextmenu()

当用户在视图控件上右键时执行,可用于实例化静态上下文( statically defined context menus )或增加新上下文( new context menus )

窗口控制器

( Window Controller )

Wddoonopen()

当窗口以对话框形式显示时,在对话框打开前执行

Wddoonclose()

当窗口以对话框形式显示时,在对话框关闭前执行

 

When a Web Dynpro application is started, the controllers are processed as follows(Web Dynpro启动时,控制器将如下执行):

  1. All controllers needed for the first display are instantiated. This means that the wddoinit() methods are processed for component controller, window controller, and view controller.(所有用于第一次显示的控制器都实例化,执行所有控制器的wddoinit()方法)
  2. The inbound plug method of the interface view related to the application is processed. By default, the Default plug is used. This means that the handledefault() method is processed.(执行接口视图的入站接头方法,默认情况下是handledefault()方法)
  3. The component controller wddobeforenavigation() method is processed.(组件控制器运行wddobeforenavigation()方法)
  4. The view controller wddomodifyview() method is processed.(视图控制器运行wddomodifyview()方法)
  5. The component controller wddopostprocessing() mehtod is processed.(组件控制器运行wddopostprocessing()方法)

 

The phase model for a request triggered by a user interaction can be described as follows(用户交互触发的相位模式可以描述成如下样子):

  • If the client side event is bound to an action, the wddobeforeaction(), onaction<ACTION>(), and wddoafteraction() methods are processed. In the component controller, the wddobeforenavigation() method is processed.(如果事件与动作绑定,wddobeforeaction(),onaction<ACTION>()和wddoafteraction()执行)
  • If an outbound plug is fired and a navigation link to an inbound plug is defined in the window, the view related to the inbound plug is instantiated and the wddoinit() method is processed. The inbound plug handle<PLUG>() method is process for this view.(如果激发一个出站接头,且入站接头定义了跳转链接,则含有入站接头的视图将实例化并执行wddoinit()方法和handle<PLUG>()方法)
  • If the lifetime of the previous view is restricted, the wddoexit() method is processed for the previous view.(如果前一个视图终止了,执行它的wddoexit()方法)
  • In the view controller, the wddomodifyview() method is processed for the next view.(视图控制器执行wddomodifyview()方法,为跳转视图做准备)
  • In the component controller, the wddopostprocessing() method is processed.(组件控制器执行wddopostprocessing()方法)

 

自定义方法( Additional Controller Methods )知识点:

  • 在Methods页签,我们可以自定义方法,其中Method Type字段允许有三种类型的方法:
  1. Method: 即普通方法( Ordinary Method )
  2. Event Handler: 即事件响应函数,此时还需要在Event字段定义响应的事件
  3. Supply Function: 即供应函数,该函数可以绑定上下文节点
  • 双击方法名称,你就可以定义方法的参数( signature )和代码( code )
  • 组件的方法为公有的,故组件内的控制器都可以使用这些方法,但视图内的方法只能本视图调用
  • 当某个控制器要调用别的控制器的方法时,必须定义一个"使用"关系( usage relation ),创建该关系的工具为Web Dynpro Code Wizard
  • 当用户自定义的方法把Interface单选框选中后,该方法将作为组件接口,此时其它组件也可以访问该方法

 

控制器属性( Controller Attributes )知识点:

  • WD_CONTEXT: 该引用指向控制器的上下文,在除接口控制器( interface controller )外的控制器中都可以看到
  • WD_THIS: 该引用指向控制器本身,在除接口控制器( interface controller )外的控制器中都可以看到
  • WD_COMP_CONTROLLER: 该引用指向组件控制器对象,只有当组件控制器定义为已使用控制器时才出现
  • 要访问已使用控制器的控制器接口,代码需这样写:

    DATA: lo_ctrl TYPE REF TO ig_<ctrl>.

    lo_ctrl = wd_this->get_<ctrl>_ctr().

 

自定义控制器属性( Additional Attributes )知识点:

  • Additional controller attributes can be defined(自定义控制器属性是允许的,在attributes tab)
  • Controller attributes may be private or public ( for all controller types but the view controller )(自定义控制器属性可以是私有的或共有的,但视图控制器除外)
  • Controller attributes may not be exposed to the component interface(控制器属性不能在组件接口展示)

13.2 Accessing the Context at Runtime with Controller Methods(运行时通过控制器方法访问上下文)

访问上下文节点和元素的代码示例:

DATA lo_nd_fights TYPE REF TO if_wd_context_node.

DATA lo_el_flights TYPE REF TO if_wd_context_element.

 

lo_nd_flights = wd_context->get_child_node( name = wd_this->wdctx_flights ).

 

*get element at lead selection

lo_el_fights = lo_nd_flights->get_element().

 

*if lead selection is not set, ELEM_FLIGHTS will be initial

IF ( lo_el_flights IS INITIAL ).

...

ENDIF.

  1. 因为屏幕元素属性properties只能跟上下文绑定,所以只能通过调整上下文的值去控制屏幕元素的属性。
  2. 上下文引用类型命名规则为IF_<ctrl>(比如这里的if_wd_context_node)。
  3. 上下文节点命名规则为WDCTX_<node>(比如这里的wd_this->wdctx_flights)。
  4. 元素引用类型恒为if_wd_context_element
  5. 要获取主选择那行数据,则使用get_element()方法。

访问上下文节点的代码写法( Reference to context node <node> )

lo_nd_<node> = wd_context->get_child_node(

name = wd_this->wdctx_<node>

).

访问主选择行( Reference to element at lead selection )

lo_el_<node> = lo_nd_<node>->get_element().

访问第n行( Reference to element with index n )

lo_el_<node> = lo_nd_<node>->get_element( index = n ).

获取行数( Get number of elements in collection )

n = lo_<node>->get_element_count().

 

获取单个属性( attributes )和静态定义属性( statically defined attributes )值:

DATA lo_nd_flights TYPE REF TO if_wd_context_node.

DATA lo_el_flights TYPE REF TO if_wd_context_element.

DATA lv_connid TYPE wd_this->element_flights-connid.

 

lo_nd_flights = wa_context->get_child_node( name = wd_this->wdctx_flights ).

 

lo_el_flights = lo_nd_flights->get_element().

 

*get single attribute

lo_el_flights->get_attributes(

EXPORTING

name = 'CONNID'

IMPORTING

value = lv_connid ).

 

DATA ls_flights TYPE wd_this->element_flights.

 

*get all statically declared attributes

lo_el_fights->get_static_attributes(

IMPORTING

static_attributes = ls_flights ).

 

DATA lt_flights TYPE wd_this->elements_flights.

 

*get all statically declared attributes of all node elements

lo_nd_flights->get_static_attributes_table(

IMPORTING

table = lt_flights ).

  1. 如果想获取某个属性的值,可以用get_attribute()函数。
  2. 如果我们的上下文节点是用DDIC的结构静态定义的,则可以通过get_static_attributes()方法直接取出整个结构的字段。
  3. 创建上下文引用IF_<ctrl>时,系统会隐式创建结构类型element_<node>,若是通过DDIC静态定义的节点,则element_<node>类型固定为DDIC结构类型,若是用户自定义的节点,则element_<node>类型与节点属性有关。
  4. 创建上下文引用IF_<ctrl>时,系统会隐式创建标准表elements_<node>,该表的每行结构类型为element_<node>。该内表可用于存放多行节点数据。
  5. 获取静态定义的上下文对应的全部数据的方法为get_static_attributes_table()。
  6. 获取用户选中的数据集的方法为get_selected_elements()。该方法返回值为表类型WDR_CONTEXT_ELEMENT_SET。返回值是否考虑主选择( lead selection )通过INCLUDING_LEAD_SELECTION参数设置。

读单属性值写法( Read value of an attribute )

DATA: lv_<attr> TYPE wd_this->element_<node>-<attr>.

lo_el_<node>->get_attribute(

EXPORTING

name = '<attr>'

IMPORTING

value = lv_<attr> ).

读单行多属性值写法( Read value of all static attributes )

DATA: ls_<node> TYPE wd_this->element_<node>.

lo_el_<node>->get_static_attributes(

IMPORTING

static_attributes = ls_<node> ).

读全部行多属性值写法( Read static attribute values for all node elements )

DATA: lt_<node> TYPE wd_this->elements_<node>.

lo_nd_<node>->get_static_attributes_table(

IMPORTING

table = lt_<node> ).

 

设置单个属性( attributes )和静态定义属性( statically defined attributes )值:

DATA lo_nd_flights TYPE REF TO if_wd_context_node.

DATA lo_el_flights TYPE REF TO if_wd_context_element.

DATA lv_connid TYPE wd_this->element_flights-connid.

 

lo_nd_flights = wd_context->get_child_node ( name = wd_this->wdctx_flights ).

 

lo_el_flights = lo_nd_flights->get_element().

 

*set value of single attribute

lo_el_flights->set_attribute(

EXPORTING

name = 'CONNID'

value = '0405' ).

 

DATA ls_flights TYPE wd_this->element_flights.

 

ls_flights-carrid = 'AZ'.

ls_flights-connid = '0123'.

 

*set values of all statically declared attributes

lo_el_flights->set_static_attributes(

EXPORTING

Static_attributes = ls_flights ).

  1. 设置单个属性的值的方法是set_attribute()。
  2. 对于静态定义的上下文,可以用结构的方式一次设置多个属性的值,方法为set_static_attributes()。

修改单行单属性值( Change a value of a single attribute )

DATA: lv_<attr> TYPE wd_this->element_<node>-<attr>.

lv_<attr> = ... .

lo_el_<node>->set_attribute(

EXPORTING

name = '<attr>'

value = lv_<attr> ).

修改单行多属性值( Change all static attributes of a node element )

DATA: ls_<node> TYPE wd_this->element_<node>.

ls_<node>-<attr> = ... .

lo_el_<node>->set_static_attributes(

EXPORTING

static_attrs = ls_<node> ).

 

13.3 Adding New Elements to a Context Node(在上下文节点上增加元素)

增加元素数据代码示例:

DATA lo_nd_fligths TYPE REF TO if_wd_context_node.

DATA lo_el_flights TYPE REF TO if_wd_context_element.

 

lo_nd_flights = wd_context->get_child_node( name = wd_this->wdctx_flights ).

 

lo_el_flights = lo_nd_flights->create_element().

 

*set attribute values

lo_el_flights->set_attribute( name = 'CARRID' value = 'LH' ).

lo_el_flights->set_attribute( name = 'CONNID' value = '0400' ).

 

*bind element FIRST_ELEMENT to node

lo_nd_flights->bind_element(

new_item = lo_el_flights

set_initial_elements = abap_false ).

  1. 创建元素对象的方法为create_element()。
  2. 创建好的元素对象需要set_attribute()方法赋值
  3. 将元素数据存入上下文的方法为bind_element()。其中参数new_item即元素对象,参数set_initial_elements = abap_false时,代表增加元素对象,set_initial_elements = abap_true时,代表用元素对象替代以前的元素

 

增加结构数据代码示例:

DATA lo_nd_flights TYPE REF TO if_wd_context_node.

DATA ls_flights TYPE wd_this->element_flights.

 

lo_nd_flights = wd_context->get_child_node( name = wd_this->wdctx_flights ).

 

*set field values of local structure

ls_flights-carrid = 'AA'.

ls_flights-connid = '0017'.

 

*bind structure to node

lo_nd_flights->bind_structure(

new_item = ls_flights

set_initial_elements = abap_false ).

  1. 将结构数据存入上下文的方法为bind_structure()。

 

增加内表数据代码示例:

DATA lo_nd_flights TYPE REF TO if_wd_context_node.

DATA ls_flight TYPE wd_this->element_flights.

DATA lt_flight TYPE wd_this->elements_flights.

 

lo_nd_flights = wd_context->get_child_node ( name = wd_this->wdctx_flights ).

 

*append lines to local table

ls_flights-carrid = 'LH'.

ls_flights-connid = '0400'.

APPEND ls_flights TO lt_flights.

 

ls_flights-carrid = 'LH'.

ls_flights-connid = '0401'.

APPEND ls_flights TO lt_flights.

 

*bind internal table to node

lo_nd_flights->bind_table(

new_items = lt_flights

set_initial_elements = abap_true

).

  1. 将内表数据存入上下文的方法为bind_table()。

创建元素对象( Create a new element )

lo_el_<node> = lo_nd_<node>->create_element().

加入元素数据( Add element to collection )

lo_nd_<node>->bind_element(

new_item = lo_el_<node>

set_initial_elements = abap_false ).

加入结构数据( Bind structure to collection )

DATA: ls_<node> TYPE wd_this->element_<node>.

lo_nd_<node>->bind_structure(

new_item = ls_<node>

set_initial_elements = abap_false ).

加入内表数据( Bind internal table to collection )

DATA: it_<node> TYPE wd_this->elements_<node>.

lo_nd_<node>->bind_table(

new_items = lt_<node>

set_initial_elements = abap_false ).

删除元素对象( Remove element from collection )

lo_nd_<node>->remove_element(

element = lo_el_<node> ).

 

13.4 Implementing Supply Functions(实现供应函数)

The Web Dynpro runtime calls the supply function automatically in the following situations(以下情况会使用供应函数):

  • If the node's collection is initial(当节点数据集为空时)
  • If the lead selection index of the parent node is changed(当主选择索引改变时)
  • If the collection of the node has been invalidated programmatically(当数据集中的值被代码改变时)

(上述条件为必要条件而非充分条件,如果节点没有被程序访问或者未与下一个屏幕的元素绑定,那么供应函数依然不会被调用)

 

供应函数的知识点:

  • 在节点的Supply Function属性设置值,可以绑定供应函数
  • PARENT_ELEMENT引用会指向当前节点的父节点(当我们选中某个子节点时必须确定唯一的父节点)
  • NODE引用类型可以存放当前节点的数据集

 

Lazy Data Instantiation: 这种实例化方式为,只有当数据需要被使用时才进行实例化。

上一篇:三代增强BADI总结


下一篇:SAP MM 预制发票相关的Function Modules