Files
MBS/PROYECTOS/isdir/isprmt003.4gl
T

363 lines
12 KiB
Plaintext

{
-------------------------------------------------------------------------------
PROGRAMA : ISPRMT003
OBJETIVO : Capturar, Modificar, Eliminar registros de la
Tabla de Costos Estandares
PROGRAMADOR : Tadeo A. Ferreras
FECHA REALIZACION : Nov. 25, 1994
-------------------------------------------------------------------------------
}
GLOBALS "isprgb000.4gl"
FUNCTION isprmt003()
CLEAR SCREEN
OPTIONS
FORM LINE 9,
ERROR LINE 23,
COMMENT LINE 21
OPEN FORM isfmmt003 FROM "isfmmt003"
DISPLAY FORM isfmmt003
CALL pantalla()
DISPLAY "isprmt003" AT 4,3 ATTRIBUTE(RED)
DISPLAY "Mantenimiento de Costos Estandares" AT 6,23 ATTRIBUTE(BLACK)
MENU "OPCIONES"
COMMAND "Adicionar"
"<Esc> Adiciona Registro <Supr> Cancela Operacion"
CLEAR FORM
LET int_flag = false
CALL ispcad003()
COMMAND "Consultar-modificar"
"<Esc> Realiza Busqueda <Supr> Cancela Operacion"
LET int_flag = false
CALL ispcmf003()
COMMAND "Salir" "Retorna Menu Anterior"
EXIT MENU
END MENU
END FUNCTION
FUNCTION ispcad003()
#WHENEVER ERROR CONTINUE
## Captura los datos que va a contener el registro
INPUT BY NAME costos.mes_ini THRU costos.costo_st
## Verifica que el costo exista en el catalogo de costos. Si existe,
## entonces despliega los datos del registro existente.
AFTER FIELD mes_ini
IF costos.mes_ini IS NULL THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD mes_ini
END IF
SELECT descrip INTO descrip1 FROM mestable
WHERE mes = costos.mes_ini and status_t is null
IF status = NOTFOUND THEN
LET numero_msg = 3
CALL msg(numero_msg)
NEXT FIELD mes_ini
END IF
DISPLAY BY NAME descrip1
AFTER FIELD mes_fin
IF costos.mes_fin IS NULL THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD mes_fin
END IF
SELECT descrip INTO descrip2 FROM mestable
WHERE mes = costos.mes_fin
IF status = NOTFOUND THEN
LET numero_msg = 3
CALL msg(numero_msg)
NEXT FIELD mes_fin
END IF
DISPLAY BY NAME descrip2
AFTER FIELD ano
IF costos.ano IS NULL THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD ano
END IF
AFTER FIELD cod_sec
IF ( costos.cod_n = 0 AND costos.cod_grupo = 0 AND
costos.cod_tipo = 0 AND costos.cod_sec = 0 ) THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD cod_n
END IF
SELECT a.mes_ini,a.mes_fin,a.ano,a.cod_n,a.cod_grupo,a.cod_tipo,
a.cod_sec
FROM istb00013 a
WHERE a.mes_ini=costos.mes_ini AND a.mes_fin=costos.mes_fin AND
a.ano=costos.ano AND a.cod_n IN(2,7) AND
a.cod_n=costos.cod_n AND a.cod_grupo=costos.cod_grupo AND
a.cod_tipo=costos.cod_tipo AND a.cod_sec= costos.cod_sec
IF status != NOTFOUND THEN
LET numero_msg = 12
CALL msg(numero_msg)
NEXT FIELD mes_ini
END IF
SELECT a.descrip_esp,a.unidad_med
INTO articulos.descrip_esp,articulos.unidad_med
FROM intb00001 a
WHERE a.cod_n= costos.cod_n AND a.cod_grupo=costos.cod_grupo
AND a.cod_tipo=costos.cod_tipo AND a.cod_sec=costos.cod_sec
AND a.status_t is null
IF status = NOTFOUND THEN
LET numero_msg = 3
CALL msg(numero_msg)
NEXT FIELD cod_n
END IF
DISPLAY BY NAME articulos.descrip_esp,articulos.unidad_med
AFTER FIELD costo_st
DISPLAY costos.costo_st USING "##,###,###.####" AT 13,17
IF costos.costo_st IS NULL THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD costo_st
END IF
AFTER INPUT
IF int_flag THEN
LET numero_msg = 2
CALL msg(numero_msg)
LET int_flag = FALSE
RETURN
END IF
IF costos.costo_st IS NULL THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD costo_st
ELSE
INSERT INTO istb00013 VALUES (costos.mes_ini,costos.mes_fin,
costos.ano,costos.cod_n,costos.cod_grupo,
costos.cod_tipo,costos.cod_sec,costos.costo_st,
null,USER,CURRENT,null, null)
CALL integridad()
IF bandera = 1 THEN
LET bandera = 0
RETURN
END IF
LET numero_msg = 1
CALL msg(numero_msg)
CLEAR FORM
LET costos.mes_ini = NULL
LET costos.mes_fin = NULL
LET costos.ano = NULL
LET costos.cod_n = NULL
LET costos.cod_grupo = NULL
LET costos.cod_tipo = NULL
LET costos.cod_sec = NULL
LET costos.costo_st = NULL
NEXT FIELD mes_ini
END IF
END INPUT
END FUNCTION
FUNCTION ispcmf003()
#WHENEVER ERROR CONTINUE
## Aqui se prepara para la captura del criterio de seleccion
CONSTRUCT criterio ON c.mes_ini,c.mes_fin,c.ano,c.cod_n,c.cod_grupo,
c.cod_tipo,c.cod_sec,c.costo_st
FROM mes_ini,mes_fin,ano,cod_n,cod_grupo,cod_tipo,
cod_sec,costo_st
IF int_flag THEN
LET numero_msg = 2
CALL msg(numero_msg)
LET int_flag = FALSE
RETURN
END IF
LET SELEC =
"SELECT UNIQUE c.mes_ini,c.mes_fin,c.ano,d.cod_n,d.cod_grupo, ",
" d.cod_tipo,d.cod_sec,c.costo_st,c.us_crea,c.fech_crea, ",
" c.us_mod,c.fech_mod,a.descrip_esp,a.unidad_med ",
"FROM istb00013 c, intb00001 d,intb00001 a ",
"WHERE c.cod_n = a.cod_n and c.cod_grupo = a.cod_grupo and ",
" c.cod_tipo = a.cod_tipo and c.cod_sec = a.cod_sec and ",
" c.cod_n = d.cod_n and c.cod_grupo = d.cod_grupo and ",
" c.cod_tipo = d.cod_tipo and c.cod_sec = d.cod_sec and ",
" c.status_t is null and ",criterio clipped,
" ORDER BY 4,5,6,7"
PREPARE busca FROM selec
DECLARE datos SCROLL CURSOR FOR busca
OPEN datos
CALL integridad()
IF bandera = 1 THEN
LET bandera = 0
RETURN
END IF
FETCH FIRST datos INTO costos.*,articulos.descrip_esp,articulos.unidad_med
IF STATUS = NOTFOUND THEN
LET numero_msg = 3
CALL msg(numero_msg)
RETURN
END IF
SELECT descrip INTO descrip1 FROM mestable
WHERE mes = costos.mes_ini and
status_t is null
DISPLAY BY NAME descrip1
SELECT descrip INTO descrip2 FROM mestable
WHERE mes = costos.mes_fin and
status_t is null
DISPLAY BY NAME descrip2
DISPLAY BY NAME costos.*,articulos.descrip_esp,articulos.unidad_med
DISPLAY costos.costo_st USING "##,###,###.####" AT 13,17
MENU "OPCIONES"
COMMAND "Siguiente"
"Presenta en pantalla el proximo registro encontrado"
FETCH NEXT datos INTO costos.*,articulos.descrip_esp,articulos.unidad_med
IF STATUS = NOTFOUND THEN
LET numero_msg = 4
CALL msg(numero_msg)
END IF
SELECT descrip INTO descrip1 FROM mestable
WHERE mes = costos.mes_ini and
status_t is null
DISPLAY BY NAME descrip1
SELECT descrip INTO descrip2 FROM mestable
WHERE mes = costos.mes_fin and
status_t is null
DISPLAY BY NAME descrip2
DISPLAY BY NAME costos.*,articulos.descrip_esp,articulos.unidad_med
DISPLAY costos.costo_st USING "##,###,###.####" AT 13,17
COMMAND "Anterior"
"Presenta en pantalla el registro anterior encontrado"
FETCH PREVIOUS datos INTO costos.*,articulos.descrip_esp,articulos.unidad_med
IF STATUS = NOTFOUND THEN
LET numero_msg = 5
CALL msg(numero_msg)
END IF
SELECT descrip INTO descrip1 FROM mestable
WHERE mes = costos.mes_ini and
status_t is null
DISPLAY BY NAME descrip1
SELECT descrip INTO descrip2 FROM mestable
WHERE mes = costos.mes_fin and
status_t is null
DISPLAY BY NAME descrip2
DISPLAY BY NAME costos.*,articulos.descrip_esp,articulos.unidad_med
DISPLAY costos.costo_st USING "##,###,###.####" AT 13,17
COMMAND "Primero"
"Presenta en pantalla el primer registro encontrado"
FETCH FIRST datos INTO costos.*,articulos.descrip_esp,articulos.unidad_med
SELECT descrip INTO descrip1 FROM mestable
WHERE mes = costos.mes_ini and
status_t is null
DISPLAY BY NAME descrip1
SELECT descrip INTO descrip2 FROM mestable
WHERE mes = costos.mes_fin and
status_t is null
DISPLAY BY NAME descrip2
DISPLAY BY NAME costos.*,articulos.descrip_esp,articulos.unidad_med
DISPLAY costos.costo_st USING "##,###,###.####" AT 13,17
LET numero_msg = 5
CALL msg(numero_msg)
COMMAND "Ultimo"
"Presenta en pantalla el ultimo registro encontrado"
FETCH LAST datos INTO costos.*,articulos.descrip_esp,articulos.unidad_med
SELECT descrip INTO descrip1 FROM mestable
WHERE mes = costos.mes_ini and
status_t is null
DISPLAY BY NAME descrip1
SELECT descrip INTO descrip2 FROM mestable
WHERE mes = costos.mes_fin and
status_t is null
DISPLAY BY NAME descrip2
DISPLAY BY NAME costos.*,articulos.descrip_esp,articulos.unidad_med
DISPLAY costos.costo_st USING "##,###,###.####" AT 13,17
LET numero_msg = 4
CALL msg(numero_msg)
COMMAND "Escoger"
"<Esc> Actualiza Registro <Supr> Cancela Operacion"
INPUT BY NAME costos.costo_st,costos.us_crea,costos.fech_crea,
costos.us_mod,costos.fech_mod WITHOUT DEFAULTS
AFTER FIELD costo_st
IF costos.costo_st IS NULL THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD costo_st
END IF
## Verifica si el usuario presiono la tecla <Supr>
AFTER INPUT
IF int_flag THEN
LET numero_msg = 2
CALL msg(numero_msg)
LET int_flag = FALSE
RETURN
END IF
UPDATE istb00013 SET costo_st = costos.costo_st,
us_mod = USER,
fech_mod = CURRENT
WHERE cod_n = costos.cod_n and
cod_grupo = costos.cod_grupo and
cod_tipo = costos.cod_tipo and
cod_sec = costos.cod_sec
LET numero_msg = 13
CALL msg(numero_msg)
EXIT INPUT
END INPUT
COMMAND KEY ("L") "eLiminar"
UPDATE istb00013 SET status_t = "E"
WHERE cod_n = costos.cod_n and
cod_grupo = costos.cod_grupo and
cod_tipo = costos.cod_tipo and
cod_sec = costos.cod_sec
LET numero_msg = 39
CALL msg(numero_msg)
COMMAND "Retornar"
"Retorna al menu anterior"
CLEAR FORM
EXIT MENU
END MENU
END FUNCTION