Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

How to fill up the tax table in AC_DOCUMENT_DIRECT_INPUT

Hello Experts, 

I am having problems using the said FM. What I want to do is that I need to post accrued PO 
related transactions but I need to compute for the tax which this FM unfortunately cannot do
since it says that automatic tax calculation is not possible.So I guess there is way to compute for
taxes by filling up the tax table.Below is my code where it populates the tables:

CONCATENATE p_gjahr
                p_monat
                '01'
                INTO lv_first_day.

    CALL FUNCTION 'LAST_DAY_OF_MONTHS'
      EXPORTING
        day_in            = lv_first_day
      IMPORTING
        last_day_of_month = lv_last_day
      EXCEPTIONS
        day_in_no_date    = 1
        OTHERS            = 2.
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
              WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.

    lt_bkpf-bukrs = p_bukrs.
    lt_bkpf-waers = 'PHP'.
    lt_bkpf-tcode = 'FB01'.

    lt_bkpf-budat(2)   = lv_last_day+4(2).
    lt_bkpf-budat+2(2) = lv_last_day+6(2).
    lt_bkpf-budat+4(4) = lv_last_day(4).

    lt_bkpf-bldat(2)   = lv_last_day+4(2).
    lt_bkpf-bldat+2(2) = lv_last_day+6(2).
    lt_bkpf-bldat+4(4) = lv_last_day(4).

    lt_bkpf-monat = lv_last_day+4(2).
    lt_bkpf-blart = gc_yearend_blart.
    APPEND lt_bkpf.
    CLEAR lt_bkpf.

    LOOP AT gt_output INTO wa_output.
      CLEAR lv_vat.
      lt_bseg-stype = 'I'.
      lt_bseg-newbs = '40'.
      lt_bseg-newko = wa_output-sakto.
      lt_bseg-kostl = wa_output-kostl.
      lt_bseg-aufnr = wa_output-aufnr.
      lv_vat = wa_output-netpr * '.12'.
      wa_output-netpr = wa_output-netpr + lv_vat.
      lt_bseg-dmbtr = wa_output-netpr.
      ADD lt_bseg-dmbtr TO lv_netpr.
      lt_bseg-wrbtr = wa_output-netpr.
      lt_bseg-sgtxt = wa_output-txz01.
      lt_bseg-ebeln = wa_output-ebeln.
      lt_bseg-ebelp = wa_output-ebelp.
      lt_bseg-mwskz = wa_output-mwskz.
      APPEND lt_bseg.
      CLEAR lt_bseg.
      lv_sgtxt = wa_output-txz01.
      lv_lifnr = wa_output-lifnr.
      lv_mwskz = wa_output-mwskz.
      AT LAST.
        lv_vat = lv_netpr * '0.12'.
        lt_btax-stype = 'I'.
        lt_btax-bschl = '40'.
*        lt_bseg-newko = '10018291'.
        lt_btax-fwste = lv_vat.
        lt_btax-fwbas = lv_vat.
*        lt_bseg-sgtxt = lv_sgtxt.
        lt_btax-mwskz = lv_mwskz.
*        lt_btax-bschl = 'MWAS'.
        APPEND lt_btax.
        CLEAR: lt_btax.

        lv_ewt = lv_netpr * '0.01'.
        lt_bwith-stype = 'I'.
        lt_bwith-WITHT = '21'.
        lt_bwith-WT_WITHCD = lv_mwskz.
*        lt_bseg-newko = '20000310'.
        lt_bwith-WT_QSSHH = lv_ewt.
        lt_bwith-WT_QSSHB = lv_ewt.
*        lt_bseg-sgtxt = lv_sgtxt.
        lt_btax-mwskz = lv_mwskz.
        lt_btax-bschl = 'MWAS'.
        APPEND lt_btax.
        CLEAR: lt_btax.

        lv_deferred = ( lv_netpr + lv_vat ) - ABS( lv_ewt ).
        lt_bseg-stype = 'I'.
        lt_bseg-newbs = '39'.
        lt_bseg-newko = lv_lifnr.
        lt_bseg-newum = 'V'.
        lt_bseg-dmbtr = lv_deferred.
        lt_bseg-wrbtr = lv_deferred.
        lt_bseg-sgtxt = lv_sgtxt.
        lt_bseg-mwskz = lv_mwskz.
        APPEND lt_bseg.
        CLEAR: lt_bseg, lv_vat, lv_ewt, lv_deferred.
      ENDAT.
    ENDLOOP.

    CALL FUNCTION 'ZFI_ACC_DOCUMENT_POST'
* EXPORTING
*   I_NODATA        =
*   I_TESTRUN       =
*   I_GRPID         =
*   I_UPLOAD        =
     IMPORTING
         e_bukrs         = lv_bukrs
         e_gjahr         = lv_gjahr
         e_belnr         = lv_belnr
      TABLES
        return          = lt_return
        t_bbkpf         = lt_bkpf
        t_bbseg         = lt_bseg
        t_bbtax         = lt_btax
*   T_BWITH         =
              .
    IF sy-subrc = 0.

      LOOP AT lt_return
        WHERE type = 'E'.

        MESSAGE e000(zfi) WITH lt_return-message.

      ENDLOOP.

      MESSAGE i000(zfi) WITH 'Document Number'
                             lv_belnr
                             'Posted to Company Code'
                             lv_bukrs.
      PERFORM f_modify_run.
    ELSE.
    ENDIF.

Tags:
Former Member
Not what you were looking for? View more on this topic or Ask a question