Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

FI Document Post

Former Member
0 Likes
1,139

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..

5 REPLIES 5
Read only

jyotheswar_p2
Active Participant
0 Likes
880

Use 'BAPI_ACC_DOCUMENT_POST'.Please read the documentation for the business type to be passed.

Read only

Former Member
0 Likes
880

 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.

Read only

RaymondGiuseppi
Active Contributor
0 Likes
880

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

Read only

Former Member
0 Likes
880

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

Read only

Former Member
0 Likes
880

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.