Quantcast
Channel: SCN : Document List - ABAP Development
Viewing all articles
Browse latest Browse all 935

PARKING INVOICES USING BAPI 'BAPI_INCOMINGINVOICE_PARK'

$
0
0

PARKING INVOICES USING BAPI 'BAPI_INCOMINGINVOICE_PARK'

 

Hi Guys,

 

Below example of code is helpful for those who create Service Entries Sheets for Purchase Order and look for Parking the Invoices with respect to Purchase Order.

 

“Account Assignment for ‘Service Entry’ Missing – This would be common error when trying to Park Invoice using 'BAPI_INCOMINGINVOICE_PARK'. To overcome this error ACCOUNTINGDATA should be passed to BAPI.

 

Code looks as below.

 

***BAPI Declarations for Parking Invoices
DATA: x_headerdata TYPE bapi_incinv_create_header,
gv_inv_doc   TYPE bapi_incinv_fld-inv_doc_no,
gv_fiscal_yr TYPE bapi_incinv_fld-fisc_year,
x_itemdata   TYPE bapi_incinv_create_item,
i_itemdata   TYPE TABLE OF bapi_incinv_create_item,
x_glaccdata  TYPE bapi_incinv_create_gl_account,
i_glaccdata  TYPE TABLE OF bapi_incinv_create_gl_account,
i_taxdata    TYPE TABLE OF bapi_incinv_create_tax,
x_taxdata    TYPE bapi_incinv_create_tax,
i_return2    TYPE TABLE OF bapiret2,
x_return2    TYPE bapiret2.

DATA: x_accountdata   TYPE bapi_incinv_create_account,
i_accountdata   TYPE TABLE OF bapi_incinv_create_account.


**HEADERDATA
x_headerdata-invoice_ind  = 'X'.
x_headerdata-doc_type     = 'RE'.
x_headerdata-doc_date     = lv_doc_date.         
x_headerdata-pstng_date   = sy-datum.

x_headerdata-ref_doc_no   = x_inv_data-po_number.

x_headerdata-comp_code    = '1000'. "This will change as per your requirement
x_headerdata-currency_iso = 'USD'.
x_headerdata-gross_amount = x_inv_data-wrbtr.
x_headerdata-bline_date   = sy-datum.
x_headerdata-item_text    = x_inv_data-url1.


**ITEM DATA
x_itemdata-invoice_doc_item = x_inv_data-po_item.
x_itemdata-po_number        = x_inv_data-po_number.
x_itemdata-po_item          = x_inv_data-po_item.
x_itemdata-item_amount      = x_inv_data-wrbtr.
x_itemdata-retention_docu_currency = x_inv_data-wrbtr.

READ TABLE i_essr INTO x_essr WITH KEY ebeln = x_inv_data-po_number
ebelp = x_inv_data-po_item.
IF sy-subrc = 0.
x_itemdata-sheet_no  = x_essr-lblni.
ENDIF.
APPEND x_itemdata TO i_itemdata.
CLEAR x_itemdata.

**ACCOUNTINGDATA
x_accountdata-invoice_doc_item = x_inv_data-po_item.   
x_accountdata-serial_no = '01'.
x_accountdata-tax_code  = 'V0'.
x_accountdata-item_amount = x_inv_data-wrbtr.

READ TABLE i_ekkn INTO x_ekkn WITH KEY ebeln = x_inv_data-po_number
ebelp = x_inv_data-po_item.
IF sy-subrc = 0.
x_accountdata-gl_account = x_ekkn-sakto.
ENDIF.

x_accountdata-costcenter = x_ekkn-kostl.
x_accountdata-cmmt_item  = x_ekkn-sakto.
x_accountdata-funds_ctr  = x_ekkn-fistl.
x_accountdata-func_area  = x_ekkn-fkber.
x_accountdata-fund       = x_ekkn-geber.
x_accountdata-co_area    = x_ekkn-kokrs.
x_accountdata-profit_ctr = x_ekkn-prctr.
x_accountdata-grant_nbr  = x_ekkn-grant_nbr.
APPEND x_accountdata TO i_accountdata.
CLEAR x_accountdata.

