[SD] Check Payment term in VA01/VA02 (FORM USEREXIT_SAVE_DOCUMENT_PREPARE)
[PURPOSE]
Check whether the payment term is suitable for the customer or not in VA01/VA02.
[TOOL]
INCLUDE: MV45AFZZ
USEREXIT: USEREXIT_SAVE_DOCUMENT_PREPARE
XVBAK ← New data if any change/else it will be same as old
YVBAK ← Old value
VBAK ← Work area
when you deal with Items it will be some thing like this..
XVBAP ← New data if any change/else it will be same as old
YVBAP ← Old data if any change(considers item) /else it is blank
If we want to get SO header where in header or items, we can obtain from WA: VBAK does not concerned to use XVBAK or YVBAK or OVBAK.
[CODE]
FORM USEREXIT_SAVE_DOCUMENT_PREPARE.
DATA: P_ZTERM TYPE KNB1-ZTERM,
P_MESSAGE TYPE STRING.
** GET PAYMENT TERM IN CUSTOMER MASTER DATA
CLEAR P_ZTERM.
SELECT SINGLE ZTERM INTO P_ZTERM FROM KNVV WHERE KUNNR = VBAK-KUNNR
AND VKORG = VBAK-VKORG
AND VTWEG = VBAK-VTWEG
AND SPART = VBAK-SPART.
** CHECK ITEM PAYMENT TERM
LOOP AT XVBKD WHERE POSNR <> '000000'.
CHECK XVBKD-ZTERM <> P_ZTERM.
CONCATENATE 'ITEM' XVBKD-POSNR 'PAYMENT TERM WON'T BE' XVBKD-ZTERM ',PLEASE CHOOSE' P_ZTERM '!' INTO P_MESSAGE.
ENDLOOP.
** CHECK HEADER PAYMENT TERM
READ TABLE XVBKD WITH KEY POSNR = '000000'.
IF XVBKD-ZTERM <> P_ZTERM.
CONCATENATE XVBAK-KUNNR 'PAYMENT TERM WOULD BE' P_ZTERM ',CHECK PLEASE!' INTO P_MESSAGE.
ENDIF.
CHECK P_MESSAGE <> ' '.
MESSAGE E001(00) WITH P_MESSAGE.
FCODE = 'ENT1'.
ENDFORM.
Check whether the payment term is suitable for the customer or not in VA01/VA02.
[TOOL]
INCLUDE: MV45AFZZ
USEREXIT: USEREXIT_SAVE_DOCUMENT_PREPARE
XVBAK ← New data if any change/else it will be same as old
YVBAK ← Old value
VBAK ← Work area
when you deal with Items it will be some thing like this..
XVBAP ← New data if any change/else it will be same as old
YVBAP ← Old data if any change(considers item) /else it is blank
If we want to get SO header where in header or items, we can obtain from WA: VBAK does not concerned to use XVBAK or YVBAK or OVBAK.
[CODE]
FORM USEREXIT_SAVE_DOCUMENT_PREPARE.
DATA: P_ZTERM TYPE KNB1-ZTERM,
P_MESSAGE TYPE STRING.
** GET PAYMENT TERM IN CUSTOMER MASTER DATA
CLEAR P_ZTERM.
SELECT SINGLE ZTERM INTO P_ZTERM FROM KNVV WHERE KUNNR = VBAK-KUNNR
AND VKORG = VBAK-VKORG
AND VTWEG = VBAK-VTWEG
AND SPART = VBAK-SPART.
** CHECK ITEM PAYMENT TERM
LOOP AT XVBKD WHERE POSNR <> '000000'.
CHECK XVBKD-ZTERM <> P_ZTERM.
CONCATENATE 'ITEM' XVBKD-POSNR 'PAYMENT TERM WON'T BE' XVBKD-ZTERM ',PLEASE CHOOSE' P_ZTERM '!' INTO P_MESSAGE.
ENDLOOP.
** CHECK HEADER PAYMENT TERM
READ TABLE XVBKD WITH KEY POSNR = '000000'.
IF XVBKD-ZTERM <> P_ZTERM.
CONCATENATE XVBAK-KUNNR 'PAYMENT TERM WOULD BE' P_ZTERM ',CHECK PLEASE!' INTO P_MESSAGE.
ENDIF.
CHECK P_MESSAGE <> ' '.
MESSAGE E001(00) WITH P_MESSAGE.
FCODE = 'ENT1'.
ENDFORM.
留言
張貼留言