采购含税价自动计算净价详解
2024-1-9 18:57:29 Author: blogs.sap.com(查看原文) 阅读量:15 收藏

本篇是在采购:中国含税采购价的基础上详细介绍第三个方案,即定制化条件类型来实现采购含税价自动计算净价的方案。希望能给大家快速实施带来帮助。

SSCUI 101094 Set condition types for pricing in purchasing

双击刚刚创建的Z000条目,进入如下配置界面。选择X表示负值条件类型。两个AA代表百分数,以及附加计算类型。

后面步骤创建了新的定价程序,别忘了再回来把新的定价程序Z10001更新上去

其实不设置成负的也可以,改变相应的增强代码就行。文章最后给大家演示正值的代码。

SSCUI 101095 Set the calculation schema for purchasing

去掉手动的勾,就会自动出现在采购订单上。否则需要再采购订单上手工输入条件类型。

SSCUI 102144 Determine Calculation Schema for Standard Purchase Orders *

此时在没有增强badi的时候我们可以看看效果:11块总价, 10%税率(负数), 净价为11-11*0.1=9.9

APP: 自定义字段和逻辑

6.1 搜增强PRCG_DOC_ITEM_CONDITION_AMOUNT

如果没有人创建过,点创建

6.2 在新建界面中选中再次搜索,点步骤2

6.3添加过滤值

随便一个数值例如1320.

这个过滤值1320 会在后面配置步骤‘将增强标识分配到例程编号’的时候被F4搜索出来。

6.4 点审核

6.5 点创建

6.6点发布

点发布之后,才能打开代码编辑器写代码

6.7 打开代码编辑器点编辑

粘贴如下代码,主要粘贴黑色字体。

* Mandatory step for all implementations:
* Move the importing parameters to the changing parameters.
MOVE-CORRESPONDING item_amounts TO item_result_amounts.
MOVE-CORRESPONDING item_attributes TO item_result_attributes.
MOVE-CORRESPONDING item_quantities TO item_result_quantities.
MOVE-CORRESPONDING prcg_element_attributes TO prcg_element_result_amounts.

* General remark:
* The enhancement ID that you assign to a routine number must correspond to the BAdI filter of the current implementation.
* In the configuratin of a pricing procedure, you assign the routine number to a condition type or to a subtotal line.

* In the following, an example implementation of a condition amount routine for the condition item is presented.
* Such type of routine can be used to change the value for a pricing element.

* The example implementation below sets the condition amount equal to the net amount plus the tax amount.
* When the routine number is assigned to a subtotal line at the end of the pricing procedure, it shows the final value of the line item.

TRY.
prcg_element_result_amounts-CONDITIONAMOUNT = prcg_element_result_amounts-CONDITIONBASEVALUE – prcg_element_result_amounts-CONDITIONBASEVALUE / ( 1 + ABS( prcg_element_result_amounts-CONDITIONRATEVALUE / 100 ) ).

prcg_element_result_amounts-CONDITIONAMOUNT = – prcg_element_result_amounts-CONDITIONAMOUNT.

IF prcg_element_result_amounts-conditionamount = 0.
* it is possible to raise a message if an issue is identified
pricing_message = ‘Check the condition amount of the condition XY01’.
* indicate a pricing error if required
item_result_attributes-pricinghaserror = abap_true.
ENDIF.
CATCH cx_sy_conversion_error cx_sy_arithmetic_error INTO DATA(lx_conversion).

prcg_element_result_amounts-conditioninactivereason = ‘X’.
prcg_element_result_amounts-conditionamount = 0.
* You should use the statement “RAISE EXCEPTION” only for critical business errors or programming runtime errors.
RAISE EXCEPTION TYPE cx_ble_runtime_error
EXPORTING
previous = lx_conversion.

* Remark: Alternative exception handling
* TRY.
* RAISE EXCEPTION TYPE cx_pricing_formula EXPORTING error_message = ‘Conversion Error’ ##NO_TEXT .
* CATCH cx_pricing_formula INTO DATA(lx_pricing_formula).
* RAISE EXCEPTION TYPE cx_ble_runtime_error
* EXPORTING
* previous = lx_pricing_formula.
* ENDTRY.

ENDTRY.

Eg 3000067

SSCUI 102430 Set Alternative Calculation of Condition Amount

增强表示符可以从F4中选步骤6.3设置的过滤值

重复步骤6,搜增强PRCG_DOC_CONDITION_AMOUNT

点击发布之后,代码可以编辑一下,什么也不用写,保存发布。这一步必须要做,因为这一步不做,步骤六的增强就不起作用。

现在来看看效果,11块的总价,10%的税率自动决定出来的净价为10块。

彩蛋环节

如果不想设置Z000条件类型成负值,我们可以设置成正值,搭配以下增强实施代码,也可以实现同样的净价结果。

MOVE-CORRESPONDING item_amounts TO item_result_amounts.
MOVE-CORRESPONDING item_attributes TO item_result_attributes.
MOVE-CORRESPONDING item_quantities TO item_result_quantities.
MOVE-CORRESPONDING prcg_element_attributes TO prcg_element_result_amounts.

prcg_element_result_amounts-CONDITIONAMOUNT = prcg_element_result_amounts-CONDITIONBASEVALUE * prcg_element_result_amounts-CONDITIONRATEVALUE / 100 / ( 1 + prcg_element_result_amounts-CONDITIONRATEVALUE / 100 ).
prcg_element_result_amounts-CONDITIONAMOUNT = – prcg_element_result_amounts-CONDITIONAMOUNT.

效果如图:

100块的总价,13%的税率自动决定出来的净价为88.5块。

欢迎各位测试,如果有尾差的问题,反应给我,简单调优一下。

本文涉及功能基于SAP S/4HANA Cloud, Public Edition 2308版本,后续版本可能会有变化请参考最新信息。
The features covered in this article are based on SAP S/4HANA Cloud, Public Edition 2308, please refer to the latest information for changes in subsequent versions.

Hope you LIKE it if it addresses your issue. After that, please feel free to comment and I will follow up.
如果有帮助到您欢迎点Like,有问题可以评论继续探讨。

更多链接

SAP S/4HANA Cloud for Sourcing and Procurement, Public Edition
https://community.sap.com/topics/s4hana-cloud-sourcing-procurement

SAP S/4HANA Cloud for Supply Chain, Public Edition
https://community.sap.com/topics/s4hana-cloud-supply-chain

SAP S/4HANA Cloud for Manufacturing, Public Edition
https://community.sap.com/topics/s4hana-cloud-manufacturing


文章来源: https://blogs.sap.com/2024/01/09/%e9%87%87%e8%b4%ad%e5%90%ab%e7%a8%8e%e4%bb%b7%e8%87%aa%e5%8a%a8%e8%ae%a1%e7%ae%97%e5%87%80%e4%bb%b7%e8%af%a6%e8%a7%a3/
如有侵权请联系:admin#unsafe.sh