Showing posts with label FI. Show all posts
Showing posts with label FI. Show all posts

Friday, May 13, 2005

Post an FI document using BAPI

To post an FI document with AR/AP/GL information one can use the BAPI BAPI_ACC_DOCUMENT_POST. Example usage is as below:

*-- Fill Header
  ls_document_hdr-username = sy-uname.
  ls_document_hdr-header_txt = ls_v_tree-mblnr.
  ls_document_hdr-bus_act = 'RMRP'.
  ls_document_hdr-comp_code = ls_v_master-cur_bukrs.
  ls_document_hdr-doc_date = sy-datum.
  ls_document_hdr-pstng_date = sy-datum.
  ls_document_hdr-doc_type = 'SA'.
  ls_document_hdr-header_txt = ls_v_tree-vbeln.
  ls_document_hdr-ref_doc_no = ls_v_tree-vbeln.
*-- fill AR (line 1)
  lt_accountreceivable-itemno_acc = 1.
  lt_accountreceivable-customer = ls_v_tree-kunnr.
  lt_accountreceivable-ref_key_1 = ls_v_tree-vbeln.
  lt_accountreceivable-ref_key_2 = ls_v_tree-vbeln.
  lt_accountreceivable-ref_key_3 = ls_v_tree-vbeln.
  APPEND lt_accountreceivable.
*-- Get
  lt_currency_amt-itemno_acc = 1.
  lt_currency_amt-currency = lv_currency.
  lt_currency_amt-amt_doccur = lv_amount * -1.
  APPEND lt_currency_amt.
  CLEAR lt_currency_amt.
** fill AP (line 2)
  lt_accountpayable-itemno_acc = 2.
  lt_accountpayable-vendor_no = lv_vendor.
  lt_accountpayable-ref_key_1 = ls_v_tree-vbeln.
  lt_accountpayable-ref_key_2 = ls_v_tree-vbeln.
  lt_accountpayable-ref_key_3 = ls_v_tree-vbeln.
  APPEND lt_accountpayable.
  lt_currency_amt-itemno_acc = 2.
  lt_currency_amt-currency = lv_currency.
  lt_currency_amt-amt_doccur = lv_amount.
  APPEND lt_currency_amt.
  CLEAR lt_currency_amt.
  CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
    EXPORTING
      documentheader          = ls_document_hdr
*     CUSTOMERCPD             =
*     CONTRACTHEADER          =
    IMPORTING
*     OBJ_TYPE                =
      obj_key                 = lv_key
*     OBJ_SYS                 =
    TABLES
*     ACCOUNTGL               =
      accountreceivable       = lt_accountreceivable
      accountpayable          = lt_accountpayable
*     ACCOUNTTAX              =
      currencyamount          = lt_currency_amt
*     CRITERIA                =
*     VALUEFIELD              =
*     EXTENSION1              =
      return                  = lt_return
*     PAYMENTCARD             =
*     CONTRACTITEM            =
*     EXTENSION2              =
*     REALESTATE              =
*     ACCOUNTWT               =
            .

Saturday, November 13, 2004

Substitution Rule

Substitution rule setup:

Go to FI->GL->Business Transaction->GL A/c posting->Carry out and Check Document settings->Substitution in A/c documents

Payment File setup

Payment file setup (MT100 and MT210)

Go to FI->AR and AP->Business Transaction->Outgoing Payments->Automatic outgoing payments->Payment media->Make settings for payment medium formats for Payment medium workbench->Create Payment medium formats