Você está na página 1de 10

* ======== =========== ========== =====================================*

* Cdigo copiado da funo standard MEPO_DOC_ITEM_PROCESS no form


* KOND_TAXES carregando os valores da estrutura TAXCOM tambm h uma
* parte da funo CALCULATE_TAX_ITEM para carregar os valores das
* estruturas KOMV e KOMP para executar o calculo e gerar os valores
* usando a funo PRICING no retorno somar o valor dos impostos com o
* valor liquido gerando o valor total do pedido somendo todos itens
*======================================================================*
* Declaraes locais
*======================================================================*
*& Tipos - Estratgia de liberao
*&---------------------------------------------------------------------*
TYPES:
BEGIN OF ty_txctl,
txjcd LIKE ttxj-txjcd,
xskfn LIKE ttxj-xskfn,
xmwsn LIKE ttxj-xmwsn,
xtxit LIKE ttxd-xtxit,
END OF ty_txctl.
*&---------------------------------------------------------------------*
*& Tabelas internas
*&---------------------------------------------------------------------*
DATA: BEGIN OF lt_mwstab OCCURS 10,
bukrs LIKE bseg-bukrs,
mwskz LIKE bseg-mwskz,
shkzg LIKE bseg-shkzg,
txjcd LIKE bseg-txjcd,
wrbtr LIKE bset-fwbas, "obsolet
wmwst LIKE bseg-wmwst, "obsolet
wskto LIKE bseg-wskto,
skfbt LIKE bset-fwbas,
fwbas LIKE bset-fwbas, "Steuerbasis Steuerzeilen
fwste LIKE bseg-wmwst, "Steuerbetrag Steuerzeilen
pruef LIKE t007a-pruef,
mwart LIKE t007a-mwart, "obsolet
egrkz LIKE t007a-egrkz, "Kennzeichen fuer EG
prsdt LIKE bkpf-budat,
waers LIKE bkpf-waers,
* HWAER LIKE T001-WAERS,
* LAND1 LIKE T001-LAND1,
* STEUER LIKE BSEG-WSKTO,
steuer_old LIKE bseg-wskto,
nskfbt LIKE bset-fwbas, "Nicht skontof. Betrag
xauto LIKE bseg-xauto, " Steuer vom Brutto
xmwsn LIKE t001-xmwsn, " Steuer Netto "N1451436
xskfn LIKE t001-xskfn, " Skonto Netto "N1451436
* ANZAHL TYPE I,
txgrp LIKE bseg-txgrp. "Gruppierungsschlssel fuer Steuer
INCLUDE STRUCTURE bsetl. "Linewise tax calculation
DATA: END OF lt_mwstab.
DATA: BEGIN OF lt_komv OCCURS 10.
INCLUDE STRUCTURE komv.
DATA: END OF lt_komv.
DATA:
lt_ekpo TYPE STANDARD TABLE OF bekpo,
*&---------------------------------------------------------------------*
*& Estruturas
*&---------------------------------------------------------------------*
ls_ekko TYPE cekko,
ls_ekpo TYPE bekpo,
ls_komk TYPE komk,
ls_komp TYPE komp,
ls_t001 TYPE t001,
ls_t005 TYPE t005,
ls_t007a TYPE t007a,
ls_ttxd TYPE ttxd,
ls_taxcom TYPE taxcom,
ls_txctl TYPE ty_txctl,
*&---------------------------------------------------------------------*
*& Variveis
*&---------------------------------------------------------------------*
lv_skonto TYPE bseg-wskto,
lv_xwia TYPE char1,
lv_gnetw TYPE cekko-gnetw,
*&---------------------------------------------------------------------*
*& Objetos
*&---------------------------------------------------------------------*
wa_exit_ref TYPE REF TO if_ex_tax_conditions.
FIELD-SYMBOLS:
<fs_gnetw> TYPE cekko-gnetw,
<fs_ebeln> TYPE ekko-ebeln.
*======================================================================*
* Cdigo
*======================================================================*
IF ( sy-ucomm EQ 'MESAVE' OR
sy-ucomm EQ 'BU' OR
sy-ucomm EQ 'PICK' ) AND
( sy-tcode = 'ME21N' OR
sy-tcode = 'ME22N' OR
sy-tcode = 'ME23N' ).
*======================================================================*
* Calcular o valor total do pedido - Dados anteriores
*======================================================================*
ASSIGN:
('(SAPLMEPO)*CEKKO-GNETW') TO <fs_gnetw>,
('(SAPLMEPO)EKKO-EBELN') TO <fs_ebeln>.
IF sy-subrc = 0.
CLEAR: ls_ekko,
lv_gnetw.
REFRESH lt_ekpo.
* Carregar cabealho do pedido
ls_ekko = i_cekko.
* Carregar itens do pedido
SELECT *
FROM ekpo
INTO CORRESPONDING FIELDS OF TABLE lt_ekpo
WHERE ebeln = <fs_ebeln>.
LOOP AT lt_ekpo INTO ls_ekpo.
CLEAR: ls_t001,
ls_t005,
wa_exit_ref.
CHECK ls_ekpo-loekz = ''.
* Selecionar as configuraes da empresa
SELECT SINGLE *
FROM t001
INTO ls_t001
WHERE bukrs = ls_ekko-bukrs.
IF sy-subrc = 0.
* Selecionar as configuraes de Pases
SELECT SINGLE *
FROM t005
INTO ls_t005
WHERE land1 = ls_t001-land1.
IF sy-subrc = 0.
* Get BAdI
CALL FUNCTION 'BADI_TAX_CONDITIONS'
EXPORTING
i_intca = ls_t005-intca
IMPORTING
e_exit = wa_exit_ref.
ENDIF.
ENDIF.
* Validar cdigo IVA
IF ls_ekpo-mwskz NE space.
CLEAR ls_taxcom.
ls_taxcom-bukrs = ls_ekpo-bukrs. "Empresa
ls_taxcom-budat = ls_ekko-bedat. "Data do documento de compra
ls_taxcom-waers = ls_ekko-waers. "Cdigo da moeda
ls_taxcom-kposn = ls_ekpo-ebelp. "N item do documento de compra
ls_taxcom-mwskz = ls_ekpo-mwskz. "Cdigo do IVA
ls_taxcom-txjcd = ls_ekpo-txjcd. "Domiclio fiscal
ls_taxcom-ebeln = ls_ekpo-ebeln. "N do documento de compras
ls_taxcom-ebelp = ls_ekpo-ebelp. "N do documento de compras
ls_taxcom-shkzg = 'H'. "Cdigo dbito/crdito
ls_taxcom-xmwst = 'X'. "Calcular imposto automaticament
e?
IF ls_ekko-bstyp EQ 'F'. " Pedido
ls_taxcom-wrbtr = ls_ekpo-netwr. "Montante em moeda do documento
ELSE. "Outros
ls_taxcom-wrbtr = ls_ekpo-zwert. "Montante em moeda do documento
ENDIF. "ls_ekko-bstyp EQ 'F'.
ls_taxcom-lifnr = ls_ekko-lifnr. "Cdigo do fornecedor
ls_taxcom-land1 = ls_t005-land1. "Cdigo do pas
ls_taxcom-ekorg = ls_ekko-ekorg. "Organizao de compras
ls_taxcom-hwaer = ls_t001-waers. "Moeda
ls_taxcom-llief = ls_ekko-llief. "Fornecedor para a remessa
ls_taxcom-bldat = ls_ekko-bedat. "Data do documento de compra
ls_taxcom-matnr = ls_ekpo-matnr. "Item
ls_taxcom-werks = ls_ekpo-werks. "Centro
ls_taxcom-bwtar = ls_ekpo-bwtar. "Tipo de avaliao
ls_taxcom-matkl = ls_ekpo-matkl. "Grupo de mercadorias
ls_taxcom-meins = ls_ekpo-meins. "Unidade de medida do pedido
*- Mengen richtig fuellen ---------------------------------------------*
* Quantidade
IF ls_ekko-bstyp EQ 'F'. "Pedido
ls_taxcom-mglme = ls_ekpo-menge. "Quantidade
ELSE. "Contrato
IF ls_ekko-bstyp EQ 'K' AND
ls_ekpo-abmng GT 0.
ls_taxcom-mglme = ls_ekpo-abmng. "Quantidade
ELSE.
ls_taxcom-mglme = ls_ekpo-ktmng. "Quantidade
ENDIF.
ENDIF.
IF ls_taxcom-mglme EQ 0. "falls keine Menge gesetzt --> auf 1 setzen
ls_taxcom-mglme = 1000. "z.B. bestellte Banf nochmal bestellt
ENDIF.
ls_taxcom-mtart = ls_ekpo-mtart. "Tipo de material
PERFORM plants_abroad_get_net_ind(sapltax1) USING lv_xwia
ls_t005-kalsm
ls_taxcom-mwskz
CHANGING ls_txctl-xmwsn
ls_txctl-xskfn.
*------- Kommunikationsbereiche fllen -------------------------------*
CLEAR ls_komk.
ls_komk-mandt = sy-mandt. "Mandante
ls_komk-kappl = 'TX'. "Aplicao
ls_komk-waerk = ls_taxcom-waers. "Moeda do documento SD
ls_komk-aland = ls_taxcom-land1. "Pas fornecedor
ls_komk-mwskz = ls_taxcom-mwskz. "Cdigo do IVA
ls_komk-kunnr = ls_taxcom-kunnr. "Emissor da ordem
ls_komk-lifnr = ls_taxcom-lifnr. "N conta do fornecedor
ls_komk-llief = ls_taxcom-llief. "Fornecedor para a remessa
ls_komk-ekorg = ls_taxcom-ekorg. "Organizao de compras
ls_komk-gsber = ls_taxcom-gsber. "Diviso
ls_komk-bukrs = ls_t001-bukrs. "Empresa
ls_komk-hwaer = ls_t001-waers. "Moeda interna
ls_komk-kalsm = ls_t005-kalsm. "Esquema (determinao preo, mensagen
s, determ.contas, ...)
IF ls_komk-aland IS INITIAL.
ls_komk-aland = ls_t001-land1. "Pas fornecedor
ENDIF.
IF ls_t001-xstdt = 'X' AND NOT ls_taxcom-bldat IS INITIAL.
ls_komk-prsdt = ls_taxcom-bldat. "Data para determinao de preo e cmbi
o de moeda
ELSE.
ls_komk-prsdt = ls_taxcom-budat. "Data para determinao de preo e cmbi
o de moeda
ENDIF.
* Carregar dados do item para condies
CLEAR ls_komp.
ls_komp-kposn = ls_taxcom-kposn. "N item ao qual se aplicam as con
dies
ls_komp-mwskz = ls_taxcom-mwskz. "Cdigo do IVA
ls_komp-matnr = ls_taxcom-matnr. "N do material
ls_komp-werks = ls_taxcom-werks. "Centro
ls_komp-bwtar = ls_taxcom-bwtar. "Tipo de avaliao
ls_komp-matkl = ls_taxcom-matkl. "Grupo de mercadorias
ls_komp-meins = ls_taxcom-meins. "Unidade de medida bsica
ls_komp-mglme = ls_taxcom-mglme. "Quantidade
ls_komp-mtart = ls_taxcom-mtart. "Tipo de material
ls_komp-evrtn = ls_taxcom-ebeln. "N do documento de compras
ls_komp-evrtp = ls_taxcom-ebelp. "N item do documento de compra
ls_komk-projk = ls_taxcom-projk. "Elemento do plano da estrutura
do projeto (elemento PEP)
ls_komk-prctr = ls_taxcom-prctr. "Centro de lucro
ls_komk-aufnr = ls_taxcom-aufnr. "N ordem
ls_komk-kostl = ls_taxcom-kostl. "Centro de custo responsvel
ls_komk-kokrs = ls_taxcom-kokrs. "rea de contabilidade de custos
ls_komk-blart = ls_taxcom-blart. "Tipo de documento
*------- MWSKZ prfen ------------------------------------------------*
CALL FUNCTION 'TAX_INDICATOR_CHECK'
EXPORTING
steuerschema = ls_komk-kalsm
steuerkennzeichen = ls_taxcom-mwskz
IMPORTING
t007a = ls_t007a
EXCEPTIONS "N1427028
not_valid = 4. "N1427028
* begin of note N1427028
IF sy-subrc = 4.
* MESSAGE e704 WITH ls_taxcom-mwskz ls_komk-kalsm
* RAISING mwskz_not_valid.
ENDIF.
IF NOT ls_taxcom-txjcd IS INITIAL. "1595604
* ------- Check Jurisdiction Data ------------------------------------*
CALL FUNCTION 'FI_TAX_CHK_JURISDICTION_IS_OK'
EXPORTING
i_kalsm = ls_komk-kalsm
i_ttxd = ls_ttxd
i_txjcd = ls_taxcom-txjcd
i_bukrs = ls_taxcom-bukrs
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0. "Invalid
ENDIF.
* end of note N1427028
ENDIF. "1595604
lt_mwstab-egrkz = ls_t007a-egrkz.
*------- US-Taxes ? --------------------------------------------------*
IF ls_ttxd-kalsm NE space.
ls_komk-txjcd = ls_taxcom-txjcd. "Domiclio fiscal
ELSE.
ls_taxcom-txjcd = space. "Domiclio fiscal
ENDIF.
*------- Steuerbasis netto ? -----------------------------------------*
IF ls_txctl-xmwsn NE space.
IF NOT ls_taxcom-wskto IS INITIAL.
lv_skonto = ls_taxcom-wskto.
ELSEIF NOT ls_taxcom-skfbt IS INITIAL.
lv_skonto = ls_taxcom-skfbt * ls_taxcom-zbd1p / 100000.
ELSE.
lv_skonto = ls_taxcom-wrbtr * ls_taxcom-zbd1p / 100000.
ENDIF.
ENDIF.
* Calcular o valor total do pedido
IF ls_taxcom-mwart NE space.
ls_komp-wrbtr = ls_taxcom-wrbtr. "Montante em moeda do documento
ELSE.
* Calcular o valor total do pedido
PERFORM komp-wrbtr_setzen(sapltax1) USING lv_skonto
ls_taxcom
' '
CHANGING ls_komp-wrbtr.
ENDIF.
*------- Steuer rechnen ----------------------------------------------*
* Add country-specific data to komk and komp
IF wa_exit_ref IS BOUND.
CALL METHOD wa_exit_ref->fill_komk_komp
EXPORTING
flt_val = ls_t005-intca
CHANGING
ch_komk = ls_komk
ch_komp = ls_komp.
ENDIF.
* Executar a pricing para calcular o valor do imposto
CLEAR lt_komv[].
CALL FUNCTION 'PRICING'
EXPORTING
comm_head_i = ls_komk
comm_item_i = ls_komp
calculation_type = 'B'
IMPORTING
comm_head_e = ls_komk
comm_item_e = ls_komp
TABLES
tkomv = lt_komv.
ENDIF.
* Valor total do pedido (Valor Lquido + Impostos)
lv_gnetw = ls_komp-mwsbp + ls_komp-netwr + lv_gnetw.
ENDLOOP. " AT lt_ekpo INTO ls_ekpo.
IF NOT lv_gnetw IS INITIAL.
* Carretgar o valor total do pedido
<fs_gnetw> = lv_gnetw.
ENDIF.
ENDIF. "sy-subrc = 0.
*======================================================================*
* Calcular o valor total do pedido - Dados atuais
*======================================================================*
CLEAR: ls_ekko,
lv_gnetw.
REFRESH lt_ekpo.
* Carregar cabealho do pedido
ls_ekko = i_cekko.
* Carregar itens do pedido
lt_ekpo[] = it_bekpo[].
LOOP AT lt_ekpo INTO ls_ekpo.
CLEAR: ls_t001,
ls_t005,
wa_exit_ref.
CHECK ls_ekpo-loekz = ''.
* Selecionar as configuraes da empresa
SELECT SINGLE *
FROM t001
INTO ls_t001
WHERE bukrs = ls_ekko-bukrs.
IF sy-subrc = 0.
* Selecionar as configuraes de Pases
SELECT SINGLE *
FROM t005
INTO ls_t005
WHERE land1 = ls_t001-land1.
IF sy-subrc = 0.
* Get BAdI
CALL FUNCTION 'BADI_TAX_CONDITIONS'
EXPORTING
i_intca = ls_t005-intca
IMPORTING
e_exit = wa_exit_ref.
ENDIF.
ENDIF.
* Validar cdigo IVA
IF ls_ekpo-mwskz NE space.
CLEAR ls_taxcom.
ls_taxcom-bukrs = ls_ekpo-bukrs. "Empresa
ls_taxcom-budat = ls_ekko-bedat. "Data do documento de compra
ls_taxcom-waers = ls_ekko-waers. "Cdigo da moeda
ls_taxcom-kposn = ls_ekpo-ebelp. "N item do documento de compra
ls_taxcom-mwskz = ls_ekpo-mwskz. "Cdigo do IVA
ls_taxcom-txjcd = ls_ekpo-txjcd. "Domiclio fiscal
ls_taxcom-ebeln = ls_ekpo-ebeln. "N do documento de compras
ls_taxcom-ebelp = ls_ekpo-ebelp. "N do documento de compras
ls_taxcom-shkzg = 'H'. "Cdigo dbito/crdito
ls_taxcom-xmwst = 'X'. "Calcular imposto automaticamente?
IF ls_ekko-bstyp EQ 'F'. " Pedido
ls_taxcom-wrbtr = ls_ekpo-netwr. "Montante em moeda do documento
ELSE. "Outros
ls_taxcom-wrbtr = ls_ekpo-zwert. "Montante em moeda do documento
ENDIF. "ls_ekko-bstyp EQ 'F'.
ls_taxcom-lifnr = ls_ekko-lifnr. "Cdigo do fornecedor
ls_taxcom-land1 = ls_t005-land1. "Cdigo do pas
ls_taxcom-ekorg = ls_ekko-ekorg. "Organizao de compras
ls_taxcom-hwaer = ls_t001-waers. "Moeda
ls_taxcom-llief = ls_ekko-llief. "Fornecedor para a remessa
ls_taxcom-bldat = ls_ekko-bedat. "Data do documento de compra
ls_taxcom-matnr = ls_ekpo-matnr. "Item
ls_taxcom-werks = ls_ekpo-werks. "Centro
ls_taxcom-bwtar = ls_ekpo-bwtar. "Tipo de avaliao
ls_taxcom-matkl = ls_ekpo-matkl. "Grupo de mercadorias
ls_taxcom-meins = ls_ekpo-meins. "Unidade de medida do pedido
*- Mengen richtig fuellen ---------------------------------------------*
* Quantidade
IF ls_ekko-bstyp EQ 'F'. "Pedido
ls_taxcom-mglme = ls_ekpo-menge. "Quantidade
ELSE. "Contrato
IF ls_ekko-bstyp EQ 'K' AND
ls_ekpo-abmng GT 0.
ls_taxcom-mglme = ls_ekpo-abmng. "Quantidade
ELSE.
ls_taxcom-mglme = ls_ekpo-ktmng. "Quantidade
ENDIF.
ENDIF.
IF ls_taxcom-mglme EQ 0. "falls keine Menge gesetzt --> auf 1 setzen
ls_taxcom-mglme = 1000. "z.B. bestellte Banf nochmal bestellt
ENDIF.
ls_taxcom-mtart = ls_ekpo-mtart. "Tipo de material
PERFORM plants_abroad_get_net_ind(sapltax1) USING lv_xwia
ls_t005-kalsm
ls_taxcom-mwskz
CHANGING ls_txctl-xmwsn
ls_txctl-xskfn.
*------- Kommunikationsbereiche fllen -------------------------------*
CLEAR ls_komk.
ls_komk-mandt = sy-mandt. "Mandante
ls_komk-kappl = 'TX'. "Aplicao
ls_komk-waerk = ls_taxcom-waers. "Moeda do documento SD
ls_komk-aland = ls_taxcom-land1. "Pas fornecedor
ls_komk-mwskz = ls_taxcom-mwskz. "Cdigo do IVA
ls_komk-kunnr = ls_taxcom-kunnr. "Emissor da ordem
ls_komk-lifnr = ls_taxcom-lifnr. "N conta do fornecedor
ls_komk-llief = ls_taxcom-llief. "Fornecedor para a remessa
ls_komk-ekorg = ls_taxcom-ekorg. "Organizao de compras
ls_komk-gsber = ls_taxcom-gsber. "Diviso
ls_komk-bukrs = ls_t001-bukrs. "Empresa
ls_komk-hwaer = ls_t001-waers. "Moeda interna
ls_komk-kalsm = ls_t005-kalsm. "Esquema (determinao preo, mensagens,
determ.contas, ...)
IF ls_komk-aland IS INITIAL.
ls_komk-aland = ls_t001-land1. "Pas fornecedor
ENDIF.
IF ls_t001-xstdt = 'X' AND NOT ls_taxcom-bldat IS INITIAL.
ls_komk-prsdt = ls_taxcom-bldat. "Data para determinao de preo e cmbio
de moeda
ELSE.
ls_komk-prsdt = ls_taxcom-budat. "Data para determinao de preo e cmbio
de moeda
ENDIF.
* Carregar dados do item para condies
CLEAR ls_komp.
ls_komp-kposn = ls_taxcom-kposn. "N item ao qual se aplicam as condies
ls_komp-mwskz = ls_taxcom-mwskz. "Cdigo do IVA
ls_komp-matnr = ls_taxcom-matnr. "N do material
ls_komp-werks = ls_taxcom-werks. "Centro
ls_komp-bwtar = ls_taxcom-bwtar. "Tipo de avaliao
ls_komp-matkl = ls_taxcom-matkl. "Grupo de mercadorias
ls_komp-meins = ls_taxcom-meins. "Unidade de medida bsica
ls_komp-mglme = ls_taxcom-mglme. "Quantidade
ls_komp-mtart = ls_taxcom-mtart. "Tipo de material
ls_komp-evrtn = ls_taxcom-ebeln. "N do documento de compras
ls_komp-evrtp = ls_taxcom-ebelp. "N item do documento de compra
ls_komk-projk = ls_taxcom-projk. "Elemento do plano da estrutura do
projeto (elemento PEP)
ls_komk-prctr = ls_taxcom-prctr. "Centro de lucro
ls_komk-aufnr = ls_taxcom-aufnr. "N ordem
ls_komk-kostl = ls_taxcom-kostl. "Centro de custo responsvel
ls_komk-kokrs = ls_taxcom-kokrs. "rea de contabilidade de custos
ls_komk-blart = ls_taxcom-blart. "Tipo de documento
*------- MWSKZ prfen ------------------------------------------------*
CALL FUNCTION 'TAX_INDICATOR_CHECK'
EXPORTING
steuerschema = ls_komk-kalsm
steuerkennzeichen = ls_taxcom-mwskz
IMPORTING
t007a = ls_t007a
EXCEPTIONS "N1427028
not_valid = 4. "N1427028
* begin of note N1427028
IF sy-subrc = 4.
* MESSAGE e704 WITH ls_taxcom-mwskz ls_komk-kalsm
* RAISING mwskz_not_valid.
ENDIF.
IF NOT ls_taxcom-txjcd IS INITIAL. "1595604
* ------- Check Jurisdiction Data ------------------------------------*
CALL FUNCTION 'FI_TAX_CHK_JURISDICTION_IS_OK'
EXPORTING
i_kalsm = ls_komk-kalsm
i_ttxd = ls_ttxd
i_txjcd = ls_taxcom-txjcd
i_bukrs = ls_taxcom-bukrs
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0. "Invalid
ENDIF.
* end of note N1427028
ENDIF. "1595604
lt_mwstab-egrkz = ls_t007a-egrkz.
*------- US-Taxes ? --------------------------------------------------*
IF ls_ttxd-kalsm NE space.
ls_komk-txjcd = ls_taxcom-txjcd. "Domiclio fiscal
ELSE.
ls_taxcom-txjcd = space. "Domiclio fiscal
ENDIF.
*------- Steuerbasis netto ? -----------------------------------------*
IF ls_txctl-xmwsn NE space.
IF NOT ls_taxcom-wskto IS INITIAL.
lv_skonto = ls_taxcom-wskto.
ELSEIF NOT ls_taxcom-skfbt IS INITIAL.
lv_skonto = ls_taxcom-skfbt * ls_taxcom-zbd1p / 100000.
ELSE.
lv_skonto = ls_taxcom-wrbtr * ls_taxcom-zbd1p / 100000.
ENDIF.
ENDIF.
* Calcular o valor total do pedido
IF ls_taxcom-mwart NE space.
ls_komp-wrbtr = ls_taxcom-wrbtr. "Montante em moeda do documento
ELSE.
* Calcular o valor total do pedido
PERFORM komp-wrbtr_setzen(sapltax1) USING lv_skonto
ls_taxcom
' '
CHANGING ls_komp-wrbtr.
ENDIF.
*------- Steuer rechnen ----------------------------------------------*
* Add country-specific data to komk and komp
IF wa_exit_ref IS BOUND.
CALL METHOD wa_exit_ref->fill_komk_komp
EXPORTING
flt_val = ls_t005-intca
CHANGING
ch_komk = ls_komk
ch_komp = ls_komp.
ENDIF. " wa_exit_ref IS BOUND.
* Executar a pricing para calcular o valor do imposto
CLEAR lt_komv[].
CALL FUNCTION 'PRICING'
EXPORTING
comm_head_i = ls_komk
comm_item_i = ls_komp
calculation_type = 'B'
IMPORTING
comm_head_e = ls_komk
comm_item_e = ls_komp
TABLES
tkomv = lt_komv.
ENDIF. " ls_ekpo-mwskz NE space.
* Valor total do pedido (Valor Lquido + Impostos)
lv_gnetw = ls_komp-mwsbp + ls_komp-netwr + lv_gnetw.
ENDLOOP. " AT lt_ekpo INTO ls_ekpo.
* Carretgar o valor total do pedido
e_cekko-gnetw = lv_gnetw.
ENDIF. "( sy-ucomm EQ 'MESAVE' OR
* sy-ucomm EQ 'BU' OR
* sy-ucomm EQ 'PICK' ) AND
* ( sy-tcode = 'ME21N' OR
* sy-tcode = 'ME22N' OR
* sy-tcode = 'ME23N' ).