ALIAS SF_FATF
VARIAVEL Znil = DbGoto(z_Recno)
VARIAVEL #TEXTO_FONTE
   Private zSelect0:=Select(), zFornClosed, zProdClosed, zMoveClosed, zDupsClosed, zPfFor:=PfFor, zNf:=PfNum, wCpNumPed:=StrZero(Sf_Fatf->PfNum,10),zPrUnit,zPrVenda,zMargem,zMarkup,m_fobs, nRow, ztValProds:=0,ztQtdPrd:=0,ztQtdUnids:=0,ztPrCusto:=0,ztPrVenda:=0, zPfVal:=Sf_Fatf->PfVal, zPcod

   SetAliasAaMm( SubStr( Dtos(pfdatache),3,4) )

   se (zMoveClosed:=(Select('se_mov')=0))  entao Abra('0NOIDX',r_siga,wSe_Mov,'se_mov',wSe_Mov_F,'mfnum')
   se (zDupsClosed:=(Select('sccpped')=0)) entao Abra("0NOIDX",r_siga,"SCCPPED","SCCPPED","SCCPNPF","CP_NUM_PED")
   se (zFornClosed:=(Select('sccpfor')=0)) entao Abra('0NOIDX',r_siga,'SCCPFOR','SCCPFOR')
   se (zProdClosed:=(select('se_prod')=0)) entao Abra('0NOIDX',r_siga,se_prod,'se_prod',seip_c,'pcod')
   SccpFor->(DbGoto( zPfFor ))
   
   DbSelectArea(zSelect0)
   
   debugalert('0 nfe05.lst  zMoveClosed='+hb_valtoexp(zMoveClosed)+'  zDupsClosed='+hb_valtoexp(zDupsClosed)+'  zFornClosed='+hb_valtoexp(zFornClosed)+'  zProdClosed='+hb_valtoexp(zProdClosed) )

   oLst:cAlias_DataCols := 'itens'
   oLst:cAliasMaster := 'itens'
   oLst:lPrtRodape := .f.
   oLst:lPortrait := .t.

   oLst:Cab1( "NOTA DE ENTRADA "+StrZero(zNf,10) )
   oLst:Cab4("")
   oLst:Cab2( "Forn "+lTrim(Str(PfFor,10))+"- "+Alltrim(sccpfor->cp_fantasi) )
   oLst:Cab4( "Chegada em "+Dtoc(pfDataChe),"Impressao em "+Dtoc(s_datual)+" as "+Time() )
   oLst:Cab4("")

   oLst:AddCol('Prod;pCod;N;999999;6;;')
   oLst:AddCol('Descricao;SE_PROD->pDesc;P;@S35;35;;')
   oLst:AddCol('Quant;mQuant;N;999999.99;9;;')
   oLst:AddCol('PrCmpUnit;mValor/mQuant;P;@E 99,999.99;9;;')
   oLst:AddCol('PrCompra;mValor;N;@E 99,999.99;9;;')
   oLst:AddCol('Gp;SE_PROD->PGPRECO;P;XX;2;;')
   oLst:AddCol('Margem;zMargem;P;@E 9999.99%;8;;')
   oLst:AddCol('Markup;zMarkup;P;@E 9999.99%;8;;')
   oLst:AddCol('PrVndUnit;Se_Prod->pVluVenda;P;@E 99,999.99;9;;')
   oLst:AddCol('Cfop;pCfop;C;99999;5;S;')
   oLst:AddCol('NCM;se_prod->pcodclafis;N;99999999;8;N;')
   // oLst:AddCol('CodBarra;se_prod->pdic6;N;99999999999999;14;N;')
   oLst:AddCol('CF;se_prod->pcategoria;C;XXX;3;N;')
   oLst:AddCol('UN;se_prod->punidade;C;XXX;3;N;')
   // oLst:AddCol('MkupGp;zMarkup;P;@E 999.99%;7;;')

   oLst:AddRodape( '_LINHA_FINA_', "", {|| "Pagina "+Str(pag++,4)+" "} )

   // oLst:PrtD( {"style"=>"font:Helvetica-BoldOblique#size:12#ncolor:99#width:80#bgfill:SombraEscuraComBorda", "COLS"=>"0,C"}, 'Dados do Emitente')
   oLst:PrtD( 'Fornecedor: '+strzero(zPfFor,6)+'- '+Alltrim(sccpfor->cp_nome) )
   oLst:PrtD( 'CNPJ: '+AllTrim(sccpfor->CP_CGC), 'RG.IE: '+AllTrim(SccpFor->cp_INSC_ES), 'Fone:'+AllTrim(SccpFor->cp_fone))
   oLst:PrtD( 'Email: '+AllTrim(SccpFor->cp_email),'Fax/Celular:'+AllTrim(SccpFor->cp_fax))
   oLst:PrtD( 'Endereco: '+SccpFor->(AllTrim(cp_rua)+' '+AllTrim(cp_numrua)+' '+AllTrim(cp_bairro)+' '+AllTrim(cp_cep)) )
   if sccpped->(DBSEEK( wCpNumPed ))
      oLst:PrtD( '_LINHA_GROSSA_' )
      oLst:PrtD( {"style"=>"font:Helvetica-BoldOblique"}, 'Parcela       Vencto' ,'Valor' )
      DbSelectArea('sccpped')      
      do while .not. eof() .and. left(cp_num_ped,10) = wCpNumPed
         if cp_cod_for=zPfFor 
            oLst:PrtD( {"style"=>"font:Helvetica-BoldOblique"}, alltrim(cp_num_ped)+' '+Dtoc(cp_dt_venc) , Transform(cp_valor,"@E 99999,999.99"))
         endif
         skip
      enddo
   endif
   oLst:PrtD( '' )
   
   oLst:PrtD( {"style"=>"font:Helvetica-BoldOblique#size:9#ncolor:99#width:80#bgfill:SombraEscuraComBorda", "COLS"=>"0,C"}, 'ITENS DO PEDIDO')
   oLst:PrtD( {"style"=>"font:Courier-Oblique"}, '_CABCOLS_')

   debugalert('1 imprimira itens vendidos na cupom.lst ')
   
   Se_Mov->( DbCreate('mem:_mov', (vStruct:=DbStruct(), aAdd(vStruct,{"PDESC","C",35,0}), vStruct) ) )
   use ('mem:_mov') new exclusive
   se_mov->( DbSeeK(zNf), DbEval({|| hReg:=Scatter(), hReg['PDESC']:=se_prod->pDesc, _mov->(AppendBlank(),Gather(@hReg)) },{||mQuant>0.And.mFgEs='E'.And.mCodForC=zPfFor.And.Se_Prod->(DbSeek(se_mov->pCod))},{||znf=mFnum}) )
   index on pdesc to ('mem:_mov')
   
   //DbSelectArea('se_mov')
   //DbSeek(zNf)
   
   do while .not. eof() .and. znf=mFnum 
      zPcod := pCod
      if mQuant > 0 .and. se_prod->(DbSeek(zPcod))
         zPrUnit := MVALOR/MQUANT
         zPrVenda := SE_PROD->PVLUVENDA
         zMargem := IF(zPrVenda>0, (zPrVenda-zPrUnit)/zPrVenda*100, 0)
         zMarkup := IF(zPrUnit>0, zPrVenda/zPrUnit*100 - 100, 0)
         oLst:PrtD( '_DATACOLS_')
         ztValProds += mValor
         ztPrVenda += mQuant * zPrVenda
         ztPrCusto += mValor
         ++ztQtdPrd
         ztQtdUnids += mQuant
      endif
      DbSkip()
   enddo
   
   _mov->(DbCloseArea())
   DbDrop('mem:_mov')

   DbSelectArea(zSelect0)

   zMargem := IF(ztPrVenda>0, (ztPrVenda-zPfVal)/ztPrVenda*100, 0)
   zMarkup := IF(ztPrCusto>0, ztPrVenda/ztPrCusto*100-100, 0)

   nRow := 0
   m_fobs:=AllTrim(Sf_Fatf->PfObs)
   do while ++nRow <= mlCount(m_fobs, 60)
      oLst:PrtD( {"style"=>"font:Courier-Oblique#size:8#col:0#row:(oPdf:pRow+1)"}, Rtrim(memoline(m_fobs,60,nRow)) )
   enddo

   oLst:PrtD( '_LINHA_GROSSA_' )
   oLst:xPrtD('** Prods:[ztQtdPrd 9999]   Total_da_NF:[zPfVal 999,999.99]   Pr_Custo:[ztPrCusto 999,999.99]   Margem_NF:[zMargem 999.99]%')
   oLst:xPrtD('** Unids:[ztQtdUnids 9999]   ICM_Retido.:[Sf_Fatf->PfValRet 999,999.99]   Pr_Venda:[ztPrVenda 999,999.99]   Markup_NF:[zMarkup 999.99]%')

   //oLst:PrtD( ztValProds>0, {"style"=>"font:Helvetica-Oblique#col:40#row:(oPdf:nLinesPorPagina-6)"}, " ","Vl.Produtos: "+   Transform(ztValProds ,"@E 99,999,999,999.99") )
   //oLst:PrtD( zTotServicos >0,  {"style"=>"font:Helvetica-Oblique#col:30#row:(oPdf:pRow+1)"},            " ","Vl.Servicos: "+   Transform(zTotServicos   ,"@E 99,999,999,999.99") )
   // oLst:PrtD( zTotDevolucoes>0, {"style"=>"font:Helvetica-Oblique#col:40#row:(oPdf:pRow+1)"},            " ","Vl.Devolucoes: "+ Transform(zTotDevolucoes ,"@E 99,999,999,999.99") )

   //oLst:PrtD( m_fDesconto>0, {"style"=>"font:Helvetica-Oblique#col:40#row:(oPdf:pRow+1)"}, " ","Descontos: "+ Transform(m_fDesconto,"@E 99,999,999,999.99") )
   //oLst:PrtD( m_fValDev>0,   {"style"=>"font:Helvetica-Oblique#col:40#row:(oPdf:pRow+1)"}, " ","Creditos: "+ Transform(m_fValDev,"@E 99,999,999,999.99") )
   //oLst:PrtD( {"style"=>"font:Helvetica-Oblique#col:40#row:(oPdf:nLinesPorPagina-2)"}, " ","VALOR: "+ Transform(m_fVal,"@E 99,999,999,999.99") )

   se zMoveClosed entao se_mov->(DbCloseArea())
   se zDupsClosed entao sccpped->(DbCloseArea())
   se zFornClosed entao sccpfor->(DbCloseArea())
   se zProdClosed entao se_prod->(DbCloseArea())
   debugalert('11 vai renderizar cupom.lst ')
   
   oLst:Run()
   oLst:End()
#FIM_TEXTO_FONTE
comando antes DbGoBottom()