{ ------------------------------------------------------------------------------- PROGRAMA : VEPRCS102 OBJETIVO : Consulta Ventas de Productos por Vendedor, Tipo de Venta y Fecha PROGRAMADOR : Lic. Abner Montalvo Zapata FECHA REALIZACION : Febrero 3, 1993 ------------------------------------------------------------------------------- } GLOBALS "veprgb000.4gl" FUNCTION veprcs102() # WHENEVER ERROR CONTINUE CLEAR SCREEN OPTIONS FORM LINE 8, ERROR LINE 23, COMMENT LINE 21 OPEN FORM vefmcs102 FROM "vefmcs102" DISPLAY FORM vefmcs102 CALL PANTALLA() DISPLAY "veprcs102" AT 4,3 DISPLAY "Ventas Por Vendedor y Tipo de Venta" AT 6,22 DISPLAY " Continua Consultando " AT 8,5 ATTRIBUTE (YELLOW,REVERSE) DISPLAY " Cancela Operacion " AT 8,50 ATTRIBUTE (YELLOW,REVERSE) LABEL volver: LET selec = NULL LET criterio = NULL LET fact_gral.sec_vend = null LET fact_gral.ventas = null LET rango.fech_in = null LET rango.fech_fi = null INPUT BY NAME fact_gral.sec_vend, fact_gral.ventas,rango.* ON KEY (CONTROL-W) CASE WHEN INFIELD (sec_vend) CALL consulta_empleados() IF int_flag THEN LET numero_msg = 2 CALL msg(numero_msg) NEXT FIELD sec_vend END IF IF NOT int_flag THEN LET fact_gral.sec_vend = transportista.sec_transp DISPLAY transportista.sec_transp TO sec_vend DISPLAY descrip6 TO descrip6 NEXT FIELD ventas END IF LET int_flag = FALSE END CASE AFTER FIELD sec_vend IF fact_gral.sec_vend = 0 or fact_gral.sec_vend is null THEN LET numero_msg = 16 CALL msg(numero_msg) NEXT FIELD sec_vend ELSE SELECT i.nom1_emp,i.apell1_emp INTO descrip1, descrip2 FROM adtb00003 i WHERE i.num_emp = fact_gral.sec_vend AND i.status_t is null IF status >= 0 THEN IF status = NOTFOUND THEN LET numero_msg = 68 CALL msg(numero_msg) NEXT FIELD sec_vend END IF LET descrip6 = descrip1 clipped," ",descrip2 clipped DISPLAY descrip6 TO descrip6 ELSE CALL integridad() IF bandera = 1 THEN LET bandera = 0 RETURN END IF END IF END IF AFTER FIELD ventas IF fact_gral.ventas IS NULL THEN LET numero_msg = 16 CALL msg(numero_msg) NEXT FIELD ventas END IF BEFORE FIELD fech_in LET rango.fech_in = today AFTER FIELD fech_in IF rango.fech_in IS NULL THEN LET numero_msg = 16 CALL msg(numero_msg) NEXT FIELD fech_in END IF BEFORE FIELD fech_fi LET rango.fech_fi = today AFTER FIELD fech_fi IF rango.fech_fi IS NULL THEN LET numero_msg = 16 CALL msg(numero_msg) NEXT FIELD fech_fi END IF IF rango.fech_in > rango.fech_fi THEN LET numero_msg = 86 CALL msg(numero_msg) NEXT FIELD fech_fi END IF AFTER INPUT IF int_flag THEN LET numero_msg = 2 CALL msg(numero_msg) LET int_flag = FALSE RETURN END IF IF fact_gral.sec_vend = 0 or fact_gral.sec_vend is null THEN LET numero_msg = 16 CALL msg(numero_msg) NEXT FIELD sec_vend ELSE SELECT i.nom1_emp,i.apell1_emp INTO descrip1, descrip2 FROM adtb00003 i WHERE i.num_emp = fact_gral.sec_vend AND i.status_t is null IF status >= 0 THEN IF status = NOTFOUND THEN LET numero_msg = 68 CALL msg(numero_msg) NEXT FIELD sec_vend END IF LET descrip6 = descrip1 clipped," ",descrip2 clipped DISPLAY descrip6 TO descrip6 ELSE CALL integridad() IF bandera = 1 THEN LET bandera = 0 RETURN END IF END IF END IF IF fact_gral.ventas IS NULL THEN LET numero_msg = 16 CALL msg(numero_msg) NEXT FIELD ventas END IF IF rango.fech_in IS NULL THEN LET numero_msg = 16 CALL msg(numero_msg) NEXT FIELD fech_in END IF IF rango.fech_in IS NULL THEN LET numero_msg = 16 CALL msg(numero_msg) NEXT FIELD fech_fi END IF IF rango.fech_in > rango.fech_fi THEN LET numero_msg = 86 CALL msg(numero_msg) NEXT FIELD fech_fi END IF EXIT INPUT END INPUT ## Seleccion de los campos que el usuario debe ver en la pantalla LET selec = "SELECT 'l', a.cod_n, a.cod_grupo, a.cod_tipo, a.cod_sec,c.descrip_esp, ", " SUM(a.cantidad-a.cantidad_2),SUM((a.cantidad-a.cantidad_2)*a.precio) ", "FROM vetb00003 a, vetb00002 b, iptb00002 c ", "WHERE a.factura=b.factura and b.ventas=? and b.fecha_factura between ? and ?", " and b.sec_vend = ? and a.cod_n=c.cod_n and a.cod_grupo=c.cod_grupo and ", " a.cod_tipo = c.cod_tipo and a.cod_sec = c.cod_sec and ", " a.status_t is null and b.status_t is null and c.status_t is null ", "GROUP BY 1,2,3,4,5,6 ORDER BY 2,3,4,5" DISPLAY "Buscando Informacion ... Espere Por Favor" AT 21,1 ATTRIBUTE(YELLOW) PREPARE busca FROM selec DECLARE accion CURSOR FOR busca OPEN accion using fact_gral.ventas, rango.fech_in, rango.fech_fi, fact_gral.sec_vend LET idx = 1 LET unidades = 0 LET valor_orig = 0 LET identifica = "N" WHILE STATUS != NOTFOUND FETCH accion INTO reg_ventas2.* IF STATUS = NOTFOUND THEN IF idx = 1 THEN LET numero_msg = 3 CALL msg(numero_msg) LET int_flag = FALSE GOTO volver END IF LET identifica = "S" END IF IF identifica = "N" THEN LET arr_ventas2[idx].codigo1 =reg_ventas2.cod_n2 using "&","-", reg_ventas2.cod_grupo2 using "&","-", reg_ventas2.cod_tipo2 using "&&","-", reg_ventas2.cod_sec2 using "&&&" LET arr_ventas2[idx].descrip1 = reg_ventas2.descrip2 LET arr_ventas2[idx].unidades1 = reg_ventas2.unidades2 using "##,###,###.###" LET arr_ventas2[idx].valor1 = reg_ventas2.valor2 using "###,###,##&.&&" LET unidades = unidades + reg_ventas2.unidades2 LET valor_orig = valor_orig + reg_ventas2.valor2 LET idx = idx + 1 END IF IF identifica = "S" THEN LET arr_ventas2[idx].codigo1 = null LET arr_ventas2[idx].descrip1 = null LET arr_ventas2[idx].unidades1 = null LET arr_ventas2[idx].valor1 = null LET arr_ventas2[idx].codigo1 = null LET arr_ventas2[idx].descrip1 = " Total General" LET arr_ventas2[idx].unidades1 = unidades using "##,###,###.###" LET arr_ventas2[idx].valor1 = valor_orig using "###,###,##&.&&" LET idx = idx + 1 EXIT WHILE END IF # Se incrementa el idx en uno para que cuando se llame la funcion set_count # traiga exactamente el total de elementos del array y no todos menos uno. END WHILE DISPLAY " " AT 21,1 CALL set_count (idx-1) DISPLAY ARRAY arr_ventas2 TO cs_102.* ## Verifica si el usuario presiono la tecla IF int_flag THEN LET numero_msg = 2 CALL msg(numero_msg) LET int_flag = FALSE RETURN ELSE CLEAR FORM GOTO volver END IF END FUNCTION