日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

【ABAP增强】基于源代码的增强

發布時間:2025/3/20 编程问答 18 豆豆
生活随笔 收集整理的這篇文章主要介紹了 【ABAP增强】基于源代码的增强 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

? ? ? ? 基于源代碼的增強實質上是對SAP所預留的空的子過程進行編碼,用戶可以編輯此子過程,并在這個子過程中添加自定義的代碼,以增加SAP標準程序的控制功能。

1、通過系統IMG信息查找基于源代碼的用戶出口

一般相近的功能的子程序出口都會放在一個統一的INCLUDE程序中,SAP的程序執行會調用該子程序,可以通過SAP的IMG(系統配置工具)獲取相關的出口程序的信息。

輸入事務代碼SPRO進入IMG界面,以查找銷售相關的出口信息為例,可依次選擇“銷售與分銷”-“系統修正”-“用戶出口”命令,如下圖所示:

單擊菜單中的按鈕,可以看到SAP所提供的該節點所對應的功能介紹,類似于F1的幫助,會對所提供的用戶出口程序類型、名稱和功能做簡單的介紹,如下圖所示:

通過說明文檔可以獲取SAP預定義的出口名稱,如上圖在IMG可以看到包含的源碼出口Include包括MV45ATZZ、MV45AOZZ、MV45AIZZ、MV45AFZZ等。

2、通過開發類來查找基于源代碼的用戶出口

大部分銷售及分銷的程序都是基于源碼控制來實現增強的,該類增強包含在開發類VMOD中,通過SE80可以查找該開發類所包含的所有對象。

執行事務代碼SE80,在對象類型下面選擇Package表示以開發類為條件,在對象名稱中輸入開發類名稱VMOD,回車,可以看到在列表中將帶出該開發類所包含的所有對象,包括字典對象、函數組、Include程序等等,該開發類所對應的出口程序都在“包含”列表中,具體如下圖所示:

3、基于源碼的用戶出口應用

以出口程序MV45AFZZ為例,該出口程序主要是在銷售訂單執行時候被調用,通過ABAP編輯打開并查看源代碼,可以發現該程序中包含了很多空的子程序,在程序中會對這些子程序做一些簡單的注釋說明,具體代碼如下:

