$set mfoo
class-id. ECF.
environment division.
input-output section.
*
object section.
class-control.
Util is class "Util"
.
special-names.
call-convention 2 is DSDLL.
*>----------------------------------------------------------------
data division.
file section.
*
working-storage section. *> Definition of global data
77 cmdstatus pic s9 comp-5.
77 cmdstatus-r pic s9.
*Crio um ponteiro
*-----variaveis do ecf --------
*variavel utilizada para carregar a DLL na memoria
01 SAT-Tanca usage is procedure-pointer.
*>----------------------------------------------------------------
class-object. *> Definition of class data and methods
*>----------------------------------------------------------------
object-storage section.
*>----------------------------------------------------------------
*> Poe Nulo no final
*>----------------------------------------------------------------
method-id. "PoeNulo".
01 i Pic X(4) comp-5.
01 j Pic X(4) comp-5.
linkage section.
77 zSTR pic x(256).
procedure division using zSTR. *> by value i.
MOVE LENGTH OF zStr TO j
perform varying i from j by -1 until i = 0
if zSTR(i:1) not = space and x"0"
add 1 to i
move x"0" to zSTR(i:1)
exit method
end-if
end-perform.
exit method.
end method "PoeNulo".
*>----------------------------------------------------------------
*>----------------------------------------------------------------
*> I N I C I O D A S R O T I N A S
*> SAT-CFe
*>----------------------------------------------------------------
*>----------------------------------------------------------------
method-id. "SATEnviarCFe".
local-storage section.
01 WS-NRO-OFI pic x(006).
01 RZ-INFADCONTRIB pic x(008).
01 retorno pic x(008).
01 codigoDeAtivacao pic x(009).
01 DataBlock-Pointer usage pointer.
01 w-campos-ret.
03 w-campo1 pic x(256).
03 w-campo2 pic x(256).
03 w-campo3 pic x(256).
03 w-campo4 pic x(256).
03 w-campo5 pic x(256).
03 w-campo6 pic x(256).
linkage section.
01 lnk-datahoraimp.
03 lnk-dataimp pic x(006).
03 lnk-horaimp pic x(006).
01 lnk-erro.
02 lnk-fs pic x(002).
02 lnk-mensagem pic x(040).
01 VDA-DATA-BLOCK.
05 VDA-IO-TEXT-BUFFER2 PIC X(256).
procedure division.
*>Seto essa variável para cada um dos sat.
set SAT-Tanca to entry "SAT.dll".
move "000001" to ws-nro-ofi
move z"12345678" to rz-infadcontrib codigoDeAtivacao
CALL DSDLL "ConsultarStatusOperacional" using
ws-Nro-ofi
by reference codigoDeAtivacao
returning DataBlock-Pointer
*>Ai pego o retorno
set address of VDA-DATA-BLOCK to DataBlock-Pointer
perform trata-retorno
move spaces to VDA-IO-TEXT-BUFFER2
exit method.
processos-ok.
CALL DSDLL "ConsultarSAT" using WS-Nro-ofi
returning DataBlock-Pointer
set address of VDA-DATA-BLOCK to DataBlock-Pointer
perform trata-retorno
move spaces to VDA-IO-TEXT-BUFFER2
CANCEL "ConsultarSAT"
exit method.
trata-retorno.
unstring VDA-IO-TEXT-BUFFER2
delimited by "|" into w-campo1
w-campo2
w-campo3
w-campo4
w-campo5
w-campo6
end method "SATEnviarCFe".
end class-object.