Te copio todo el codigo para fastreport , este mismo me funciona con ADO , el problema que tengo con la relacion de tablas uso cuatro. en PROCEDURE DETE_PROD es donde tengo el problema
La relacion entre tablas sewria oQry:planta , oQry:codprod , oQry:verprod este es el problema que tengo
Code: Select all
cSelect := "SELECT A1.codcia,A1.tipdoc,A1.codprov,A1.codprod,A1.verprod,A1.consec,A1.simbolo,A1.referencia "+;
" FROM product AS A1 ORDER BY A1.codprov ASC, A1.codprod ASC, A1.verprod ASC "
oDbf := oApp:oServer:Query(cSelect)
cSelect := "SELECT A1.codcia,A1.planta,A1.codprod,A1.verprod,A1.tippro,A1.hor_cor,A1.hor_ali,A1.mts_min "+;
" FROM prodtiem AS A1 ORDER BY A1.planta ASC,A1.codprod ASC,A1.verprod ASC, A1.tippro ASC "
oDbf01:= oApp:oServer:Query(cSelect)
cSelect := "SELECT A1.codcia,A1.tipdoc,A1.planta,A1.codprov,A1.codprod,A1.verprod,A2.tippro,A2.mezc,A2.codmat,A2.tipo "+;
"FROM product AS A1 ORDER BY A1.planta ASC,A1.codprod ASC,A2.mezc ASC "
oDbf02 := oApp:oServer:Query(cSelect)
cSelect:= "SELECT A1.codcia,A1.tipdoc,A1.planta,A1.numorden,A1.codprod,A1.verprod,A1.codprov,A1.consec,A1.ordcom,"+;
"A21.nombre AS nombre_tipped,A22.nombre AS nombre_gmat1,A23.nombre AS nombre_mat1,A23.nombre1 AS nombre_mat2c "+;
"FROM pedidos AS A1 "+;
oDbf03 := oApp:oServer:Query(cSelect)
oFrP := frReportManager():new()
aBlock := {|| DETE_PROD( oDbf, oDbf01, oDbf02, oDbf03 ) }
MAKEDATASET( oFrP, "Productos", oDbf,aBlock )
MAKEDATASET( oFrP, "Materiales", oDbf01) //, bBlock
MAKEDATASET( oFrP, "Tiempos", oDbf02 )
MAKEDATASET( oFrP, "Historia", oDbf03)
def_Varfastr(oFrP,::DGRUPO,"rep_pxp050_1a")
def_Desigfasr(oFrP)
*-------
Static Function def_Varfastr(oFrP,DGRUPO,LMOD)
with object oFrP
:LoadLangRes( "Spanish.xml" )
:SetIcon(9001)
:AddVariable( "EMPRESA", "NOMBRE", "'"+oApp:x_NOMEMP+"'" )
:AddVariable( "EMPRESA", "SINONIMO", "'"+oApp:x_SIGLA+"'" )
:AddVariable( "EMPRESA", "DIRECCION", "'"+oApp:x_DIREMP+"'" )
:AddVariable( "EMPRESA", "CIUDAD", "'"+oApp:x_CIUEMP+"'" )
:AddVariable( "EMPRESA", "DEPTO", "'"+oApp:x_DEPEMP+"'" )
End
Return Nil
//--------------------------------------------//
function mysqlfield1( oQry ) // coloca las colunas separada por ; Eje codprov;nombre,ciud
Local clField := ""
local nLen, x
nLen := oQry:FCount()
for x := 1 to oQry:FCount()
cLfield := cLfield + oQry:FieldName( x ) + iif( x < nLen ,";","" )
Next
Return cLfield
//--------------------------------------------------------------------------/
PROCEDURE MAKEDATASET( oFr, cAlias, oQry, bRelation )
*--
LOCAL nHeader
LOCAL cHeader := ''
*--
DEFAULT bRelation := { || NIL }
*--
cHeader := mysqlfield1( oQry )
oFr:SetUserDataSet(cAlias, cHeader,;
{||oQry:Skip(), EVAL( bRelation ) },;
{||oQry:Skip(-1), EVAL( bRelation ) }, ;
{||oQry:GoTop(), EVAL( bRelation ) }, ;
{||oQry:EOF() },;
{| cField | bs_mostda12(oQry,cField," "," ") } )
*--
RETURN
******************************************************************************************
STATIC PROCEDURE DETE_PROD( oQry, oQry1, oQry2, oQry3 ) // aVar )
*--
LOCAL cFiltro,cSele12
If ! oQry:Eof()
cFiltro := " planta = '"+alltrim(oQry:planta)+"' "
cFiltro += " AND codprod = '"+alltrim(oQry:codprod)+"' "
cFiltro += " AND verprod = "+alltrim(str(oQry:verprod))
If ! oQry1:Eof() > 0
oQry1:SetWhere( cFiltro, .T. )
Endif
If ! oQry2:Eof() > 0
oQry2:SetWhere( cFiltro, .T. )
Endif
If ! oQry3:Eof() > 0
oQry3:SetWhere( cFiltro, .T. )
Endif
Else
Endif
RETURN
*--