Skip to Content
0

Line items was updating in foreground and not updating in background using BAPI_ACC_DOC_POST

May 13, 2017 at 05:58 PM

63

avatar image

Not able to fill the assignment field in background scheduling in fb03.

LOOP AT lt_zscb_mt942_table INTO wa_zscb_mt942_table.

IF wa_zscb_mt942_table-doc_number IS INITIAL.

*------Header

PERFORM header.

*------Account GL

PERFORM general_ledger.

*-------Account Receivable

PERFORM account_rec.

*-------Currency Amount

PERFORM currency_amount.

*-----------Post Accounting Document

CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'

EXPORTING

documentheader = wa_documentheader

TABLES

accountgl = lt_accountgl

accountreceivable = lt_accountreceivable

currencyamount = lt_currencyamount

return = lt_return.

**---SAVE DATA IN DATABASE

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING wait = c_x.

endloop.

FORM header .

wa_documentheader-username = c_username. "username

wa_documentheader-comp_code = c_comp_code. " company code

wa_documentheader-bus_act = c_bus_act. "'RFBU'.

wa_documentheader-doc_date = wa_zscb_mt942_table-document_date. wa_documentheader-pstng_date = wa_zscb_mt942_table-posting_date.

*Get Fiscal Year

CALL FUNCTION 'BAPI_COMPANYCODE_GET_PERIOD'

EXPORTING

companycodeid = wa_documentheader-comp_code

posting_date = wa_documentheader-pstng_date

IMPORTING

fiscal_year = lv_fiscal_year

* RETURN = .

wa_documentheader-fisc_year = lv_fiscal_year.

wa_documentheader-doc_type = c_doc_type.

wa_documentheader-ref_doc_no = c_ref_doc_no.

ENDFORM. " HEADER

FORM general_ledger .

wa_accountgl-itemno_acc = c_itemno_acc_1.

wa_accountgl-gl_account = c_gl_account. "0000372301

CONCATENATE c_ref_doc_no ':' wa_zscb_mt942_table-kunnr INTO wa_accountgl-item_text .

wa_accountgl-value_date = wa_zscb_mt942_table-posting_date.

lv_utr_no_len = strlen( wa_zscb_mt942_table-utr_no ).

IF lv_utr_no_len GE 18.

wa_accountgl-alloc_nmbr = wa_zscb_mt942_table-utr_no+5(18).

ELSEIF lv_utr_no_len LE 16.

wa_accountgl-alloc_nmbr = wa_zscb_mt942_table-utr_no.

ENDIF.

APPEND wa_accountgl TO lt_accountgl.

CLEAR : wa_accountgl,lv_utr_no_len.

ENDFORM. " GENERAL_LEDGER

FORM account_rec .

wa_accountreceivable-itemno_acc = c_itemno_acc_2. " '2',

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

input = wa_zscb_mt942_table-kunnr

IMPORTING

output = wa_zscb_mt942_table-kunnr .

wa_accountreceivable-customer = wa_zscb_mt942_table-kunnr.

wa_accountreceivable-alloc_nmbr = wa_zscb_mt942_table-utr_no.

CONCATENATE c_ref_doc_no ':' wa_zscb_mt942_table-kunnr INTO wa_accountreceivable-item_text.

wa_accountreceivable-sp_gl_ind = c_stat_con_a. "'A'

APPEND wa_accountreceivable TO lt_accountreceivable. CLEAR : wa_accountreceivable.

ENDFORM. " ACCOUNT_REC

FORM currency_amount .

wa_currencyamount-itemno_acc = c_itemno_acc_1.

wa_currencyamount-currency = wa_zscb_mt942_table-currency.

wa_currencyamount-amt_doccur = wa_zscb_mt942_table-amount.

APPEND wa_currencyamount TO lt_currencyamount.

CLEAR wa_currencyamount.

wa_currencyamount-itemno_acc = c_itemno_acc_2.

wa_currencyamount-currency = wa_zscb_mt942_table-currency.

wa_currencyamount-amt_doccur = wa_zscb_mt942_table-amount * -1.

APPEND wa_currencyamount TO lt_currencyamount.

CLEAR wa_currencyamount.

ENDFORM. " CURRENCY_AMOUNT

Please help me to solve the issue

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

0 Answers