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

Help on how to use BAPI_ACC_DOCUMENT_POST...

aris_hidalgo
Contributor
0 Likes
575

Hello experts,

Please help me on how to use the BAPI BAPI_ACC_DOCUMENT_POST. I dont have the time to

record via SHDB and do BDC and I would like to try out the said BAPI. I think this will be faster

I need to fill in the header, line items, etc. Any detailed examples will be highly appreciated.

Thanks a lot guys and take care!

Hello experts,

Please help me on how to use the BAPI BAPI_ACC_DOCUMENT_POST. I dont have the time to

record via SHDB and do BDC and I would like to try out the said BAPI. I think this will be faster

I need to fill in the header, line items, etc. Any detailed examples will be highly appreciated.

Thanks a lot guys and take care!

1 REPLY 1
Read only

Former Member
0 Likes
354

Take a look at the following code :


* IF GL ACCOUNT

*       Accountgl / Compte générale
        ws_accountgl-itemno_acc   = w_compt.
        ws_accountgl-comp_code    = p_bukrs.
        ws_accountgl-pstng_date   = ws_reformat-datecpt.
        ws_accountgl-fisc_year    = ws_reformat-datecpt(4).
        ws_accountgl-fis_period   = ws_reformat-datecpt+4(2).
        ws_accountgl-doc_type     = p_blart.
        ws_accountgl-item_text    = ws_reformat-libel.

        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
          EXPORTING
            input  = ws_reformat-cptclf
          IMPORTING
            output = ws_accountgl-gl_account.

        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
          EXPORTING
            input  = ws_reformat-kostl
          IMPORTING
            output = ws_accountgl-costcenter.

      ELSE. " ACC. PAYABLE

*       Account Payable /  Compte fournisseur
        ws_accountpayable-itemno_acc   = w_compt.
        ws_accountpayable-comp_code    = p_bukrs.
        ws_accountpayable-item_text    = ws_reformat-libel.

        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
          EXPORTING
            input  = ws_reformat-cptclf
          IMPORTING
            output = ws_accountpayable-vendor_no.
        APPEND ws_accountpayable TO accountpayable.

      ENDIF.

*     Currencyamount Struct.
      ws_currencyamount-itemno_acc = w_compt.
      ws_currencyamount-currency = 'EUR'.
*     ws_currencyamount-curr_type = '00'.
      IF ws_reformat-sign EQ 'C'.
        ws_reformat-wrbtr_c = ws_reformat-wrbtr_c * ( - 1 ).
      ENDIF.
      ws_currencyamount-amt_doccur = ws_reformat-wrbtr_c.
      APPEND ws_currencyamount TO currencyamount.


* BAPI
    CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
      EXPORTING
        documentheader = documentheader
      TABLES
        accountgl      = accountgl
        accountpayable = accountpayable
        currencyamount = currencyamount
        return         = t_return.

    IF sy-subrc <> 0.
      MESSAGE e999(re) WITH 'Problem occured'.
    ELSE.
        CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
    ENDIF.