SAP 开发 SD 相关的增强BADI_第1页
SAP 开发 SD 相关的增强BADI_第2页
SAP 开发 SD 相关的增强BADI_第3页
SAP 开发 SD 相关的增强BADI_第4页
SAP 开发 SD 相关的增强BADI_第5页
已阅读5页,还剩91页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、SD相关的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_FO

2、RMULA_BUILDERBADI Implementation with Formula BuilderVA_BADIBADIs R/3 SalesVF_BADIBAdIs for Billingsap的用户出口总共有三代:1、第一代sap提供一个空代码的子过程,在这个子过程中用户可以添加自己的代码,控制自己的需求。这类增强都需要修改sap的标准代码。示例:USEREXIT. in SAPMV45A2、第二代sap提供的是CUSTOMER-FUNCTION,它是通过SMOD和CMOD完成实现。参见我的/CompassButton/archive/2006

3、/08/31/1150258.aspx3、第三代sap提供的第三代的用户出口就是BADI,他的调用方式是CALL METHOD (instance),(相关的TCODE是SE18和SE19),你可以通过EXIT_HANDLER这个单词查找BADI。另外还有一种出口叫BTE相关TCODE: FIBFBusiness Transaction Events (Open FI)The Open FI enhancement technique was developed in the Financial Accounting component. Open FI is based upon the f

4、ollowing 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 one

5、 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 te

6、chniques 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 wil

7、l 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、关于增强的简单介绍1.1SMOD包含具体的增强,而CMOD是包含一组SMOD编写的增强. 1.2 User exits (Function module exits)是sap提供出口,它的命名规则如下: EXIT_ 示例:sd的VA01事务,对应的程序是SAPMV45A ,你会在程序里查到(用CALL CUSTOMER-FUNCTION字符串)如下代码:CALL CUSTOMER-FUNCTION 003 exporting xvbak = vbak xvbuk = vbuk xkomk = tkomk importing lvf_subrc = lvf

9、_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、选择“代码修改”按钮进入函数模块;2.5、双击函数模块的包含单元,进入包含单元加入自定义代码并激活保存;3、使用CMOD建立增强项目

10、3.1、输入自定义的项目名,点击“创建”;3.2、进入增强项目,选择“配置增强”,进入增强配置屏幕;3.3、输入增强名如:SDVFX0013.4、保存,并退出;4、使用CMOD将增强项目激活,便大工告成。如何查找*判断是否存在相应增强的定义(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 = SMO

11、D and obj_name = PPCO0002.*判断是否存在相应增强项目的定义(CMOD) SELECT SINGLE name FROM MODATTR into mod0-name WHERE NAME = PPCO0002.*提取增强的定义的组件 (可以用此反查增强定义) select * from modsap where name = PPCO0002.*判断该增强是否移植到BADI实现*Enhancement & has already been migrated in Business Add-In definition select single migrated bad

12、i_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表内*获取增强组件的参见函数MOD_SAP_MEMBER_TEXT*获得退出功能模块的信息 select single * from tftit whe

13、re SPRAS = 1 AND FUNCNAME = EXIT_SAPLCORE_001 if sy-subrc = 0. endif.*值得学习的函数MOD_KUN_ACTIVATE(会操作相关报表)如何从SAP中查找BADIBADI作为SAP的第三代用户出口,他的应用也越来越广泛,但如何找到合适的badi是许多abap程序员的困惑。我这里就介绍一下我个人的应用的经验,供大家参考。1、badi对象的信息存储在SXS_INTER, SXC_EXIT, SXC_CLASS 和SXC_ATTR这四个表中(参见SECE包);2、sap程序都会调用cl_exithandler=get_instanc

14、e来判断对象是否存在,并返回实例;其实get_instance就是对上述几个表和他们的视图(V_EXT_IMP和 V_EXT_ACT)进行查询和搜索。3、基于这个机理,我查用ST05来监控一个TCODE来跟踪,然后选择查找有关上述几个表和视图的操作,就可获得相关BADI。4、se18 查找接口,se19 实现接口就可以实现用户增强。示例:用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_l

16、og-MSGID = ZDN_ERROR. 這一個class要自己建wa_log-MSGNO = 001.append wa_log to ct_log. Error log寫入endif.endloop.ENDMETHOD. 如何实现标准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 maintain

17、 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 foll

18、owing: 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. Func

19、tion 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 u

20、nder 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 functi

21、on 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 h

23、ave 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 info

25、rmation 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 structur

27、e 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. T

29、est 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): Ex

31、it 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 Customi

32、zing 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 DocumentationThi

33、s 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 functio

34、n 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 P

35、arametersUnderstanding 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 subscre

36、en 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 field

37、s 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 into

38、 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 the

41、 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 the

42、 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 i

43、t 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 which

44、 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 of

45、 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 to

46、 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. DevelopmentCr

47、eating 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 Inc

48、lude 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 an

49、d 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_SA

51、PLAIST_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_00

52、3 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 t

54、o 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 layou

55、t 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 S

56、AP 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 your

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论