SAP 開發(fā) SD 相關(guān)的增強BADI_第1頁
SAP 開發(fā) SD 相關(guān)的增強BADI_第2頁
SAP 開發(fā) SD 相關(guān)的增強BADI_第3頁
SAP 開發(fā) SD 相關(guān)的增強BADI_第4頁
SAP 開發(fā) SD 相關(guān)的增強BADI_第5頁
已閱讀5頁,還剩91頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)

文檔簡介

1、.SD相關(guān)的BADIHU_BADIBusiness Add-Ins for Handling UnitsLE_SHP_BADIBusiness Add-Ins in ShippingLE_TRA_BADIBusiness Add-Ins in TransportationLE_WM_BADIBusiness Add-Ins in Warehouse ManagementMRM_BADIBusiness Add-Ins in Invoice VerificationPL_PACKINST_BADIBusiness Add-In in the Packing InstructionS_BADI_F

2、ORMULA_BUILDERBADI Implementation with Formula BuilderVA_BADIBADIs R/3 SalesVF_BADIBAdIs for Billingsap的用戶出口總共有三代:1、第一代sap提供一個空代碼的子過程,在這個子過程中用戶可以添加自己的代碼,控制自己的需求。這類增強都需要修改sap的標準代碼。示例:USEREXIT. in SAPMV45A2、第二代sap提供的是CUSTOMER-FUNCTION,它是通過SMOD和CMOD完成實現(xiàn)。參見我的/CompassButton/archive/200

3、6/08/31/1150258.aspx3、第三代sap提供的第三代的用戶出口就是BADI,他的調(diào)用方式是CALL METHOD (instance),(相關(guān)的TCODE是SE18和SE19),你可以通過EXIT_HANDLER這個單詞查找BADI。另外還有一種出口叫BTE相關(guān)TCODE: FIBFBusiness Transaction Events (Open FI)The Open FI enhancement technique was developed in the Financial Accounting component. Open FI is based upon the

4、following principles:Application developers must define their interface in a function module, an assignment table is read in the accompanying (generated) code, and the customer modules assigned are called dynamically.This technique differentiates between enhancements that are only allowed to have on

5、e implementation and enhancements that can call multiple implementations in any sequence desired. Both industry-specific and country-specific enhancements may be defined. The concepts behind the Business Add-Ins enhancement technique and Open FI are basically the same. However, the two enhancement t

6、echniques do differ from each other in the following points: Open FI can only be used to make program enhancements, that is, you can only enhance source code using Open FI. You cannot enhance user interface elements with Open FI like you can with Business Add-Ins. Open FI assumes that enhancement wi

7、ll only take place on three levels (SAP - partners - customers), whereas with Business Add-Ins you can create and implement enhancements in as many software layers as you like. Open FI uses function modules for program enhancements. With Business Add-Ins, ABAP Objects is used to enhance programs.如何使

8、用SMOD和CMOD進行SD的用戶增強1、關(guān)于增強的簡單介紹1.1SMOD包含具體的增強,而CMOD是包含一組SMOD編寫的增強. 1.2 User exits (Function module exits)是sap提供出口,它的命名規(guī)則如下: EXIT_ 示例:sd的VA01事務(wù),對應(yīng)的程序是SAPMV45A ,你會在程序里查到(用CALL CUSTOMER-FUNCTION字符串)如下代碼:CALL CUSTOMER-FUNCTION 003 exporting xvbak = vbak xvbuk = vbuk xkomk = tkomk importing lvf_subrc = lv

9、f_subrc tables xvbfa = xvbfa xvbap = xvbap xvbup = xvbup. 則exit calls function module的名稱就是: EXIT_SAPMV45A_003 2、先試用SMOD建立一個SAP增強2.1、選擇一個增強,如:SDVFX001,點擊修改,進入sap增強維護屏幕;2.2、點擊“組件”按鈕,進入組件維護屏;2.3、將光標移到“功能模塊名”,輸入模塊名,如:EXIT_SAPLV60B_001;2.4、選擇“代碼修改”按鈕進入函數(shù)模塊;2.5、雙擊函數(shù)模塊的包含單元,進入包含單元加入自定義代碼并激活保存;3、使用CMOD建立增強項

10、目3.1、輸入自定義的項目名,點擊“創(chuàng)建”;3.2、進入增強項目,選擇“配置增強”,進入增強配置屏幕;3.3、輸入增強名如:SDVFX0013.4、保存,并退出;4、使用CMOD將增強項目激活,便大工告成。如何查找*判斷是否存在相應(yīng)增強的定義(SMOD) select single name from modsapa into mod0-name where name = PPCO0002. if sy-subrc = 0. endif. select single * from tadir into ps_tadir_db where pgmid = R3TR and object = SM

