SD--订单最小量限制的增强

在现实的销售活动中考虑到配送成本,需要限制小额订单的开具,为了达到该目的,我们可以对出口USEREXIT_SAVE_DOCUMENT_PREPARE进行增强,具体步骤如下.

一、设计订单起定量设置表,自定义(销售公司+订单类型)具体定义参见下图

SD--订单最小量限制的增强_第1张图片

建立通过sap表维护工具来维护自定义表程序和事务妈。请参考:http://blog.csdn.net/CompassButton/archive/2007/06/04/1637580.aspx

二、设计订单起定量设置(客户)表,自定义(客户)具体定义参见下图

SD--订单最小量限制的增强_第2张图片

建立通过sap表维护工具来维护自定义表程序和事务妈。

三、增强代码

se38打开单元MV45AFZZ,修改USEREXIT_SAVE_DOCUMENT_PREPARE过程,代码如下

*---------------------------------------------------------------------*
* 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.
*{ INSERT DEVK938281 1
DATA: zzamount LIKE vbak-netwr.
DATA: zmin LIKE vbak-netwr.
IF vbak-waerk NE tvko-waers. "
CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'
EXPORTING
date = sy-datum
foreign_amount = vbak-netwr
foreign_currency = vbak-waerk
local_currency = sy-waers
IMPORTING
local_amount = zzamount
EXCEPTIONS
no_rate_found = 01
overflow + 02.
IF sy-subrc NE 0.
zzamount = vbak-netwr.
ENDIF.
ELSE.
zzamount = vbak-netwr.
ENDIF.
*minimum order value check in local currency
TABLES: zorderlimit, zorder_limit.
DATA minvalue LIKE vbak-netwr.
DATA difference LIKE vbak-netwr.
SELECT SINGLE * FROM zorder_limit
WHERE vkorg EQ vbak-vkorg
and auart EQ vbak-auart.
IF sy-subrc EQ 0.
SELECT SINGLE * FROM zorderlimit
WHERE KUNNR EQ vbak-KUNNR.
IF sy-subrc EQ 0.
zmin = zorderlimit-ZZNETWR * 100.
IF zzamount < zmin.
MESSAGE '单据小于公司规定的订单起定量,系统不能保存!' TYPE 'E'.
sy-subrc = 4.
exit.
ENDIF.
ELSE.
zmin = zorder_limit-ZZNETWR * 100.
IF zzamount < zmin.
MESSAGE '单据小于公司规定的订单起定量,系统不能保存!' TYPE 'E'.
sy-subrc = 4.
exit.
ENDIF.
ENDIF.
ENDIF.
*
*} INSERT


ENDFORM.
*eject

四、结果如下图

你可能感兴趣的:(.net,活动,Blog)