2011年3月30日 星期三

[SD] Pricing Procedure - included tax and down payment

含稅的定價程序與訂金
StepCntrCTypDescriptionFromToMan.MdtStatPrintSubToReqtAltCTyAltCBVActKyAccrls
11ZPR0PriceXXX2
13ZPB0Price (Gross)XXX
14ZENZPriceXXX
100Gross ValueXX1
105NETWValue of GoodsX2902ERL
500Z001Down PaymentXX2Z3
510DiscountAmount5003
800Net Value4902
900MWSTTaxXS1019MWS
930Total800910A4
940ZPRSStandard CostXB4
950VPRSCostXB4
970Profit segment11
Formula 902
*&---------------------------------------------------------------------*
*& Form FRM_KONDI_WERT_902
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM frm_kondi_wert_902.
DATA: lv_subrc LIKE sy-subrc,
lv_kwert LIKE xkwert,
lv_mwst LIKE xkwert.

CLEAR: lv_subrc, lv_kwert, lv_mwst.
IF xkomv-kschl = 'NETW'.
CATCH SYSTEM-EXCEPTIONS conversion_errors = 1
arithmetic_errors = 5.
lv_kwert = komp-kzwi1 * 100 / 105 + komp-kzwi3.
lv_kwert = lv_kwert + lv_kwert / 20.
* Tax Diff
lv_mwst = lv_kwert - komp-kzwi1.
xkwert = komp-kzwi1 * 100 / 105 - lv_mwst.
ENDCATCH.
lv_subrc = sy-subrc.
ELSE. " Net Value
CATCH SYSTEM-EXCEPTIONS conversion_errors = 1
arithmetic_errors = 5.
xkwert = komp-kzwi2 + komp-kzwi3. " Net Value
ENDCATCH.
lv_subrc = sy-subrc.
ENDIF.

IF sy-subrc = 1 OR sy-subrc = 5.
MESSAGE s802.
xkomv-kinak = 'X'.
xkwert = 0.
xkomv-kwert = 0.
xkomv-fxmsg = '802'.
komp-fxmsg = '802'.
ENDIF.

ENDFORM. "FRM_KONDI_WERT_902
User Exit: RV61AFZB
*---------------------------------------------------------------------*
* FORM USEREXIT_XKOMV_BEWERTEN_END *
*---------------------------------------------------------------------*
FORM userexit_xkomv_bewerten_end.

IF komk-kalsm = 'ZRA01Z'.
DATA: lv_kwert LIKE xkwert,
lv_mwst LIKE xkwert,
lv_adjed LIKE xkwert,
lw_xkomv LIKE xkomv.
CLEAR: lv_kwert, lv_mwst, lw_xkomv.

CLEAR: lv_kwert, lv_mwst, lw_xkomv.
LOOP AT xkomv WHERE kschl = 'MWST'.
CATCH SYSTEM-EXCEPTIONS conversion_errors = 1
arithmetic_errors = 5.
xkomv-kawrt = komp-kzwi1 * 100 / 105 + komp-kzwi3.
lv_kwert = xkomv-kawrt.
lv_adjed = xkomv-kawrt / 20.
lv_kwert = lv_kwert + lv_adjed.
lv_mwst = lv_kwert - komp-kzwi1.
IF lv_mwst NE 0 AND xkomv-kwert NE lv_adjed.
xkomv-kwert = xkomv-kwert + lv_mwst.
xkomv-kherk = 'I'.
MODIFY xkomv.
ENDIF.
ENDCATCH.
ENDLOOP.

LOOP AT xkomv WHERE kschl = 'NETW'.
READ TABLE xkomv WITH KEY kschl = 'MWST'
INTO lw_xkomv.
IF lw_xkomv-kherk EQ 'I' AND
xkomv-kherk NE 'I'.
CATCH SYSTEM-EXCEPTIONS conversion_errors = 1
arithmetic_errors = 5.
* NETW + MWST + down payment
lv_kwert = xkomv-kwert + lw_xkomv-kwert + komp-kzwi3.
* NETW Diff
lv_mwst = lv_kwert - komp-kzwi1.
IF lv_mwst NE 0.
xkomv-kwert = xkomv-kwert - lv_mwst + xkomv-kdiff.
xkomv-kdiff = lv_mwst - xkomv-kdiff.
xkomv-kherk = 'I'.
MODIFY xkomv.
ENDIF.
ENDCATCH.
ENDIF.
ENDLOOP.

* Net Value
READ TABLE xkomv WITH KEY kschl = 'NETW'
INTO lw_xkomv.
IF lw_xkomv-kherk = 'I'.
LOOP AT xkomv WHERE stunr = '800'.
xkomv-kwert = komp-kzwi2 + komp-kzwi3.
MODIFY xkomv.
ENDLOOP.
ENDIF.

ENDIF.

ENDFORM. "USEREXIT_XKOMV_BEWERTEN_END