I have a problem with the above BAPI - it gives me error message M8 524 - 'You cannot process conditions for delivery costs'. My code can be found below. I am not trying to process conditions for delivery costs but merely passing the condition type and the amount.
Any input would be much appreciated.
loop at gt_pohd.
ls_HEADERDATA-INVOICE_IND = 'X'.
ls_HEADERDATA-DOC_DATE = sy-datum.
ls_HEADERDATA-PSTNG_DATE = gt_pohd-budat.
ls_HEADERDATA-COMP_CODE = gt_pohd-bukrs.
ls_HEADERDATA-GROSS_AMOUNT = gt_pohd-netwr.
ls_HEADERDATA-CURRENCY = gt_pohd-waers.
loop at gt_podt where ebeln = gt_pohd-ebeln.
on change of gt_podt-matnr.
l_item = l_item + 1.
lt_itemdata-INVOICE_DOC_ITEM = l_item.
lt_itemdata-PO_NUMBER = gt_pohd-belnr.
lt_itemdata-PO_ITEM = gt_podt-ebelp.
lt_itemdata-TAX_CODE = 'V0'.
lt_itemdata-ITEM_AMOUNT = gt_podt-netwr.
lt_itemdata-QUANTITY = gt_podt-menge.
lt_itemdata-PO_UNIT = 'EA'.
lt_itemdata-cond_type = gt_podt-kschl.
at end of ebeln.
CALL FUNCTION 'BAPI_INCOMINGINVOICE_CREATE'
headerdata = ls_headerdata
itemdata = lt_itemdata
TAXDATA = lt_taxdata
return = lt_return
loop at lT_return.
move lt_return to gt_return.
concatenate 'Doc No/PO no' gt_pohd-ebeln '/'
gt_pohd-belnr ':' lt_return-message
separated by space.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
return = ls_bapiret2.
I got this from OSS note and may help you.
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.