如何使用SMOD和CMOD进行SD的用户增强
1、关于增强的简单介绍
1.1 SMOD包含具体的增强,而CMOD是包含一组SMOD编写的增强.??
1.2 User exits (Function module exits)是sap提供出口,它的命名规则如下:?
EXIT_<program name><3 digit suffix>??
示例:
sd的VA01事务,对应的程序是SAPMV45A ,你会在程序里查到(用CALL CUSTOMER-FUNCTION字符串)如下代码:
CALL CUSTOMER-FUNCTION '003'?
? exporting?
??? xvbak?? = vbak?
??? xvbuk?? = vbuk?
??? xkomk?? = tkomk?
? importing?
??? lvf_subrc = lvf_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建立增强项目
3.1、输入自定义的项目名,点击“创建”;
3.2、进入增强项目,选择“配置增强”,进入增强配置屏幕;
3.3、输入增强名如:SDVFX001
3.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??????? =? 'SMOD'
???????????????????????????? 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 badi_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
???????????? where "SPRAS" = '1' AND "FUNCNAME" = 'EXIT_SAPLCORE_001'
????? if sy-subrc = 0.
????? endif.
*值得学习的函数
MOD_KUN_ACTIVATE(会操作相关报表)