MAIN DEFINE iconteo RECORD cod_n SMALLINT, cod_grupo SMALLINT, cod_tipo SMALLINT, cod_Sec SMALLINT, descripcion CHAR(40), unidad_med CHAR(4), fisico DEC(12,4), teorico DEC(12,4), diferencia DEC(12,4), costo DEC(12,4), valor1 DEC(12,4), valor2 DEC(12,4), usuario CHAR(40), fechacrea DATETIME YEAR TO MINUTE END RECORD, pnombre_cia CHAR(30) DEFINE handler om.SaxDocumentHandler, -- return value from fgl_report_commitCurrentSettings() r_filename STRING, -- filename of Report Design Document including .4rp extension r_output STRING, -- output format option preview INTEGER -- TRUE/FALSE, to set preview option DEFER INTERRUPT --pregunta al usuario por la salida del reporte CALL selectOutput() RETURNING r_filename, r_output, preview -- configure report engine; the functions prefixed fgl that are called here are part of the GRW API IF fgl_report_loadCurrentSettings(r_filename) THEN -- load the .4rp file CALL fgl_report_selectDevice(r_output) -- changing default CALL fgl_report_selectPreview(preview) -- changing default LET handler = fgl_report_commitCurrentSettings() -- commit changes ELSE EXIT PROGRAM END IF --run the report IF handler IS NOT NULL THEN -- report engine was configured ok START REPORT imprime TO "archivo" CONNECT TO "smarmotech" USER "jsoto" USING "lmmjvsd2009" LET pnombre_Cia = "M A R M O T E C H, S. A." # ESTO LO TENGO EN UNA TABLA, LA IGUALE AL VALOR PARA NO PASARTE ESTA ESTRUCTURA DECLARE busca_conteo CURSOR FOR SELECT b.cod_n,b.cod_grupo,b.cod_tipo,b.cod_sec,b.descrip_esp,b.unidad_med,a.cantidad,'0','0','0','0','0',a.us_crea,a.fech_crea FROM irtb00002 AS b LEFT OUTER JOIN irtb00011 AS a ON a.cod_n = b.cod_n AND a.cod_grupo = b.cod_grupo AND a.cod_tipo = b.cod_tipo AND a.cod_Sec = b.cod_Sec AND a.cod_n = 7 and a.cod_grupo = 0 and a.cod_tipo = 0 and a.cod_Sec between 3 and 13 and CAST(a.fecha AS DATE) = '11/18/2009' ORDER by b.cod_n,b.cod_Grupo,b.cod_tipo,b.cod_sec FOREACH busca_conteo INTO iconteo.* OUTPUT TO REPORT imprime(iconteo.*,pnombre_cia) END FOREACH ELSE EXIT PROGRAM END IF END MAIN REPORT imprime(x,nombre_cia) DEFINE x RECORD cod_n SMALLINT, cod_grupo SMALLINT, cod_tipo SMALLINT, cod_Sec SMALLINT, descripcion CHAR(40), unidad_med CHAR(4), fisico DEC(12,4), teorico DEC(12,4), diferencia DEC(12,4), costo DEC(12,4), valor1 DEC(12,4), valor2 DEC(12,4), usuario CHAR(40), fechacrea DATETIME YEAR TO MINUTE END RECORD, nombre_cia CHAR(50), pcodigo CHAR(20), total_general dec(12,2) ORDER EXTERNAL BY nombre_cia FORMAT PAGE HEADER ON EVERY ROW LET pcodigo = x.cod_n USING "&&","-",x.cod_grupo USING "&&&&","-", x.cod_tipo USING "&&&&","-",x.cod_sec USING "&&&&" # LET total_general = total_general + x.valor2 PRINTX pcodigo,x.*,nombre_cia,total_general ON LAST ROW LET total_general = SUM(x.valor2) END REPORT