11、OD and obj_name = PPCO0002.*判斷是否存在相應(yīng)增強項目的定義(CMOD) SELECT SINGLE name FROM MODATTR into mod0-name WHERE NAME = PPCO0002.*提取增強的定義的組件 (可以用此反查增強定義) select * from modsap where name = PPCO0002.*判斷該增強是否移植到BADI實現(xiàn)*Enhancement & has already been migrated in Business Add-In definition select single migrated ba

12、di_def into (migrated, exit_name) from modsapa where name = modname. if sy-subrc = 0 and migrated = seex_true. message s621 with modname exit_name. check mode ne CHAM. endif.MODTYP 類型:E : 功能退出S : 屏幕T : 表C : GUI代碼sap增強存在MODSAP表內(nèi)*獲取增強組件的參見函數(shù)MOD_SAP_MEMBER_TEXT*獲得退出功能模塊的信息 select single * from tftit wh

13、ere SPRAS = 1 AND FUNCNAME = EXIT_SAPLCORE_001 if sy-subrc = 0. endif.*值得學(xué)習(xí)的函數(shù)MOD_KUN_ACTIVATE(會操作相關(guān)報表)如何從SAP中查找BADIBADI作為SAP的第三代用戶出口,他的應(yīng)用也越來越廣泛,但如何找到合適的badi是許多abap程序員的困惑。我這里就介紹一下我個人的應(yīng)用的經(jīng)驗,供大家參考。1、badi對象的信息存儲在SXS_INTER, SXC_EXIT, SXC_CLASS 和SXC_ATTR這四個表中(參見SECE包);2、sap程序都會調(diào)用cl_exithandler=get_instan

14、ce來判斷對象是否存在,并返回實例;其實get_instance就是對上述幾個表和他們的視圖(V_EXT_IMP和 V_EXT_ACT)進行查詢和搜索。3、基于這個機理,我查用ST05來監(jiān)控一個TCODE來跟蹤,然后選擇查找有關(guān)上述幾個表和視圖的操作,就可獲得相關(guān)BADI。4、se18 查找接口,se19 實現(xiàn)接口就可以實現(xiàn)用戶增強。示例:用LE_SHP_DELIVERY_PROC控制跨月CancelMETHOD IF_EX_LE_SHP_DELIVERY_PROCCHANGE_DELIVERY_HEADER .data : thismonth(2) type c.data : wa_likp

15、 type line of SHP_LIKP_T.data : wa_log type line of SHP_BADI_ERROR_LOG_T.clear ct_log,thismonth.thismonth = sy-datum+4(2). -這一個月的月份loop at it_xlikp into wa_likp.check IS_V50AGL-WARENAUSG_STORNO =X.-代表作GI cancelif wa_likp-WADAT_IST+4(2) thismonth.wa_log-VBELN = cs_likp-vbeln.wa_log-MSGTY = E. 錯誤訊息wa_

16、log-MSGID = ZDN_ERROR. 這一個class要自己建wa_log-MSGNO = 001.append wa_log to ct_log. Error log寫入endif.endloop.ENDMETHOD. 如何實現(xiàn)標準TCODE的屏幕增強(HOWTO:Implement a screen exit to a standard SAP transaction)IntroductionSAP provides standard transactions to enter data into database. But a client may want to maintai

17、n some additional information in SAP other than what is provided. To make provisions for this, additional screens have to be provided and additional fields must be added into appropriate database table. To pave way for this, SAP has provided the option for screen exits. Usually, SAP provides the fol

18、lowing: 1. An append structure in the database table with the new fields. 2. A subscreen area into the standard screen where the programmer can attach his subscreen of his own program with the new fields. 3. A function group under which the new subscreen has to be created with the new fields. 4. Fun

19、ction exits to synchronize the PBO and PAI of the standard SAP program with the PBO and PAI of the subscreen so that data can flow back and forth between the standard SAP program and the program written by the developer for the subscreen. These function modules also exist in the same function group

20、under which the subscreen will have to be developed. Finally, a linkage has to be done between the subscreen area of standard SAP screen with the custom subscreen constructed by the developer. Typically, SAP provides an enhancement in which the developer can create an append structure, use the funct

