Help on BAPI_ACC_DOCUMENT_POST

Hi All,
I need to create a posting interface or BDC to do a manual tax posting? can we use the BAPI_ACC_DOCUMENT_POST for the same.
For Complete scenario kindly check the attached document Step-1 and Step-2 image file.
In case you need more clarification please let me know.
Thanks and best regards,
Niteesh Rai

Hello Rai,
You can use above BAPI. Check mentioned SAP Note
626235 - Tax postings with accounting BAPIs

Similar Messages

  • Need help in BAPI_ACC_DOCUMENT_POST.

    Hi Friends,
    Can any one help me in passing on the TAX parameters and currency parameters to
    BAPI_ACC_DOCUMENT_POST.
    this is the code i am using . it is posting the document and a TAX line is not created .
    LOOP AT IT_ITEM WHERE HEAD_COL = IT_HEADER-FIRST_COL.
          V_ITEM = V_ITEM + 1.
          CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
            EXPORTING
              INPUT  = V_ITEM
            IMPORTING
              OUTPUT = V_ITEM.
    *      IT_ACCGL-ITEMNO_ACC = V_ITEM.        "IT_ITEM-NEWBS.
    *for vendor / gl accounts based on newbs
          IF IT_ITEM-NEWBS = '40' OR IT_ITEM-NEWBS = '50'.
            IT_ACCGL-GL_ACCOUNT = IT_ITEM-NEWKO.
            IT_ACCGL-ITEMNO_ACC = V_ITEM.        "IT_ITEM-NEWBS.
            IT_ACCGL-ITEM_TEXT  = IT_ITEM-SGTXT.
            IT_ACCGL-TAX_CODE   = IT_ITEM-MWSKZ.
            CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
              EXPORTING
                INPUT  = IT_ITEM-AUFNR
              IMPORTING
                OUTPUT = IT_ACCGL-ORDERID.
            IT_ACCGL-ALLOC_NMBR = IT_ITEM-ZUONR.
            CONCATENATE IT_HEADER-BUDAT+0(4) IT_HEADER-BUDAT+5(2) IT_HEADER-BUDAT+8(2) INTO IT_ACCGL-PSTNG_DATE.
            CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
              EXPORTING
                INPUT  = IT_ITEM-KOSTL
              IMPORTING
                OUTPUT = IT_ACCGL-COSTCENTER.
            IT_ACCGL-ITEM_TEXT  = IT_ITEM-SGTXT.
            CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
              EXPORTING
                INPUT  = IT_ITEM-PRCTR
              IMPORTING
                OUTPUT = IT_ITEM-PRCTR.
            IT_ACCGL-PROFIT_CTR = IT_ITEM-PRCTR.
            APPEND IT_ACCGL.
    *for Account tax
            IT_ACCTAX-ITEMNO_ACC = V_ITEM.
            IT_ACCTAX-ACCT_KEY   = 'VST'.
            IT_ACCTAX-GL_ACCOUNT = IT_ITEM-NEWKO.
            IT_ACCTAX-TAX_CODE   = IT_ITEM-MWSKZ.
            IT_ACCTAX-TAX_RATE   = IT_MWDAT-KBETR.
            APPEND IT_ACCTAX.
    **CURRENCY
    *populate it_curr - BAPI currency table
            IT_CURR-ITEMNO_ACC = V_ITEM.      "IT_ITEM-NEWBS.
            IT_CURR-CURRENCY   = IT_HEADER-WAERS.
            IT_CURR-AMT_DOCCUR = IT_ITEM-WRBTR.
            IT_CURR-EXCH_RATE = IT_HEADER-KURSF.
            CLEAR IT_BSEG.
            READ TABLE IT_BSEG WITH KEY BELNR = IT_ITEM-NEWKO
                                        MWSKZ = IT_ITEM-MWSKZ
                                        WRBTR = IT_ITEM-WRBTR.
            IT_CURR-AMT_BASE = IT_BSEG-FWBAS.
            V_BUKRS = IT_HEADER-BUKRS.
            V_MWSKZ = IT_ITEM-MWSKZ.
            V_WAERS = IT_HEADER-WAERS.
            V_WRBTR = IT_ITEM-WRBTR.
            CALL FUNCTION 'CALCULATE_TAX_FROM_GROSSAMOUNT'
              EXPORTING
                I_BUKRS                       = V_BUKRS
                I_MWSKZ                       = V_MWSKZ
    *   I_TXJCD                       = ' '
                I_WAERS                       = V_WAERS
                I_WRBTR                       = V_WRBTR
    * IMPORTING
    *   E_FWNAV                       =
    *   E_FWNVV                       =
    *   E_FWSTE                       =
    *   E_FWAST                       =
             TABLES
               T_MWDAT                       = IT_MWDAT
             EXCEPTIONS
               BUKRS_NOT_FOUND               = 1
               COUNTRY_NOT_FOUND             = 2
               MWSKZ_NOT_DEFINED             = 3
               MWSKZ_NOT_VALID               = 4
               ACCOUNT_NOT_FOUND             = 5
               DIFFERENT_DISCOUNT_BASE       = 6
               DIFFERENT_TAX_BASE            = 7
               TXJCD_NOT_VALID               = 8
               NOT_FOUND                     = 9
               KTOSL_NOT_FOUND               = 10
               KALSM_NOT_FOUND               = 11
               PARAMETER_ERROR               = 12
               KNUMH_NOT_FOUND               = 13
               KSCHL_NOT_FOUND               = 14
               UNKNOWN_ERROR                 = 15
               OTHERS                        = 16
            IF SY-SUBRC = 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
              IT_CURR-TAX_AMT = IT_MWDAT-KBETR.
              IT_CURR-AMT_BASE = IT_MWDAT-KAWRT.
            ENDIF.
            APPEND IT_CURR.
    ***Extension1
    *populate it_extension1 - BAPI extension1 table
            V_NEWBS = IT_ITEM-NEWBS.
            IT_EXTENSION1-FIELD1(10) = V_ITEM.
            IT_EXTENSION1-FIELD1+10(2) = IT_ITEM-MWSKZ.
            IF NOT IT_ITEM-MWSKZ IS INITIAL.
              IT_EXTENSION1-FIELD2(10) = V_ITEM.
              IT_EXTENSION1-FIELD2+10(1) = 'X'.
            ENDIF.
    *for posting key
            IT_EXTENSION1-FIELD3 = V_NEWBS.
    ***for posting key IN EXTENSION2
            IT_EXTENSION2-STRUCTURE = 'ACCIT'.
            IT_TES-POSNR = V_ITEM.
            IT_TES-BSCHL = V_NEWBS.
            IT_TES-KBETR = IT_MWDAT-KBETR.
    **        IT_TES-MWSKZ = IT_ITEM-MWSKZ.
    **        IT_TES-XMWST = 'X'.
            IT_EXTENSION2-VALUEPART2(10) = V_ITEM.
            IT_EXTENSION2-VALUEPART2 = IT_ITEM-MWSKZ.
            IF NOT IT_ITEM-MWSKZ IS INITIAL.
              IT_EXTENSION2-VALUEPART3(10) = V_ITEM.
              IT_EXTENSION2-VALUEPART3+10(1) = 'X'.
            ENDIF.
            MOVE IT_TES TO IT_EXTENSION2-VALUEPART1.            "#EC ENHOK
            APPEND IT_EXTENSION2.
          ELSEIF IT_ITEM-NEWBS = '21' OR
                 IT_ITEM-NEWBS = '22' OR
                 IT_ITEM-NEWBS = '23' OR
                 IT_ITEM-NEWBS = '24' OR
                 IT_ITEM-NEWBS = '25' OR
                 IT_ITEM-NEWBS = '26' OR
                 IT_ITEM-NEWBS = '27' OR
                 IT_ITEM-NEWBS = '28' OR
                 IT_ITEM-NEWBS = '29' OR
                 IT_ITEM-NEWBS = '30' OR
                 IT_ITEM-NEWBS = '31' OR
                 IT_ITEM-NEWBS = '32' OR
                 IT_ITEM-NEWBS = '33' OR
                 IT_ITEM-NEWBS = '34' OR
                 IT_ITEM-NEWBS = '35' OR
                 IT_ITEM-NEWBS = '36' OR
                 IT_ITEM-NEWBS = '37' OR
                 IT_ITEM-NEWBS = '38' OR
                 IT_ITEM-NEWBS = '39'.
            IF IT_HEADER-BLART = 'KR' OR IT_HEADER-BLART = 'KA'.
              IT_ACCREC-ITEMNO_ACC = V_ITEM.
              CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
                EXPORTING
                  INPUT  = IT_ITEM-NEWKO
                IMPORTING
                  OUTPUT = IT_ITEM-NEWKO.
              IT_ACCREC-VENDOR_NO = IT_ITEM-NEWKO.
    *for GL account
              CLEAR IT_LFB1.
              READ TABLE IT_LFB1 WITH KEY LIFNR = IT_ITEM-NEWKO.
              IF IT_LFB1-BUKRS = IT_HEADER-BUKRS.
                IT_ACCREC-GL_ACCOUNT = IT_LFB1-AKONT.
                IT_ACCREC-COMP_CODE  = IT_HEADER-BUKRS.
                IT_ACCREC-ITEM_TEXT  = IT_ITEM-SGTXT.
                IT_ACCREC-TAX_CODE   = IT_ITEM-MWSKZ.
              ENDIF.
              APPEND IT_ACCREC.
              CLEAR IT_ACCREC.
    *for Account tax
              IT_ACCTAX-ITEMNO_ACC = V_ITEM.
              IT_ACCTAX-ACCT_KEY   = 'VST'.
              IT_ACCTAX-GL_ACCOUNT = IT_LFB1-AKONT.
              IT_ACCTAX-TAX_CODE   = IT_ITEM-MWSKZ.
              IT_ACCTAX-TAX_RATE = IT_MWDAT-KBETR.
              APPEND IT_ACCTAX.
    **CURRENCY
    *populate it_curr - BAPI currency table
              IT_CURR-ITEMNO_ACC = V_ITEM.      "IT_ITEM-NEWBS.
              IT_CURR-CURRENCY   = IT_HEADER-WAERS.
              IT_CURR-AMT_DOCCUR = IT_ITEM-WRBTR * -1.
              IT_CURR-EXCH_RATE = IT_HEADER-KURSF.
              V_BUKRS = IT_HEADER-BUKRS.
              V_MWSKZ = IT_ITEM-MWSKZ.
              V_WAERS = IT_HEADER-WAERS.
              V_WRBTR = IT_ITEM-WRBTR.
              CALL FUNCTION 'CALCULATE_TAX_FROM_GROSSAMOUNT'
                EXPORTING
                  I_BUKRS                       = V_BUKRS
                  I_MWSKZ                       = V_MWSKZ
                  I_WAERS                       = V_WAERS
                  I_WRBTR                       = V_WRBTR
    * IMPORTING
    *   E_FWNAV                       =
    *   E_FWNVV                       =
    *   E_FWSTE                       =
    *   E_FWAST                       =
               TABLES
                 T_MWDAT                       = IT_MWDAT
               EXCEPTIONS
                 BUKRS_NOT_FOUND               = 1
                 COUNTRY_NOT_FOUND             = 2
                 MWSKZ_NOT_DEFINED             = 3
                 MWSKZ_NOT_VALID               = 4
                 ACCOUNT_NOT_FOUND             = 5
                 DIFFERENT_DISCOUNT_BASE       = 6
                 DIFFERENT_TAX_BASE            = 7
                 TXJCD_NOT_VALID               = 8
                 NOT_FOUND                     = 9
                 KTOSL_NOT_FOUND               = 10
                 KALSM_NOT_FOUND               = 11
                 PARAMETER_ERROR               = 12
                 KNUMH_NOT_FOUND               = 13
                 KSCHL_NOT_FOUND               = 14
                 UNKNOWN_ERROR                 = 15
                 OTHERS                        = 16
              IF SY-SUBRC = 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
                IT_CURR-TAX_AMT  = IT_MWDAT-KBETR.
                IT_CURR-AMT_BASE = IT_MWDAT-KAWRT.
              ENDIF.
              APPEND IT_CURR.
    ***Extension1
    *populate it_extension1 - BAPI extension1 table
              V_NEWBS = IT_ITEM-NEWBS.
              IT_EXTENSION1-FIELD1(10) = V_ITEM.
              IT_EXTENSION1-FIELD1+10(2) = IT_ITEM-MWSKZ.
              IF NOT IT_ITEM-MWSKZ IS INITIAL.
                IT_EXTENSION1-FIELD2(10) = V_ITEM.
                IT_EXTENSION1-FIELD2+10(1) = 'X'.
              ENDIF.
    *for posting key
              IT_EXTENSION1-FIELD3 = V_NEWBS.
    *for posting key IN EXTENSION2
              IT_EXTENSION2-STRUCTURE = 'ACCIT'.
              IT_TES-POSNR = V_ITEM.
              IT_TES-BSCHL = V_NEWBS.
              IT_TES-MWSKZ = IT_ITEM-MWSKZ.
    *          IT_TES-XMWST = 'X'.
              IT_TES-KBETR = IT_MWDAT-KBETR.
              MOVE IT_TES TO IT_EXTENSION2-VALUEPART1.          "#EC ENHOK
              IT_EXTENSION2-VALUEPART2(10) = V_ITEM.
              IT_EXTENSION2-VALUEPART2 = IT_ITEM-MWSKZ.
              IF NOT IT_ITEM-MWSKZ IS INITIAL.
                IT_EXTENSION2-VALUEPART3(10) = V_ITEM.
                IT_EXTENSION2-VALUEPART3+10(1) = 'X'.
              ENDIF.
              APPEND IT_EXTENSION2.
            ENDIF.
          ENDIF.
        ENDLOOP.
        CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
          EXPORTING
            DOCUMENTHEADER          = IT_DOC
    *   CUSTOMERCPD             =
    *   CONTRACTHEADER          =
         IMPORTING
           OBJ_TYPE                = V_OBJ_TYPE
           OBJ_KEY                 = V_OBJ_KEY
           OBJ_SYS                 = V_OBJ_SYS
          TABLES
           ACCOUNTGL               = IT_ACCGL
    *   ACCOUNTRECEIVABLE       =
           ACCOUNTPAYABLE          = IT_ACCREC
    *       ACCOUNTTAX              = IT_ACCTAX
            CURRENCYAMOUNT          = IT_CURR
    *   CRITERIA                =
    *   VALUEFIELD              =
           EXTENSION1               = IT_EXTENSION1
            RETURN                  = IT_RETURN
    *   PAYMENTCARD             =
    *   CONTRACTITEM            =
           EXTENSION2              = IT_EXTENSION2
    *   REALESTATE              =
    *   ACCOUNTWT               =
    this is for Vendor account upload to F-02.
    in the flat file i am getting the Tax codes J0 and J1. for J0 there is no tax. for j1 we have 17% tax.
    I am not clear in passing the values. i tried to pass the values through EXTENSION1 and EXTENSION2 also.
    Kindly help me n solving this.
    Thanks in Advance.
    Vikki.

    Hi All,
    Still i am not able to get the required result.
    Now i am passing the Values to the Tax values to ACCOUNTTAX strcture.
    But the GL is not posted .
    Can you give me some code snippets on how to pass on the value to ACCOUNTTAX, CURRENCY................
    For each and every Line item how we need to pass on the TAX and CURRECNY details?
    For the items which have TAX , a extra line for TAX item should be created/
    Is it possible to do this with EXTENSION1 or EXTENSION2?
    it will be very helpful to me if you can guide me in solving this.
    Awaiting your replies.
    Vikki.

  • Help with bapi_acc_document_post

    Hello, i´m working with bapi_acc_document_post.
    I need to post this document:
    Position 1:   vendor  1000 usd 
    Posicion2:   vat         1000 usd
    but the bapi does not post it correctly.
    Does anyone knows how to fill the internal tables to post it?
    Thanks!

    You can try to Fill
    CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
           EXPORTING
                documentheader    = lx_head
           TABLES
                accountgl         = li_gl
                accountreceivable = li_ar
                currencyamount    = li_cr
                return            = li_ret.
    Fill All the paramerters as below
    Header contruction to be done based on retireval as per your reuirement
          lx_head-bus_act    = 'RFBU'
          lx_head-username   = sy-uname.
          lx_head-header_txt = 'abcd'
          lx_head-comp_code  = bukrs.
          lx_head-doc_date   =  budat.
          lx_head-pstng_date =  budat.
          lx_head-fisc_year  =  year.
          lx_head-fis_period =  monat.
          lx_head-doc_type   =  blart.
          lx_head-ref_doc_no = rebzg.
    SELECT *
                 INTO TABLE li_bseg
                 FROM bseg
                 WHERE bukrs = Compnay Code
                 AND   belnr =  BELNR
                 AND   gjahr = Fiscal Year
          CLEAR lx_ar.
          lx_ar-itemno_acc =   " Fill First item count from BSEG.
          lx_ar-customer   = lx_bseg-kunnr.
          lx_ar-sp_gl_ind  = lx_bseg-umskz.
          lx_ar-gl_account = x_zfipr2-hkont1.
          lx_ar-ref_key_1  = lx_bseg-xref1.
          lx_ar-ref_key_3  = lx_bseg-rebzg.
          lx_ar-comp_code  = lx_bseg-bukrs.
          lx_ar-alloc_nmbr = lx_bseg-zuonr.
          lx_ar-item_text  = lx_bseg-sgtxt.
          APPEND lx_ar TO li_ar.
        fill GL account data li_gl  based on BSEG data
        Fill  amount /Documen tcurrency /Currency /Item no_acc into li_cr. This can be done agin with BSEG data
    ~Pramod

  • Help on how to use BAPI_ACC_DOCUMENT_POST...

    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!

    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.

  • Help with fm BAPI_ACC_DOCUMENT_POST

    Hello!
    Would like to request for some help with BAPI's, since it is my first time to use them.  The programming requirement is to create an uploading utility to post the beginning balances of vendor and customer.  I was recommended to use the fm BAPI_ACC_DOCUMENT_POST since it's easier than coding it in  batch input, but I'm not quite sure which goes where. My questions are:
    1. If the  posting requires credit vendor/debit clearing account, would this mean the vendor item will be in the ACCOUNTPAYABLE/BAPIACAP09 table and the GL clearing account in the ACCOUNTGL/BAPIACGL09 table? 
    2. All amounts are placed in the  CURRENCYAMOUNT/BAPIACCR09 table?
    3. The fm automatically determines the posting key to be used?
    Thank you in advance for any replies.  Sample codes would also be greatly appreciated.

    Hi,
    Check this link: https://forums.sdn.sap.com/click.jspa?searchID=850430&messageID=493291
    There is one more BAPI_ACC_DOCUMENT_CHECK, this will check if the parameter values which enter is feasible to create a document or not.
    First use this FM and if sy-subrc = 0, then you can call the BAPI_ACC_DOCUMENT_POST and also call BAPI_TRANSACTION_COMMIT to save the changes.
    Refer to the Function Module Documentation [ a push button on the toolbar ] for more detailed information.
    Regards
    Subramanian

  • Error when using functions BAPI_ACC_DOCUMENT_POST

    Hello,
    When I used BAPI_ACC_DOCUMENT_POST function, the message: Document posted successfully appears, but really not documens are created, and the FI number range are modified.
    See the example code:
    *& Report  ZPBA_PC                                                     *
    REPORT  zpba_pc MESSAGE-ID m3.
    DATA: obj_type LIKE bapiache09-obj_type,
          obj_key LIKE  bapiache09-obj_key,
          obj_sys LIKE  bapiache09-obj_sys.
    DATA: it_hdr    LIKE bapiache09,
          it_gl     LIKE bapiacgl09 OCCURS 0 WITH HEADER LINE,
          it_curr   LIKE bapiaccr09 OCCURS 0 WITH HEADER LINE,
          t_result  LIKE bapiret2   OCCURS 0 WITH HEADER LINE.
    Header Data
    it_hdr-obj_type   = 'BKPFF'.
    it_hdr-obj_key    = '$'.
    it_hdr-obj_sys    = 'LA122D'.
    it_hdr-bus_act    = 'RFBU'.
    it_hdr-comp_code  = 'VEZS'.
    it_hdr-fisc_year  = '2004'.
    it_hdr-fis_period = '12'.
    it_hdr-doc_date   = '20041218'..
    it_hdr-pstng_date = '20041218'.
    it_hdr-doc_type   = 'ZI'.
    it_hdr-header_txt = 'TEXTO CAB'.
    it_hdr-username   = sy-uname.
    it_hdr-compo_acc  = 'GL'.
    it_hdr-ref_doc_no_long = 'REFERENCIA'.
    First Item
    Account number
    it_gl-itemno_acc = '1'.
    it_gl-gl_account = '0014401001'.
    it_gl-item_text  = 'PRUEBA TEXTO 1'.
    it_gl-profit_ctr = 'VE2020'.
    APPEND it_gl.
    Second Item
    Account number
    it_gl-itemno_acc = '2'.
    it_gl-gl_account = '0014401001'.
    it_gl-item_text  = 'PRUEBA TEXTO 2'.
    it_gl-profit_ctr = 'VE2020'.
    APPEND it_gl.
    Set amount
    it_curr-itemno_acc = '1'.
    it_curr-currency = 'VEB'.
    it_curr-amt_doccur = '10'.
    APPEND it_curr.
    it_curr-itemno_acc = '2'.
    it_curr-currency = 'VEB'.
    it_curr-amt_doccur = '-10'.
    APPEND it_curr.
    check posting
    CALL FUNCTION 'BAPI_ACC_DOCUMENT_CHECK'
      EXPORTING
        documentheader = it_hdr
      TABLES
        accountgl      = it_gl
        currencyamount = it_curr
        return         = t_result.
    LOOP AT t_result WHERE ( type = 'E' OR type = 'A' ).
      EXIT.
    ENDLOOP.
    if sy-subrc ne 0.
    REFRESH t_result.
    CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
      EXPORTING
        documentheader = it_hdr
      IMPORTING
        obj_type       = obj_type
        obj_key        = obj_key
        obj_sys        = obj_sys
      TABLES
        accountgl      = it_gl
        currencyamount = it_curr
        return         = t_result.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
    COMMIT WORK.
    WRITE: obj_key.
    endif.
    I appreciated your help to solve that error.
    Regards,
    Piero Cimule.
    <b></b>

    Hi,
    Please check the changes :
    *& Report ZPBA_PC *
    REPORT zpba_pc MESSAGE-ID m3.
    DATA: obj_type LIKE bapiache09-obj_type,
    obj_key LIKE bapiache09-obj_key,
    obj_sys LIKE bapiache09-obj_sys,
    <b>l_flag type c.</b>
    DATA: it_hdr LIKE bapiache09,
    it_gl LIKE bapiacgl09 OCCURS 0 WITH HEADER LINE,
    it_curr LIKE bapiaccr09 OCCURS 0 WITH HEADER LINE,
    t_result LIKE bapiret2 OCCURS 0 WITH HEADER LINE.
    Header Data
    it_hdr-obj_type = 'BKPFF'.
    it_hdr-obj_key = '$'.
    it_hdr-obj_sys = 'LA122D'.
    it_hdr-bus_act = 'RFBU'.
    it_hdr-comp_code = 'VEZS'.
    it_hdr-fisc_year = '2004'.
    it_hdr-fis_period = '12'.
    it_hdr-doc_date = '20041218'..
    it_hdr-pstng_date = '20041218'.
    it_hdr-doc_type = 'ZI'.
    it_hdr-header_txt = 'TEXTO CAB'.
    it_hdr-username = sy-uname.
    it_hdr-compo_acc = 'GL'.
    it_hdr-ref_doc_no_long = 'REFERENCIA'.
    First Item
    Account number
    it_gl-itemno_acc = '1'.
    it_gl-gl_account = '0014401001'.
    it_gl-item_text = 'PRUEBA TEXTO 1'.
    it_gl-profit_ctr = 'VE2020'.
    APPEND it_gl.
    Second Item
    Account number
    it_gl-itemno_acc = '2'.
    it_gl-gl_account = '0014401001'.
    it_gl-item_text = 'PRUEBA TEXTO 2'.
    it_gl-profit_ctr = 'VE2020'.
    APPEND it_gl.
    Set amount
    it_curr-itemno_acc = '1'.
    it_curr-currency = 'VEB'.
    it_curr-amt_doccur = '10'.
    APPEND it_curr.
    it_curr-itemno_acc = '2'.
    it_curr-currency = 'VEB'.
    it_curr-amt_doccur = '-10'.
    APPEND it_curr.
    check posting
    CALL FUNCTION 'BAPI_ACC_DOCUMENT_CHECK'
    EXPORTING
    documentheader = it_hdr
    TABLES
    accountgl = it_gl
    currencyamount = it_curr
    return = t_result.
    LOOP AT t_result WHERE ( type = 'E' OR type = 'A' ).
    <b>l_flag = 'X'.</b>
    EXIT.
    ENDLOOP.
    <b>if l_flag is initial.</b>
    REFRESH t_result.
    CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
    EXPORTING
    documentheader = it_hdr
    IMPORTING
    obj_type = obj_type
    obj_key = obj_key
    obj_sys = obj_sys
    TABLES
    accountgl = it_gl
    currencyamount = it_curr
    return = t_result.
    <b>Clear l_flag.
    LOOP AT t_result WHERE ( type = 'E' OR type = 'A' ).
    l_flag = 'X'.
    EXIT.
    ENDLOOP.</b><b>if l_flag is initial.</b>
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
    <b>COMMIT WORK AND WAIT.</b>
    <b>endif.</b>
    WRITE: obj_key.
    endif.
    Best regards,
    Prashant

  • Error when using BAPI_ACC_DOCUMENT_POST...

    [code]
    Hello Experts,
    Iam using the said BAPI for the first time and I am not sure if I filled up the
    fields correctly. What I want to do is to post multiple debit entries(40) and a
    special G/L entry for vendor(posting key 39). I also need to generate the tax and
    withholding tax. So my entries will be like:
    40 -->amount = 1,120(This value has a VAT included which is 12% or 120)
    39 -->amount = 1,120(Special G/L for vendor)
    For these 2 entries below, they must be generated automatically.
    40 -->amount = 120(Tax)
    50 -->amount = 20(This is the EWT or withholding tax)
    Below is my code:
    wa_documentheader-obj_type = 'BKPFF'.
    CONCATENATE sy-sysid sy-mandt INTO wa_documentheader-obj_sys.
    wa_documentheader-obj_key = '$'.
      wa_documentheader-username = sy-uname.
      wa_documentheader-comp_code = '1000'.
      wa_documentheader-bus_act = 'RFBU'.
      wa_documentheader-header_txt = 'AVH Testing...'.
      wa_documentheader-fisc_year = '2007'.
      wa_documentheader-doc_date = sy-datum.
      wa_documentheader-pstng_date = sy-datum.
      wa_documentheader-fis_period = '11'.
      wa_documentheader-doc_type = 'S3'.
      CLEAR wa_accountpayable.
      wa_accountpayable-itemno_acc = 1.
      wa_accountpayable-vendor_no  = '2000000058'.
      wa_accountpayable-sp_gl_ind  = 'V'.
      wa_accountpayable-tax_code   = 'DI'.
      APPEND wa_accountpayable TO it_accountpayable.
      CLEAR: wa_accountgl.
      wa_accountgl-itemno_acc = 2.
      wa_accountgl-gl_account = '0060000061'.
      wa_accountgl-item_text = 'Aris' .
      wa_accountgl-DE_CRE_IND = 'S'.
      wa_accountgl-tax_code  = 'DI'.
      wa_accountgl-comp_code = '1000'.
      wa_accountgl-fisc_year = '2007'.
      wa_accountgl-fis_period = '11'.
      wa_accountgl-pstng_date = sy-datum.
      wa_accountgl-doc_type = 'S3'.
      INSERT wa_accountgl INTO TABLE it_accountgl.
      CLEAR wa_accounttax.
      wa_accounttax-itemno_acc = 3.
      wa_accounttax-tax_code = 'DI'.
      wa_accounttax-gl_account = '0010018291'.
      wa_accounttax-acct_key = 'VST'.
      APPEND wa_accounttax TO it_accounttax.
      CLEAR: wa_currency.
      wa_currency-itemno_acc = 1.
      wa_currency-currency = 'PHP'.
      wa_currency-curr_type = '00'.
      wa_currency-amt_doccur = 1120.
      wa_currency-amt_base = 1000.
    wa_currency-exch_rate = 1.
      APPEND wa_currency TO it_currency.
      CLEAR: wa_currency.
      wa_currency-itemno_acc = 2.
      wa_currency-currency = 'PHP'.
      wa_currency-curr_type = '00'.
      wa_currency-amt_doccur = 1120.
      wa_currency-amt_base = 1000.
    wa_currency-exch_rate = 1.
      APPEND wa_currency TO it_currency.
      CLEAR: wa_currency.
      wa_currency-itemno_acc = 3.
      wa_currency-currency = 'PHP'.
      wa_currency-curr_type = '00'.
      wa_currency-amt_doccur = 120.
    wa_currency-amt_base = 120.
    wa_currency-exch_rate = 1.
      APPEND wa_currency TO it_currency.
    Post
      CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
        EXPORTING
          documentheader = wa_documentheader
        IMPORTING
          obj_type       = obj_type
          obj_key        = obj_key
          obj_sys        = obj_sys
        TABLES
          accountgl      = it_accountgl
          currencyamount = it_currency
          return         = it_return.
      LOOP AT it_return INTO wa_return.
        WRITE : /1 wa_return-message.
      ENDLOOP.
      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
        EXPORTING
          wait   = 'X'
        IMPORTING
          return = wa_return3.
    When I checked the return table there are 2 problems that says:
    1. Error in document: BKPFF $ ED1CLNT140
    2. Balance in transaction currency
    Hope you can help me guys. Simple examples will be appreciated. Thank you and take care!
    [/code]

    <u>you can check the code.</u>
    IF NOT wa_data-lifnr  IS INITIAL.
          ADD 1 TO g_lino.
          x_vendoritem-itemno_acc        = g_lino.
          x_vendoritem-vendor_no         = wa_data-lifnr.
          IF wa_data-newbk IS INITIAL.
            x_vendoritem-comp_code = wa_data-bukrs.
          ELSE.
            x_vendoritem-comp_code = wa_data-newbk.
          ENDIF.
          x_vendoritem-comp_code         = t001-bukrs.
          x_vendoritem-item_text         = wa_data-csgtxt.
          x_vendoritem-pmnttrms          = wa_data-pyterm.
          x_vendoritem-bline_date        = wa_data-bldate.
          x_vendoritem-pymt_meth         = wa_data-zlsch.
          x_vendoritem-alloc_nmbr        = wa_data-zuonr.
          x_vendoritem-tax_code          = wa_data-mwskz.
          x_vendoritem-taxjurcode        = wa_data-txjcd.
          APPEND x_vendoritem TO it_vendoritem.
          x_currencyamount-itemno_acc    = g_lino.
          x_currencyamount-curr_type     = c_ct1.
          x_currencyamount-currency      = t001-waers.
          x_currencyamount-amt_doccur    = wa_data-cwrbtr.
          APPEND x_currencyamount TO it_currencyamount.
          x_currencyamount-curr_type     = c_ct2.
          APPEND x_currencyamount TO it_currencyamount.
          IF t001-land1 = c_lnd.
            x_currencyamount-curr_type   = c_ct3.
            APPEND x_currencyamount TO it_currencyamount.
          ENDIF.
        ENDIF.
        IF NOT wa_data-dsaknr IS INITIAL.
          CLEAR:
            x_accountgl,
            x_currencyamount,
            x_vendoritem.
          ADD 1 TO g_lino.
          x_accountgl-itemno_acc         = g_lino.
          x_accountgl-doc_type           = x_doc_hdr-doc_type.
          IF wa_data-newbk IS INITIAL.
            x_accountgl-comp_code = wa_data-bukrs.
          ELSE.
            x_accountgl-comp_code = wa_data-newbk.
          ENDIF.
          x_accountgl-gl_account         = wa_data-dsaknr.
          x_accountgl-costcenter         = wa_data-dkostl.
          x_accountgl-item_text          = wa_data-dsgtxt.
          x_accountgl-orderid            = wa_data-daufnr.
          x_accountgl-wbs_element        = wa_data-dwbs.
          x_accountgl-pstng_date         = p_pdate.
          x_accountgl-vendor_no          = wa_data-lifnr .
          x_accountgl-alloc_nmbr         = wa_data-zuonr.
          x_accountgl-tax_code           = wa_data-mwskz.
          x_accountgl-taxjurcode         = wa_data-txjcd.
          APPEND x_accountgl TO it_accountgl.
          x_currencyamount-itemno_acc    = g_lino.
          x_currencyamount-curr_type     = c_ct1.
          x_currencyamount-currency      = t001-waers.
          x_currencyamount-amt_doccur    = - wa_data-dwrbtr.
          APPEND x_currencyamount TO it_currencyamount.
          x_currencyamount-curr_type     = c_ct2.
          APPEND x_currencyamount TO it_currencyamount.
          IF t001-land1 = c_lnd.
            x_currencyamount-curr_type     = c_ct3.
            APPEND x_currencyamount TO it_currencyamount.
          ENDIF.
        ENDIF.
    CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'                   
        EXPORTING
          documentheader = x_doc_hdr
        TABLES
          accountgl      = it_accountgl
          accountpayable = it_vendoritem
          currencyamount = it_currencyamount
          return         = it_return.
      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
    Reward if helpful.

  • Error on bapi_acc_document_post

    Hi experts,
         when i executing this bapi_acc_document_post, am getting error  " FI/CO interface: Line item entered several times"  i mention code below  so please give me suggestion.
    *& Report  ZSAMPLE
    REPORT  ZSAMPLE.
    data: BEGIN OF WA_HEADER,
            ID TYPE I,
            KUNNR TYPE n LENGTH 10,
            INV_DATE TYPE c LENGTH 10,
            PST_DATE TYPE c LENGTH 10,
            REF TYPE invfo-xblnr,
            AMT_DOCCUR TYPE PA2010-BETRG,
            TXT(40),
       END OF WA_HEADER.
    DATA : IT_HEADER like WA_HEADER OCCURS 0  WITH HEADER LINE.
    data: BEGIN OF WA_ITEM,
            ID TYPE I,
            GL_ACCOUNT TYPE n LENGTH 10,
            ITEM_TEXT TYPE BAPIACGL09-ITEM_TEXT,
            BUS_AREA  TYPE BAPIACGL09-BUS_AREA,
            AMT_DOCCUR TYPE BAPIACCR09-AMT_DOCCUR,
            KOSTL TYPE CSKT-KOSTL,
    *       VAT(2),
       END OF WA_ITEM.
    DATA : IT_ITEM like WA_ITEM OCCURS 0  WITH HEADER LINE.
    *      value of excel-cell
    TYPES: ty_d_itabvalue             TYPE alsmex_tabline-value,
    *      internal table containing the excel data
            ty_t_itab                  TYPE alsmex_tabline   OCCURS 0,
    *      line type of sender table
            BEGIN OF ty_s_senderline,
              line(4096)               TYPE c,
            END OF ty_s_senderline,
    *      sender table
            ty_t_sender                TYPE ty_s_senderline  OCCURS 0.
    CONSTANTS:  gc_esc              VALUE '"'.
    DATA  temp_row TYPE I.
    DATA  TEMP(4).
    INCLUDE lalsmexf01.
    DATA: it_data1 TYPE ty_t_itab.
    DATA: it_data2 TYPE ty_t_itab.
    DATA: it_data_wa LIKE LINE OF it_data1.
    DATA: it_data_wa2 LIKE LINE OF it_data1.
    * DATA DECLARATION
    data: st_rw_s1 TYPE i VALUE '2'.
    data: st_cl_s1 TYPE i VALUE '1'.
    data: st_rw_s2 TYPE i VALUE '2'.
    data: st_cl_s2 TYPE i VALUE '1'.
    data: ed_rw_s1 TYPE i VALUE '3'.
    data: ed_cl_s1 TYPE i VALUE '7'.
    data: ed_rw_s2 TYPE i VALUE '5'.
    data: ed_cl_s2 TYPE i VALUE '8'.
    DATA: excel_tab TYPE ty_t_sender,
    excel_tab1 TYPE ty_t_sender.
    DATA: ld_separator TYPE c.
    DATA: application TYPE ole2_object,
    workbook TYPE ole2_object,
    sheet TYPE ole2_object,
    range TYPE ole2_object,
    worksheet TYPE ole2_object.
    DATA: h_cell TYPE ole2_object,
    h_cell1 TYPE ole2_object.
    DATA: ld_rc TYPE i.
    TYPE-POOLS ole2.
    *AT SELECTION-SCREEN.
       PARAMETERS: filename LIKE rlgrap-filename.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR filename.
       PERFORM value_help.
    sTART-OF-SELECTION.
    *  CASE sy-ucomm .
    *    WHEN 'ONLI'.
           PERFORM execute.
           PERFORM bapi.
    *  ENDCASE.
    * MESSAGE DEFINATION
       DEFINE m_message.
         case sy-subrc.
           when 0.
           when 1.
             message id sy-msgid type sy-msgty number sy-msgno
             with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
           when others. raise upload_ole.
         endcase.
       END-OF-DEFINITION.
    *&      Form  VALUE_HELP
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM VALUE_HELP .
       CALL FUNCTION 'DSVAS_DOC_WS_FILENAME_GET_50'
         EXPORTING
           def_filename     = ' '
           def_path         = ' '
           mask             = ',*.*,*.*.'
           mode             = 'O'
           title            = ' '
         IMPORTING
           filename         = filename
         EXCEPTIONS
           inv_winsys       = 1
           no_batch         = 2
           selection_cancel = 3
           selection_error  = 4
           OTHERS           = 5.
       IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
       ENDIF.
    ENDFORM.                    " VALUE_HELP
    *&      Form  EXECUTE
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM EXECUTE .
    * PARAMETER CHECK
       IF st_rw_s1 > ed_rw_s1.
         RAISE inconsistent_parameters.
       ENDIF.
       IF st_cl_s1 > ed_cl_s1.
         RAISE inconsistent_parameters.
       ENDIF.
       IF st_rw_s2 > ed_rw_s2.
         RAISE inconsistent_parameters.
       ENDIF.
       IF st_cl_s2 > ed_cl_s2.
         RAISE inconsistent_parameters.
       ENDIF.
       CLASS cl_abap_char_utilities DEFINITION LOAD.
       ld_separator = cl_abap_char_utilities=>horizontal_tab.
    * OPENING EXCEL FILE
       IF application-header = space OR application-handle = -1.
         CREATE OBJECT application 'Excel.Application'.
         m_message.
       ENDIF.
       CALL METHOD OF
           application
           'Workbooks' = workbook.
       m_message.
       CALL METHOD OF
           application
           'Workbooks' = workbook.
       m_message.
       CALL METHOD OF
           workbook
           'Open'
         EXPORTING
           #1       = filename.
       m_message.
       CALL METHOD OF
           application
           'Worksheets' = sheet
         EXPORTING
           #1           = 1.
       m_message.
       CALL METHOD OF
           application
           'Worksheets' = sheet
         EXPORTING
           #1           = 1.
       m_message.
       CALL METHOD OF
           sheet
           'Activate'.
       m_message.
       GET PROPERTY OF application 'ACTIVESHEET' = sheet.
       m_message.
    * MARKING OF WHOLE SPREADSHEET
       CALL METHOD OF
           sheet
           'Cells' = h_cell
         EXPORTING
           #1      = st_rw_s1
           #2      = st_cl_s1.
       m_message.
       CALL METHOD OF
           sheet
           'Cells' = h_cell1
         EXPORTING
           #1      = ed_rw_s1
           #2      = ed_cl_s1.
       m_message.
       CALL METHOD OF
           sheet
           'RANGE' = range
         EXPORTING
           #1      = h_cell
           #2      = h_cell1.
       m_message.
       CALL METHOD OF
           range
           'SELECT'.
       m_message.
    * Copy marked area (SHEET1) into Clippboard
       CALL METHOD OF
           range
           'COPY'.
       m_message.
    * Read clipboard into ABAP
       CALL METHOD cl_gui_frontend_services=>clipboard_import
         IMPORTING
           data                 = excel_tab
         EXCEPTIONS
           cntl_error           = 1
    *     ERROR_NO_GUI         = 2
    *     NOT_SUPPORTED_BY_GUI = 3
           OTHERS               = 4.
       IF sy-subrc <> 0.
         MESSAGE a037(alsmex).
       ENDIF.
       PERFORM separated_to_intern_convert TABLES excel_tab it_data1
       USING ld_separator.
    * Clear the clipboard
       REFRESH excel_tab.
       CALL METHOD cl_gui_frontend_services=>clipboard_export
         IMPORTING
           data                 = excel_tab
         CHANGING
           rc                   = ld_rc
         EXCEPTIONS
           cntl_error           = 1
    *     ERROR_NO_GUI         = 2
    *     NOT_SUPPORTED_BY_GUI = 3
           OTHERS               = 4.
    * Working in Second Excel Work Sheet
       CALL METHOD OF
           application
           'Worksheets' = sheet
         EXPORTING
           #1           = 2.
       m_message.
       CALL METHOD OF
           sheet
           'Activate'.
       m_message.
       GET PROPERTY OF application 'ACTIVESHEET' = sheet.
       m_message.
    * Mark Sheet2
       CALL METHOD OF
           sheet
           'Cells' = h_cell
         EXPORTING
           #1      = st_rw_s2
           #2      = st_cl_s2.
       m_message.
       CALL METHOD OF
           sheet
           'Cells' = h_cell1
         EXPORTING
           #1      = ed_rw_s2
           #2      = ed_cl_s2.
       m_message.
       CALL METHOD OF
           sheet
           'RANGE' = range
         EXPORTING
           #1      = h_cell
           #2      = h_cell1.
       m_message.
       CALL METHOD OF
           range
           'SELECT'.
       m_message.
    * Copy Marked Area (Sheet2) into Clippboard
       CALL METHOD OF
           range
           'COPY'.
       m_message.
    * Read Clipboard into ABAP
       CALL METHOD cl_gui_frontend_services=>clipboard_import
         IMPORTING
           data                 = excel_tab1
         EXCEPTIONS
           cntl_error           = 1
    *     ERROR_NO_GUI         = 2
    *     NOT_SUPPORTED_BY_GUI = 3
           OTHERS               = 4.
       IF sy-subrc <> 0.
         MESSAGE a037(alsmex).
       ENDIF.
       PERFORM separated_to_intern_convert TABLES excel_tab1 it_data2
       USING ld_separator.
    * Clear Clipboard
       REFRESH excel_tab.
       CALL METHOD cl_gui_frontend_services=>clipboard_export
       IMPORTING
       data = excel_tab1
       CHANGING
       rc = ld_rc
       EXCEPTIONS
       cntl_error = 1
    * ERROR_NO_GUI = 2
    * NOT_SUPPORTED_BY_GUI = 3
       OTHERS = 4
    * Leaving Application
       CALL METHOD OF
           application
           'QUIT'.
       m_message.
       FREE OBJECT application.
       m_message.
       LOOP AT it_data1 INTO it_data_wa2.
         IF temp_row ne it_data_wa2-ROW AND temp_row IS NOT INITIAL.
           temp_row = it_data_wa2-ROW.
           APPEND IT_HEADER.
         ELSE.
           temp_row = it_data_wa2-ROW.
         ENDIF.
         CASE it_data_wa2-COL.
           WHEN '0001'.
             IT_HEADER-ID = it_data_wa2-VALUE.
           WHEN '0002'.
             IT_HEADER-KUNNR = it_data_wa2-VALUE.
           WHEN '0003'.
             IT_HEADER-INV_DATE = it_data_wa2-value.
           WHEN '0004'.
             IT_HEADER-PST_DATE = it_data_wa2-VALUE.
           WHEN '0005'.
             IT_HEADER-REF = it_data_wa2-VALUE.
           WHEN '0006'.
             IT_HEADER-AMT_DOCCUR = it_data_wa2-VALUE.
           WHEN '0007'.
             IT_HEADER-TXT = it_data_wa2-VALUE.
         ENDCASE.
       ENDLOOP.
       APPEND IT_HEADER.
       CLEAR:temp_row.
       LOOP AT it_data2 INTO it_data_wa ."WHERE ROW = it_data_wa2-ROW.
         IF temp_row ne it_data_wa-ROW AND temp_row IS NOT INITIAL.
           temp_row = it_data_wa-ROW.
           APPEND IT_ITEM.
         ELSEIF ( temp_row NE it_data_wa-ROW AND temp_row IS  INITIAL ).
           temp_row = it_data_wa-ROW.
    *           ELSE
         ENDIF.
         CASE it_data_wa-COL.
           WHEN '0001'.
             IT_ITEM-ID = it_data_wa-VALUE.
           WHEN '0002'.
             IT_ITEM-GL_ACCOUNT = it_data_wa-VALUE.
           WHEN '0003'.
             IT_ITEM-AMT_DOCCUR = it_data_wa-value.
           WHEN '0004'.
             IT_ITEM-ITEM_TEXT = it_data_wa-VALUE.
           WHEN '0005'.
             IT_ITEM-BUS_AREA = it_data_wa-VALUE.
           WHEN '0006'.
             IT_ITEM-KOSTL = it_data_wa-VALUE.
    *      WHEN '0007'.
    *        IT_ITEM-VAT = it_data_wa-VALUE.
         ENDCASE.
       ENDLOOP.
       APPEND IT_ITEM.
    ENDFORM.                    " EXECUTE
    *ENDLOOP.
    *&      Form  BAPI
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM BAPI .
       DATA: it_acc_gl LIKE bapiacgl09 OCCURS 0 WITH HEADER LINE,
      it_acc_ap LIKE bapiacap09 OCCURS 0 WITH HEADER LINE,
      it_acc_aR LIKE bapiacaR09 OCCURS 0 WITH HEADER LINE,
      it_return LIKE bapiret2 OCCURS 0 WITH HEADER LINE,
      it_curr_amt LIKE bapiaccr09 OCCURS 0 WITH HEADER LINE,
      it_doc_header LIKE bapiache09 OCCURS 0 WITH HEADER LINE,
      it_acc_tax LIKE bapiactx09 OCCURS 0 WITH HEADER LINE,
      obj_type LIKE bapiache09-obj_type,
      obj_key LIKE bapiache09-obj_key,
      obj_sys LIKE bapiache09-obj_sys,
      pstng_date LIKE it_doc_header-pstng_date,
      doc_date LIKE it_doc_header-doc_date,
      loop_cnt TYPE i VALUE 0,
      gv_vendor(10) TYPE c,
      gv_gl_acc(10) TYPE c.
       DATA  conv_s_amt TYPE BETRG.
       DATA  cur_line TYPE P.
       data item_no type POSNR_ACC.
       data item_no1 type POSNR_ACC.
       CLEAR: obj_type, obj_sys, obj_key, pstng_date, doc_date, gv_vendor, gv_gl_acc.
    *  CLEAR: it_doc_header,it_acc_gl,it_curr_amt,IT_ACC_AR,IT_RETURN.
       LOOP AT it_HEADER INTO WA_HEADER .
         REFRESH it_doc_header.
         it_doc_header-bus_act = 'RFBU'.
         it_doc_header-username = sy-uname.
    *   it_doc_header = WA_HEADER-KUNNR." Customer Number
         it_doc_header-header_txt = WA_HEADER-TXT." bdc_source-col_h. " Invoice Text
         it_doc_header-comp_code = 'JPOL'."bdc_source-col_a. " Company Code
         CONCATENATE WA_HEADER-INV_DATE+6(4) WA_HEADER-INV_DATE+3(2) WA_HEADER-INV_DATE(2)
         into it_doc_header-doc_date.
         CONCATENATE WA_HEADER-pst_date+6(4) WA_HEADER-pst_date+3(2) WA_HEADER-pst_date(2)
          into it_doc_header-pstng_date.
         it_doc_header-doc_type = 'DR'. " Return Order...?
         it_doc_header-fisc_year = '2013'. " Return Order...?
         it_doc_header-fis_period = '02'. " Return Order...?
         it_doc_header-ref_doc_no = '123'."bdc_source-col_d. " Invoice Number
         APPEND it_doc_header.
         REFRESH it_acc_aR.
         it_acc_aR-itemno_acc = '1'. " Invoice Number
         it_acc_aR-customer = WA_HEADER-KUNNR. " Customer Number
         it_acc_aR-comp_code = 'JPOL'. " Company Code
         it_acc_aR-item_text = WA_HEADER-txt. " Line Item Text
         APPEND it_acc_aR.
    *    it_acc_aR-itemno_acc = '4'. " Invoice Number
    *    it_acc_aR-customer = WA_HEADER-KUNNR. " Customer Number
    *    it_acc_aR-comp_code = 'JPOL'. " Company Code
    *    it_acc_aR-item_text = WA_HEADER-txt. " Line Item Text
    *    APPEND it_acc_aR.
         REFRESH it_acc_gl.
         REFRESH IT_CURR_AMT.
    *    ITEM_NO = 1.
         "GL Information details collected
    CLEAR : ITEM_NO,item_no1.
         LOOP AT it_ITEM INTO WA_ITEM where id = wa_header-ID.
           ITEM_NO = ITEM_NO + 1.
           it_acc_gl-itemno_acc = ITEM_NO.
           it_acc_gl-gl_account = WA_ITEM-GL_ACCOUNT."gv_gl_acc. " GL Account
           it_acc_gl-item_text = WA_ITEM-ITEM_TEXT. "bdc_source-col_o. " Line Item Text
           it_acc_gl-doc_type = 'DR'. " Return Order...?
           it_acc_gl-comp_code = 'JPOL'."bdc_source-col_a. " Company Code
           it_acc_gl-bus_area = WA_ITEM-BUS_AREA."bdc_source-col_a. " Company Code
           it_acc_gl-CUSTOMER = WA_HEADER-KUNNR.
           conv_s_amt = WA_ITEM-AMT_DOCCUR."bdc_source-col_f. " Invoice Amount
           IF conv_s_amt < 0.
             it_acc_gl-de_cre_ind = 'H'. " H-Credit
             conv_s_amt = - conv_s_amt.
           ELSE.
             it_acc_gl-de_cre_ind = 'S'. " S-Debit
           ENDIF.
           APPEND it_acc_gl.
           ITEM_NO1 = ITEM_NO1 + 1.
           it_curr_amt-itemno_acc =  ITEM_NO1 . " Invoice Number
           it_curr_amt-curr_type = '00'.
           it_curr_amt-currency = 'INR'. " Currancy
           it_curr_amt-amt_doccur = conv_s_amt . " Line Item Amount
           APPEND it_curr_amt.
           ITEM_NO1 = ITEM_NO1 + 1.
           it_curr_amt-itemno_acc =  ITEM_NO1 . " Invoice Number
           it_curr_amt-curr_type = '00'.
           it_curr_amt-currency = 'INR'. " Currancy
           it_curr_amt-amt_doccur = conv_s_amt * -1. " Line Item Amount
                  APPEND it_curr_amt.
         ENDLOOP.
         REFRESH it_return.
         "Customer Invoice
    * Do the post to GL Account and AP
         CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
           EXPORTING
             documentheader    = it_doc_header
           IMPORTING
             obj_type          = obj_type
             obj_key           = obj_key
             obj_sys           = obj_sys
           TABLES
             accountgl         = it_acc_gl
             currencyamount    = it_curr_amt
             accountreceivable = it_acc_aR
             return            = it_return.
         CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
           EXPORTING
             wait = 'X'.
    * Check for any errors
         WRITE : obj_key.
         LOOP at IT_RETURN WHERE TYPE = 'E'.
           WRITE : / 'Error :', IT_RETURN-MESSAGE .
         endloop.
       ENDLOOP.
    ENDFORM.                    " BAPI
    Result:

    Hi
    Thank you for your help i did small modification i mention code below
    REPORT  ZCUS_INVOICE.
    data: BEGIN OF WA_HEADER,
    ID TYPE I,
    KUNNR TYPE n LENGTH 10,
    INV_DATE TYPE c LENGTH 10,
    PST_DATE TYPE c LENGTH 10,
    REF TYPE invfo-xblnr,
    PRD_TEXT TYPE BAPIACGL09-ITEM_TEXT,
    CMP_CODE TYPE BAPIACGL09-COMP_CODE,
    AMT_DOCCUR TYPE PA2010-BETRG,
    TXT(40),
    END OF WA_HEADER.
    DATA : IT_HEADER like WA_HEADER OCCURS 0  WITH HEADER LINE.
    data: BEGIN OF WA_ITEM,
    ID TYPE I,
    GL_ACCOUNT TYPE n LENGTH 10,
    ITEM_TEXT TYPE BAPIACGL09-ITEM_TEXT,
    BUS_AREA  TYPE BAPIACGL09-BUS_AREA,
    AMT_DOCCUR TYPE BAPIACCR09-AMT_DOCCUR,
    KOSTL TYPE CSKT-KOSTL,
    *       VAT(2),
    END OF WA_ITEM.
    DATA : IT_ITEM like WA_ITEM OCCURS 0  WITH HEADER LINE.
    *      value of excel-cell
    TYPES: ty_d_itabvalue             TYPE alsmex_tabline-value,
    *      internal table containing the excel data
    ty_t_itab                  TYPE alsmex_tabline   OCCURS 0,
    *      line type of sender table
    BEGIN OF ty_s_senderline,
    line(4096)               TYPE c,
    END OF ty_s_senderline,
    *      sender table
    ty_t_sender                TYPE ty_s_senderline  OCCURS 0.
    CONSTANTS:  gc_esc              VALUE '"'.
    DATA  temp_row TYPE I.
    DATA  TEMP(4).
    INCLUDE lalsmexf01.
    DATA: it_data1 TYPE ty_t_itab.
    DATA: it_data2 TYPE ty_t_itab.
    DATA: it_data_wa LIKE LINE OF it_data1.
    DATA: it_data_wa2 LIKE LINE OF it_data1.
    * DATA DECLARATION
    data: st_rw_s1 TYPE i value '2'.
    data: st_cl_s1 TYPE i value '1'.
    data: st_rw_s2 TYPE i value '2'.
    data: st_cl_s2 TYPE i value '1'.
    data: ed_rw_s1 TYPE i value '50'.
    data: ed_cl_s1 TYPE i value '9'.
    data: ed_rw_s2 TYPE i value '50'.
    data: ed_cl_s2 TYPE i value '6'.
    DATA: excel_tab TYPE ty_t_sender,
    excel_tab1 TYPE ty_t_sender.
    DATA: ld_separator TYPE c.
    DATA: application TYPE ole2_object,
    workbook TYPE ole2_object,
    sheet TYPE ole2_object,
    range TYPE ole2_object,
    worksheet TYPE ole2_object.
    DATA: h_cell TYPE ole2_object,
    h_cell1 TYPE ole2_object.
    DATA: ld_rc TYPE i.
    TYPE-POOLS ole2.
    *AT SELECTION-SCREEN.
    PARAMETERS: filename LIKE rlgrap-filename.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR filename.
    PERFORM value_help.
    sTART-OF-SELECTION.
    *  CASE sy-ucomm .
    *    WHEN 'ONLI'.
    PERFORM execute.
    PERFORM bapi.
    *  ENDCASE.
    * MESSAGE DEFINATION
    DEFINE m_message.
    case sy-subrc.
    when 0.
    when 1.
    message id sy-msgid type sy-msgty number sy-msgno
    with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    when others. raise upload_ole.
    endcase.
    END-OF-DEFINITION.
    *&      Form  VALUE_HELP
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM VALUE_HELP .
    CALL FUNCTION 'DSVAS_DOC_WS_FILENAME_GET_50'
    EXPORTING
    def_filename     = ' '
    def_path         = ' '
    mask             = ',*.*,*.*.'
    mode             = 'O'
    title            = ' '
    IMPORTING
    filename         = filename
    EXCEPTIONS
    inv_winsys       = 1
    no_batch         = 2
    selection_cancel = 3
    selection_error  = 4
    OTHERS           = 5.
    IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    ENDFORM.                    " VALUE_HELP
    *&      Form  EXECUTE
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM EXECUTE .
    * PARAMETER CHECK
    IF st_rw_s1 > ed_rw_s1.
    RAISE inconsistent_parameters.
    ENDIF.
    IF st_cl_s1 > ed_cl_s1.
    RAISE inconsistent_parameters.
    ENDIF.
    IF st_rw_s2 > ed_rw_s2.
    RAISE inconsistent_parameters.
    ENDIF.
    IF st_cl_s2 > ed_cl_s2.
    RAISE inconsistent_parameters.
    ENDIF.
    CLASS cl_abap_char_utilities DEFINITION LOAD.
    ld_separator = cl_abap_char_utilities=>horizontal_tab.
    * OPENING EXCEL FILE
    IF application-header = space OR application-handle = -1.
    CREATE OBJECT application 'Excel.Application'.
    m_message.
    ENDIF.
    CALL METHOD OF
    application
    'Workbooks' = workbook.
    m_message.
    CALL METHOD OF
    application
    'Workbooks' = workbook.
    m_message.
    CALL METHOD OF
    workbook
    'Open'
    EXPORTING
    #1       = filename.
    m_message.
    CALL METHOD OF
    application
    'Worksheets' = sheet
    EXPORTING
    #1           = 1.
    m_message.
    CALL METHOD OF
    application
    'Worksheets' = sheet
    EXPORTING
    #1           = 1.
    m_message.
    CALL METHOD OF
    sheet
    'Activate'.
    m_message.
    GET PROPERTY OF application 'ACTIVESHEET' = sheet.
    m_message.
    * MARKING OF WHOLE SPREADSHEET
    CALL METHOD OF
    sheet
    'Cells' = h_cell
    EXPORTING
    #1      = st_rw_s1
    #2      = st_cl_s1.
    m_message.
    CALL METHOD OF
    sheet
    'Cells' = h_cell1
    EXPORTING
    #1      = ed_rw_s1
    #2      = ed_cl_s1.
    m_message.
    CALL METHOD OF
    sheet
    'RANGE' = range
    EXPORTING
    #1      = h_cell
    #2      = h_cell1.
    m_message.
    CALL METHOD OF
    range
    'SELECT'.
    m_message.
    * Copy marked area (SHEET1) into Clippboard
    CALL METHOD OF
    range
    'COPY'.
    m_message.
    * Read clipboard into ABAP
    CALL METHOD cl_gui_frontend_services=>clipboard_import
    IMPORTING
    data                 = excel_tab
    EXCEPTIONS
    cntl_error           = 1
    *     ERROR_NO_GUI         = 2
    *     NOT_SUPPORTED_BY_GUI = 3
    OTHERS               = 4.
    IF sy-subrc <> 0.
    MESSAGE a037(alsmex).
    ENDIF.
    PERFORM separated_to_intern_convert TABLES excel_tab it_data1
    USING ld_separator.
    * Clear the clipboard
    REFRESH excel_tab.
    CALL METHOD cl_gui_frontend_services=>clipboard_export
    IMPORTING
    data                 = excel_tab
    CHANGING
    rc                   = ld_rc
    EXCEPTIONS
    cntl_error           = 1
    *     ERROR_NO_GUI         = 2
    *     NOT_SUPPORTED_BY_GUI = 3
    OTHERS               = 4.
    * Working in Second Excel Work Sheet
    CALL METHOD OF
    application
    'Worksheets' = sheet
    EXPORTING
    #1           = 2.
    m_message.
    CALL METHOD OF
    sheet
    'Activate'.
    m_message.
    GET PROPERTY OF application 'ACTIVESHEET' = sheet.
    m_message.
    * Mark Sheet2
    CALL METHOD OF
    sheet
    'Cells' = h_cell
    EXPORTING
    #1      = st_rw_s2
    #2     

  • How to send Sales Document Number and Item to BAPI_ACC_DOCUMENT_POST?

    Hello SAPients,
    We are using BAPI_ACC_DOCUMENT_POST to create an accounting document similar to what FB01 does, in FB01 you can type the number and position of a Sales Document even if you are using an Account Receivable account number. But in the BAPI, the  ACCOUNTRECEIVABLE table doesn't have a field to include those numbers. How should I pass the sales order number and item to the BAPI? I have tried several things but every time I receive more complicated error messages.
    Thank you in advance for your kind help.

    Let me know if you have any questions:
    Loop through your records and fill in the appropriate structure based on record type (GL, Vendor or Customer)
    IF NOT pcard_post_rec-zlsapac IS INITIAL.
        gt_gl_item-itemno_acc   = ls_posnr.
        gt_gl_item-gl_account = pcard_post_rec-zlsapac.
        gt_gl_item-comp_code = pcard_post_rec-zlsapco.
        "gt_gl_item-pstng_date = pcard_post_rec-zlgpsdt.
        gt_gl_item-pstng_date = gv_posting_date.
        gt_gl_item-doc_type = doctype.
        gt_gl_item-alloc_nmbr = ls_assignment.
        gt_gl_item-ref_key_3 = pcard_post_rec-zlgvend.
        IF pcard_post_rec-zlsapac < 500000.
          gt_gl_item-item_text    = ''.
        ELSE.
          gt_gl_item-item_text    = pcard_post_rec-zlguser.
        ENDIF.
        gt_gl_item-costcenter = pcard_post_rec-zlsapcc.
        gt_gl_item-orderid = lv_ordnum.
        APPEND gt_gl_item.
      ELSEIF NOT pcard_post_rec-zlsapven IS INITIAL.
        gt_ap_item-itemno_acc = ls_posnr.
        gt_ap_item-vendor_no = pcard_post_rec-zlsapven.
        gt_ap_item-comp_code = pcard_post_rec-zlsapco.
        gt_ap_item-alloc_nmbr = ls_assignment.
        gt_ap_item-ref_key_3 = pcard_post_rec-zlgvend.
        IF pcard_post_rec-zlsapac < 500000.
          gt_ap_item-item_text = ''.
        ELSE.
          gt_ap_item-item_text    = pcard_post_rec-zlguser.
        ENDIF.
        APPEND gt_ap_item.
      ELSEIF NOT pcard_post_rec-zlsapcus IS INITIAL.
        gt_ar_item-itemno_acc = ls_posnr.
        gt_ar_item-customer = pcard_post_rec-zlsapcus.
        gt_ar_item-comp_code = pcard_post_rec-zlsapco.
        gt_ar_item-alloc_nmbr = ls_assignment.
        gt_ar_item-ref_key_3 = pcard_post_rec-zlgvend.
        IF pcard_post_rec-zlsapac < 500000.
          gt_ar_item-item_text = ''.
        ELSE.
          gt_ar_item-item_text    = pcard_post_rec-zlguser.
        ENDIF.
        APPEND gt_ar_item.
      ENDIF.

  • Posting period problem in BAPI_ACC_DOCUMENT_POST

    I am using BAPI_ACC_DOCUMENT_POST to post documents for AR.It works fine in all the scenarios except when 2 posting periods are open.The previous posting period is open till 1st week of next month.I want to post in the 1st week for the previous posting period.I get the error
    period 05 is not allowed.Is there any value i need to pass
    to the function module.Please help.The normal fb01 does post to the previous period.

    Hi,
    BAPI will return if period is not open like this.
    'perios 04 2006 is not open for posting'.
    but your error message is period 05 is not allowed. please check the date that you are passing and check the year that you are passing to it.
    If not get period and year using the FM 'FI_PERIOD_DETERMINE' and pass this year and period to it.
    Thanks.

  • Error getting while using BAPI "BAPI_ACC_DOCUMENT_POST" in the Web Dynpro

    Hello Everyone,
    I am trying to use BAPI_ACC_DOCUMENT_POST to post a docuemnt, for this I have created a web application and in that I have created one view. In the layout of the view I have developed three groups 1. document header 2.Currency 3. GL account. for user inputs and at the root node i have created a button and on the action f the button I am calling the BAPI but when i tested it I am getting the following error:
    The following error text was processed in the system RS2 : Adapter error in INPUT_FIELD "GROUP_2_ITEMNO_ACC" of view "ZTEST_RAGI_INVOICE_POST.MAIN": Context binding of property VALUE cannot be resolved: Node MAIN.1.CURRENCYAMOUNT does not contain any elements .
    Can you please help me in this.
    Thanks,
    Rajat

    helll rajat ,
    The following error text was processed in the system RS2 : Adapter error in INPUT_FIELD "GROUP_2_ITEMNO_ACC" of view "ZTEST_RAGI_INVOICE_POST.MAIN": Context binding of property VALUE cannot be resolved: Node MAIN.1.CURRENCYAMOUNT does not contain any elements .
    ---> pass amount to that currency table.
    regards
    Prabhu

  • Issue with posting G/L using the BAPI " BAPI_ACC_DOCUMENT_POST"

    Hi all,
    I am trying to create a G/L document using the BAPI "BAPI_ACC_DOCUMENT_POST". The Bapi is returning me a success message, but i am not able to see the document in BKPF/BSEG.
    Can somebody please let me know if there is any customization that needs to be done to get the document number reflected in the corresponding tables after i execute this BAPI.
    Here is the part of the code that i am using to fill the header structure:
      docheader-obj_type = 'REACI'.
        docheader-obj_key = 'TEST'.
        docheader-obj_sys = 'ECSCLNT010'.
        docheader-bus_act = 'RFBU'.
        docheader-username = sy-uname.
        docheader-header_txt = 'HDR TEXT'.
        docheader-comp_code = 'SC01'.
        docheader-doc_date = sy-datum.
        docheader-pstng_date = sy-datum.
        CASE wa_input_tmp-batch_type .
          WHEN '0'.
            docheader-doc_type = 'SA'.
          WHEN '1'.
            docheader-doc_type = 'RA'.
        ENDCASE.
    Any help is much appreciated.
    Thanks in Advance,
    Suresh

    See the below code :
    I have tested program in my system :
    *&---HEADER DECLARATION
    DATA: HEADER TYPE BAPIACHE09.                " HEADER DATA
                 INTERNAL TABLE DECLARATION
    *&----G/L ACCOUNT ITEM
    DATA: ACCOUNTGL TYPE STANDARD TABLE OF BAPIACGL09.
    *&---CURRENCY ITEMS
    DATA: CURRENCY_AMOUNT TYPE STANDARD TABLE OF BAPIACCR09.
    *&----RETURN PARAMETER
    DATA: RETURN  TYPE STANDARD TABLE OF BAPIRET2 with header line.
                         WORK-AREA DECLARATION
    *&----WORKAREA FOR G/L ACCOUNT ITEM
    DATA: WA_ACCOUNTGL TYPE BAPIACGL09.
    *&---WORKAREA FOR CURRENCY ITEMS
    DATA: WA_CURRENCY_AMOUNT TYPE BAPIACCR09.
                        INITIALIZATION
    HEADER-HEADER_TXT  = 'TEST HEADER'.
    HEADER-USERNAME    = 'DEVELOPER'.
    HEADER-COMP_CODE   = '0002'.
    HEADER-FISC_YEAR   = '2007'.
    HEADER-DOC_DATE    = '20070502'.
    HEADER-PSTNG_DATE  = '20070502'.
    HEADER-TRANS_DATE  = '20070502'.
    HEADER-DOC_TYPE    = 'SA'.
    HEADER-BUS_ACT     = 'RFBU'.
    WA_ACCOUNTGL-ITEMNO_ACC  = '0000000010'.
    WA_ACCOUNTGL-GL_ACCOUNT = '0000113020'.
    WA_ACCOUNTGL-ITEM_TEXT  = 'SO_DOC'.
    WA_ACCOUNTGL-DE_CRE_IND = 'S'.
    APPEND WA_ACCOUNTGL TO ACCOUNTGL.
    CLEAR WA_ACCOUNTGL.
    WA_ACCOUNTGL-ITEMNO_ACC  = '0000000020'.
    WA_ACCOUNTGL-GL_ACCOUNT = '0000113020'.
    WA_ACCOUNTGL-ITEM_TEXT  = 'SO_DOC'.
    WA_ACCOUNTGL-DE_CRE_IND = 'H'.
    APPEND WA_ACCOUNTGL TO ACCOUNTGL.
    CLEAR WA_ACCOUNTGL.
    WA_CURRENCY_AMOUNT-ITEMNO_ACC = '0000000010'.
    WA_CURRENCY_AMOUNT-AMT_DOCCUR = '500'.
    WA_CURRENCY_AMOUNT-CURRENCY   = 'INR'.
    APPEND WA_CURRENCY_AMOUNT TO CURRENCY_AMOUNT.
    CLEAR WA_CURRENCY_AMOUNT.
    WA_CURRENCY_AMOUNT-ITEMNO_ACC = '0000000020'.
    WA_CURRENCY_AMOUNT-AMT_DOCCUR = '-500'.
    WA_CURRENCY_AMOUNT-CURRENCY   = 'INR'.
    APPEND WA_CURRENCY_AMOUNT TO CURRENCY_AMOUNT.
    CLEAR WA_CURRENCY_AMOUNT.
                    START-OF-SELECTION
    START-OF-SELECTION.
    CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
      EXPORTING
        documentheader          = HEADER
      CUSTOMERCPD             =
      CONTRACTHEADER          =
    IMPORTING
      OBJ_TYPE                =
      OBJ_KEY                 =
      OBJ_SYS                 =
      tables
       ACCOUNTGL               =   ACCOUNTGL
      ACCOUNTRECEIVABLE       =
      ACCOUNTPAYABLE          =
      ACCOUNTTAX              =
        currencyamount          = CURRENCY_AMOUNT
      CRITERIA                =
      VALUEFIELD              =
      EXTENSION1              =
        return                  = RETURN
      PAYMENTCARD             =
      CONTRACTITEM            =
      EXTENSION2              =
      REALESTATE              =
    IF return-type NA 'EA'.
    call function 'BAPI_TRANSACTION_COMMIT'
    EXPORTING
       WAIT          = 'X'.
    IMPORTING
      RETURN        = RETURN.
      write:/ return-message.
    else.
      write:/ return-message.
    ENDIF.
    Reward Points if it is helpful
    Thanks
    Seshu

  • Problem in Posting a document using BAPI_ACC_DOCUMENT_POST

    Hi,,
    I am using the function module "BAPI_ACC_DOCUMENT_POST" to post a vendor Invoice (KR). i think the t-code to post this is FV60.when i post the document, the document number is getting generated but amount is missing  in t-code fbv3 but bseg table is getting updated properly. Can any one help the actual input to be given to create a document and tax
    Regards

    I have a suggestion:
    Try to post this kind of document (KR) with transaction code FB01. If you can see the document correctly with FBV3 transaction, then you can use BAPI you mention.
    The following function modules may be useful for calculating taxes:
    CALCULATE_TAX_FROM_NET_AMOUNT
    CALCULATE_TAX_FROM_GROSSAMOUNT
    Regards.
    Rafael Rojas.

  • BAPI_ACC_DOCUMENT_POST    Giving an error while posting

    Hi friends,
    I wanted to post a Document using  bapi BAPI_ACC_DOCUMENT_POST with tax data and jurisdiction code. Getting an error message " E RW 003 No currency information transferred into Accounting" though I have given  the Currency info.    
    Below is the data that passed to the BAPI
    <header> data
    OBJ_TYPE                       BKPFF         
    OBJ_KEY                        $             
    OBJ_SYS                        T90CLNT810    
    BUS_ACT                        RFBU          
    USERNAME                       MNAGOORI      
    HEADER_TXT                      DOCU POST MD 
    COMP_CODE                      3000          
    DOC_DATE                       17.01.2007    
    PSTNG_DATE                     17.01.2007    
    TRANS_DATE                                   
    FISC_YEAR                      2007          
    FIS_PERIOD                     01            
    DOC_TYPE                       WE            
    REF_DOC_NO                                   
    ACCOUNTGL TABLE DATA
    ITEMNO_ACC                  0000000001 
    GL_ACCOUNT                  445000     
    ITEM_TEXT                      TEST FOR MD1
    REF_KEY_3                      40         
    ACCT_KEY                                  
    ACCT_TYPE                      S          
    COMP_CODE                    3000       
    BUS_AREA                       9900       
    ACCOUNTPAYABLE
    ITEMNO_ACC                     0000000002
    VENDOR_NO                      9999      
    GL_ACCOUNT                     191100    
    REF_KEY_1                                
    REF_KEY_2                                
    REF_KEY_3                      50        
    COMP_CODE                      3000      
    BUS_AREA                       9900      
    ITEM_TEXT                        TEST
    AccountTax table
    ITEMNO_ACC                     0000000001
    GL_ACCOUNT                     445000   
    COND_KEY                       JP1I     
    ACCT_KEY                       NVV      
    TAX_CODE                       I1       
    TAX_RATE                          6,000 
    TAX_DATE                                
    TAXJURCODE                     PA0000000
    ITEMNO_ACC                     0000000002
    GL_ACCOUNT                     191100    
    COND_KEY                       JP1I      
    ACCT_KEY                       NVV       
    TAX_CODE                       I1        
    TAX_RATE                          6,000  
    TAX_DATE                                 
    TAXJURCODE                     PA0000000 
    CurrencyAmount table
    ITEMNO_ACC                     0000000001                    
    CURR_TYPE                      00                            
    CURRENCY                       USD                           
    CURRENCY_ISO                   USD                           
    AMT_DOCCUR                                          100,0000 
    EXCH_RATE                                                    
    EXCH_RATE_V                                                  
    AMT_BASE                                            100,0000 
    ITEMNO_ACC                     0000000002                     
    CURR_TYPE                      00                             
    CURRENCY                       USD                            
    CURRENCY_ISO                   USD                            
    AMT_DOCCUR                                          100,0000- 
    EXCH_RATE                                                     
    EXCH_RATE_V                                                   
    AMT_BASE                                            100,0000- 
    I could able to post without tax data.
         I feel some of the feilds are missing the required data. Please any one could help me.
    Thanks
    Md

    Hi Aaron,
                I am testing the BAPI in SE37, the values are given below  which I am trying to post.
    [code]
    ****<header> data
    OBJ_TYPE         BKPFF
    OBJ_KEY           $
    OBJ_SYS           T90CLNT810
    BUS_ACT            RFBU
    USERNAME        MNuser
    HEADER_TXT      DOCU POST MD
    COMP_CODE      3000
    DOC_DATE          17.01.2007
    PSTNG_DATE      17.01.2007
    TRANS_DATE
    FISC_YEAR          2007
    FIS_PERIOD         01
    DOC_TYPE           WE
    REF_DOC_NO
    ACCOUNTGL TABLE DATA
    ITEMNO_ACC             0000000001
    GL_ACCOUNT            445000
    ITEM_TEXT                 TEST FOR MD1
    REF_KEY_3                40
    ACCT_TYPE                S
    COMP_CODE              3000
    BUS_AREA                 9900
    ACCOUNTPAYABLE
    ITEMNO_ACC                0000000002
    VENDOR_NO                9999
    GL_ACCOUNT               191100
    REF_KEY_1
    REF_KEY_2
    REF_KEY_3                   50
    COMP_CODE                3000
    BUS_AREA                    9900
    ITEM_TEXT                     TEST
    AccountTax table
    ITEMNO_ACC               0000000001
    GL_ACCOUNT               445000
    COND_KEY                 JP1I
    ACCT_KEY                  NVV
    TAX_CODE                   I1
    TAX_RATE                   6,000
    TAX_DATE
    TAXJURCODE                PA0000000
    ITEMNO_ACC               0000000002
    GL_ACCOUNT             191100
    COND_KEY                 JP1I
    ACCT_KEY                  NVV
    TAX_CODE                    I1
    TAX_RATE                   6,000
    TAX_DATE
    TAXJURCODE               PA0000000
    CurrencyAmount table
    ITEMNO_ACC            0000000001
    CURR_TYPE             00
    CURRENCY               USD
    CURRENCY_ISO         USD
    AMT_DOCCUR           100,0000
    AMT_BASE               100,0000
    ITEMNO_ACC               0000000002
    CURR_TYPE                00
    CURRENCY                 USD
    CURRENCY_ISO          USD
    AMT_DOCCUR             100,0000-
    AMT_BASE                 100,0000-
    [/code]
    Thanks
    Md

  • Lock Error while posting document through bapi_acc_document_post

    Hi,
       We are trying to Post documents in R/3 using Bapi_acc_document_post from BW system using ABAP report. The report groups data using certain criteria and makes a Bapi call for each group.
    Problem : The program has 2 modes test mode and actual run.
    When the program was run in a test mode 15 groups were created. Hence 15 documents should get created in R/3.
    Now when the actual run was done the program gave an output saying doc1 created,doc2 created....doc11 created.. and suddenly Bapi error .. doc1 is locked by another user, doc1 is locked by another user, doc1 is locked by another user, doc1 is locked by another user.
    Moreover Doc1 never got created in R/3. Doc 2 to Doc11 were created in R/3 and then the BApi error.
    Can anyone please help me understand why this could have happened?
    P.S : We use same Bapi for Check run as well as Actual run. Only difference is that in actual run a BApi_commit is done.
    Do you think using BAP_ACC_DOCUMENT_CHECK during check run will help ?
    PLease advice.

    Setting the WAIT parameter = 'X' will make your updates synchronous which might solve your problem.
    Please try and let me know.

Maybe you are looking for