***G/L Account Data

***Read EKKN Data
IF i_ekkn[] IS NOT INITIAL.
READ TABLE i_ekkn INTO x_ekkn WITH KEY ebeln = x_inv_data-po_number
ebelp = x_inv_data-po_item.
IF sy-subrc = 0.
x_glaccdata-invoice_doc_item = '000001'.
x_glaccdata-gl_account  x_ekkn-sakto.
x_glaccdata-item_amount = x_inv_data-wrbtr.
x_glaccdata-db_cr_ind = 'S'.
x_glaccdata-comp_code = '1000'. "This will change as per your requirement
x_glaccdata-item_text = x_inv_data-url1.

x_glaccdata-costcenter = x_ekkn-kostl.
x_glaccdata-cmmt_item  = x_ekkn-sakto.
x_glaccdata-funds_ctr  = x_ekkn-fistl.
x_glaccdata-func_area  = x_ekkn-fkber.
x_glaccdata-profit_ctr = x_ekkn-prctr.
x_glaccdata-fund       = x_ekkn-geber.
x_glaccdata-grant_nbr  = x_ekkn-grant_nbr.


APPEND x_glaccdata TO i_glaccdata.
CLEAR x_glaccdata.
x_glaccdata-invoice_doc_item = '000002'.
x_glaccdata-gl_account  x_ekkn-sakto.
x_glaccdata-item_amount = x_inv_data-wrbtr.
x_glaccdata-db_cr_ind = 'H'.
x_glaccdata-comp_code = '1000'. "This will change as per your requirement
x_glaccdata-item_text = x_inv_data-url1.

x_glaccdata-costcenter = x_ekkn-kostl.
x_glaccdata-cmmt_item  = x_ekkn-sakto.
x_glaccdata-funds_ctr  = x_ekkn-fistl.
x_glaccdata-func_area  = x_ekkn-fkber.
x_glaccdata-profit_ctr = x_ekkn-prctr.
x_glaccdata-fund       = x_ekkn-geber.
x_glaccdata-grant_nbr  = x_ekkn-grant_nbr.

APPEND x_glaccdata TO i_glaccdata.
CLEAR x_glaccdata.
ENDIF.
ENDIF.

READ TABLE i_ekpo INTO x_ekpo WITH KEY ebeln = x_inv_data-po_number
ebelp = x_inv_data-po_item.
IF sy-subrc = 0.
IF x_ekpo-mwskz IS NOT INITIAL.
x_taxdata-tax_code x_ekpo-mwskz.
ELSE.
x_taxdata-tax_code 'V0'.
ENDIF.
APPEND x_taxdata TO i_taxdata.
CLEAR x_taxdata.
ENDIF.

CALL FUNCTION 'BAPI_INCOMINGINVOICE_PARK'

      EXPORTING
headerdata          = x_headerdata
IMPORTING
invoicedocnumber    = gv_inv_doc
fiscalyear          = gv_fiscal_yr
TABLES
itemdata            = i_itemdata[]
accountingdata      = i_accountdata[]
glaccountdata       = i_glaccdata[]
taxdata              = i_taxdata[]
return              = i_return2[].

IF gv_inv_doc IS NOT INITIAL.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.

 

 

“Account Assignment for ‘Service Entry’ Missing – This would common error when trying to Park Invoice using 'BAPI_INCOMINGINVOICE_PARK'

I debugged BAPI and found in a include where two different structures are compared

  1. S_COBL_MRM_COMP – Input goes to this structure from Progam
  2. S_COBL_MRM_FILL – It contains data from the 

                  PO

When the value of comparison fails then the error would be raised.

 

 

 


 

-Regards

Mohammed Rafi


Viewing all articles
Browse latest Browse all 935

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>