效果图如下:

  1. VBAP添加客制化字段。

  1. 子屏幕8459添加增强字段。

PBO更改属性。

MODULE CHANGE_ATT OUTPUT.
if T180-TRTYP eq 'A' .
  LOOP AT SCREEN .
    SCREEN-INPUT .
    MODIFY  SCREEN .
  ENDLOOP.
ENDIF .
ENDMODULE.    

.

BAPI: BAPI_SALESORDER_CREATEFROMDAT2/BAPI_SALESORDER_CHANGE添加客制化字段。

BAPI_SALESORDER_CHANGE为例子:

解释如下:

短文本

Customer Enhancement for VBAK, VBAP, VBEP

Description

You can use this parameter to transfer user-specific enhancments to a BAPI. The customer has to complete the EXTENSION structure and the system automatically continues processing it. If you have not defined any user-specific fields, then you can transfer a blank EXTENSIONIN structure.

Technical information about Customer Enhancements

The following description uses an example to explain how to proceed with customer enhancements to the SD tables VBAK, VBKD, VBAP and VBEP.

The customer has added their own fields to table VBAP using the INCLUDE structure CUTEST. This structure contains 2 fields:
CFIELD1, CHAR 10
CFIELD2, CHAR 3.

The customer also requires that these two fields can be maintained with the BAPI.

1. Maintain structure CUTEST in table VBAP

2. Because the BAPIs work with checkboxes, you must also define a CUTESTX checkbox for the customer structure. It should be structured like this:

Field name       Data element
CFIELD1            CHAR1
CFIELD2          CHAR1

3. Define these customer structures in the structures VBAPKOZ und VBAPKOZX using INCLUDE or APPEND.

4. Add the customer structures to the BAPE_VBAP and BAPE_VBAPX BAPI structures using the APPEND technique.

5. Adjust the following structures for customer enhancements to table VBAK:

a) VBAKKOZ

b) VBAKKOZX

c) BAPE_VBAK

d) BAPE_VBAKX

6. Adjust the following structures for customer enhancements to table VBEK:

a) VBEPKOZ

b) VBEPKOZX

c) BAPE_VBEP

d) BAPE_VBEPX

7. Generally, the data should be added to the BAPI interface in the internal communication structures (VBAKKOM, and so on). There, you can process the data in the SD tables (VBAK, and so on).

8. If the EXTENSIONIN parameter contains customer data, you must complete at least the key fields in the relevant standard parameters.

For example:
You want to change customer field VBAP-CFIELD2 for item 20 to "XYZ" in order 4711.
The following entries are expected:

Import:     BAPIVBELN-VBELN       = '0000004711'  Document number
            BAPISDHD1X-UPDATEFLAG = 'U'           UPDKZ for doc header
Tables:     BAPISDITM-ITM_NUMBER  = '000020'      Item number
            BAPISDITMX-ITM_NUMBER = '000020'      Item number
          + BAPISDITMX-UPDATEFLAG = 'U'           UPDKZ for item

You must complete the EXTENSION table as follows:

STRUCTURE                          VALUEPART1       1234561234567890123

BAPE_VBAP                       0000004711000020                 XYZ
BAPE_VBAPX                      0000004711000020       X

Further information

You can find more information in the BAPI programming guide in the chapter for enhancements to BAPIs.

Notes

You must complete the STRUCTURE field with the name of the relevant enhancement structure (BAPE_VBAK, BAPE_VBAP, BAPE_VBEP). You can complete the remaining fields with the append structures from the enhancement structures.

At the moment, you can use the BAPI to store enhancements in the following structures:

  • VBAK : An enhancement to header data requires an append structure to BAPE_VBAK and an enhancement to structure VBAKKOZ.
  • VBAP : An enhancement to item data requires an append structure to BAPE_VBAP and an enhancment to structure VBAPKOZ.
  • VBEP : An enhancement to schedule line data requires an append structure to BAPE_VBEP and an enhancement to structure VBEPKOZ.
  • VBKD : If you are using an enhancement for header data, you must add an append structure to BAPE_VBAK. You also need to enhance structure VBAKKOZ. If it is for item data, you need to add an append structure to BAPE_VBAP. You must also enhance structure VBAPKOZ.

If you also want to work with checkboxes, each X-structure must also contain an append structure.

For example:

A customer has created an order and wants to include the material long text (50 digits long).

The EXTENSIONIN structure must be completed with BAPE_VBAP. Two fields have fixed definitions in this structure. These are in the VBAP host key (VBELN, POSNR). The customer sets up an append structure that contains field ZMAT50.

Because the VBELN is normally blank when you create an order, the data can look like this:

STRUCTURE   |BAPE_VBAP

VALUEPART1  |          000010Customermateriallongtext50

              VBELN     POSNR ZMAT50

按照函数说明操作如下:VBAPKOZ添加客制化字段

VBAPKOZX添加客制化字段。

BAPE_VBAP添加客制化字段

BAPE_VBAPX添加客制化字段

  DATA:LT_EXTENSIONIN  LIKE TABLE OF  BAPIPAREX,
       LS_EXTENSIONIN LIKE  BAPIPAREX .

  DATA:LS_DATA TYPE  BAPE_VBAP ,
       LS_DATAX TYPE BAPE_VBAPX .

              CLEAR LS_DATA .
            LS_DATA-VBELN =  GS_OUTPUT-VBELN .
            LS_DATA-POSNR GS_OUTPUT-POSNR.
            LS_DATA-ZZABGRU GS_OUTPUT-ABGRU+0(2).

            CLEAR LS_EXTENSIONIN .
            LS_EXTENSIONIN-STRUCTURE 'BAPE_VBAP' .
            LS_EXTENSIONIN+30 LS_DATA .
            APPEND LS_EXTENSIONIN TO LT_EXTENSIONIN .

            CLEAR LS_DATAX .
            LS_DATAX-VBELN =  GS_OUTPUT-VBELN .
            LS_DATAX-POSNR =  GS_OUTPUT-POSNR.
            LS_DATAX-ZZABGRU 'X' .

            CLEAR LS_EXTENSIONIN .
            LS_EXTENSIONIN-STRUCTURE 'BAPE_VBAPX' .
            LS_EXTENSIONIN+30 LS_DATAX .
            APPEND LS_EXTENSIONIN TO LT_EXTENSIONIN .

函数其它参数如下:

Import:     BAPIVBELN-VBELN       = XXXXXXXX'  Document number
            BAPISDHD1X-UPDATEFLAG = 'U'           UPDKZ for doc header
Tables:     BAPISDITM-ITM_NUMBER  = '000020'      Item number
            BAPISDITMX-ITM_NUMBER = '000020'      Item number
          + BAPISDITMX-UPDATEFLAG = 'U'           UPDKZ for item

Logo

开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!

更多推荐