***INCLUDE MV45AFZZ .************************************************************************ * * * This include is reserved for user modifications * * * * Forms for sales document processing * * * * The name of modification modules should begin with 'ZZ'. * * * *************************************************************************---------------------------------------------------------------------* * FORM ZZEXAMPLE * *---------------------------------------------------------------------* * text...................................... * *---------------------------------------------------------------------* *FORM ZZEXAMPLE.* ...*ENDFORM.*eject *---------------------------------------------------------------------* * FORM USEREXIT_DELETE_DOCUMENT * *---------------------------------------------------------------------* * This userexit can be used to delete data in additional tables * * when a sales document is deleted. * * * * This form is called in dialog at the end of form BELEG_LOESCHEN* * just before form BELEG_SICHERN is performed to delete the * * datas on the database. * * * *---------------------------------------------------------------------* FORM USEREXIT_DELETE_DOCUMENT.ENDFORM. *eject*---------------------------------------------------------------------* * FORM USEREXIT_FIELD_MODIFICATION * *---------------------------------------------------------------------* * This userexit can be used to modify the attributes of * * screen fields. * * This form is processed for each field in the screen. * * * * The use of the fields screen-group1 to screen-group4 is: * * * * Screen-group1: Automatic modification contolles by transaction* * MFAW. * * Screen-group2: Contents 'LOO' for steploop-fields. * * Screen-group3: Used for modififaction, which are dependent on * * control tables or other fix information. * * Screen-group4: Unused * * * * For field mofifications, which are dependent on the document * * status, you can use the status field in the workareas * * XVBAP for item status and XVBUK for header status. * * * * This form is called from module FELDAUSWAHL. * * * *---------------------------------------------------------------------* FORM USEREXIT_FIELD_MODIFICATION.* CASE SCREEN-GROUP3. * WHEN '900'. * IF VBAK-VBTYP NE 'A'. * SCREEN-ACTIVE = 0. * ENDIF. * ENDCASE.* CASE SCREEN-NAME. * WHEN 'VBAK-VBELN'. * SCREEN-ACTIVE = 0. * ENDCASE.ENDFORM. *eject*---------------------------------------------------------------------* * FORM USEREXIT_MOVE_FIELD_TO_VBAK * *---------------------------------------------------------------------* * This userexit can be used to move some fields into the sales * * dokument header workaerea VBAK. * * * * SVBAK-TABIX = 0: Create header * * SVBAK-TABIX > 0: Change header * * * * This form is called at the end of form VBAK_FUELLEN. * * * *---------------------------------------------------------------------* FORM USEREXIT_MOVE_FIELD_TO_VBAK.* vbak-zzfield = xxxx-zzfield2.ENDFORM. *eject*---------------------------------------------------------------------* * FORM USEREXIT_MOVE_FIELD_TO_VBAP * *---------------------------------------------------------------------* * This userexit can be used to move some fields into the sales * * dokument item workaerea VBAP * * * * SVBAP-TABIX = 0: Create item * * SVBAP-TABIX > 0: Change item * * * * This form is called at the end of form VBAP_FUELLEN. * * * *---------------------------------------------------------------------* FORM USEREXIT_MOVE_FIELD_TO_VBAP.* VBAP-zzfield = xxxx-zzfield2.ENDFORM. *eject*---------------------------------------------------------------------* * FORM USEREXIT_MOVE_FIELD_TO_VBEP * *---------------------------------------------------------------------* * This userexit can be used to move some fields into the sales * * dokument schedule line workaerea VBEP * * * * SVBEP-TABIX = 0: Create schedule line * * SVBEP-TABIX > 0: Change schedule line * * * * This form is called at the end of form VBEP_FUELLEN. * * * *---------------------------------------------------------------------* FORM USEREXIT_MOVE_FIELD_TO_VBEP.* VBEP-zzfield = xxxx-zzfield2.ENDFORM. *eject*---------------------------------------------------------------------* * FORM USEREXIT_MOVE_FIELD_TO_VBKD * *---------------------------------------------------------------------* * This userexit can be used to move some fields into the sales * * dokument business data workaerea VBKD * * * * SVBKD-TABIX = 0: Create data * * SVBKD-TABIX > 0: Change data * * * * This form is called at the end of form VBKD_FUELLEN. * * * *---------------------------------------------------------------------* FORM USEREXIT_MOVE_FIELD_TO_VBKD.* VBKD-zzfield = xxxx-zzfield2.ENDFORM. *eject*---------------------------------------------------------------------* * FORM USEREXIT_NUMBER_RANGE * *---------------------------------------------------------------------* * This userexit can be used to determine the numberranges for * * the internal document number. * * * * US_RANGE_INTERN - internal number range * * * * This form is called from form BELEG_SICHERN * * * *---------------------------------------------------------------------* FORM USEREXIT_NUMBER_RANGE USING US_RANGE_INTERN.* Example: Numer range from TVAK like in standard * US_RANGE_INTERN = TVAK-NUMKI.ENDFORM. *eject*---------------------------------------------------------------------* * FORM USEREXIT_PRICING_PREPARE_TKOMK * *---------------------------------------------------------------------* * This userexit can be used to move additional fields into the * * communication table which is used for pricing: * * * * TKOMK for header fields * * * * This form is called from form PREISFINDUNG_VORBEREITEN. * * * *---------------------------------------------------------------------* FORM USEREXIT_PRICING_PREPARE_TKOMK.* TKOMK-zzfield = xxxx-zzfield2.ENDFORM. *eject*---------------------------------------------------------------------* * FORM USEREXIT_PRICING_PREPARE_TKOMP * *---------------------------------------------------------------------* * This userexit can be used to move additional fields into the * * communication table which is used for pricing: * * * * TKOMP for item fields * * * * This form is called from form PREISFINDUNG_VORBEREITEN. * * * *---------------------------------------------------------------------* FORM USEREXIT_PRICING_PREPARE_TKOMP.ENDFORM. *eject*---------------------------------------------------------------------* * FORM USEREXIT_READ_DOCUMENT * *---------------------------------------------------------------------* * This userexit can be used to read data in additional tables * * when the program reads a sales document. * * * * This form is called at the end of form BELEG_LESEN. * * * *---------------------------------------------------------------------* FORM USEREXIT_READ_DOCUMENT.ENDFORM. *eject*---------------------------------------------------------------------* * FORM USEREXIT_SAVE_DOCUMENT * *---------------------------------------------------------------------* * This userexit can be used to save data in additional tables * * when a document is saved. * * * * If field T180-TRTYP contents 'H', the document will be * * created, else it will be changed. * * * * This form is called at from form BELEG_SICHERN, before COMMIT * * * *---------------------------------------------------------------------* FORM USEREXIT_SAVE_DOCUMENT.* Example: * CALL FUNCTION 'ZZ_EXAMPLE' * IN UPDATE TASK * EXPORTING * ZZTAB = ZZTAB.ENDFORM. *eject *---------------------------------------------------------------------* * FORM USEREXIT_SAVE_DOCUMENT_PREPARE * *---------------------------------------------------------------------* * This userexit can be used for changes or checks, before a * * document is saved. * * * * If field T180-TRTYP contents 'H', the document will be * * created, else it will be changed. * * * * This form is called at the beginning of form BELEG_SICHERN * * * *---------------------------------------------------------------------* FORM USEREXIT_SAVE_DOCUMENT_PREPARE.ENDFORM. *eject

