100% found this document useful (1 vote)
188 views4 pages

ICMS ST Logic Example

This method recalculates ICMS-ST taxes for a document. It first checks validation rules for the tax, then recalculates the tax base amount and tax amount based on the document's ICMS tax rate. It exports the recalculated tax values to store in a tax memo record in case the values need to be changed manually later.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
188 views4 pages

ICMS ST Logic Example

This method recalculates ICMS-ST taxes for a document. It first checks validation rules for the tax, then recalculates the tax base amount and tax amount based on the document's ICMS tax rate. It exports the recalculated tax values to store in a tax memo record in case the values need to be changed manually later.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

IF_EX_BADI_J1B_EXTEND_TAXES~ICMS_ST_RECALCULATE

METHOD if_ex_badi_j1b_extend_taxes~icms_st_recalculate.

    DATA: vl_base(12)     TYPE p DECIMALS 6,
          vl_valor(12)    TYPE p DECIMALS 6,
          vl_fator        TYPE p DECIMALS 2,
          vl_st_base      TYPE z_tax,
          vl_st_amount    TYPE z_tax,
          vl_st_rate      TYPE z_tax,
          rl_iva          TYPE RANGE OF mwskz, "Inc DM01
          rl_iva_difal_st TYPE RANGE OF mwskz, "Inc DM01

          wl_valida_st    TYPE zzmm_valid_st.

    ASSIGN ('(SAPLV61A)KOMP-STEUC') TO FIELD-SYMBOL(<fs_ncm>).
    ASSIGN ('(SAPLV61A)KOMK-LIFNR') TO FIELD-SYMBOL(<fs_lifnr>). "Inc DM0
1
    ASSIGN ('(SAPLV61A)KOMP-MWSKZ') TO FIELD-SYMBOL(<fs_iva>).   "Inc DM0
1
    SELECT SINGLE *
      FROM zzmm_valid_st
      INTO wl_valida_st
      WHERE bukrs = is_icms_st_recalculation-komk-bukrs
        AND werks = is_icms_st_recalculation-komp-werks.

    IF wl_valida_st IS NOT INITIAL.

      "Begin of DM01
      "Tratamento para Simples Nacional
      CLEAR rl_iva.
      CALL FUNCTION '/PGTPA/PARAM_BUSCA_VALORES'
        EXPORTING
          i_modulo            = 'MM'
          i_param1            = 'SIMPLES_NACIONAL'
          i_param2            = 'IVA_DIFAL'
        TABLES
          t_range             = rl_iva
        EXCEPTIONS
          nao_encontrado      = 1
          range_nao_informado = 2
          OTHERS              = 3.

      DATA(vl_result) = abap_false.
      IF rl_iva IS NOT INITIAL.
        IF <fs_lifnr> IS ASSIGNED.
          SELECT SINGLE tdt
            FROM lfa1
            INTO @DATA(vl_tdt)
            WHERE lifnr = @<fs_lifnr>.
          IF sy-subrc IS INITIAL AND vl_tdt = 'SN'. "Fornecedor Simples N
acional
            CLEAR rl_iva_difal_st.
            CALL FUNCTION '/PGTPA/PARAM_BUSCA_VALORES'
              EXPORTING
                i_modulo            = 'MM'
                i_param1            = 'DIFAL_ST'
                i_param2            = 'IVA'
              TABLES
                t_range             = rl_iva_difal_st
              EXCEPTIONS
                nao_encontrado      = 1
                range_nao_informado = 2
                OTHERS              = 3.

            IF rl_iva_difal_st IS NOT INITIAL AND
               <fs_iva> IS ASSIGNED AND
               <fs_iva> IN rl_iva_difal_st[].
              vl_result = abap_true. "Fazer novo cálculo
            ENDIF.
          ENDIF.
        ENDIF.
      ENDIF.
      "End of DM01

      IF vl_result = abap_true. "Inc DM01
        vl_fator  = is_icms_st_recalculation-icms_destination_rate.

        vl_base   = is_icms_st_recalculation-icms_base - is_icms_st_recal
culation-icms_amount.

        vl_valor  = is_icms_st_recalculation-icms_base - is_icms_st_recal
culation-icms_amount.

        cv_icms_st_base = vl_base + ( vl_valor * vl_fator ).
        cv_icms_st_amount = vl_valor * vl_fator.
      ELSE.
        vl_fator  = 1 - is_icms_st_recalculation-icms_destination_rate.

        vl_base = is_icms_st_recalculation-icms_base - is_icms_st_recalcu
lation-icms_amount.
        vl_base = vl_base / vl_fator.

        vl_valor = vl_base * is_icms_st_recalculation-
icms_destination_rate.
        vl_valor = vl_valor - is_icms_st_recalculation-icms_amount.

        cv_icms_st_base = vl_base.
        cv_icms_st_amount = vl_valor.
      ENDIF.

      IF <fs_ncm> IS NOT INITIAL AND wl_valida_st-ncm = <fs_ncm>.
        CLEAR: cv_icms_st_amount,
               cv_icms_st_base.
      ENDIF.

      "Exporta valores para recálculo da MIRO em caso de mudança manual 
de valores
      "importação realizada no include LJ1BB2FC3 - Enhancement ZENH_CALC
_ICMS_33_2

      ASSIGN ('(SAPLV61A)KOMP-EVRTN') TO FIELD-SYMBOL(<fs_ebeln>).
      ASSIGN ('(SAPLV61A)KOMP-EVRTP') TO FIELD-SYMBOL(<fs_ebelp>).

      IF <fs_ebeln> IS ASSIGNED.
        IF <fs_ebelp> IS ASSIGNED.

          vl_st_base = is_icms_st_recalculation-icms_base.
          vl_st_amount = is_icms_st_recalculation-icms_amount.
          vl_st_rate = is_icms_st_recalculation-icms_destination_rate.

          CALL FUNCTION 'ZMM_ST_MEMO'
            EXPORTING
              i_ebeln     = <fs_ebeln>
              i_ebelp     = <fs_ebelp>
              i_st_base   = vl_st_base
              i_st_amount = vl_st_amount
              i_st_rate   = vl_st_rate.

        ENDIF.
      ENDIF.
    ENDIF.

  ENDMETHOD.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy