Age: 46 Joined: 05 Nov 2007 Posts: 725 Location: КраснАдар
Posted: Mon Dec 29, 2008 1:07 pm Post subject:
По-русски звучит как "Обработка условий у затрат на доставку невозможна". Можно делать выводы.
К примеру, в ITEMDATA не передавать COND_TYPE "Вид условия"...
*&---------------------------------------------------------------------*
*& Form post
*&---------------------------------------------------------------------*
FORM post.
DATA:
ls_head TYPE bapi_incinv_create_header,
lt_items TYPE TABLE OF bapi_incinv_create_item WITH HEADER LINE,
lt_accountingdata type table of bapi_incinv_create_account
WITH HEADER LINE,
ret TYPE TABLE OF bapiret2 WITH HEADER LINE,
l_tabix TYPE sy-tabix.
DATA: BEGIN OF it_ekko OCCURS 0,
ebeln TYPE ekko-ebeln,
END OF it_ekko.
LOOP AT report_table INTO report_table_line
WHERE load_status EQ icon_green_light.
it_ekko-ebeln = report_table_line-rm08m_ebeln.
COLLECT it_ekko.
ENDLOOP.
LOOP AT it_ekko.
*fill header
CLEAR ls_head.
SELECT SINGLE *
FROM ekko
WHERE ebeln = report_table_line-rm08m_ebeln.
LOOP AT report_table INTO report_table_line
WHERE rm08m_ebeln = it_ekko-ebeln.
IF ls_head-comp_code IS INITIAL.
ls_head-comp_code = p_bukrs.
ENDIF.
IF ls_head-invoice_ind IS INITIAL.
ls_head-invoice_ind = 'X'. "Invoice
ENDIF.
* Invoice Date in Document
IF ls_head-doc_date IS INITIAL.
ls_head-doc_date = report_table_line-invfo_bldat.
ENDIF.
* Posting date in the document
IF ls_head-pstng_date IS INITIAL.
ls_head-pstng_date = report_table_line-invfo_budat.
ENDIF.
* Reference document number
IF ls_head-ref_doc_no IS INITIAL.
ls_head-ref_doc_no = report_table_line-invfo_xblnr.
ENDIF.
* Currency Key
IF ls_head-currency IS INITIAL.
ls_head-currency = report_table_line-invfo_waers.
ENDIF.
* Amount in document currency
IF ls_head-gross_amount IS INITIAL.
ls_head-gross_amount = report_table_line-invfo_wrbtr.
ENDIF.
* Different invoicing party
IF ls_head-diff_inv IS INITIAL.
ls_head-diff_inv = report_table_line-bkpf_lifnr.
ENDIF.
* Tax amount in document currency
* IF ls_head- IS INITIAL.
* ls_head- = report_table_line-invfo_wmwst.
* ENDIF.
* Tax Code
* Tax code for delivery costs
IF ls_head-del_costs_taxc IS INITIAL.
ls_head-del_costs_taxc = report_table_line-invfo_mwskz.
* Calculate tax automatically
ls_head-calc_tax_ind = 'X'.
ENDIF.
* Item Text
IF ls_head-item_text IS INITIAL.
ls_head-item_text = report_table_line-invfo_sgtxt.
ENDIF.
* Payment method
IF report_table_line-invfo_zlsch IS INITIAL.
MESSAGE w000(su) WITH
'Payment Methot set to ''N'''(017)
INTO sy-msgli.
PERFORM add_message USING c_type_p report_table_line-rm08m_ebeln.
report_table_line-invfo_zlsch = 'N'.
ENDIF.
IF ls_head-pymt_meth IS INITIAL.
ls_head-pymt_meth = report_table_line-invfo_zlsch.
ENDIF.
ENDLOOP.
*fill items
REFRESH lt_items.
LOOP AT report_table INTO report_table_line
WHERE rm08m_ebeln = it_ekko-ebeln.
l_tabix = sy-tabix.
CLEAR lt_items.
SELECT SINGLE *
FROM ekpo
WHERE ebeln = report_table_line-rm08m_ebeln
AND ebelp = report_table_line-rm08m_ebelp.
* Purchase order number
lt_items-po_number = report_table_line-rm08m_ebeln.
* Invoice document number
lt_items-invoice_doc_item = report_table_line-rm08m_ebelp.
* Purchasing document item number
lt_items-po_item = report_table_line-rm08m_ebelp.
* Tax code
lt_items-tax_code = report_table_line-drseg_mwskz.
* Amount in document currency
lt_items-item_amount = report_table_line-drseg_wrbtr.
* Quantity
* lt_items-quantity = report_table_line-drseg_menge.
* IF lt_items-quantity IS INITIAL AND NOT p_exinv IS INITIAL.
* lt_items-quantity = ekpo-menge.
* ENDIF.
* Order unit
* lt_items-po_unit = ekpo-meins.
* IF lt_items-po_unit IS INITIAL AND NOT p_exinv IS INITIAL.
* lt_items-po_unit = ekpo-meins.
* ENDIF.
* Account number of vendor or creditor
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = report_table_line-bkpf_lifnr
IMPORTING
output = lt_items-freight_ven.
* Item Text
lt_items-item_text = report_table_line-drseg_sgtxt.
APPEND lt_items.
*Populate Accounting Data
lt_accountingdata-invoice_doc_item = report_table_line-rm08m_ebelp.
lt_accountingdata-serial_no = '01'.
SELECT SINGLE *
FROM ekkn
WHERE ebeln EQ report_table_line-rm08m_ebeln
AND ebelp EQ report_table_line-rm08m_ebelp
AND zekkn EQ '01'.
* GL Account number
lt_accountingdata-gl_account = report_table_line-drseg_saknr.
IF lt_accountingdata-gl_account IS INITIAL AND
NOT p_exinv IS INITIAL.
lt_accountingdata-gl_account = ekkn-sakto.
ENDIF.
* Cost Center number
lt_accountingdata-costcenter = report_table_line-drseg_kostl.
IF lt_accountingdata-costcenter IS INITIAL AND
NOT p_exinv IS INITIAL.
lt_accountingdata-costcenter = ekkn-kostl.
ENDIF.
* WBS number
lt_accountingdata-wbs_elem = report_table_line-drseg_ps_psp_pnr.
IF lt_accountingdata-wbs_elem IS INITIAL AND
NOT p_exinv IS INITIAL.
lt_accountingdata-wbs_elem = ekkn-ps_psp_pnr.
ENDIF.
APPEND lt_accountingdata.
ENDLOOP.
*Create Invoice
IF p_test IS INITIAL.
CALL FUNCTION 'BAPI_INCOMINGINVOICE_CREATE'
EXPORTING
headerdata = ls_head
IMPORTING
invoicedocnumber = report_table_line-rbkp_belnr
TABLES
itemdata = lt_items
accountingdata = lt_accountingdata
return = ret.
LOOP AT ret.
sy-msgid = ret-id.
sy-msgty = ret-type.
sy-msgno = ret-number.
sy-msgv1 = ret-message_v1.
sy-msgv2 = ret-message_v2.
sy-msgv3 = ret-message_v3.
sy-msgv4 = ret-message_v4.
PERFORM add_message USING c_type_p
report_table_line-rm08m_ebeln.
ENDLOOP.
LOOP AT ret WHERE type = 'A' OR type = 'E'.
EXIT.
ENDLOOP.
IF NOT sy-subrc IS INITIAL. "No errors
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'
IMPORTING
return = ret.
ELSE. "Errors exist
LOOP AT report_table INTO report_table_line
WHERE rm08m_ebeln = it_ekko-ebeln.
report_table_line-post_status = icon_red_light.
MODIFY report_table FROM report_table_line
TRANSPORTING post_status.
ENDLOOP.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'
IMPORTING
return = ret.
ENDIF.
LOOP AT ret.
sy-msgid = ret-id.
sy-msgty = ret-type.
sy-msgno = ret-number.
sy-msgv1 = ret-message_v1.
sy-msgv2 = ret-message_v2.
sy-msgv3 = ret-message_v3.
sy-msgv4 = ret-message_v4.
PERFORM add_message USING c_type_p
report_table_line-rm08m_ebeln.
ENDLOOP.
LOOP AT ret WHERE type = 'A' OR type = 'E'.
EXIT.
ENDLOOP.
IF sy-subrc IS INITIAL. "Errors
LOOP AT report_table INTO report_table_line
WHERE rm08m_ebeln = it_ekko-ebeln.
report_table_line-post_status = icon_red_light.
MODIFY report_table FROM report_table_line
TRANSPORTING post_status.
ENDLOOP.
ENDIF.
ENDIF.
LOOP AT report_table INTO report_table_line
WHERE rm08m_ebeln = it_ekko-ebeln
AND post_status IS initial.
report_table_line-post_status = icon_green_light.
MODIFY report_table FROM report_table_line
TRANSPORTING post_status rbkp_belnr.
ENDLOOP.
ENDLOOP.
Age: 46 Joined: 05 Nov 2007 Posts: 725 Location: КраснАдар
Posted: Mon Dec 29, 2008 3:08 pm Post subject:
Могу предположить два варианта действий:
1. Посмотреть в справке к ФМ как формировать данные для счета с транспортными расходами. Вроде бы не нужно ACCOUNTINGDATA заполнять, а в ITEMDATA нужно по две строчки на позицию - в первую стоимость продукта, во вторую - стоимость перевозки.
2. Посмотреть Note 591415 - BAPI: Delivery costs and freight vendors
Quote:
Note:
You can define delivery costs in BAPIs BAPI_INCOMINGINVOICE_CREATE and BAPI_INCOMINGINVOICE_PARK either via the condition type or via the level number and the condition counter (see the BAPI online help). For this, the following cases can be differentiated respectively:
a) You specify a delivery costs line with a delivery vendor L1 and a condition type K1 at the BAPI interface and
there are two different delivery vendors L1 and L2 for the same condition K1: the system generates a line L1/K1.
there are two different conditions K1 and K2 for a delivery vendor L1: the system generates a line L1/K1. If you additionally want to create a line L1/K2, you have to specify this second one at the BAPI interface as well.
b) You specify a delivery costs line without a delivery vendor L1 for condition type K1 at the BAPI interface and
there are two different delivery vendors L1 and L2 for the same condition K1: the system generates the error message 'Processing of the conditions with delivery costs not possible'. The reason is the missing uniqueness concerning the line specified at the interface. In this case, you best create a second delivery costs line at the interface with K1/L2 in order to eliminate this problem and to fill the delivery vendor field of the first one with L1.
there are two different conditions K1 and K2 for a delivery vendor L1: the system generates a line L1/K1.
If a combinatin occurs in which no unique assignment is possible between the lines which are specified at the interface of the BAPI and the still open, to be settled delivery costs, the system issues an error message.
Это конечно не совсем то, но можно для справки и в этом направлении копнуть.
John Doe, Вы правы, проблема была из-за вендоров. Заработало.
Code:
*&---------------------------------------------------------------------*
*& Form post
*&---------------------------------------------------------------------*
FORM post USING p_fcode.
CONSTANTS: c_blart TYPE bkpf-blart VALUE 'RE'. " Document type
FIELD-SYMBOLS: <fs_line> LIKE report_table_line.
DATA:
ls_head TYPE bapi_incinv_create_header,
lt_items TYPE TABLE OF bapi_incinv_create_item WITH HEADER LINE,
lt_accountingdata TYPE TABLE OF bapi_incinv_create_account
WITH HEADER LINE,
ret TYPE TABLE OF bapiret2 WITH HEADER LINE,
l_items_count TYPE sy-tabix,
l_created_belnr LIKE report_table_line-rbkp_belnr,
w_counter TYPE sy-tabix.
DATA: BEGIN OF it_ekko OCCURS 0,
ebeln TYPE ekko-ebeln,
END OF it_ekko.
PERFORM refresh_messages USING c_type_p.
LOOP AT report_table INTO report_table_line
WHERE load_status EQ icon_green_light.
it_ekko-ebeln = report_table_line-rm08m_ebeln.
COLLECT it_ekko.
ENDLOOP.
LOOP AT it_ekko.
*fill header
CLEAR: ls_head,
l_items_count.
SELECT SINGLE *
FROM ekko
WHERE ebeln = report_table_line-rm08m_ebeln.
* Set document type
ls_head-doc_type = c_blart.
* Set company code
ls_head-comp_code = p_bukrs.
LOOP AT report_table INTO report_table_line
WHERE rm08m_ebeln = it_ekko-ebeln.
* Calculate items count
l_items_count = l_items_count + 1.
IF ls_head-invoice_ind IS INITIAL.
ls_head-invoice_ind = 'X'. "Invoice
ENDIF.
* Invoice Date in Document
IF ls_head-doc_date IS INITIAL.
ls_head-doc_date = report_table_line-invfo_bldat.
ENDIF.
* Posting date in the document
IF ls_head-pstng_date IS INITIAL.
ls_head-pstng_date = report_table_line-invfo_budat.
ENDIF.
* Reference document number
IF ls_head-ref_doc_no IS INITIAL.
ls_head-ref_doc_no = report_table_line-invfo_xblnr.
ENDIF.
* Currency Key
IF ls_head-currency IS INITIAL.
ls_head-currency = report_table_line-invfo_waers.
ENDIF.
* Amount in document currency
IF ls_head-gross_amount IS INITIAL.
ls_head-gross_amount = report_table_line-invfo_wrbtr.
ENDIF.
* Different invoicing party
IF ls_head-diff_inv IS INITIAL.
ls_head-diff_inv = report_table_line-bkpf_lifnr.
ENDIF.
* Tax amount in document currency
* IF ls_head- IS INITIAL.
* ls_head- = report_table_line-invfo_wmwst.
* ENDIF.
* Tax Code
* Tax code for delivery costs
IF ls_head-del_costs_taxc IS INITIAL.
ls_head-del_costs_taxc = report_table_line-invfo_mwskz.
* Calculate tax automatically
ls_head-calc_tax_ind = 'X'.
ENDIF.
* Item Text
IF ls_head-item_text IS INITIAL.
ls_head-item_text = report_table_line-invfo_sgtxt.
ENDIF.
* Payment method
IF report_table_line-invfo_zlsch IS INITIAL.
MESSAGE w000(su) WITH
'Payment Methot set to ''N'''(017)
INTO sy-msgli.
PERFORM add_message USING c_type_p report_table_line-rm08m_ebeln
report_table_line-rm08m_ebelp.
report_table_line-invfo_zlsch = 'N'.
ENDIF.
IF ls_head-pymt_meth IS INITIAL.
ls_head-pymt_meth = report_table_line-invfo_zlsch.
ENDIF.
ENDLOOP.
*fill items
REFRESH: lt_items,
lt_accountingdata.
w_counter = 0.
LOOP AT report_table INTO report_table_line
WHERE rm08m_ebeln = it_ekko-ebeln.
CLEAR lt_items.
SELECT SINGLE *
FROM ekpo
WHERE ebeln = report_table_line-rm08m_ebeln
AND ebelp = report_table_line-rm08m_ebelp.
* Purchase order number
lt_items-po_number = report_table_line-rm08m_ebeln.
* Invoice document number
lt_items-invoice_doc_item = report_table_line-rm08m_ebelp.
* Purchasing document item number
lt_items-po_item = report_table_line-rm08m_ebelp.
* Tax code
lt_items-tax_code = report_table_line-drseg_mwskz.
* Amount in document currency
lt_items-item_amount = report_table_line-drseg_wrbtr.
IF l_items_count > 1.
* Quantity
lt_items-quantity = report_table_line-drseg_menge.
IF lt_items-quantity IS INITIAL AND NOT p_exinv IS INITIAL.
lt_items-quantity = ekpo-menge.
ENDIF.
* Order unit
lt_items-po_unit = ekpo-meins.
IF lt_items-po_unit IS INITIAL AND NOT p_exinv IS INITIAL.
lt_items-po_unit = ekpo-meins.
ENDIF.
ENDIF.
IF lt_items-quantity IS INITIAL.
lt_items-po_unit = space.
ENDIF.
* Item Text
lt_items-item_text = report_table_line-drseg_sgtxt.
APPEND lt_items.
*Populate Accounting Data
CLEAR lt_accountingdata.
SELECT SINGLE *
FROM ekkn
WHERE ebeln EQ report_table_line-rm08m_ebeln
AND ebelp EQ report_table_line-rm08m_ebelp
AND zekkn EQ '01'.
* GL Account number
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = report_table_line-drseg_saknr
IMPORTING
output = report_table_line-drseg_saknr.
lt_accountingdata-gl_account = report_table_line-drseg_saknr.
IF lt_accountingdata-gl_account IS INITIAL AND
NOT p_exinv IS INITIAL.
lt_accountingdata-gl_account = ekkn-sakto.
ENDIF.
* Cost Center number
lt_accountingdata-costcenter = report_table_line-drseg_kostl.
IF lt_accountingdata-costcenter IS INITIAL AND
NOT p_exinv IS INITIAL.
lt_accountingdata-costcenter = ekkn-kostl.
ENDIF.
* WBS number
lt_accountingdata-wbs_elem = report_table_line-drseg_ps_psp_pnr.
IF lt_accountingdata-wbs_elem IS INITIAL AND
NOT p_exinv IS INITIAL.
lt_accountingdata-wbs_elem = ekkn-ps_psp_pnr.
ENDIF.
IF l_items_count > 1.
lt_accountingdata-po_unit = lt_items-po_unit.
lt_accountingdata-quantity = lt_items-quantity.
IF lt_accountingdata-quantity IS INITIAL AND
NOT p_exinv IS INITIAL.
lt_accountingdata-quantity = ekkn-menge.
ENDIF.
ENDIF.
APPEND lt_accountingdata.
ENDLOOP.
*----------------------------------------------------------------------*
* The following coding is to solve the problem
* mentioned in OSS Note 518338.
* Same PO item within several invoice items.
SORT lt_items BY po_number po_item.
LOOP AT lt_items.
ON CHANGE OF lt_items-po_number OR lt_items-po_item.
w_counter = 1.
LOOP AT lt_items WHERE po_number = lt_items-po_number
AND po_item = lt_items-po_item.
* To solve the repetition of PO item in subsequent invoices.
ELSEIF sy-tabix EQ 1.
w_counter = 1.
LOOP AT lt_items WHERE po_number = lt_items-po_number
AND po_item = lt_items-po_item.
LOOP AT ret.
sy-msgid = ret-id.
sy-msgty = ret-type.
sy-msgno = ret-number.
sy-msgv1 = ret-message_v1.
sy-msgv2 = ret-message_v2.
sy-msgv3 = ret-message_v3.
sy-msgv4 = ret-message_v4.
PERFORM add_message USING c_type_p
report_table_line-rm08m_ebeln
space.
ENDLOOP.
LOOP AT ret WHERE type = 'A' OR type = 'E'.
EXIT.
ENDLOOP.
IF NOT sy-subrc IS INITIAL. "No errors
REFRESH ret.
IF p_fcode EQ c_simulate.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'
IMPORTING
return = ret.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'
IMPORTING
return = ret.
ENDIF.
ELSE. "Errors exist
report_table_line-post_status = icon_red_light.
MODIFY report_table FROM report_table_line
TRANSPORTING post_status
WHERE rm08m_ebeln = it_ekko-ebeln
AND post_status IS initial.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'
IMPORTING
return = ret.
ENDIF.
LOOP AT ret.
sy-msgid = ret-id.
sy-msgty = ret-type.
sy-msgno = ret-number.
sy-msgv1 = ret-message_v1.
sy-msgv2 = ret-message_v2.
sy-msgv3 = ret-message_v3.
sy-msgv4 = ret-message_v4.
PERFORM add_message USING c_type_p
report_table_line-rm08m_ebeln
space.
ENDLOOP.
LOOP AT ret WHERE type = 'A' OR type = 'E'.
EXIT.
ENDLOOP.
IF sy-subrc IS INITIAL. "Errors
report_table_line-post_status = icon_red_light.
MODIFY report_table FROM report_table_line
TRANSPORTING post_status
WHERE rm08m_ebeln = it_ekko-ebeln
AND post_status IS initial.
ENDIF.
LOOP AT report_table ASSIGNING <fs_line>
WHERE rm08m_ebeln = it_ekko-ebeln
AND post_status IS initial.
<fs_line>-post_status = icon_green_light.
<fs_line>-rbkp_belnr = l_created_belnr.
MESSAGE i000(su) WITH 'Document no. & created'(019)
INTO sy-msgli.
REPLACE '&' WITH l_created_belnr INTO sy-msgv1.
PERFORM add_message USING c_type_p
<fs_line>-rm08m_ebeln space.
ENDLOOP.
ENDLOOP.
ENDFORM. " f_call_post
*&---------------------------------------------------------------------*
*& Form show_load_status
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_TYPE text
* -->P_EBELN text
* -->P_EBELP text
*----------------------------------------------------------------------*
FORM show_status USING p_type p_ebeln p_ebelp.
DATA: ls_messages TYPE ty_messages,
l_is_messages.
CALL FUNCTION 'MESSAGES_INITIALIZE'.
LOOP AT gt_messages INTO ls_messages
WHERE type EQ p_type
AND ebeln EQ p_ebeln
AND ebelp EQ p_ebelp.
CALL FUNCTION 'MESSAGE_STORE'
EXPORTING
arbgb = ls_messages-msgid
msgty = ls_messages-msgty
msgv1 = ls_messages-msgv1
msgv2 = ls_messages-msgv2
msgv3 = ls_messages-msgv3
msgv4 = ls_messages-msgv4
txtnr = ls_messages-msgno.
l_is_messages = 'X'.
ENDLOOP.
IF NOT l_is_messages IS INITIAL.
CALL FUNCTION 'MESSAGES_SHOW'.
ENDIF.
ENDFORM. " show_load_status
*&---------------------------------------------------------------------*
*& Form add_message
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_TYPE text
* -->P_EBELN text
* -->P_EBELP text
*----------------------------------------------------------------------*
FORM add_message USING p_type p_ebeln p_ebelp.
DATA: ls_messages TYPE ty_messages.
MOVE-CORRESPONDING sy TO ls_messages.
ls_messages-type = p_type.
ls_messages-ebeln = p_ebeln.
ls_messages-ebelp = p_ebelp.
APPEND ls_messages TO gt_messages.
ENDFORM. " add_message
*&---------------------------------------------------------------------*
*& Form refresh_messages
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->p_type text
*----------------------------------------------------------------------*
FORM refresh_messages USING p_type.
DELETE gt_messages WHERE type EQ p_type.
ENDFORM. " refresh_messages
Age: 46 Joined: 05 Nov 2007 Posts: 725 Location: КраснАдар
Posted: Tue Jan 13, 2009 11:33 am Post subject:
У меня у самого вчера такая же проблема всплыла
Сообщение M8 524 также получилось в случае, если попадалось ценовое условие по фрахту с нулевой суммой из позиции заказа . Вылечилось простым удалением подобных записей в itemdata.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.