_reportpreview = "D:\ROA_RB\ROAGEST\reportpreview.app"

SET PROCEDURE TO d:\roa_rb\roagest\comun\programe\oproceduri_comune.prg ADDITIVE 
x = SQLCONNECT("roa_romfast2","wert","123")
lcSql = [SELECT GROUPING_ID(NRORD, DENUMIRE) AS GID, ] + ;
[ NRORD, ] + ;
[ DENUMIRE, ] + ;
[ SUM(cante) as Iesiri, ] + ;
[ SUM(cante * pret) as Valoare_iesiri_ach_ ] + ;
[  FROM vrul ] + ;
[ WHERE (AN * 12 + LUNA BETWEEN 24085 AND 24089) ] + ;
[   AND ((CANTE > 0 AND ID_TIP_RULAJ = 0)) ] + ;
[ GROUP BY ROLLUP(NRORD, DENUMIRE) ] + ;
[ ORDER BY NRORD, DENUMIRE, GID, NRORD, DENUMIRE ]
lnSucces = SQLEXEC(x, lcSql, "crsRul")
IF lnSucces < 0
	AERROR(ERR)
	MESSAGEBOX(ERR(3))
ENDIF 	
SQLDISCONNECT(x)
IF USED('CRSRUL')
	SELECT IIF(GID > 0, "TOTAL", SPACE(5)) AS EXPLICATIE, * FROM CRSRUL INTO CURSOR CRSRAPORT
ENDIF 
PCTITLU = ""
PCSUBTITLU = ""
GCANTET = ""
GCCOPYRIGHT = ""
GNPA = 2
GNPCANT = 3
PCDATAORA = TRANSFORM(DATETIME())
loListener  = NEWOBJECT('EffectsListener', 'd:\roa_rb\roagest\comun\programe\reports\dynamicformatting.prg')
loListener.OUTPUTTYPE = 1
REPORT FORM "d:\roa_rb\roagest\rapoarte\rap_rul_consum_lucrari.frx" OBJECT loListener

