Escolar Documentos
Profissional Documentos
Cultura Documentos
unction z_interface_00001650.
*"--------------------------------------------------------------------
--
*"*"Interface local:
*" IMPORTING
*" VALUE(I_POSTAB) LIKE RFPOS STRUCTURE RFPOS
*" EXPORTING
*" VALUE(E_POSTAB) LIKE RFPOS STRUCTURE RFPOS
*"--------------------------------------------------------------------
--
*-------------- Initialize Output by using the following line -------
---
* E_POSTAB = I_POSTAB.
e_postab = i_postab.
tables: t074t, skat, kna1, lfa1, lfbk, ska1, bseg.
data: n type i.
clear: t074t, skat, kna1, lfa1, lfbk, ska1, bseg.
* Preenche Descrição do Razão Especial
statics i074t type t074t occurs 0 with header line.
describe table i074t lines n.
if n eq 0 .
select * from t074t into table i074t.
endif.
read table i074t with key spras = sy-langu
koart = i_postab-koart
shbkz = i_postab-umskz.
if sy-subrc = 0.
write i074t-ltext to e_postab-zztext.
else.
* e_postab-zztext = 'Partidas Normais '.
e_postab-zztext = 'Razão Especial'.
endif.
* Preenche Dados de Clientes
if e_postab-koart eq 'D'.
select single * from kna1 into kna1 where
kunnr eq e_postab-konto.
if sy-subrc eq 0.
move kna1-name1 to e_postab-zzname1.
move kna1-ort01 to e_postab-zzort01_gp.
endif.
endif.
* Preenche Dados de Fornecedores
if e_postab-koart eq 'K'.
select single * from lfa1 into lfa1 where
lifnr eq e_postab-konto.
if sy-subrc eq 0.
move lfa1-name1 to e_postab-zzname1.
move lfa1-ort01 to e_postab-zzort01_gp.
endif.
* Preenche dados de cadastro bancário dos fornecedores
select single * from lfbk into lfbk
where lifnr eq e_postab-konto
and bvtyp eq '1'.
if sy-subrc = 0.
move:
lfbk-bankl to e_postab-zzbankl,
lfbk-bankn to e_postab-zzbankn,
lfbk-bkont to e_postab-zzbkont,
lfbk-bvtyp to e_postab-zzbvtyp1.
else.
select single * from lfbk into lfbk
where lifnr eq e_postab-konto.
if sy-subrc = 0.
move:
lfbk-bankl to e_postab-zzbankl,
lfbk-bankn to e_postab-zzbankn,
lfbk-bkont to e_postab-zzbkont,
lfbk-bvtyp to e_postab-zzbvtyp1.
endif.
endif.
endif.
* Preenche Dados de contas contábeis
if e_postab-koart eq 'S'.
select single * from skat into skat where
ktopl eq 'nome do seu plano de conta' and
saknr eq e_postab-konto.
if sy-subrc eq 0.
move skat-txt20 to e_postab-zzname1.
endif.
endif.
* Preenche dados de variação cambial já lançadas na fatura
select single * from bseg into bseg where
bukrs = i_postab-bukrs and
belnr = i_postab-belnr and
gjahr = i_postab-gjahr and
buzei = i_postab-buzei.
if sy-subrc = 0.
e_postab-zzbdiff = bseg-bdiff.
e_postab-zzrdiff = bseg-rdiff.
endif.
* Final
endfunction.