{ =========================================================================== Programa : CTPRMT014 Sistema : Inventario Producto en Proceso Proceso : Factor Costo (Labor) Autor : Tadeo A. Ferreras Fecha : Junio 29, 1993 =========================================================================== } GLOBALS "ctprgb000.4gl" DEFINE mes_ant SMALLINT DEFINE datos_m RECORD cod_n INTEGER, cod_grupo INTEGER, cod_tipo INTEGER, cod_sec INTEGER, mes SMALLINT, ano CHAR(4), cantidad DECIMAL(14,5) END RECORD, descrip CHAR(30), unidad CHAR(15), puntero INTEGER FUNCTION ctprmt014() LET int_flag = FALSE CLEAR SCREEN OPTIONS FORM LINE 9, ERROR LINE 23, COMMENT LINE 21 CALL pantalla() DISPLAY "ctprmt014" AT 4,3 DISPLAY "Inventario Producto en Proceso" AT 6,25 OPEN FORM ctfmmt014 FROM "ctfmmt014" DISPLAY FORM ctfmmt014 MENU "OPCIONES" COMMAND "Adicionar" " Adiciona Registro Cancela Operacion" CLEAR FORM CALL ctadmt014() COMMAND "Consultar-modificar" " Realiza Busqueda Cancela Operacion" CLEAR FORM CALL ctmdmt014() COMMAND "Salir" EXIT MENU END MENU END FUNCTION FUNCTION ctadmt014() LABEL nuevo: INPUT BY NAME datos_m.* AFTER FIELD cod_sec IF datos_m.cod_sec IS NULL THEN LET numero_msg = 16 CALL msg(numero_msg) NEXT FIELD cod_sec END IF SELECT UNIQUE descrip_esp,unidad_med INTO descrip,unidad FROM intb00001 WHERE status_t IS NULL AND cod_n = datos_m.cod_n and cod_grupo = datos_m.cod_grupo and cod_tipo = datos_m.cod_tipo and cod_sec = datos_m.cod_sec IF STATUS = NOTFOUND THEN LET numero_msg = 3 CALL msg(numero_msg) NEXT FIELD cod_n END IF LET mes_ant = month(today) using "&&" DISPLAY BY NAME descrip,unidad BEFORE FIELD ano LET datos_m.ano = YEAR(today) USING "&&&&" DISPLAY BY NAME datos_m.ano BEFORE FIELD mes LET datos_m.mes = mes_ant DISPLAY BY NAME datos_m.mes AFTER FIELD mes LET mes_ant = datos_m.mes IF datos_m.ano = YEAR(today) AND datos_m.mes > MONTH(today) THEN LET numero_msg = 173 CALL msg(numero_msg) NEXT FIELD mes END IF AFTER FIELD ano IF datos_m.ano IS NULL THEN LET datos_m.ano = YEAR(today) USING "&&&&" END IF IF datos_m.ano > YEAR(today) THEN LET numero_msg = 173 CALL msg(numero_msg) NEXT FIELD ano END IF SELECT UNIQUE a.cod_n FROM cttb00015 a WHERE a.cod_n = datos_m.cod_n AND a.cod_grupo = datos_m.cod_grupo AND a.cod_tipo = datos_m.cod_tipo AND a.cod_sec = datos_m.cod_sec AND a.ano = datos_m.ano AND a.mes = datos_m.mes AND a.status_t IS NULL IF STATUS != NOTFOUND THEN LET numero_msg = 12 CALL msg(numero_msg) NEXT FIELD cod_n END IF AFTER FIELD cantidad IF datos_m.cantidad IS NULL THEN LET numero_msg = 16 CALL msg(numero_msg) NEXT FIELD cantidad END IF END INPUT IF int_flag THEN LET numero_msg = 2 CALL msg(numero_msg) LET int_flag = FALSE RETURN END IF IF datos_m.cod_n IS NOT NULL AND datos_m.cod_grupo IS NOT NULL AND datos_m.cod_tipo IS NOT NULL AND datos_m.cod_sec IS NOT NULL AND datos_m.ano IS NOT NULL AND datos_m.cantidad IS NOT NULL AND datos_m.mes IS NOT NULL AND datos_m.cantidad > 0 THEN INSERT INTO cttb00015 VALUES(datos_m.*,NULL,USER,CURRENT,NULL,NULL) LET numero_msg = 1 CALL msg(numero_msg) CLEAR FORM GOTO nuevo END IF END FUNCTION FUNCTION ctmdmt014() LET int_flag = FALSE CONSTRUCT criterio ON a.cod_n,a.cod_grupo,a.cod_tipo,a.cod_sec,a.mes,a.ano FROM cod_n,cod_grupo,cod_tipo,cod_sec,mes,ano IF int_flag THEN LET numero_msg = 2 CALL msg(numero_msg) LET int_flag = FALSE RETURN END IF LET selec = "SELECT a.rowid,a.cod_n,a.cod_grupo,a.cod_tipo,a.cod_sec, ", "a.mes,a.ano,a.cantidad,b.descrip_esp,b.unidad_med, ", "a.us_crea,a.fech_crea,a.us_mod,a.fech_mod ", "FROM cttb00015 a, intb00001 b WHERE a.status_t IS NULL AND ", "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 ", criterio CLIPPED,"ORDER BY 2,3,4,5" PREPARE comando FROM selec DECLARE pro SCROLL CURSOR FOR comando OPEN pro FETCH FIRST pro INTO puntero,datos_m.*,descrip,unidad, usuario_c,fecha_c,usuario_m,fecha_m IF STATUS = NOTFOUND THEN LET numero_msg = 3 CALL msg(numero_msg) RETURN END IF DISPLAY BY NAME datos_m.*,descrip,unidad, usuario_c,fecha_c,usuario_m,fecha_m MENU "Opcion" COMMAND "Siguiente" "Presenta en pantalla el proximo registro encontrado" FETCH NEXT pro INTO puntero,datos_m.*,descrip,unidad, usuario_c,fecha_c,usuario_m,fecha_m IF STATUS = NOTFOUND THEN LET numero_msg = 4 CALL msg(numero_msg) FETCH LAST pro INTO puntero,datos_m.*,descrip,unidad, usuario_c,fecha_c,usuario_m,fecha_m END IF DISPLAY BY NAME datos_m.*,descrip,unidad , usuario_c,fecha_c,usuario_m,fecha_m COMMAND "Anterior" "Presenta en pantalla el registro anterior encontrado" FETCH PREVIOUS pro INTO puntero,datos_m.*,descrip,unidad, usuario_c,fecha_c,usuario_m,fecha_m IF STATUS = NOTFOUND THEN LET numero_msg = 5 CALL msg(numero_msg) FETCH LAST pro INTO puntero,datos_m.*,descrip,unidad, usuario_c,fecha_c,usuario_m,fecha_m END IF DISPLAY BY NAME datos_m.*,descrip,unidad, usuario_c,fecha_c,usuario_m,fecha_m COMMAND "Primero" "Presenta en pantalla el primer registro encontrado" FETCH FIRST pro INTO puntero,datos_m.*,descrip,unidad, usuario_c,fecha_c,usuario_m,fecha_m LET numero_msg = 5 CALL msg(numero_msg) DISPLAY BY NAME datos_m.*,descrip,unidad, usuario_c,fecha_c,usuario_m,fecha_m COMMAND "Ultimo" "Presenta en pantalla el ultimo registro encontrado" FETCH LAST pro INTO puntero,datos_m.*,descrip,unidad, usuario_c,fecha_c,usuario_m,fecha_m DISPLAY BY NAME datos_m.*,descrip,unidad, usuario_c,fecha_c,usuario_m,fecha_m COMMAND "Escoger" INPUT BY NAME datos_m.* WITHOUT DEFAULTS AFTER FIELD cod_sec IF datos_m.cod_sec IS NULL THEN LET numero_msg = 16 CALL msg(numero_msg) NEXT FIELD cod_sec END IF SELECT UNIQUE descrip_esp,unidad_med INTO descrip,unidad FROM intb00001 WHERE status_t IS NULL AND cod_n = datos_m.cod_n and cod_grupo = datos_m.cod_grupo and cod_tipo = datos_m.cod_tipo and cod_sec = datos_m.cod_sec IF STATUS = NOTFOUND THEN LET numero_msg = 3 CALL msg(numero_msg) NEXT FIELD cod_n END IF LET mes_ant = month(today) using "&&" DISPLAY BY NAME descrip,unidad AFTER FIELD mes IF datos_m.mes is null THEN LET numero_msg = 16 CALL msg(numero_msg) NEXT FIELD cantidad END IF AFTER FIELD cantidad IF datos_m.cantidad IS NULL THEN LET numero_msg = 16 CALL msg(numero_msg) NEXT FIELD cantidad END IF END INPUT IF int_flag THEN LET numero_msg = 2 CALL msg(numero_msg) LET int_flag = FALSE RETURN END IF UPDATE cttb00015 SET (ano,mes,cantidad,cod_n,cod_grupo,cod_tipo,cod_sec, us_mod,fech_mod) = (datos_m.ano,datos_m.mes,datos_m.cantidad,datos_m.cod_n,datos_m.cod_grupo, datos_m.cod_tipo,datos_m.cod_sec,USER,CURRENT) WHERE rowid = puntero LET numero_msg = 13 CALL msg(numero_msg) COMMAND KEY ("L") "eLiminar" UPDATE cttb00015 SET (status_t,us_mod,fech_mod) = ("E",USER,CURRENT) WHERE rowid = puntero COMMAND "Retornar" EXIT MENU END MENU END FUNCTION