如何编写多client多公司的增强

本文介绍了一种在SAP中为不同客户进行定制化开发的方法,通过创建特定程序避免代码冲突,并详细解释了如何为不同的公司代码或客户端激活相应的增强功能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在 sap的使用中,存在多个多个开发团队为不同 client进行开发维护,为了避免增强的影响,我们可以如下框架去编写增强

1)参照MV45AFZA创建一个程序为Y+XXXX+XX_MV45AFZA
XXXX=〉公司代码
XX=〉Modlue abbreviation

2) add Y+XXXX+XX before all form names to avoid form name conflict
For example
*---------------------------------------------------------------------*
* FORM USEREXIT_MOVE_FIELD_TO_KOMKD *
*---------------------------------------------------------------------*
* This userexit can be used to move some fields into the *
* communication workarea for product substitution. *
* *
* This form is called from form KOMKD_KOMPD_FUELLEN. *
* *
*---------------------------------------------------------------------*
FORM USEREXIT_MOVE_FIELD_TO_KOMKD.
* KOMKD-zzfield = xxxx-zzfield2.
ENDFORM.

*---------------------------------------------------------------------*
* FORM USEREXIT_MOVE_FIELD_TO_KOMKG *
*---------------------------------------------------------------------*
* This userexit can be used to move some fields into the *
* communication workarea for product listing or exclusion. *
* *
* This form is called from form KOMKG_KOMPG_FUELLEN. *
* *
*---------------------------------------------------------------------*
form y0029sd_move_field_to_komkg.
* KOMKG-zzfield = xxxx-zzfield2.
endform.

3)add include statement into MV45AFZA
include y0000sd_mv45afza. "
include y0077sd_mv45afza. "
include y0076sd_mv45afza. "
include y0029sd_mv45afza. "
include y0031sd_mv45afza. "
*} INSERT*
************************************************************************
* *
* This include is reserved for user modifications *
* *
* Forms for sales document processing *
* *
* The name of modification modules should begin with 'ZZ'. *
* *
************************************************************************

*---------------------------------------------------------------------*
* FORM USEREXIT_MOVE_FIELD_TO_KOMKD *
*---------------------------------------------------------------------*
* This userexit can be used to move some fields into the *
* communication workarea for product substitution. *
* *
* This form is called from form KOMKD_KOMPD_FUELLEN. *
* *
*---------------------------------------------------------------------*
FORM USEREXIT_MOVE_FIELD_TO_KOMKD.

* KOMKD-zzfield = xxxx-zzfield2.
ENDFORM.

4) add code depent company or client into Y+XXXX+XX_MV45AFZA
*---------------------------------------------------------------------*
* FORM USEREXIT_MOVE_FIELD_TO_KOMKD *
*---------------------------------------------------------------------*
* This userexit can be used to move some fields into the *
* communication workarea for product substitution. *
* *
* This form is called from form KOMKD_KOMPD_FUELLEN. *
* *
*---------------------------------------------------------------------*
form y0029sd_move_field_to_komkd.
perform xvbpa_lesen(sapfv45k) using 'ZH' vbap-posnr sy-tabix.
move xvbpa-kunnr to komkd-yyheadq.
DATA: BEGIN OF yhpath OCCURS 10.
INCLUDE STRUCTURE vbpavb.
DATA: END OF yhpath.
CLEAR: yhpath.
REFRESH: yhpath.
CALL FUNCTION 'SD_CUSTOMER_HIERARCHY_PATH'
EXPORTING
customer = vbak-kunnr "sold-to party
date = sy-datum "todays date
htype = 'A' "Customer hierarchy A
sales_channel = vbak-vtweg "distr. channel
sales_division = vbak-spart "division
sales_org = vbak-vkorg "sales org.
TABLES
hpath = yhpath
EXCEPTIONS
hityp_not_exist = 1
node_not_exist = 2
parvw_not_exist = 3
OTHERS = 4.
IF sy-subrc = 0.
LOOP AT yhpath.
CASE sy-tabix.
WHEN 1.
komkd-yy0000sd_hienr01 = yhpath-kunnr.
WHEN 2.
komkd-yy0000sd_hienr02 = yhpath-kunnr.
WHEN 3.
komkd-yy0000sd_hienr03 = yhpath-kunnr.
WHEN 4.
komkd-yy0000sd_hienr04 = yhpath-kunnr.

