ALIAS HELP

VARIAVEL zFatTmp := 'mem:_fatnf'
VARIAVEL z_NPed = 0
VARIAVEL zLoja = 0
VARIAVEL zDe := Date()
VARIAVEL zAte := Date()
variavel zAreaOrig := select()

T08,10,14,40,Listar Cancelamentos
T2,2,Data Inicial:,10,zDe,99.99.9999
T3,2,Data Final..:,10,zAte,99.99.9999
T4,2,Loja........:,2,zLoja,99

COMANDO ANTES DbGoBottom()
COMANDO ANTES #TEXTO_FONTE
   private zCodVnd,zNomeVnd, zCrNumPed, zSiCaixa, zCmdsDurante, zfValES

   oLst:Cab1( "Relacao de Pedidos Cancelados")
   oLst:Cab2( "Periodo de "+Dtoc(zDe)+" a "+Dtoc(zAte)+" , em "+dtoc(date())+" as "+time()  )

   oLst:AddCab( '_LINHA_FINA_' )
   oLst:AddCab( '_CABCOLS_' )
   oLst:AddCab( '_LINHA_GROSSA_' )

   oLst:AddCol('Emissao;fdataemi;D;99.99.9999;10;N;')
   oLst:AddCol('Hora;fhora;C;xx:xx;5;N;')
   oLst:AddCol('Pedido;fnumped;N;999999999;9;N;;Direita;NaoSome;Imprima;')
   oLst:AddCol('*;if(fvaldev>0,"*"," ");P;X;1;N;')
   oLst:AddCol('Valor;fVal;N;@E 999,999.99;10;N;;Direita;Some;Imprima;')
   oLst:AddCol('COO;fnumcoo;N;999999;6;N;')
   oLst:AddCol('Cx;zSiCaixa;P;99;2;N;')
   oLst:AddCol('Usu_Canc;fusucanc;C;@S8;8;N;')
   oLst:AddCol('Vendedor;znomeVnd;P;@S20;20;N;')
   oLst:AddCol('Especie;zfValES;P;@E 999,999.99;10;N;;Direita;Some;Imprima;')
   oLst:AddCol('Cheques;fvalch;N;@E 999,999.99;10;N;;Direita;Some;Imprima;')
   oLst:AddCol('Cartao;fvalct;N;@E 999,999.99;10;N;;Direita;Some;Imprima;')
   oLst:AddCol('Convenio;fValcv;N;@E 999,999.99;10;N;;Direita;Some;Imprima;')
   oLst:AddCol('Carne;fValca;N;@E 999,999.99;10;;;Direita;Some;Imprima;')
   oLst:AddCol('Prds;ftotprod;N;9999;4;;;Direita;NaoSome;Imprima;')
   oLst:AddCol('Unds;ftotunid;N;9999;4;;;Direita;NaoSome;Imprima;')

   set(11,"off")

   AgregaFat(@zFatTmp, @zDe, @zAte , {||deleted().and.fdataemi>=zde.and.fdataemi<=zate}, {||deleted().and.fdataemi>=zde.and.fdataemi<=zate} ) 

   Abra ('0NOIDX', r_siga, 'SCCRDUP', 'SCCRDUP', 'SCRID_ND','CR_NUM_PED')
   Abra ('0NOIDX', r_siga, 'sf_vend', 'sf_vend')
   Abra ('0EXCLUSIVENOIDX', '', zFatTmp, '_fatnf')

   BLOCO_TXT zCmdsDurante
         zfValES  := if( (fVal-(fValch+fValct+fValcv+fValca))>0, fVal-(fValch+fValct+fValcv+fValca), 0)
         z_nped   := z_nped + 1
         zCodVnd  := fvendedor
         sf_vend->(DbGoto(zCodVnd))
         zNomeVnd := pad( str(sf_vend->fnumero,4)+" "+left(sf_vend->nome,1)+lower(substr(sf_vend->nome,2)), 30)
         if s_sys_d
            dbSelectArea("sccrdup")
            zSiCaixa   := 'X'
            zCrNumPed  := right(strZero(fnumped,10),6)
            dbSeek(zCrNumPed)
            Do WHILE .not. eof() .and. zCrNumPed=left(cr_num_ped,6)
               IF val(cr_local)=zLoja .and. deleted()
                  zSiCaixa := cr_ha_juro
                  EXIT 
               ENDIF
               dbSkip()
            ENDDO
            dbSelectarea(zAreaOrig)
        else
            zSiCaixa := lTrim(Str(si_caixa,2))
        endif
   ENDTEXT

   oLst:DbEval(zCmdsDurante, {||zLoja=0.or.zLoja=fLoja} )

   _fatnf->(DbCloseArea())
   sccrdup->(DbCloseArea())
   sf_vend->(DbCloseArea())
   DbDrop(zFatTmp)

   oLst:SetFormatSomaCol(1, {||"**TOTAIS"}, .t.)

   oLst:PrtD( '_LINHA_DUPLA_' )
   oLst:PrtD( {"style"=>"font:Courier-BoldOblique"}, '_SOMACOLS_GLOBAL_' )
   oLst:PrtD( '_LINHA_DUPLA_' )
   oLst:PrtD( '** Numero de Pedidos Cancelados: '+Str(z_nped,4) )

   oLst:Run()
   oLst:End()

   Set(11,"on")

#FIM_TEXTO_FONTE