21、ion exits to synchronize the PBO and PAI of the standard SAP program and the custom subscreen program, and make the necessary linking( as mentioned above in step 4. But, again, this is not a hard and fast rule. Linking in some case, is also done by configurations.) SAP also usually provides the name

22、 of the function group under which the subscreen has to be developed. Necessary guidance about implementing a screen exit development is usually available in the Documentation section of the enhancement ( can be availed by transaction SMOD). Pre-RequisitesThe developer to work on screen exit should

23、have essential knowledge on the following: DDIC concepts, including the knowledge of append structure. Concept of SAP Enhancements and implementing them using Projects. Concept of function exits. Knowledge on Module Pool including subscreens, Tabstrip controls etc. StepsGuidelinesSo, a developer can

24、 follow the guidelines mentioned below to implement a screen exit to a standard SAP transaction, as and when required: Find out the Required Enhancements1. Go to SMOD. Press F4 in the Enhancement field. In the next popup window, click pushbutton SAP Applications. A list will appear that contains inf

25、ormation on all the enhancements, categorized under functional areas. Developer must search for the enhancements relevant to his functional area of interest for e.g., Purchasing, Asset Accounting, etc. 2. Note down the enhancements. Then, come to the initial screen of SMOD and view the documentation

26、 of each enhancement to find out which one is required for your development. Utilize the Enhancement in a ProjectAfter you have found one, do as directed in the documentation. Generally, the steps are as follows: 1. Create a project using CMOD including your enhancement. 2. Create the append structu

27、re with new fields. 3. Go to the desired function group and create a subscreen with the new fields. Write PBO and PAI for the subscreen, if required. 4. Use the function exits in the enhancement to link the PBO and PAI of the subscreen with that of the main SAP program supporting the SAP transaction

28、. 5. Maintain necessary linkage between the subscreen area of standard SAP program with the custom subscreen developed along with the custom program name. This can be done in the project (developed by CMOD including the enhancement) or outside as a part of configuration. 6. Activate the project. 7.

29、Test to ensure that required functionality are met. Case Study 1Add three new custom fields for Asset master and maintain information for them RequirementThree fields in the legacy system have to be maintained in Asset master. These fields are: 1. Original Asset number 20 characters 2. Location 2 15

30、 Characters. 3. Model no 20 characters Location 2 should start with L. Pre-AnalysisFinding out the EnhancementAs described above, the enhancement is determined. It was found, that enhancement AIST0002 will serve the purpose. It contains the following components (can be viewed by transaction SMOD): E

31、xit Type Description EXIT_SAPL1022_001 Function Exit Check of User-Defined Fields when Using Create and Change BAPI EXIT_SAPLAIST_002 Function Exit Transfer Data for User Subscreens in PBO. EXIT_SAPLAIST_003 Function Exit Transfer of User-Defined Fields to SAP Master Data Transactions CI_ANLU Custom

32、izing Include Include structure to add new fields Studying the Function ExitsThe function module level documentation for the function exits are then viewed from transaction SE37. The documentation clearly laid out for the purpose for their use: EXIT_SAPLAIST_002 Function module Level DocumentationTh

33、is function module is called by asset master data maintenance at the start of the dialog. (When changing, it is called after reading of the data from the database; when creating it is called after the transfer of the default values from the asset class and reference asset.) The purpose of the functi

34、on module is to enable this function group to recognize the master data. For interpreting or controlling master data fields that are important for user fields, it is possible to transfer to global variables at this point, so that they can be recognized when the user subscreens are processed. Import

35、ParametersUnderstanding This function module is called at the PBO to pass the information retrieved from the database to pass them to the custom subscreen and its underlying program. Import parameter: I_ANLU will be populated with the values for user-defined fields which will be passed to the subscr

36、een program. So, there must be some sort of variable assignment from I_ANLU. EXIT_SAPLAIST_003 Function module Documentation: This function module is called by SAP asset master data maintenance after the screens are processed, but before saving. The purpose of the function module is to transfer fiel

37、ds entered on user sub-screens of SAP asset data maintenance to the database for updating. The export parameter for this function module is: Understanding This function module will be used to transfer the user entered data in the subscreen fields to the main SAP program, which will then be saved int

