Hi,
I know this message was posted a long time ago. However, in order to help anyone else who comes across the same need I post the solution.
The BAPI you should use is BAPI_ACC_DOCUMENT_POST. To fully implement the solution, you have then to use BTE for process RWBAPI01, or as in my case implement the method CHANGE of the BAdI BADI_ACC_DOCUMENT. I have tested both alternatives and achieved the same result. So it is up to you to decide whether to go with the BTE or with the BAdI.
In your case you need to create a customer noted item.
data: lw_header TYPE bapiache09,
lt_account_receivable TYPE TABLE OF bapiacar09, "<- because it is for customer
lw_account_receivable TYPE bapiacar09, "<-because it is for customer
lt_curr_amount TYPE TABLE OF bapiaccr09,
lw_curr_amount TYPE bapiaccr09,
lv_item_nr TYPE posnr_acc VALUE 1,
lv_objkey LIKE bapiache09-obj_key,
lt_extension2 TYPE TABLE OF bapiparex,
lw_extension2 TYPE bapiparex.
** Fill document header
lw_header-doc_type = 'ST'.
lw_header-username = sy-uname.
lw_header-doc_date = sy-datum.
lw_header-pstng_date = lw_header-doc_date.
lw_header-fisc_year = lw_header-doc_date(4).
lw_header-fis_period = lw_header-doc_date+4(2).
lw_header-ref_doc_no = 'Testing'.
lw_header-comp_code = 'ABC'.
** Fill customer item table
lw_account_receivable= lv_item_nr.
lw_account_receivable-customer = '12345678'. "<- customer_account.
lw_account_receivable-bline_date = lw_header-doc_date.
APPEND lw_account_receivableTO lt_account_receivable.
** Fill amount table
lw_curr_amount-itemno_acc = lv_item_nr. "<- this is the amount for the customer item. It works like a key to identify the correct amount for the customer item table.
lw_curr_amount-currency = 'EUR'.
lw_curr_amount-amt_doccur = lw_doc-montante_mi. "<- in case it was a noted item for supplier, then this amount should be negative
lw_curr_amount-disc_base = lw_doc-montante_mi. "<- in case it was a noted item for supplier, then this amount should be negative
APPEND lw_curr_amount TO lt_curr_amount.
Now, it is where we prepare the data to be used in the BTE or BAdI.
The difference is, if you choose the BTE you must fill the table EXTENSION1of the BAPI, if you choose the BAdI then you should fill the table EXTENSION2.