ENDCASE.
ENDLOOP.
ENDIF.
endform.

5) modify MV45AFZA source form code to check whether different company or client enhancement is active, If it is active, it is will be called
*---------------------------------------------------------------------*
* FORM USEREXIT_MOVE_FIELD_TO_KOMKD *
*---------------------------------------------------------------------*
* This userexit can be used to move some fields into the *
* communication workarea for product substitution. *
* *
* This form is called from form KOMKD_KOMPD_FUELLEN. *
* *
*---------------------------------------------------------------------*
FORM USEREXIT_MOVE_FIELD_TO_KOMKD.
* KOMKD-zzfield = xxxx-zzfield2.
*{ INSERT TASK900030 1
*{ INSERT TE1K900020 1
*** functionality: determine customer number of partner ZH (headquarter)
data: c_programm like y0000ca_userexit-yprogramm value 'MV45AFZA'.
data: c_funcname like y0000ca_userexit-yfuncname value
'USEREXIT_MOVE_FIELD_TO_KOMKD'.
data: w_programm like y0000ca_userexit-yprogramm.
data: w_funcname like y0000ca_userexit-yfuncname.
data: w_active like y0000ca_userexit-yactive.
data: w_subrc like sy-subrc.
data: w_mandt like sy-mandt.
*** check whether the user exit is activated for this client:
call function 'Y_0000CA_CHECK_USEREXIT'
exporting
pi_programm = c_programm
pi_funcname = c_funcname
importing
pe_programm = w_programm
pe_funcname = w_funcname
pe_active = w_active
pe_subrc = w_subrc.
*** if userexit is active execute it.
if sy-subrc = 0.
if ( w_active <> ' ' ) and ( w_subrc = 0 ).
w_mandt = sy-mandt. w_mandt+2(1) = '0'.
case w_mandt.
when '900' .
perform y0000sd_move_field_to_komkd.
* when '400' .
* perform y0077sd_move_field_to_komkd.
when '410' .
perform y0076sd_move_field_to_komkd.
when '440' .
perform y0031sd_move_field_to_komkd.
when others.
endcase.
endif.
endif.
*} INSERT
*} INSERT
ENDFORM.
*eject

6) 建立一个自定义表维护哪些增强已经激活

7)建立检查激活函数
FUNCTION y_0000ca_check_userexit.
*"----------------------------------------------------------------------
*"*"Local interface:
*" IMPORTING
*" REFERENCE(PI_PROGRAMM) LIKE Y0000CA_USEREXIT-YPROGRAMM
*" REFERENCE(PI_FUNCNAME) LIKE Y0000CA_USEREXIT-YFUNCNAME
*" EXPORTING
*" REFERENCE(PE_PROGRAMM) LIKE Y0000CA_USEREXIT-YPROGRAMM
*" REFERENCE(PE_FUNCNAME) LIKE Y0000CA_USEREXIT-YFUNCNAME
*" REFERENCE(PE_ACTIVE) LIKE Y0000CA_USEREXIT-YACTIVE
*" REFERENCE(PE_SUBRC) LIKE SY-SUBRC
*"----------------------------------------------------------------------

TABLES: y0000ca_userexit.
DATA: w_client LIKE y0000ca_userexit-ymandt.
*** first check whether the user exit is active in the current client:
w_client = sy-mandt.
SELECT SINGLE * FROM y0000ca_userexit CLIENT SPECIFIED
WHERE yprogramm = pi_programm
AND yfuncname = pi_funcname
AND ymandt = w_client.
*** if first check not successful check again with client xx0:
*** this client xx0 should exist in .
IF sy-subrc NE 0.
w_client+2(1) = '0'.
SELECT SINGLE * FROM y0000ca_userexit CLIENT SPECIFIED
WHERE yprogramm = pi_programm
AND yfuncname = pi_funcname
AND ymandt = w_client.
ENDIF.
*** if something was found return the values else only the return code:
pe_subrc = sy-subrc.
IF sy-subrc EQ 0.
pe_active = y0000ca_userexit-yactive.
pe_programm = y0000ca_userexit-yprogramm_exec.
pe_funcname = y0000ca_userexit-yfuncname_exec.
ELSE.
CLEAR: pe_active.
CLEAR: pe_programm.
CLEAR: pe_funcname.
ENDIF.
ENDFUNCTION.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值