Documente Academic
Documente Profesional
Documente Cultură
Muito foi mexido na estrutura original dos tax codes para permitir o desenvolvimento do
sistema de localização para o Brasil. Algumas funcionalidades Standard foram alteradas
e outras extendidas.
Com relação as extensões, o R/3 permite a customização do sistema para que a rotina
de cálculo dos impostos seja feita externamente ao sistema, sendo exatamente o que
ocorre com a localização Brasil, por exemplo, a rotina original que considerava apenas
o Vendor para determinação correta dos impostos, agora considera Vendor, ship-from,
ship-to, uso do material, etc… substituindo as fórmulas originais para tratamento dos
impostos pelas “Fórmulas de Condição” que são nada mais do que “programas
chamados” pelo sistema, que executam algumas operações internas e retornam os
parâmetros já calculados para o R/3.
Condition Formulas
301 IPI for the industrialization case (301 + 302 may occur together)
302 IPI for the consumption case (301 + 302 may occur together)
303 ICMS for all cases
304 Substituicao Tributaria
305 ICMS complement (in MM) and ICMS Zona Franca discount (in SD)
306 ISS (only calculated in SD)
307 ICMS Sub.Trib. on freight offset
308 not used
309 Zero value
Veja por exemplo, na configuração do Tax Code C3, que embora as linhas de
complemento de ICMS estivessem ativas, as mesmas não foram calculadas na emissão
do pedido; isto porque a “Fórmula de Condição” ( 305 no caso ) analisou as condições
de material, ship-from, ship-to, entre outras e “decidiu” que esta linha deveria ter valor
zero.
No detalhe do Pedido
Estrutura de Funcionamento
Observações: O sistema Standard vem hoje com uma série de opções de impostos
que tem seus valores definidos segundo uma série de informações (Preço do Item,
Produto, Estado de Origem, Estado de Destino, País de Orígem, Sujeição a
Substituição Tributária ou não, Condições de Venda da mercadoria (Exemplo:
Consignação), Informações do Tax Code ( 100, 100- e Fórmulas de Condições
definidas )). Quaisquer condições diferentes das apresentadas pelo sistema standard
( ICM1, IPI1, STFR, ICS1…) podem incorrer em erros, principalmente com relação a
parte fiscal, sendo que sua utilização deve ser feita de forma extremamente criteriosa.
Fica como sujestão, quando da ocorrência de situações onde seja necessário criar um
novo tax code específico, que seja feito um estudo das características de cada uma das
conditions type e se existe alguma maneira de “enganar” o sistema
Genéricos
Obs.: Para que esta operação funcione, é necessário que se tenha acesso a edição de
programas, ou seja, senha de desenvolvedor.
J_1BDETERMINE_JURISDICTION **
J_1BCALCULATE_TAXES **
** Estas funções podem ser definidas pelo path : IMG >> Contab.financeira >> Opções
básicas contab.financeira >> IVA >> Configuração >> Cálculo de impostos externo >>
Definir destino lógico
Ou ainda podem ser visualizadas via transação SE37.
Os programas SAPLF80T, SAPLTAX1, SAPLTAX2, SAPLFYTX não serão
apresentados em detalhe neste relatório uma vez que são programas auxiliares, com
funcões pouco relevantes, neste momento, para determinação de possíveis novas
funcionalidades.
______________________________________________________________________
Programas
Se IPI Pauta, determina: amount / no unit / uom ( unidade de medida ) / direito tributário
IPI Pauta por unidade de preço
OBS.: O roteiro acima é extremamente sintético, porém serve para dar uma noção dos
assuntos tratados por este programa. Quaisquer informações mais a fundo,
necessitaram da ajuda da equipe de programação para análise detalhada do programa.
J_1BDETERMINE_JURISDICTION
FUNCTION J_1BDETERMINE_JURISDICTION
REFRESH LOCATION_RESULTS.
IF LOCATION_DATA-STATE NE SPACE.
SELECT * FROM J_1BTREGX WHERE LAND1 = LOCATION_DATA-COUNTRY
AND BLAND = LOCATION_DATA-STATE.
LOCATION_RESULTS = LOCATION_DATA.
LOCATION_RESULTS-STATE = J_1BTREGX-TXREG.
LOCATION_RESULTS-TXJCD = J_1BTREGX-TXREG.
APPEND LOCATION_RESULTS.
ENDSELECT.
ENDIF.
CLEAR LOCATION_ERR.
ENDFUNCTION.
J_1BCALCULATE_TAXES
Obs.: Este função controla engloba grande parte da rotina de localização Brasil, e pelo
fato de a mesma ser muito extensa, foi anexado neste documento apenas a parte da
documentação da mesma.
*"----------------------------------------------------------------------
*"*"Local interface:
*" IMPORTING
*" VALUE(TAX_DATA) LIKE COM_TAX STRUCTURE COM_TAX
*" VALUE(ADD_DATA) LIKE J_1BTXCALC STRUCTURE J_1BTXCALC
*" OPTIONAL
*" EXPORTING
*" VALUE(TAX_ERR) LIKE COM_ERR STRUCTURE COM_ERR
*" VALUE(TAX_RESULT) LIKE COM_TAX STRUCTURE COM_TAX
*" VALUE(ADD_RESULT) LIKE J_1BTXCALC
*" STRUCTURE J_1BTXCALC
*"----------------------------------------------------------------------
*----------------------------------------------------------------------*
*
* This function can be called in two ways:
*
* - Via the external tax interface (FV64A300). In this case the
* parameters are TAX_DATA, TAX_ERR and TAX_RESULT. Additional
* information about the calculated values is exported via
* the tables 'NF_VALUES' and 'NF_LAWS'.
*
* - Via a special formula exit in SD to calculate the taxes
* ICMS and ISS based on a net amount as input data. In this
* case the parameters are TAX_DATA, TAX_ERR, TAX_RESULT,
* ADD_DATA and ADD_RESULT.
*
* In this special case only the tax values for ICMS and ISS
* are returned to the calling exit. Tables NF_VALUES and NF_LAWS
* are not changed. The output values are transferred via the
* export parameter 'ADD_RESULT'.
*
* In this special calling case it is possible to do the calculation
* of ICMS based on the price per unit and not on the total.
* A restriction then is that this calculation does NOT support
* any NF discounts and the base must not include ICMS
*
*
* Expected input values:
*
* - If the function is called from MM or the function is called
* from SD with 'ADD_DATA-ONLY_TAX' = 'X' the calculation expects
* the amount not including any taxes.
*
* - If the function is called from SD with the special parameter
* in 'ADD_DATA' the calculation expects the amount including
* ICMS and ISS (depending on the setting in 'ADD_DATA'
*
*----------------------------------------------------------------------*
______________________________________________________________________
Fórmulas
*---------------------------------------------------------------------*
* FORM FRM_KONDI_WERT_300 *
*---------------------------------------------------------------------*
***********************************************************************
******************* SAP - Sales Tax Interface *************************
***********************************************************************
* Collection of the required data for the communication to *
* an external tax system (calculation module). The data is *
* collected int an internal communication structure and passed *
* over to a function module 'RFC_CALCULATE_TAXES' or the *
* corresponding entry in TTXC *
*---------------------------------------------------------------------*
FORM FRM_KONDI_WERT_300.
**********************************************************************
* Data definitions and tables *
**********************************************************************
DEFINE DEFAULT_ON_INITIAL.
IF COM_TAX-&1 IS INITIAL OR COM_TAX-&1 = SPACE.
COM_TAX-&1 = &2.
ENDIF.
END-OF-DEFINITION.
COM_TAX-TAXPCT6 = QUANTITY.
ELSEIF COUNTER = 4.
AMOUNT = XKOMV-KWERT.
COM_TAX-TAXAMT7 = AMOUNT.
QUANTITY = XKOMV-KBETR.
COM_TAX-TAXPCT7 = QUANTITY.
ELSEIF COUNTER = 5.
AMOUNT = XKOMV-KWERT.
COM_TAX-TAXAMT8 = AMOUNT.
QUANTITY = XKOMV-KBETR.
COM_TAX-TAXPCT8 = QUANTITY.
ELSEIF COUNTER = 6.
AMOUNT = XKOMV-KWERT.
COM_TAX-TAXAMT9 = AMOUNT.
QUANTITY = XKOMV-KBETR.
COM_TAX-TAXPCT9 = QUANTITY.
ENDIF.
ENDCASE.
COM_TAX-TAXAMOV = COM_TAX-TAXAMOV + AMOUNT.
COM_TAX-TAXPCOV = COM_TAX-TAXPCOV + QUANTITY.
CLEAR: AMOUNT, QUANTITY.
ENDLOOP.
XKOMV = SAVE_XKOMV. "reset XKOMV entry
ENDIF.
*----End of Pricing Copy Logic
POSNR = KOMP-KPOSN.
* Initialize MWSKZ
IF XKOMV-MWSK1 IS INITIAL.
MWSKZ = KOMP-MWSKZ. "MWSKZ aus Position (MM/FI)
ELSE.
MWSKZ = XKOMV-MWSK1. "MWSKZ aus Kondition (SD)
ENDIF.
* Tax Exemptions
SELECT SINGLE * FROM T007A WHERE KALSM = T005-KALSM
AND MWSKZ = MWSKZ.
IF T007A-TXREL = 2. " Tax Exempt
* in case of tax exempt customers skip the call to ext. package
EXEMPT_FLAG = 'X'.
ENDIF.
CLEAR PERCENTAGE.
* begin of change J1B_0028 (Brazil localization)
DATA: J1B_ACTIVE(1) TYPE C. "Indicator Brazil Active
CALL FUNCTION 'J_1BSA_COMPONENT_CHECK'
EXPORTING
COMPONENT = 'BR'
EXCEPTIONS
COMPONENT_NOT_INSTALLED = 01.
IF SY-SUBRC IS INITIAL.
CALL FUNCTION 'J_1BSA_COMPONENT_ACTIVE'
EXPORTING
BUKRS = KOMK-BUKRS
COMPONENT = 'BR'
EXCEPTIONS
COMPONENT_NOT_ACTIVE = 1.
IF SY-SUBRC = 0.
* set PERCENTAGE so that no exemption is processed
PERCENTAGE = 100.
J1B_ACTIVE = 'X'.
ENDIF.
ENDIF.
* end of change J1B_0028 (Brazil localization)
SAVE_XKOMV = XKOMV.
LOOP AT XKOMV WHERE KNTYP CA '1234'.
PERCENTAGE = PERCENTAGE + XKOMV-KBETR.
IF NOT PERCENTAGE IS INITIAL.
EXIT.
ENDIF.
ENDLOOP.
* READ TABLE XKOMV INDEX XKOMV_TABIX.
XKOMV = SAVE_XKOMV.
IF PERCENTAGE IS INITIAL.
* in case of tax exempt customers skip the call to ext. package
EXEMPT_FLAG = 'X'.
ENDIF.
* Initialize TTXD
ON CHANGE OF T005-KALSM.
SELECT SINGLE * FROM TTXD WHERE KALSM = T005-KALSM.
CHECK SY-SUBRC = 0 AND NOT TTXD-XEXTN IS INITIAL.
ENDON.
* Read T007A
SELECT SINGLE * FROM T007A WHERE KALSM = T005-KALSM
AND MWSKZ = MWSKZ.
IF SY-SUBRC NE 0.
MESSAGE S873(FS) WITH T005-KALSM MWSKZ.
KOMP-PRSOK = SPACE.
XKOMV-KINAK = 'X'.
XKOMV-FXMSG = '899'.
CALL FUNCTION 'SET_ERROR_FLAG'.
ENDIF.
* Populate COM_TAX
COM_TAX-CLIENT = SY-MANDT. " Client
COM_TAX-COMP_CODE = KOMK-BUKRS. " Company Code
COM_TAX-COUNTRY = KOMK-ALAND. " Country for Tax Determinatio
COM_TAX-DOC_NUMBER = KOMK-BELNR. " Document Reference Number
* COM_TAX-ACCNT_NO = KOMK-KUNNR. " Customer/Vendor Account Numb
COM_TAX-TXJCD_L1 = TTXD-LENG1. " Length of the 1th part of Ju
COM_TAX-TXJCD_L2 = TTXD-LENG2. " Length of the 2th part of Ju
COM_TAX-TXJCD_L3 = TTXD-LENG3. " Length of the 3th part of Ju
COM_TAX-TXJCD_L4 = TTXD-LENG4. " Length of the 4th part of Ju
COM_TAX-MATNR = KOMP-MATNR. " Material
* begin of change J1B_ (Brazil localization)
* com_tax-unit = komp-vrkme. " Sales Unit of Measure
* MGLME + MEINS belong together / also on LTAX1U02 and LTAX1U07
COM_TAX-UNIT = KOMP-MEINS.
IF COM_TAX-UNIT IS INITIAL.
COM_TAX-UNIT = KOMP-VRKME.
ENDIF.
* end of change J1B_ (Brazil localization)
COM_TAX-CURRENCY = KOMK-WAERK. " Currency Key
* COM_TAX-TAX_TYPE = ' '. " Indicator: sales/use/rental
* COM_TAX-EXEMPT_IND = '0'. " Exempt from Taxes
* COM_TAX-CREDIT_IND = " Credit/Debit Indicator
* COM_TAX-FREIGHT_AM =
* COM_TAX-EXEMPT_AMT =
AMOUNT = XKOMV-KAWRT.
IF NOT XKOMV-KSTAT IS INITIAL OR XKOMV-KSCHL IS INITIAL.
IF AMOUNT IS INITIAL.
AMOUNT = XKOMV-KWERT.
ENDIF.
ENDIF.
COM_TAX-AMOUNT = AMOUNT. " Gross Amount
QUANTITY = KOMP-MGLME.
COM_TAX-QUANTITY = QUANTITY. " Quantity
IF KOMK-TXJCD = T001-TXJCD.
EXEMPT_FLAG = 'X'.
ENDIF.
* begin of change J1B_0041 (Brazil localization)
ENDIF.
* end of change J1B_0041 (Brazil localization)
SAVE_COM_TAX = COM_TAX.
IF COM_TAX-TXJCD_SF IS INITIAL.
MESSAGE S882(FS) RAISING TAX_DETERMINATION_ERROR.
ENDIF.
IF COM_TAX-TXJCD_ST IS INITIAL.
MESSAGE S883(FS) RAISING TAX_DETERMINATION_ERROR.
ENDIF.
COM_TAX-TXJCD_L3 = SAVE_COM_TAX-TXJCD_L3.
COM_TAX-TXJCD_L4 = SAVE_COM_TAX-TXJCD_L4.
IF KOMK-HWAER = SPACE.
KOMK-HWAER = T001-WAERS.
ENDIF.
IF KOMK-HWAER <> KOMK-WAERK.
* begin of change J1B_0041 (Brazil localization)
* process message only if Brazil is not active
IF J1B_ACTIVE = SPACE.
* end of change J1B_0041 (Brazil localization)
CALL FUNCTION 'CUSTOMIZED_MESSAGE'
EXPORTING
I_ARBGB = 'FS'
I_DTYPE = 'E'
I_MSGNR = '885'.
* begin of change J1B_0041 (Brazil localization)
ENDIF.
* end of change J1B_0041 (Brazil localization)
ENDIF.
* fill BR_KONP
REFRESH BR_KONP.
LOOP AT XKONP.
BR_KONP = XKONP-KONP.
APPEND BR_KONP.
ENDLOOP.
CALL FUNCTION 'J_1BCOMPLETE_TAX_DATA'
EXPORTING
I_KOMK = KOMK
I_KOMP = KOMP
I_T007A = T007A
I_KOMV = BR_KOMV
TABLES
T_KOMV = XXKOMV
T_KONP = BR_KONP.
* changing
* c_tax = com_tax.
ENDIF.
* end of change J1B_0014 (Brazil localization)
IF SY-SUBRC NE 0.
MESSAGE S870(FS).
KOMP-PRSOK = SPACE.
XKOMV-KINAK = 'X'.
XKOMV-FXMSG = '899'.
CALL FUNCTION 'SET_ERROR_FLAG'.
EXIT.
ELSEIF COM_ERR-RETCODE <> 0.
MESSAGE S872(FS) WITH COM_ERR-ERRCODE COM_ERR-ERRMSG.
KOMP-PRSOK = SPACE.
XKOMV-KINAK = 'X'.
XKOMV-FXMSG = '899'.
CALL FUNCTION 'SET_ERROR_FLAG'.
EXIT.
ENDIF.
ELSE. " gross amount is zero
COM_TAX-TAXAMT0 = 0. " Federal Tax Amount
COM_TAX-TAXAMT1 = 0. " State Tax Amount
COM_TAX-TAXAMT2 = 0. " County Tax Amount
COM_TAX-TAXAMT3 = 0. " City/Local Tax Amount
COM_TAX-TAXAMT4 = 0. " Distict Tax Amount
COM_TAX-TAXAMT5 = 0. " Secondary City Tax Amount
COM_TAX-TAXAMT6 = 0. " Other Tax Amount
COM_TAX-TAXAMT7 = 0. " Other Tax Amount
COM_TAX-TAXAMT8 = 0. " Other Tax Amount
COM_TAX-TAXAMT9 = 0. " Other Tax Amount
COM_TAX-TAXAMOV = 0. " Total overall Tax Amount
TAXPCT0 = COM_TAX-TAXPCT0.
TAXPCT1 = COM_TAX-TAXPCT1.
TAXPCT2 = COM_TAX-TAXPCT2.
TAXPCT3 = COM_TAX-TAXPCT3.
TAXPCT4 = COM_TAX-TAXPCT4.
TAXPCT5 = COM_TAX-TAXPCT5.
TAXPCT6 = COM_TAX-TAXPCT6.
TAXPCT7 = COM_TAX-TAXPCT7.
TAXPCT8 = COM_TAX-TAXPCT8.
TAXPCT9 = COM_TAX-TAXPCT9.
ENDFORM.
301 IPI for the industrialization case (301 + 302 may occur together)
*---------------------------------------------------------------------*
* FORM FRM_KONDI_WERT_301 *
*---------------------------------------------------------------------*
* Set tax values and percentage into condition structure and *
* fill tax base amount *
*---------------------------------------------------------------------*
FORM FRM_KONDI_WERT_301.
TAXBAS1 = XKOMV-KAWRT.
ENDFORM.
302 IPI for the consumption case (301 + 302 may occur together)
*---------------------------------------------------------------------*
* FORM FRM_KONDI_WERT_302 *
*---------------------------------------------------------------------*
* Set tax values and percentage into condition structure and *
* fill tax base amount *
*---------------------------------------------------------------------*
FORM FRM_KONDI_WERT_302.
TAXBAS2 = XKOMV-KAWRT.
ENDFORM.
*---------------------------------------------------------------------*
* FORM FRM_KONDI_WERT_303 *
*---------------------------------------------------------------------*
* Set tax values and percentage into condition structure and *
* fill tax base amount *
*---------------------------------------------------------------------*
FORM FRM_KONDI_WERT_303.
TAXBAS3 = XKOMV-KAWRT.
ENDFORM.
*---------------------------------------------------------------------*
* FORM FRM_KONDI_WERT_304 *
*---------------------------------------------------------------------*
* Set tax values and percentage into condition structure and *
* fill tax base amount *
*---------------------------------------------------------------------*
FORM FRM_KONDI_WERT_304.
TAXBAS4 = XKOMV-KAWRT.
ENDFORM.
305 ICMS complement (in MM) and ICMS Zona Franca discount (in SD)
*---------------------------------------------------------------------*
* FORM FRM_KONDI_WERT_305 *
*---------------------------------------------------------------------*
* Set tax values and percentage into condition structure and *
* fill tax base amount *
*---------------------------------------------------------------------*
FORM FRM_KONDI_WERT_305.
TAXBAS5 = XKOMV-KAWRT.
ENDFORM.
*---------------------------------------------------------------------*
* FORM FRM_KONDI_WERT_306 *
*---------------------------------------------------------------------*
* Set tax values and percentage into condition structure and *
* fill tax base amount *
*---------------------------------------------------------------------*
FORM FRM_KONDI_WERT_306.
TAXBAS6 = XKOMV-KAWRT.
ENDFORM.
*---------------------------------------------------------------------*
* FORM FRM_KONDI_WERT_307 *
*---------------------------------------------------------------------*
* Set tax values and percentage into condition structure and *
* fill tax base amount *
*---------------------------------------------------------------------*
FORM FRM_KONDI_WERT_307.
TAXBAS7 = XKOMV-KAWRT.
ENDFORM.
*---------------------------------------------------------------------*
* FORM FRM_KONDI_WERT_309 *
*---------------------------------------------------------------------*
* Set tax values and percentage into condition structure and *
* fill tax base amount *
*---------------------------------------------------------------------*
FORM FRM_KONDI_WERT_309.
TAXBAS9 = XKOMV-KAWRT.
ENDFORM.