SD--对于定价过程参考步骤 (Condition Step)(T683S-STUNB and T683S-STUN2)的使用代码分析

阅读更多

1)概述

对于参考步骤 (Condition Step)(T683S-STUNB and T683S-STUN2)的使用代码分析
SAP对定价过程中的从参考步骤(T683S-STUNB)和到参考步骤T683S-STUN2)的使用分两种情况:无条件类型的小计项目和有条件计算项目。
在LV61AA55单元会根据定价过程生成的xkomv内表来循环计算各项值
*LOOP
loop at xkomv.
* calculate condition basis(有条件计算项目),(162行),调用konditionsbasis_ermitteln子过程填写kawrt(条件基值),供后续项目计算使用
perform konditionsbasis_ermitteln.
.....
* scale basis changed or 0
* KON-KBETR should not be there if scale basis is 0
( ( xkstbs ne ykstbs ) or xkstbs eq 0 ) and
xkomv-kmprs is initial and
xkomv-ksteu eq 'A'.
perform xkomv_kbetr_aus_staffel.
endif.
if xkomv-krech na absolute or xkomv-kgrpe ne 'X'.
perform xkomv_kwert_ermitteln.
endif.
endif.
else.
if xkomv-kschl eq space."
*(无条件类型的小计项目),调用xkomv_kwert_ermitteln子过程直接将汇总填写到小计项目的kwert字段
perform xkomv_kwert_ermitteln.
endif.
endif.
.....
 endloop.
2)无条件类型的小计项目计算代码分析
xkomv_kwert_ermitteln代码参见单元LV61AA43的下列代码,这段代码会调用子过程xkomv_kawrt_ermitteln将相应定价项目的字段(kwert)汇总填写到小计项目的kwert字段,参见红色部分。
FORM xkomv_kwert_ermitteln.
DATA: xkbetr(16) TYPE p DECIMALS 2.
DATA: cond_curr_is_euro, doc_curr_is_euro.
* sum line owning reference step
IF xkomv-kschl = space AND xkomv-stunb NE 0.
CATCH SYSTEM-EXCEPTIONS conversion_errors = 1
arithmetic_errors = 5.
PERFORM xkomv_kawrt_ermitteln.
xkomv-kwert = xkawrt.
ENDCATCH.
IF sy-subrc = 1 OR sy-subrc = 5.
MESSAGE s802.
xkomv-kinak = 'X'.
xkomv-kwert = 0.
xkomv-fxmsg = '802'.
komp-fxmsg = '802'.
ENDIF.
* no calculation for KDUPL conditions because condition value is
* calculated by formula 36.
ELSEIF xkomv-kdupl NE 'B'.
3)有条件计算项目代码分析
konditionsbasis_ermitteln代码参见单元LV61AA74的下列代码,这段代码会调用子过程xkomv_kawrt_ermitteln将相应定价项目的字段(kwert)汇总填写到小计项目的kawrt(条件基值),参见红色部分。
form konditionsbasis_ermitteln.
data: da_xxmglme like komp-brgew,
da_xxmeins like komp-gewei,
da_fxmsg like xkomv-fxmsg.
data: arbfeld_dec(16) type p decimals 3.
xkomv-kawrt = 0.
if xkomv-krech ca prz_abs and not xkomv-krech = 'T'.
if xkomv-stunb ne 0 or xkomv-stun2 ne 0 or xkomv-koaid = 'D'.
perform xkomv_kawrt_ermitteln.
xkomv-kawrt = xkawrt.
endif.
if xkomv-stunb = 0 and xkomv-stun2 = 0.
xkomv-kawrt = zwisu.
endif.
endif.

4)循环合计子过程代码的摘抄,参见红色部分

form xkomv_kawrt_ermitteln.

data: axkomv like komv.

* assign & initialize
axkomv = xkomv.
xkawrt = 0.

* set from - to step number comming form pricing procedure
xstunr = xkomv-stunb.
xstun2 = xkomv-stun2.
if xstun2 lt xstunr.
xstun2 = xstunr.
endif.
if xstun2 = 0.
xstun2 = xkomv-stunr.
endif.

* build up key to read XKOMV table
komv_key-mandt = komk-mandt.
komv_key-knumv = komk-knumv.
komv_key-kposn = komp-kposn.
komv_key-stunr = xstunr.
komv_key-zaehk = 0.
read table xkomv with key komv_key binary search.
if sy-subrc lt 8.
read table xkomv index sy-tabix.
if xkomv-stunr gt xstun2.
read table xkomv index xkomv_tabix.
xkomv = axkomv.
exit.
else.
loop at xkomv.
if xkomv-stunr gt xstun2 or sy-tabix = xkomv_tabix.
read table xkomv index xkomv_tabix.
xkomv = axkomv.
exit.
endif.
if ( xkomv-stunr ge xstunr and xkomv-stunr le xstun2 ) and
xkomv-kinak na 'AKLMX'.
add xkomv-kwert to xkawrt.
endif.
endloop.
endif.
endif.

if xkomv_tabix ne 0.
read table xkomv index xkomv_tabix.
endif.
xkomv = axkomv.

endform.

你可能感兴趣的:(UP)