BAPI_ACC_MANUAL_ALLOC_POST 費用分配函數的小bug及解決辦法

來源:互聯網
上載者:User

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,表示小數點後兩位進行四捨五入。然後儲存。

測試通過。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.