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 Headerls_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.*-- Getlt_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'EXPORTINGdocumentheader = ls_document_hdr* CUSTOMERCPD =* CONTRACTHEADER =IMPORTING* OBJ_TYPE =obj_key = lv_key* OBJ_SYS =TABLES* ACCOUNTGL =accountreceivable = lt_accountreceivableaccountpayable = lt_accountpayable* ACCOUNTTAX =currencyamount = lt_currency_amt* CRITERIA =* VALUEFIELD =* EXTENSION1 =return = lt_return* PAYMENTCARD =* CONTRACTITEM =* EXTENSION2 =* REALESTATE =* ACCOUNTWT =.