‎2010 Oct 04 7:37 AM
Hi,
A FI document is posted against a customer. Now I want to copy the details of same document and post it to another customer and post one more document for the original customer with the debit indicator.
Do we have any FM or BAPI for this ..
Please help me.. I am stuck in the issue...
Thanks & Rgds,
Sameer..
‎2010 Oct 04 7:39 AM
Use 'BAPI_ACC_DOCUMENT_POST'.Please read the documentation for the business type to be passed.
‎2010 Oct 05 11:57 AM
CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
EXPORTING
documentheader = documentheader
TABLES
accountgl = accountgl
currencyamount = currencyamount
return = return
extension1 = extension1
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
MESSAGE e999(re) WITH 'Problem occured'.
ELSE.
‎2010 Oct 05 12:09 PM
Use [BAPI_ACC_DOCUMENT_POST|http://www.sdn.sap.com/irj/scn/advancedsearch?query=bapi_acc_document_post#sdn_content_category_value_wiki] to post to the new customer and [BAPI_ACC_DOCUMENT_REV_POST|http://www.sdn.sap.com/irj/scn/advancedsearch?query=bapi_acc_document_post#sdn_content_category_value_wiki] for the old one.
Regards,
Raymond
‎2010 Oct 07 8:30 AM
Example:
DATA:
obj_type LIKE bapiache02-obj_type,
obj_key LIKE bapiache02-obj_key,
obj_sys LIKE bapiache02-obj_sys,
* documentheader LIKE bapiache08,
documentheader LIKE bapiache09,
* accountgl LIKE bapiacgl08 OCCURS 0 WITH HEADER LINE,
* currencyamount LIKE bapiaccr08 OCCURS 0 WITH HEADER LINE,
* extension1 LIKE bapiextc OCCURS 0 WITH HEADER LINE,
return LIKE bapiret2 OCCURS 0 WITH HEADER LINE,
accountgl LIKE bapiacgl09 OCCURS 0 WITH HEADER LINE,
currencyamount LIKE bapiaccr09 OCCURS 0 WITH HEADER LINE,
extension1 LIKE bapiacextc OCCURS 0 WITH HEADER LINE,
t_edidd LIKE edidd OCCURS 0 WITH HEADER LINE,
bapi_retn_info LIKE bapiret2 OCCURS 0 WITH HEADER LINE.
DATA: error_flag.
DATA: gs_wait TYPE bapita-wait,
wa_comm_return TYPE bapiret2.
DATA : zline LIKE bapiacgl09-itemno_acc.
LOOP AT itab.
IF itab-shkzg = 'H'.
CONCATENATE itab-mblnr itab-mjahr INTO documentheader-header_txt.
documentheader-username = sy-uname.
documentheader-comp_code = '1000'.
documentheader-doc_date = itab-bldat.
documentheader-pstng_date = itab-budat.
documentheader-doc_type = 'SA'.
documentheader-ref_doc_no = itab-xblnr.
***line item 1
accountgl-itemno_acc = '2'.
accountgl-gl_account = '0000232900'.
accountgl-comp_code = '1000'.
accountgl-pstng_date = itab-budat.
accountgl-doc_type = 'SA'.
accountgl-profit_ctr = itab-prctr.
accountgl-alloc_nmbr = itab-zuonr.
accountgl-po_number = itab-ebeln.
accountgl-po_item = itab-ebelp.
* accountgL-DE_CRE_IND = 'S'.
APPEND accountgl.
currencyamount-itemno_acc = '2'.
currencyamount-currency = 'USD'.
currencyamount-amt_doccur = itab-grval.
APPEND currencyamount.
* zline = zline + 1.
***line itme 2
accountgl-itemno_acc = '1'.
accountgl-gl_account = '0000261000'.
accountgl-comp_code = '1000'.
accountgl-pstng_date = itab-budat.
accountgl-doc_type = 'SA'.
accountgl-profit_ctr = itab-prctr.
accountgl-alloc_nmbr = itab-zuonr.
* accountgl-po_number = itab-ebeln.
accountgl-po_item = itab-ebelp.
* accountgL-DE_CRE_IND = 'H'.
APPEND accountgl.
currencyamount-itemno_acc = '1'.
currencyamount-currency = 'USD'.
itab-grval = itab-grval * -1.
currencyamount-amt_doccur = itab-grval.
APPEND currencyamount.
ELSE.
documentheader-username = sy-uname.
CONCATENATE itab-mblnr itab-mjahr INTO documentheader-header_txt.
documentheader-comp_code = '1000'.
documentheader-doc_date = itab-bldat.
documentheader-pstng_date = itab-budat.
documentheader-doc_type = 'SA'.
documentheader-ref_doc_no = itab-xblnr.
***line item 1
accountgl-itemno_acc = '1'.
accountgl-gl_account = '0000261000'.
accountgl-comp_code = '1000'.
accountgl-pstng_date = itab-budat.
accountgl-doc_type = 'SA'.
accountgl-profit_ctr = itab-prctr.
accountgl-alloc_nmbr = itab-zuonr.
* accountgL-DE_CRE_IND = 'S'.
APPEND accountgl.
currencyamount-itemno_acc = '1'.
currencyamount-currency = 'USD'.
currencyamount-amt_doccur = itab-grval.
APPEND currencyamount.
* zsched_line = zsched_line + 1.
***line itme 2
accountgl-itemno_acc = '2'.
accountgl-gl_account = '0000232900'.
accountgl-comp_code = '1000'.
accountgl-pstng_date = itab-budat.
accountgl-doc_type = 'SA'.
accountgl-profit_ctr = itab-prctr.
accountgl-alloc_nmbr = itab-zuonr.
accountgl-po_number = itab-ebeln.
accountgl-po_item = itab-ebelp.
* accountgL-DE_CRE_IND = 'H'.
APPEND accountgl.
currencyamount-itemno_acc = '2'.
currencyamount-currency = 'USD'.
itab-grval = itab-grval * -1.
currencyamount-amt_doccur = itab-grval.
APPEND currencyamount.
ENDIF.
Edited by: Krupaji on Oct 7, 2010 9:30 AM
‎2010 Oct 07 8:31 AM
Continue...........
CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
EXPORTING
documentheader = documentheader
TABLES
accountgl = accountgl
currencyamount = currencyamount
return = return
extension1 = extension1
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
MESSAGE e999(re) WITH 'Problem occured'.
ELSE.
.
LOOP AT return.
IF NOT return IS INITIAL.
CLEAR bapi_retn_info.
MOVE-CORRESPONDING return TO bapi_retn_info.
IF return-type = 'A' OR return-type = 'E'.
error_flag = 'X'.
ENDIF.
APPEND bapi_retn_info.
ENDIF.
ENDLOOP.
IF error_flag = 'X'.
MESSAGE e999(re) WITH 'Problem occured'.
ROLLBACK WORK.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = gs_wait
IMPORTING
return = wa_comm_return.
WRITE :/ return-message+0(30),return-message+36(10).
ENDIF.
ENDIF.
REFRESH: currencyamount,accountgl,return,extension1.
CLEAR: currencyamount,accountgl,documentheader,return,extension1.
ENDLOOP.