Skip to Content
author's profile photo Former Member
Former Member

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.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Dec 13, 2008 at 05:50 AM

    Check if this is useful:

    BAPI for posting accounting documents

    Neha

    Add a comment
    10|10000 characters needed characters exceeded

    • Hi,

      there is no need to use extensions.in accounttax table pass the glaccounts and taxcodes for tax.provide the corresponding line item numbers in currencyamount table with -ve sign for credit amounts.so u need to provide all line items in glaccount,accounttax...in currencyamount table.

      for tax amount, just enter the 'baseamount' in 'currencyamount'.system will calculate the tax amount from the tax code u gave in 'accounttax'.

      regards

      Arjun

  • author's profile photo Former Member
    Former Member
    Posted on Dec 13, 2008 at 05:52 AM

    hi,

    i think you are passing your values in wrong table.

    to create tax item, there is another table structure provided in bapi is ACCOUNTTAX.

    Try to pass the your values correctly there.

    This is just a suggestion. be ensure befor going further.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 18, 2008 at 08:48 AM

    answered

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.