雙擊某一個子程序名,如USEREXIT_MOVE_FIELD_TO_VBAK,可以看到其在主程序中被調用的具體位置,如下圖所示:

(現在好像該功能已經失效)

4、如何查找基于源碼的用戶出口的默認參數

出口程序通過通過ABAP來進行修改,在ABAP編輯器中可以直接在所定義的子程序中添加代碼。

做出口程序開發需要特別注意,僅能在指定的子程序中間穿插代碼,不能對子程序的結構或者名稱做任何改變,而且必須保證所編譯代碼可以正常激活,否則可能導致正常的業務發生異常。

出口開發必須要了解業務需求以及該處增強在系統中所對應的功能組,以確定對哪一部分代碼進行更改,并能找到程序中所能使用到的系統參數,以上面的MV45AFZZ為例,其主要的功能包括銷售訂單的創建、檢查以及保存。SAP的銷售訂單數據主要保存在VBAK和VBAP表中,而且SAP程序執行中會對這些數據臨時存放于內表XVBAK和XVKAP中。

查找出口中能使用到哪些內表是整個開發的關鍵,可以通過網絡資源來找到SAP官方提供的一些信息。

●查找出口程序所對應的主程序,通過ABAP編輯器能找到該出口程序的所處清單,即查看該出口程序具體由哪些程序調用。首先在ABAP編輯器中輸入出口程序名稱“MV45AFZZ”,單擊工具欄的“所用處清單”,將提示需要比較程序類型,默認即可。

●單擊確定按鈕后將看到該出口程序被主程序SAPMV45A所調用,如下圖所示:

●選中命中清單中的程序名稱,單擊工具欄中的“查看”按鈕,查看該程序的源代碼。

SAP的程序規則一般會把不同的功能代碼封裝在不同的Include中,如變量定義一般存放在程序以TOP結尾的Include中,主程序SAPMV45A中包含Include程序MV45ATOP,如下圖所示:

●雙擊Include程序mv45atop,即可查看該程序所對應的代碼。mv45atop中也包含了很多Include程序,例如其下級程序copydata中包含了部分內表及變量的定義,如圖所示:

5、通過源碼出口來增強VA01功能實例

程序中所看到的變量及內表數據都可以在用戶出口對應的子程序中直接引用,系統執行中的一些業務數據會被暫時存在指定的內表中供出口程序判斷和使用。根據這些子程序的名稱及簡介可以初步判斷其調用的過程,例如子程序USEREXIT_SAVE_DOCUMENT_PREPARE則會在訂單維護(VA01和VA02)保存前調用,下面以實例來介紹出口應用。

例如:在SAP標準功能中,保存銷售訂單一般不會判斷采購訂單編碼,本例中需要實現在訂單創建時,若訂單類型為ZOR1,要求必須填入采購訂單號,否則無法保存。

通過F1鍵查找屏幕字段的技術信息,在訂單創建事務代碼VA01中可以找到訂單類型在屏幕中的字段名稱為VBAK-AUART,采購訂單編碼在屏幕中的字段名稱為VBKD-BSTKD,對應字段可以直接在用戶出口中進行引用,出口代碼如下所示:

*---------------------------------------------------------------------* * FORM USEREXIT_SAVE_DOCUMENT_PREPARE * *---------------------------------------------------------------------* * This userexit can be used for changes or checks, before a * * document is saved. * * * * If field T180-TRTYP contents 'H', the document will be * * created, else it will be changed. * * * * This form is called at the beginning of form BELEG_SICHERN * * * *---------------------------------------------------------------------* FORM USEREXIT_SAVE_DOCUMENT_PREPARE.if vbak-auart = 'ZOR1' and vbak-bstkd is initial.message '該類型下必輸采購訂單編號' type 'E'. endif.ENDFORM.

?

程序中還包含了其他很多出口,用戶可以在程序中通過設置斷點Debug的方式來查找程序執行時不同功能所對應的出口。

總結

以上是生活随笔為你收集整理的【ABAP增强】基于源代码的增强的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。