一、自定义字段增强
在使用SAP系统时,我们会发现很多时候需要使用到自定义的字段,而这些字段往往并不在标准系统中预置。这时候就需要使用到自定义字段增强功能,通过该功能可以轻松地在业务对象内添加自定义字段,并且这些字段可以像标准字段一样参与系统内各种功能的逻辑处理。
*&---------------------------------------------------------------------* *& Report ZDEMO_ENHANCEMENT_FIELD *&---------------------------------------------------------------------* *& 自定义字段增强示例报表 *&---------------------------------------------------------------------* REPORT ZDEMO_ENHANCEMENT_FIELD. TABLES: ZDEMO_ENHANCEMENT. DATA: WA_ENHANCEMENT LIKE LINE OF ZDEMO_ENHANCEMENT. START-OF-SELECTION. SELECT * FROM ZDEMO_ENHANCEMENT INTO WA_ENHANCEMENT. WRITE:/ WA_ENHANCEMENT-FIELD1, WA_ENHANCEMENT-FIELD2, WA_ENHANCEMENT-FIELD3. END-OF-SELECTION.
二、屏幕增强
在SAP系统中很多时候需要在标准屏幕上添加自定义的字段或者屏幕元素。这时候就需要使用到屏幕增强功能,通过该功能可以在一个标准屏幕内添加自定义的字段或/和屏幕元素。
*&---------------------------------------------------------------------* *& Report ZDEMO_SCREEN_ENHANCEMENT *&---------------------------------------------------------------------* *& 屏幕增强示例报表 *&---------------------------------------------------------------------* REPORT ZDEMO_SCREEN_ENHANCEMENT. TABLES: ZDEMO_ENHANCEMENT. DATA: WA_ENHANCEMENT LIKE LINE OF ZDEMO_ENHANCEMENT. START-OF-SELECTION. SELECT * FROM ZDEMO_ENHANCEMENT INTO WA_ENHANCEMENT. CALL SCREEN 0101. END-OF-SELECTION. *&---------------------------------------------------------------------* *& Module STATUS_0101 OUTPUT *&---------------------------------------------------------------------* MODULE STATUS_0101 OUTPUT. SET PF-STATUS '0100'. LOOP AT ZDEMO_ENHANCEMENT INTO WA_ENHANCEMENT. WRITE:/ WA_ENHANCEMENT-FIELD1, WA_ENHANCEMENT-FIELD2, WA_ENHANCEMENT-FIELD3. ENDLOOP. ENDMODULE.
三、菜单增强
在SAP系统中很多时候需要通过菜单快捷方式来进入各种功能模块,这时候就需要使用到菜单增强功能,通过该功能可以在标准菜单上添加自定义的菜单。
*&---------------------------------------------------------------------* *& Report ZDEMO_MENU_ENHANCEMENT *&---------------------------------------------------------------------* *& 菜单增强示例报表 *&---------------------------------------------------------------------* REPORT ZDEMO_MENU_ENHANCEMENT. TABLES: ZDEMO_ENHANCEMENT. DATA: WA_ENHANCEMENT LIKE LINE OF ZDEMO_ENHANCEMENT. START-OF-SELECTION. SELECT * FROM ZDEMO_ENHANCEMENT INTO WA_ENHANCEMENT. END-OF-SELECTION. *&---------------------------------------------------------------------* *& Module USER_COMMAND_0100 INPUT *&---------------------------------------------------------------------* MODULE USER_COMMAND_0100 INPUT. IF SY-UCOMM = 'ZDEMO_ENHANCEMENT'. CALL TRANSACTION 'ZDEMO_ENHANCEMENT'. ENDIF. ENDMODULE.
四、功能增强
在SAP系统中很多时候需要对标准功能进行扩展,以满足业务需要,这时候就需要使用到功能增强功能,通过该功能可以在标准功能上增加自定义的功能逻辑。
*&---------------------------------------------------------------------* *& Report ZDEMO_FUNCTION_ENHANCEMENT *&---------------------------------------------------------------------* *& 功能增强示例报表 *&---------------------------------------------------------------------* REPORT ZDEMO_FUNCTION_ENHANCEMENT. TABLES: ZDEMO_ENHANCEMENT. DATA: WA_ENHANCEMENT LIKE LINE OF ZDEMO_ENHANCEMENT. START-OF-SELECTION. SELECT * FROM ZDEMO_ENHANCEMENT INTO WA_ENHANCEMENT. END-OF-SELECTION. *&---------------------------------------------------------------------* *& Form FUNCTION_ENHANCEMENT *&---------------------------------------------------------------------* FORM FUNCTION_ENHANCEMENT USING P_MATNR TYPE MATNR. DATA: V_MATERIAL TYPE MARA-MATNR. SELECT SINGLE MATNR INTO V_MATERIAL FROM MARA WHERE MATNR = P_MATNR. IF SY-SUBRC = 0. "进行业务逻辑操作 ENDIF. ENDFORM.
五、BADI增强
在SAP系统中很多时候需要对标准程序进行扩展,以满足业务需要,这时候就需要使用到BADI增强功能,通过该功能可以在标准程序中嵌入自定义的业务逻辑实现。
*&---------------------------------------------------------------------* *& Report ZDEMO_BADI_ENHANCEMENT *&---------------------------------------------------------------------* *& BADI增强示例报表 *&---------------------------------------------------------------------* REPORT ZDEMO_BADI_ENHANCEMENT. TABLES: ZDEMO_ENHANCEMENT. DATA: WA_ENHANCEMENT LIKE LINE OF ZDEMO_ENHANCEMENT. START-OF-SELECTION. SELECT * FROM ZDEMO_ENHANCEMENT INTO WA_ENHANCEMENT. END-OF-SELECTION. *&---------------------------------------------------------------------* *& Object ZDEMO_BADI_IMPLE *&---------------------------------------------------------------------* CLASS ZDEMO_BADI_IMPLE DEFINITION. PUBLIC SECTION. INTERFACES: IF_EX_ZDEMO_BADI. PRIVATE SECTION. ENDCLASS. *&---------------------------------------------------------------------* *& Interface IF_EX_ZDEMO_BADI *&---------------------------------------------------------------------* INTERFACE IF_EX_ZDEMO_BADI. METHODS: ENHANCEMENT. ENDINTERFACE. *&---------------------------------------------------------------------* *& Class ZDEMO_BADI_IMPLE Implementation *&---------------------------------------------------------------------* CLASS ZDEMO_BADI_IMPLE IMPLEMENTATION. METHOD IF_EX_ZDEMO_BADI~ENHANCEMENT. * 进行自定义逻辑处理 ENDMETHOD. ENDCLASS.通过以上几种方式的增强,我们可以大大提高SAP系统的使用效率,减少企业内部的工作量,进而得到更高的生产效益。