Enhancement Framework 联系客服

发布时间 : 星期一 文章Enhancement Framework更新完毕开始阅读ac6da9075fbfc77da369b141

and what the return values mean.

In other systems that are based on ERP, a country-specific implementation can/must be provided in accordance with the contract.

Execution

The two parts of an enhancement option described above are implemented using the following ABAP statements:

? GET BADI – for getting objects

? CALL BADI – for calling interface methods

You might have a BAdI definition created in ERP with the name badi_check_validity. This definition can have a method check_validity with an input parameter data that verifies the validity of the order day and the country filter of the BAdIs, which has the name country. In this case, the enhancement option can look as follows:

DATA bd TYPE REF TO badi_check_validity. GET BADI bd FILTERS country = cntry.

CALL BADI bd->check_validity EXPORTING data = ...

Explanation

The code fragment shows that the BAdI is addressed in an ABAP program through a reference variable of the type REF TO badi_check_validity. An object that points to such a reference variable is called BAdI Handle. BAdI names are therefore in the same namespace as all global objects and data types. The statement GET BADI searches in the Repository for all currently activated implementations of the BAdIs and chooses those that are defined for the filter value in cntry. These are instantiated and are referenced by the BAdI handle created in the statement. In the following statement CALL BADI, the method call is automatically passed to the actual BAdI implementation instances referenced by the BAdI handle.

Definition of BAdIs

Use

When you define a BAdI, you must specify a name, a BAdI interface as the interface for the enhancement option, and the required filters. The name of a BAdI is in the same namespace as data types from the ABAP Dictionary, global classes, or interfaces. It is recommended that you use suitable prefixes, such as “BADI_”.

A filter consists of a filter name and a data type (integer, string, and so on).

In addition, you also define BAdI properties that are relevant at runtime of a program with the appropriate statements GET BADI and CALL BADI. For more information, see Instance Generation Mode and Multiple Use.

可以被分配到BAdi include的其他属性:

● 一个可选的BAdi退回类。当没有符合过滤条件的BAdi实现,并且找不到标准的实

现时,使用这个可选的退回类。

● BAdi是不是内部的

一个内部BAdi只允许被SAP实现,并且在SAP外不可见。

● BAdi是否是function code or screen enhancement.。

作为function code增强定义的BAdi不能含有任何过滤,不能定义为多次使用,也不能分配给任何switch。可以包含独立于实际function code增强的方法。(It may contain methods that are independent of the actual function code enhancement.)

作为屏幕增强定义的BAdi为了实例重用,必须以instance generation模式来定义,并且不能定义多次使用。它可以包含BAdi方法,用来填充或者评估各个子屏幕的屏幕字段。 See also:

Definition of BAdIs in the Enhancement Builder

Instance Generation Mode

Definition

这个属性控制对象插件的实例化,在GET BADI语句执行期间。以下是可能的技术说明:

? Newly created instantiation(最近创建的实例化) ? Reused instantiation(可重用的实例化)

? Context-dependent instantiation(上下文依赖的实例化)

Use

开始的2个说明定义的是上下文无关的BAdIs。当是newly created instantiation时,在每次执行GET BADI语句时,都会创建一个新的对象插件。当是Reused instantiation时,如果一个对象被调用了多次,在当前内部模式下使用的对象插件是可以重用的,即不生成新的对象。 当是context-dependent instantiation时,必须为GET BADI指定一个上下文环境。这个上下文环境控制实例化。对象只为每个上下文和执行类而创建。如果每次调用GET BADI时,上下文相同,则不创建新的对象。上下文环境是实现了标签接口if_badi_context的类的一个实例。The specification takes place in the form of a reference to such an instance.

如果对象插件是为了得到可重用的数据,只有技术说明1和2可用。

Example

The figures below show the situation for context-free BAdIs, after two statements following each other:

GET BADI bd1. GET BADI bd2.

The upper rectangles represent the BAdI objects. The broken-line arrows show which object plug-ins are referenced by the BAdI objects, whereby the case of two suitable BAdI implementation classes cl_imp1 and cl_imp2 is demonstrated.

Figure 1 shows the newly created instantiation. Each time a BAdI object is created, new object plug-ins are created – first imp1 and imp2, then imp3 and imp4.

Figure 2 shows the reused instantiation. For each BAdI implementation class, only one instance is created. All BAdI objects reference the same instance, irrespective of where (in internal mode) and how the BAdI object is called.

Multiple Use

Definition

这个属性定义了,在GET BADI语句初始化BAdi对象期间,通过特定的过滤参数,是否只有一个实现可以被选中,或者是否任意数量的实现(或者根本没有实现)可以被选中。

在GET BADI时,如果一个BAdI是单次使用的,但是却选中了多个实现,会触发cx_badi_multiply_implemented异常。如果找不到实现类,触发cx_badi_not_implemented异常。

Use

You can define whether a BAdI is to be provided for single or multiple use. In the standard version, a BAdI is provided for single use, but a multiple use can also be selected.

In the case of a multiple use, there is a general restriction – in addition to the general restriction regarding variable attributes – that the BAdI methods must not have any EXPORTING or RETURNING parameters. The reason for this is that, if you have a call with CALL BADI, the methods of all the object plug-ins referenced by the BAdI object are called and that there is no definition regarding from which of the implementations a returned value will actually come. CHANGING parameters, on the other hand, are allowed since these are changed by all the calling methods, one after the other, so that a method can also access the parameter changed in a previous method.

Definition of BAdIs in the Enhancement Builder

Use

The BAdIs of the enhancement concept are not treated as standalone(独立的) objects, but are integrated in the overall concept. Thus, the tools for defining BAdIs are part of the Enhancement Builder included in the ABAP Workbench.

Transaction SE18, up to now the only entry point for defining classic BAdIs, now manages classic and new BAdIs. When an existing BAdI is displayed or changed, it analyzes whether the BAdI is a classic or a new one, and then switches to the respective tool. In the case of a new BAdI, this tool is the enhancement spot editor.

Creating classic BAdIs is no longer supported.

Since the classic SE18 transaction represents only a side entry point into the Enhancement Builder, the sections below describe the procedure in the Object Navigator:

? Creating a BAdI

? Displaying, Changing, or Deleting a BAdI

Creating a BAdI

Procedure

1. Start the Object Navigator (SE80).