‎2010 May 24 9:23 AM
Hi All,
Do you know any function module/BAPI to create customer noted item ( Tcode : F - 49 )?
Please let me know if you know any.
Thanks & Reagrds,
Senthil.
Edited by: senthil nathan on May 24, 2010 1:54 PM
‎2016 Mar 29 11:14 AM
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,
lt_return TYPE TABLE OF bapiret2.
** 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_receivable TO 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.
It in the BTE or BAdI that we assign the document business activity, in this case should be RFST, and the posting key, special G/L indicator and document status. The last field should be 'S' (Noted items).
You can prepare the data in the program where the BAdI is being invoked or in the BAdI itself. I recommend the first option, since the BAdI, when active will run everytime a document is posted via BAPI_ACC_DOCUMENT_POST.
You can add whatever the data you want, just make sure the code in the BAdI for the noted item is only executed when you post a noted item via the BAdI. So in my case, what I did, was to identify the purpose in the first record of the extension2 table.
**Fill the extension table
lw_extension2-structure = 'TYPE'.
lw_extension2-valuepart1 = 'NOTED ITEM' .
APPEND lw_extension2 TO lt_extension2.
*** posting key
lw_extension2-structure = lv_item_nr. "<- once again, this makes sure that the posting key 14 is for the first item of the document as you could have more than one item
lw_extension2-valuepart1 = 'BSCHL'.
lw_extension2-valuepart2 = '14'.
*** special G/L indicator
lw_extension2-structure = lv_item_nr.
lw_extension2-valuepart1 = 'UMSKZ'.
lw_extension2-valuepart2 = 'T'.
APPEND lw_extension2 TO lt_extension2.
*** document status
lw_extension2-structure = lv_item_nr.
lw_extension2-valuepart1 = 'BSTAT'.
lw_extension2-valuepart2 = 'S'.
APPEND lw_extension2 TO lt_extension2.
CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
EXPORTING
documentheader = lw_header
IMPORTING
obj_key = lv_objkey
TABLES
accountreceivable = lt_account_receivable
currencyamount = lt_curr_amount
return = lt_return
extension2 = lt_extension2.
** Now the code for the method CHANGE of BADI_ACC_DOCUMENT.
METHOD if_ex_acc_document~change.
DATA: lw_extension2 TYPE bapiparex,
lw_c_accit TYPE accit,
lv_index TYPE sy-tabix,
lv_aux TYPE string.
READ TABLE c_extension2 WITH KEY structure = 'TYPE' INTO lw_extension2.
IF lw_extension2-valuepart1 = 'NOTED ITEM'.
LOOP AT c_accit INTO lw_c_accit.
lv_index = sy-tabix.
lv_aux = lw_c_accit-posnr.
LOOP AT c_extension2 INTO lw_extension2 WHERE structure = lv_aux.
CASE lw_extension2-valuepart1.
WHEN 'BSCHL'.
lw_c_accit-bschl = lw_extension2-valuepart2.
WHEN 'BSTAT'.
lw_c_accit-bstat = lw_extension2-valuepart2.
WHEN 'UMSKZ'.
lw_c_accit-umskz = lw_extension2-valuepart2.
ENDCASE.
ENDLOOP.
MODIFY c_accit INDEX lv_index FROM lw_c_accit.
ENDLOOP.
C_ACCHD-GLVOR = 'RFST'.
ENDIF.
ENDMETHOD.
And that is it.
Regards,
Tabrez Hanif