【实例】
比如某企业配置了销项税条件类型可以手动修改,那么如何通过外部接口传值进行SO的税率更新呢?
其实采用常用的BAPI:'BAPI_SALESORDER_CHANGE'就可以实现了。
其中会调用函数'SD_SALES_ITEM_COND_MAINTAIN'进行更新。
其中的函数'PRICING_CHECK_CONDITION_LINES'我们需要了解一下,会对传入的内容进行一系列的校验。
【源码】
FUNCTION pricing_check_condition_lines.
*"----------------------------------------------------------------------
*"*"Globale Schnittstelle:
*" IMPORTING
*" VALUE(RETURN_WHEN_ERROR) TYPE BAPIFLAG
*" VALUE(NO_EXP_CURR_CHECK) TYPE BAPIFLAG OPTIONAL
*" TABLES
*" TKOMK STRUCTURE KOMK
*" TKOMP STRUCTURE KOMP
*" TRAWCL STRUCTURE RAW_COND_LINE
*" TCLOK STRUCTURE RAW_COND_LINE
*" TCLNOTOK STRUCTURE BAPIRET2
*" EXCEPTIONS
*" NO_PRIC_PROC
*"----------------------------------------------------------------------
* refresh the tables which will represent finally the check results
REFRESH tclok.
REFRESH tclnotok.
CLEAR tclok.
CLEAR tclnotok.
* read pricing procedure
READ TABLE xt683s INDEX 1.
IF xt683s-kappl NE tkomk-kappl OR
xt683s-kalsm NE tkomk-kalsm OR
sy-subrc NE 0.
SELECT kappl kalsm stunr kschl kstat kobed
INTO CORRESPONDING FIELDS OF TABLE xt683s
FROM t683s
WHERE kvewe = 'A' AND
kappl = tkomk-kappl AND
kalsm = tkomk-kalsm.
* pricing procedure does not exist
IF sy-subrc NE 0.
RAISE no_pric_proc.
ENDIF.
ENDIF.
* perform the checks for all 'raw condition lines'
LOOP AT trawcl.
tabix = sy-tabix.
* at least one errror has already occured
* ==> stop checking due to specification of RETURN_WHEN_ERROR
IF return_when_error = 'X' AND NOT tclnotok[] IS INITIAL.
EXIT.
* continue checking ==> clear workareas of tclok and tclnotok
ELSE.
CLEAR tclok.
CLEAR tclnotok.
ENDIF.
* message type and message id are always the same
tclnotok-type = 'E'.
tclnotok-id = 'VH_BAPI'.
* error case: check if condition type is filled
IF trawcl-kschl IS INITIAL.
tclnotok-number = '023'.
tclnotok-message_v1 = trawcl-kposn.
tclnotok-message_v2 = trawcl-stunr.
tclnotok-row = trawcl-row.
APPEND tclnotok.
CONTINUE.
ENDIF.
* error case: check if update-flag is correct
IF trawcl-updateflag NA 'DIU '.
tclnotok-number = '036'.
tclnotok-message_v1 = trawcl-kposn.
tclnotok-message_v2 = trawcl-kschl.
tclnotok-message_v3 = trawcl-updateflag.
tclnotok-row = trawcl-row.
APPEND tclnotok.
CONTINUE.
ENDIF.
* read customizing of condition type
READ TABLE xt685a WITH KEY kschl = trawcl-kschl
kappl = tkomk-kappl.
IF sy-subrc NE 0.
SELECT SINGLE kschl kmanu kposi kkopf kaend_loe
koaid kntyp kdupl kvarc krech kappl
knega
FROM t685a
INTO CORRES