Files
MBS/PROYECTOS/indir/inprmt004.4gl
T

636 lines
23 KiB
Plaintext

{
-------------------------------------------------------------------------
PROGRAMA : INPRMT004
OBJETIVO : Programa Captura, Modifica, Elimina Registros
Archivo Maestro Equivalentes Materia Prima.
PROGRAMADOR : Juan Fco. Soto (Johnny)
FECHA REALIZACION : Julio 27, 1992.
-------------------------------------------------------------------------
}
GLOBALS
"inprgb000.4gl"
FUNCTION inprmt004()
CLEAR SCREEN
OPTIONS
FORM LINE 8,
ERROR LINE 23,
COMMENT LINE 21
OPEN FORM infmmt004 FROM "infmmt004"
DISPLAY FORM infmmt004
CALL pantalla()
DISPLAY "Materias Primas Equivalentes" AT 6,26
DISPLAY "inprmt004" AT 4,2
MENU "OPCIONES"
COMMAND "Adicionar"
"<Esc> Adiciona Registro <Ctrl-C> Cancela Operacion"
LET INT_FLAG = FALSE
LET numero_msg = 0
LET INT_FLAG = FALSE
CALL inpcad004()
COMMAND "Consultar-modificar"
"<Esc> Realiza Busqueda <Ctrl-C> Cancela Operacion"
LET numero_msg = 0
CALL inpcmf004()
COMMAND "Salir" "Retorna Menu Anterior"
EXIT MENU
END MENU
END FUNCTION
### FUNCION PARA AGREGAR REGISTROS SUSTITUTOS A MAESTRA SUSTITUTOS ###
FUNCTION inpcad004()
DEFINE cerrada CHAR(1)
DEFINE total_cantidad,porciento,recibida,ordenada,r_cantidad_1,r_cantidad
DECIMAL(12,2)
WHENEVER ERROR CONTINUE
CLEAR FORM
LET INT_FLAG = FALSE
##### CAPTURA INFORMACION PARA LA MAESTRA SUSTITUTOS
INPUT BY NAME c_equivalente.*
AFTER FIELD cod_sec
SELECT descrip_esp,descrip_ing
INTO descrip1,descrip3 FROM intb00001
WHERE cod_n = c_equivalente.cod_n and
cod_grupo = c_equivalente.cod_grupo and
cod_tipo = c_equivalente.cod_tipo and
cod_sec = c_equivalente.cod_sec and
status_t is null
## CHEQUEA QUE EL CODIGO SE ENCUENTRE EN LA TABLA DE ARTICULOS
IF status >= 0 THEN
IF status = NOTFOUND THEN
LET numero_msg = 3
CALL msg(numero_msg)
NEXT FIELD COD_N
END IF
ELSE
CALL integridad()
if bandera = 1 THEN
LET bandera = 0
RETURN
end if
END IF
## DESPLEGA LA DESCRIPCION EN ESPANOL(descrip1) Y EN INGLES(descrip3
DISPLAY BY NAME descrip1,descrip3 ATTRIBUTE (YELLOW)
AFTER FIELD cod_sec_e
SELECT UNIQUE descrip_esp,descrip_ing
INTO descrip2,descrip4
FROM intb00001
WHERE cod_n = c_equivalente.cod_n_e and
cod_grupo = c_equivalente.cod_grupo_e and
cod_tipo = c_equivalente.cod_tipo_e and
cod_sec = c_equivalente.cod_sec_e
## CHEQUEA QUE EL CODIGO ESTE EN LA TABLA DE ARTICULOS GRALES.
IF status >= 0 THEN
IF status = NOTFOUND THEN
LET numero_msg = 3
CALL msg(numero_msg)
NEXT FIELD COD_N_E
END IF
ELSE
CALL integridad()
if bandera = 1 THEN
LET bandera = 0
RETURN
end if
END IF
# Cheque que un codigo tenga su equivalencia.
SELECT UNIQUE * INTO c_equivalente.* FROM intb00004
WHERE cod_n = c_equivalente.cod_n and
cod_grupo = c_equivalente.cod_grupo and
cod_tipo = c_equivalente.cod_tipo and
cod_sec = c_equivalente.cod_sec and
cod_n_e = c_equivalente.cod_n_e and
cod_grupo_e = c_equivalente.cod_grupo_e and
cod_tipo_e = c_equivalente.cod_tipo_e and
cod_sec_e = c_equivalente.cod_sec_e
IF status >= 0 THEN
IF status != NOTFOUND THEN
IF c_equivalente.status_t = "E" THEN
LET numero_msg = 36
CALL msg(numero_msg)
NEXT FIELD cod_n
END IF
LET numero_msg = 8
CALL msg(numero_msg)
DISPLAY BY NAME descrip2,descrip4,descrip1,descrip3,
c_equivalente.us_crea,
c_equivalente.fech_crea, c_equivalente.us_mod,
c_equivalente.fech_mod ATTRIBUTE (YELLOW)
NEXT FIELD cod_n
END IF
ELSE
CALL integridad()
if bandera = 1 THEN
LET bandera = 0
RETURN
end if
END IF
# Busca Descripcion Materia Prima
### DESPLEGA LA DESCRIPCION EN ESPANOL(descrip1) Y EN INGLES(descrip4)
DISPLAY BY NAME descrip2,descrip4
IF c_equivalente.cod_n = c_equivalente.cod_n_e and
c_equivalente.cod_grupo = c_equivalente.cod_grupo_e and
c_equivalente.cod_tipo = c_equivalente.cod_tipo_e and
c_equivalente.cod_sec = c_equivalente.cod_sec_e THEN
LET numero_msg = 11
CALL msg(numero_msg)
NEXT FIELD COD_N
END IF
AFTER FIELD cod_uso_e
IF c_equivalente.cod_uso_e != "0" AND c_equivalente.cod_uso_e != "1" THEN
LET numero_msg = 7
CALL msg(numero_msg)
NEXT FIELD cod_uso_e
END IF
AFTER INPUT
IF INT_FLAG THEN
LET numero_msg = 2
CALL msg(numero_msg)
LET INT_FLAG = FALSE
RETURN
END IF
IF c_equivalente.cod_uso_e != "0" AND c_equivalente.cod_uso_e != "1" THEN
LET numero_msg = 7
CALL msg(numero_msg)
NEXT FIELD cod_uso_e
END IF
SELECT descrip_esp,descrip_ing
INTO descrip1,descrip3 FROM intb00001
WHERE cod_n = c_equivalente.cod_n and
cod_grupo = c_equivalente.cod_grupo and
cod_tipo = c_equivalente.cod_tipo and
cod_sec = c_equivalente.cod_sec AND
status_t is NULL
## CHEQUEA QUE EL CODIGO SE ENCUENTRE EN LA TABLA DE ARTICULOS
IF status >= 0 THEN
IF status = NOTFOUND THEN
LET numero_msg = 3
CALL msg(numero_msg)
NEXT FIELD COD_N
END IF
ELSE
CALL integridad()
if bandera = 1 THEN
LET bandera = 0
RETURN
end if
END IF
# Busca Descripcion Materia Prima
SELECT UNIQUE descrip_esp,descrip_ing
INTO descrip2,descrip4
FROM intb00001
WHERE cod_n = c_equivalente.cod_n_e and
cod_grupo = c_equivalente.cod_grupo_e and
cod_tipo = c_equivalente.cod_tipo_e and
cod_sec = c_equivalente.cod_sec_e and
status_t is null
## CHEQUEA QUE EL CODIGO ESTE EN LA TABLA DE ARTICULOS GRALES.
IF status >= 0 THEN
IF status = NOTFOUND THEN
LET numero_msg = 3
CALL msg(numero_msg)
NEXT FIELD COD_N_E
END IF
ELSE
CALL integridad()
if bandera = 1 THEN
LET bandera = 0
RETURN
end if
END IF
## DESPLEGA LA DESCRIPCION EN ESPANOL(descrip1) Y EN INGLES(descrip3
IF c_equivalente.cod_n = 0 and
c_equivalente.cod_grupo = 0 and
c_equivalente.cod_tipo = 0 and
c_equivalente.cod_sec = 0 then
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD cod_n
END IF
IF
c_equivalente.cod_n_e = 0 and
c_equivalente.cod_grupo_e = 0 and
c_equivalente.cod_tipo_e = 0 and
c_equivalente.cod_sec_e = 0 THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD cod_n
END IF
SELECT UNIQUE * INTO c_equivalente.* FROM intb00004
WHERE cod_n = c_equivalente.cod_n and
cod_grupo = c_equivalente.cod_grupo and
cod_tipo = c_equivalente.cod_tipo and
cod_sec = c_equivalente.cod_sec and
cod_n_e = c_equivalente.cod_n_e and
cod_grupo_e = c_equivalente.cod_grupo_e and
cod_tipo_e = c_equivalente.cod_tipo_e and
cod_sec_e = c_equivalente.cod_sec_e
IF status >= 0 THEN
IF status != NOTFOUND THEN
IF c_equivalente.status_t = "E" THEN
LET numero_msg = 36
CALL msg(numero_msg)
NEXT FIELD cod_n
END IF
LET numero_msg = 8
CALL msg(numero_msg)
DISPLAY BY NAME descrip2,descrip4,descrip1,descrip3 ATTRIBUTE (YELLOW)
NEXT FIELD cod_n
END IF
ELSE
CALL integridad()
if bandera = 1 THEN
LET bandera = 0
RETURN
end if
end if
IF c_equivalente.cod_n = c_equivalente.cod_n_e and
c_equivalente.cod_grupo = c_equivalente.cod_grupo_e and
c_equivalente.cod_tipo = c_equivalente.cod_tipo_e and
c_equivalente.cod_sec = c_equivalente.cod_sec_e THEN
LET numero_msg = 11
CALL msg(numero_msg)
NEXT FIELD COD_N
END IF
INSERT INTO intb00004 VALUES
(c_equivalente.cod_n,c_equivalente.cod_grupo,
c_equivalente.cod_tipo,c_equivalente.cod_sec,
c_equivalente.cod_n_e,
c_equivalente.cod_grupo_e,
c_equivalente.cod_tipo_e,
c_equivalente.cod_sec_e,c_equivalente.cod_uso_e, 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)
SELECT UNIQUE us_crea,fech_crea,us_mod,fech_mod
INTO c_equivalente.us_crea,c_equivalente.fech_crea,
c_equivalente.us_mod,c_equivalente.fech_mod
FROM intb00004
WHERE cod_n = c_equivalente.cod_n_e and
cod_grupo = c_equivalente.cod_grupo_e and
cod_tipo = c_equivalente.cod_tipo_e and
cod_sec = c_equivalente.cod_sec_e
DISPLAY BY NAME descrip2,descrip4,c_equivalente.us_crea,
c_equivalente.fech_crea ATTRIBUTE (YELLOW)
NEXT FIELD cod_n
AFTER FIELD fech_mod
EXIT INPUT
END INPUT
#### CHEQUE QUE LA VARIABLE BOLEANA DE INTERRUPCION (INT_FLAG) ESTE FALSA O
#### VERDADERA, SI ESTA VERDADERA EL USUARIO PRESIONO LA TECLA (DEL)A
END FUNCTION
## FUNCION QUE BUSCA Y MODIFICA SI ES NECESARIO LAS INFORMACIONES EN PANTALLA
FUNCTION inpcmf004()
WHENEVER ERROR CONTINUE
LET INT_FLAG = FALSE
## AQUI SE PREPARA PARA LA CAPTURA DEL CRITERIO DE SELECCION
CLEAR FORM
CONSTRUCT criterio ON intb00004.* FROM intb00004.*
IF INT_FLAG THEN
LET numero_msg = 2
CALL msg(numero_msg)
LET INT_FLAG = FALSE
RETURN
end if
LET SELEC = " SELECT UNIQUE * FROM intb00004 where ",
" status_t is null and ",
criterio clipped,
" ORDER BY 1,2,3,4"
PREPARE busca FROM selec
CALl integridad()
if bandera = 1 THEN
LET bandera = 0
RETURN
end if
DECLARE datos SCROLL CURSOR WITH HOLD FOR BUSCA
OPEN datos
FETCH NEXT datos INTO c_equivalente.*
IF status >= 0 THEN
IF status = NOTFOUND THEN
LET numero_msg = 3
CALL msg(numero_msg)
RETURN
END IF
ELSE
CALl integridad()
if bandera = 1 THEN
LET bandera = 0
RETURN
end if
END IF
SELECT descrip_esp,descrip_ing INTO descrip1,descrip3
FROM intb00001
WHERE cod_n = c_equivalente.cod_n and
cod_grupo = c_equivalente.cod_grupo and
cod_tipo = c_equivalente.cod_tipo and
cod_sec = c_equivalente.cod_sec
SELECT descrip_esp,descrip_ing INTO descrip2,descrip4
FROM intb00001
WHERE cod_n = c_equivalente.cod_n_e and
cod_grupo = c_equivalente.cod_grupo_e and
cod_tipo = c_equivalente.cod_tipo_e and
cod_sec = c_equivalente.cod_sec_e
DISPLAY BY NAME c_equivalente.*,descrip1,descrip3,descrip2,descrip4
MENU "OPCIONES"
COMMAND "Siguiente"
"Presenta en pantalla el proximo registro encontrado"
FETCH NEXT datos INTO c_equivalente.*
IF status = NOTFOUND THEN
LET numero_msg = 4
CALL msg(numero_msg)
END IF
SELECT descrip_esp,descrip_ing INTO descrip1,descrip3
FROM intb00001
WHERE cod_n = c_equivalente.cod_n and
cod_grupo = c_equivalente.cod_grupo and
cod_tipo = c_equivalente.cod_tipo and
cod_sec = c_equivalente.cod_sec
SELECT descrip_esp,descrip_ing INTO descrip2,descrip4
FROM intb00001
WHERE cod_n = c_equivalente.cod_n_e and
cod_grupo = c_equivalente.cod_grupo_e and
cod_tipo = c_equivalente.cod_tipo_e and
cod_sec = c_equivalente.cod_sec_e
DISPLAY BY NAME c_equivalente.*,descrip1,descrip2,descrip3,descrip4
COMMAND "Anterior"
"Presenta en pantalla el registro anterior encontrado"
FETCH PREVIOUS datos INTO c_equivalente.*
IF status = NOTFOUND THEN
LET numero_msg = 5
CALL msg(numero_msg)
END IF
SELECT descrip_esp,descrip_ing INTO descrip1,descrip3
FROM intb00001
WHERE cod_n = c_equivalente.cod_n and
cod_grupo = c_equivalente.cod_grupo and
cod_tipo = c_equivalente.cod_tipo and
cod_sec = c_equivalente.cod_sec
SELECT descrip_esp,descrip_ing INTO descrip2,descrip4
FROM intb00001
WHERE cod_n = c_equivalente.cod_n_e and
cod_grupo = c_equivalente.cod_grupo_e and
cod_tipo = c_equivalente.cod_tipo_e and
cod_sec = c_equivalente.cod_sec_e
DISPLAY BY NAME c_equivalente.*,descrip1,descrip2,descrip3,descrip4
COMMAND "Primero"
"Presenta en pantalla el primer registro encontrado"
FETCH FIRST datos INTO c_equivalente.*
SELECT descrip_esp,descrip_ing INTO descrip1,descrip3
FROM intb00001
WHERE cod_n = c_equivalente.cod_n and
cod_grupo = c_equivalente.cod_grupo and
cod_tipo = c_equivalente.cod_tipo and
cod_sec = c_equivalente.cod_sec
SELECT descrip_esp,descrip_ing INTO descrip2,descrip4
FROM intb00001
WHERE cod_n = c_equivalente.cod_n_e and
cod_grupo = c_equivalente.cod_grupo_e and
cod_tipo = c_equivalente.cod_tipo_e and
cod_sec = c_equivalente.cod_sec_e
DISPLAY BY NAME c_equivalente.*,descrip1,descrip2,descrip3,descrip4
LET numero_msg = 5
CALL msg(numero_msg)
COMMAND "Ultimo"
"Presenta en pantalla el ultimo registro encontrado"
FETCH LAST datos INTO c_equivalente.*
SELECT descrip_esp,descrip_ing INTO descrip1,descrip3
FROM intb00001
WHERE cod_n = c_equivalente.cod_n and
cod_grupo = c_equivalente.cod_grupo and
cod_tipo = c_equivalente.cod_tipo and
cod_sec = c_equivalente.cod_sec
SELECT descrip_esp,descrip_ing INTO descrip2,descrip4
FROM intb00001
WHERE cod_n = c_equivalente.cod_n_e and
cod_grupo = c_equivalente.cod_grupo_e and
cod_tipo = c_equivalente.cod_tipo_e and
cod_sec = c_equivalente.cod_sec_e
DISPLAY BY NAME c_equivalente.*,descrip1,descrip2,descrip3,descrip4
LET numero_msg = 4
CALL msg(numero_msg)
COMMAND "Escoger" "<Esc> Actualiza Registro <Ctrl-C> Cancela Operacion"
INPUT BY NAME c_equivalente.* WITHOUT DEFAULTS
BEFORE FIELD cod_n
NEXT FIELD cod_n_e
AFTER FIELD cod_sec_e
# Busca Descripcion Materia Prima
SELECT UNIQUE descrip_esp,descrip_ing
INTO descrip2,descrip4
FROM intb00001
WHERE cod_n = c_equivalente.cod_n_e and
cod_grupo = c_equivalente.cod_grupo_e and
cod_tipo = c_equivalente.cod_tipo_e and
cod_sec = c_equivalente.cod_sec_e and
status_t is null
## CHEQUEA QUE EL CODIGO ESTE EN LA TABLA DE ARTICULOS GRALES.
IF status = NOTFOUND THEN
LET numero_msg = 3
CALL msg(numero_msg)
NEXT FIELD cod_n_e
END IF
SELECT UNIQUE us_crea,fech_crea,us_mod,fech_mod
INTO c_equivalente.us_crea,c_equivalente.fech_crea,
c_equivalente.us_mod,c_equivalente.fech_mod
FROM intb00004
WHERE cod_n = c_equivalente.cod_n_e and
cod_grupo = c_equivalente.cod_grupo_e and
cod_tipo = c_equivalente.cod_tipo_e and
cod_sec = c_equivalente.cod_sec_e and
status_t is null
### DESPLEGA LA DESCRIPCION EN ESPANOL(descrip1) Y EN INGLES(descrip4)
DISPLAY BY NAME descrip2,descrip4,c_equivalente.us_crea,
c_equivalente.fech_crea,c_equivalente.us_mod,
c_equivalente.fech_mod
AFTER INPUT
IF INT_FLAG THEN
LET numero_msg = 2
CALL msg(numero_msg)
LET INT_FLAG = FALSE
RETURN
END IF
SELECT UNIQUE descrip_esp,descrip_ing
INTO descrip2,descrip4
FROM intb00001
WHERE cod_n = c_equivalente.cod_n_e and
cod_grupo = c_equivalente.cod_grupo_e and
cod_tipo = c_equivalente.cod_tipo_e and
cod_sec = c_equivalente.cod_sec_e and
status_t is null
## CHEQUEA QUE EL CODIGO ESTE EN LA TABLA DE ARTICULOS GRALES.
IF status = NOTFOUND THEN
LET numero_msg = 3
CALL msg(numero_msg)
NEXT FIELD COD_N_E
END IF
SELECT UNIQUE us_crea,fech_crea,us_mod,fech_mod
INTO c_equivalente.us_crea,c_equivalente.fech_crea,
c_equivalente.us_mod,c_equivalente.fech_mod
FROM intb00004
WHERE cod_n = c_equivalente.cod_n_e and
cod_grupo = c_equivalente.cod_grupo_e and
cod_tipo = c_equivalente.cod_tipo_e and
cod_sec = c_equivalente.cod_sec_e and
status_t is null
IF c_equivalente.cod_n = 0 and
c_equivalente.cod_grupo = 0 and
c_equivalente.cod_tipo = 0 and
c_equivalente.cod_sec = 0 then
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD cod_n
END IF
IF
c_equivalente.cod_n_e = 0 and
c_equivalente.cod_grupo_e = 0 and
c_equivalente.cod_tipo_e = 0 and
c_equivalente.cod_sec_e = 0 THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD cod_n
END IF
IF c_equivalente.cod_n = c_equivalente.cod_n_e and
c_equivalente.cod_grupo = c_equivalente.cod_grupo_e and
c_equivalente.cod_tipo = c_equivalente.cod_tipo_e and
c_equivalente.cod_sec = c_equivalente.cod_sec_e THEN
LET numero_msg = 11
CALL msg(numero_msg)
NEXT FIELD COD_N
END IF
IF INT_FLAG THEN
LET numero_msg = 13
CALL msg(numero_msg)
LET INT_FLAG = FALSE
RETURN
END IF
AFTER FIELD fech_mod
EXIT INPUT
END INPUT
#### CHEQUE QUE LA VARIABLE BOLEANA DE INTERRUPCION (INT_FLAG) ESTE FALSA O
#### VERDADERA, SI ESTA VERDADERA EL USUARIO PRESIONO LA TECLA (DEL)A
IF INT_FLAG THEN
LET numero_msg = 2
CALL msg(numero_msg)
LET int_flag = false
RETURN
END IF
UPDATE intb00004 set cod_n_e = c_equivalente.cod_n_e,
cod_grupo_e = c_equivalente.cod_n_e,
cod_tipo_e = c_equivalente.cod_tipo_e,
cod_sec_e = c_equivalente.cod_sec_e,
cod_uso_e = c_equivalente.cod_uso_e,
us_mod = user,
fech_mod = current
WHERE cod_n = c_equivalente.cod_n and
cod_grupo = c_equivalente.cod_grupo and
cod_tipo = c_equivalente.cod_tipo and
cod_sec = c_equivalente.cod_sec
CALL integridad()
if bandera = 1 THEN
LET bandera = 0
RETURN
end if
LET numero_msg = 13
CALL msg(numero_msg)
COMMAND KEY ("L") "eLiminar"
UPDATE intb00004 set status_t = "E"
WHERE cod_n = c_equivalente.cod_n and
cod_grupo = c_equivalente.cod_grupo and
cod_tipo = c_equivalente.cod_tipo and
cod_sec = c_equivalente.cod_sec
LET numero_msg = 39
CALL msg(numero_msg)
SLEEP 2
COMMAND "Retornar"
CLEAR FORM
EXIT MENU
END MENU
END FUNCTION
{FUNCTION inpcmt003()
LET pa_act = arr_curr()
LET scr_l = scr_line()
OPEN WINDOW consulta AT 3,10 WITH FORM "infmco004"
ATTRIBUTE (BORDER,FORM LINE 2)
DECLARE CONSULTA CURSOR FOR
SELECT i.cod_n_e,i.cod_grupo_e,i.cod_tipo_e,i.cod_sec_e,
d.descrip_esp,d.descrip_ing
FROM intb00004 i,intb00001 d
WHERE i.cod_n = c_equivalente.cod_n AND
i.cod_grupo = c_equivalente.cod_grupo AND
i.cod_tipo = c_equivalente.cod_tipo AND
i.cod_sec = c_equivalente.cod_sec AND
i.cod_n = d.cod_n and
i.cod_grupo = d.cod_grupo and
i.cod_tipo = d.cod_tipo and
i.cod_sec = d.cod_sec
FOREACH consulta INTO c_busca[idx].*
LET idx = idx + 1
END FOREACH
CALL set_count(idx -1)
DISPLAY ARRAY c_busca to s_desplega.*
LET idx = arr_curr()
CLOSE WINDOW consulta
END FUNCTION}