您的位置:首页 > 其它

BAPI_ACC_MANUAL_ALLOC_POST 费用分配函数的小bug及解决办法

2010-05-15 14:35 816 查看
function bapi_acc_manual_alloc_post.

*"----------------------------------------------------------------------

*"*"Lokale Schnittstelle:

*" IMPORTING

*" VALUE(DOC_HEADER) LIKE BAPIDOCHDRU12P STRUCTURE BAPIDOCHDRU12P

*" VALUE(IGNORE_WARNINGS) LIKE BAPIIW-IGNWARN DEFAULT SPACE

*" EXPORTING

*" VALUE(DOC_NO) LIKE BAPIDOCHDRU12P-DOC_NO

*" TABLES

*" DOC_ITEMS STRUCTURE BAPIMAITM

*" RETURN STRUCTURE BAPIRET2

*" CUSTOMER_FIELDS STRUCTURE BAPIEXTC OPTIONAL

*"----------------------------------------------------------------------

项目中我们用这个BAPI来做费用分摊,有一次竟然报错“请输入有计量单位的数量”。本能的反应以为是没有输入单位,后来跟踪检查才发现了这个
BAPI的内幕。

BAPI中调用了函数
K40C_CO_ACTUAL_POSTING,在这个函数,会对许多参数进行校验,其中有一个函数 'K40C_DOCUMENT_LINE_CHECK'
,里面调用了一个函数

call
function
'UNIT_CONVERSION_SIMPLE'

exporting

input
= doc_item-ausbr

round_sign = 'X'

unit_in = doc_item-aubeh

unit_out = itobjects-auseh

importing

output
= ausbtr

这是个简单的单位转换函数,但是由于设置了round_sign = 'X'
表示会在单位转换后进行四舍五入,这样就会把5毛钱以下的金额舍为0,于是便出现了错误。

之前认为BAPI_ACC_MANUAL_ALLOC_POST
只能进行5毛钱以上的费用分摊,后来向SAP提了message,回复得到的消息是已经在一个note中得到解决。

原文如下:

“the message has been forwarded to us in CO-OM development. As far as
described,
I think note 614127 should be the exact alternative to avoid
rounding of quantities for manual CO-postings.”

找到note 614127,描述如下:

Symptom

You enter quantities for manual CO actual
postings. Even though you can enter up to three decimal places for the
quantity, the system rounds the quantity.

Reason and
Prerequisites


You have implemented the
corrections from Note 503659 or you have imported one of the Support
Packages SAPKH46B41, SAPKH46C32 or SAPKH46C33.

The quantities are
always rounded according to the number of decimal places defined for
the selected unit of measure. This was not the case for the manual
actual postings due to a program error that was corrected with Note
503659.

Solution

Change the number
of decimal places for the
selected unit of measure (transaction CUNI, maintenance of units of
measurement). Note the following: The "Decimal pl. rounding" field
(number of decimal places to which figure is to be rounded) in the
"Conversion" section is relevant for rounding quantities. The "Decimal
places" field in the "Display" section is not relevant.

or

Implement the program modification. This prevents the rounding
of the quantity.

这里面提到了note
503659,检查了一下系统,一般补丁都已经打了。于是按照解决方法里面写的步骤,运行CUNI,修改单位的配置参数。在
BAPI_ACC_MANUAL_ALLOC_POST里面用到的单位是EA,于是双击EA,将Decimal pl.
rounding填入2,表示小数点后两位进行四舍五入。然后保存。

测试通过。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: