Используется функциональный модуль BAPI_ACC_DOCUMENT_POST.
DATA: ls_docheader TYPE bapiache09, lv_obj_type TYPE bapiache09-obj_type, lv_obj_key TYPE bapiache09-obj_key, lv_obj_sys TYPE bapiache09-obj_sys, lt_accountgl TYPE TABLE OF bapiacgl09, lt_accountrec TYPE TABLE OF bapiacar09, lt_accountpay TYPE TABLE OF bapiacap09, lt_accounttax TYPE TABLE OF bapiactx09, lt_curramount TYPE TABLE OF bapiaccr09, lt_return TYPE TABLE OF bapiret2, lv_bukrs TYPE bkpf-bukrs VALUE 'RU01', lv_blart TYPE bkpf-blart 'AB', lv_mwskz TYPE bseg-mwskz 'A1', lv_wrbtr TYPE bseg-wrbtr, lv_fwste TYPE bset-fwste, lt_mwdat TYPE TABLE OF rtax1u15. FIELD-SYMBOLS: <lfs_accountgl> LIKE LINE OF lt_accountgl, <lfs_accountrec> LIKE LINE OF lt_accountrec, <lfs_accountpay> LIKE LINE OF lt_accountpay, <lfs_accounttax> LIKE LINE OF lt_accounttax, <lfs_curramount> LIKE LINE OF lt_curramount, <lfs_return> LIKE LINE OF lt_return. CLEAR: ls_docheader, lv_obj_type, lv_obj_key, lv_obj_sys. REFRESH: lt_accountgl, lt_curramount, lt_return. ls_docheader-username = sy-uname. ls_docheader-comp_code = lv_bukrs. ls_docheader-doc_date = sy-datum. ls_docheader-pstng_date = sy-datum. ls_docheader-doc_type = lv_blart. ls_docheader-ref_doc_no = ''. ls_docheader-bus_act = 'RFBU'. INSERT INITIAL LINE INTO TABLE lt_accounttax ASSIGNING <lfs_accounttax>. <lfs_accounttax>-itemno_acc = 1. <lfs_accounttax>-gl_account = '0000480000'. <lfs_accounttax>-tax_code = lv_mwskz. <lfs_accounttax>-direct_tax = 'X'. INSERT INITIAL LINE INTO TABLE lt_curramount ASSIGNING <lfs_curramount>. <lfs_curramount>-itemno_acc = 1. <lfs_curramount>-curr_type = '00'. <lfs_curramount>-currency = 'RUB'. <lfs_curramount>-amt_base = -100. lv_wrbtr = <lfs_curramount>-amt_base. CALL FUNCTION 'CALCULATE_TAX_FROM_NET_AMOUNT' EXPORTING i_bukrs = ls_docheader-comp_code i_mwskz = lv_mwskz i_waers = 'RUB' i_wrbtr = lv_wrbtr IMPORTING e_fwste = lv_fwste TABLES t_mwdat = lt_mwdat EXCEPTIONS bukrs_not_found = 1 country_not_found = 2 mwskz_not_defined = 3 mwskz_not_valid = 4 ktosl_not_found = 5 kalsm_not_found = 6 parameter_error = 7 knumh_not_found = 8 kschl_not_found = 9 unknown_error = 10 account_not_found = 11 txjcd_not_valid = 12 OTHERS = 13. <lfs_curramount>-amt_doccur = lv_fwste. INSERT INITIAL LINE INTO TABLE lt_accounttax ASSIGNING <lfs_accounttax>. <lfs_accounttax>-itemno_acc = 2. <lfs_accounttax>-gl_account = '0000430000'. <lfs_accounttax>-tax_code = lv_mwskz. <lfs_accounttax>-direct_tax = 'X'. INSERT INITIAL LINE INTO TABLE lt_curramount ASSIGNING <lfs_curramount>. <lfs_curramount>-itemno_acc = 2. <lfs_curramount>-curr_type = '00'. <lfs_curramount>-currency = 'RUB'. <lfs_curramount>-amt_base = 100. lv_wrbtr = <lfs_curramount>-amt_base. CALL FUNCTION 'CALCULATE_TAX_FROM_NET_AMOUNT' EXPORTING i_bukrs = ls_docheader-comp_code i_mwskz = lv_mwskz i_waers = 'RUB' i_wrbtr = lv_wrbtr IMPORTING e_fwste = lv_fwste TABLES t_mwdat = lt_mwdat EXCEPTIONS bukrs_not_found = 1 country_not_found = 2 mwskz_not_defined = 3 mwskz_not_valid = 4 ktosl_not_found = 5 kalsm_not_found = 6 parameter_error = 7 knumh_not_found = 8 kschl_not_found = 9 unknown_error = 10 account_not_found = 11 txjcd_not_valid = 12 OTHERS = 13. <lfs_curramount>-amt_doccur = lv_fwste. CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST' EXPORTING documentheader = ls_docheader * customercpd = * contractheader = IMPORTING obj_type = lv_obj_type obj_key = lv_obj_key obj_sys = lv_obj_sys TABLES accountgl = lt_accountgl accountreceivable = lt_accountrec accountpayable = lt_accountpay accounttax = lt_accounttax currencyamount = lt_curramount * criteria = * valuefield = * extension1 = return = lt_return * paymentcard = * contractitem = * extension2 = * realestate = * accountwt = . LOOP AT lt_return ASSIGNING <lfs_return> WHERE type CA 'EAX'. EXIT. ENDLOOP. IF sy-subrc EQ 0. ROLLBACK WORK. ELSE. COMMIT WORK AND WAIT. ENDIF.
Комментариев нет:
Отправить комментарий