38、o the database. Studying the Documentation of the EnhancementThe enhancement documentation (as is viewed from the initial screen of SMOD also supports the idea. Moreover, it informs that we need to develop a subscreen under function group XAIS. This is the function group under which the two function

39、 exit modules also exist. So, if the custom subscreen refers to the global data of the function group XAIS, then those values will also be available to these function exits as well. Going to SE80 and viewing the function group XAIS helps us to inform that there are three DDIC tables declared for it:

40、 Deciding the Final course of ActionAfter making all the investigations, the final course of action was determined. SrlNo Step Justification 1. A project has to be created using transaction CMOD where the enhancement AIST0002 will be included. 2. Customizing include CI_ANLU has to be created with th

41、e custom fields demanded When CI_ANLU will be developed, the custom fields will get appended to the database table ANLU. Also, these fields will be used to create screen fields in the new subscreen. 3. A custom subscreen, say, 9000 will be developed under function group XAIS. The screen group for th

42、e screen will be CUST (or any name). The three custom fields added to table ANLU (by creating CI_ANLU) will be used to create new fields in the screen. In the PAI of the subscreen, validation for Location to start with L will be added. The subscreen with three new fields has to be developed so that

43、it can be attached to a subscreen area of the asset master screens. 1. In the custom include of the function exit module EXIT_SAPLAIST_002, the following code will be written:- ANLU = I_ANLU. I_ANLU is the import parameter of this FM. The value is assigned to the global variable ANLU, referring whic

44、h the three new subscreen fields are developed. So, data retrieved from database table ANLU will be passed to this FM as I_ANLU by the standard SAP main program. The value will be taken and passed to the global variable of the function group XAIS, so that the three custom fields (referring to ANLU o

45、f XAIS) get populated. 1. In the custom include of the function exit module EXIT_SAPLAIST_003, the following code will be written:- E_ANLU = ANLU. The changed values in the subscreen fields exist in global variable ANLU for the function group XAIS. This function exit module will pass the data back t

46、o the SAP main program as E_ANLU. 1. Proper linkage/configuration has to be done so that the new subscreens get linked to the appropriate subscreen area of the Asset master screen. This has to be done otherwise, the new custom subscreen will not be displayed in the Asset master screens. DevelopmentC

47、reating a Project to include the enhancement1. Go to transaction CMOD and create a project. 2. Enter a description for the project. Then, click on the pushbutton Enhancement Assignments in the Application Toolbar. 3. Enter the name of the enhancement and Save. 4. Go to Components. Creating Custom In

48、clude for ANLUThe screen shown below will appear, showing all the enhancement components under the assignment AIST0002. Double-click on the name of the Include Structure to create it. Create the include structure with three new fields, as required. Then, save and activate it. Develop the subscreen a

49、nd the programGo to transaction SE80. For the function group XAIS, create a new subscreen 9000. Create it as subscreen. Then, go to the Layout of the screen and create three new fields from Database table ANLU. Drag the fields in the screen body and place them. Then, save and activate the screen and

50、 come back to screen flow editor. Create the PAI module to add validation for field “Location 2”, as required . Activate the whole function group and come out. Write code in the Function Exits to synchronize the programsNow, code has to be written in the function modules EXIT_SAPLAIST_002 and EXIT_S

51、APLAIST_003 so that data flows to and fro between the main SAP program and custom subscreen program. For that, go back to transaction CMOD and change the function exits. Write code in the function module EXIT_SAPLAIST_002 called once at the beginning of the transaction: Write code in EXIT_SAPLAIST_0

52、03 to pass the data from the subscreen to SAP main program. Then, activate everything the whole project and come out. Complete the configuration to link the subscreenThe development portion is complete. Now, linking of the subscreen has to be done with the subscreen area of the main program. In most

53、 of the cases, this linking can be done in the enhancement itself. But, here, requirement is a bit different. It is done by configuration using SPRO. Assets are created under Asset class. And for each asset class, there is a layout assigned to it. For a layout, there are multiple tab pages assigned

54、to it. And, for each tab page, there are multiple screen groups/field groups assigned. Here, the requirement is to create these three custom fields in the tab page General of asset master screen ( AS01/AS02/AS03/AS91). Determine the LayoutTo achieve this, first of all, we need to find out which layo

55、ut is assigned to asset class 1000.For that, go to transaction AOLK( information has to be obtained from functional consultant).Select the Asset Class 1000 and click on folder General Assignment of Layout. Here, for Asset class 1000, for all the user groups, tab layout SAP is assigned. Since layout

56、SAP cannot be changed, it has to be copied and manipulated to include our screen group. Later, the new layout has to be assigned over here. Create new tab layoutGo to transaction AOLA. Copy the tab layout SAP to create another layout, say, YSUB. System will copy all the settings and will inform you about that. Select your newly created layout and double-click on the folder Tab page titles. You want to put yo

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論