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

743 lines
24 KiB
Plaintext

{
----------------------------------------------------------------------------
PROGRAMA : ISPRMT036
OBJETIVO : Programa Captura Documento Movimiento:
REQUISICION DE SUMINISTROS de Inventario de Suministros
PROGRAMADOR : Ing. Juan Fco. Soto (Copiado del INPRMT016)
FECHA REALIZACION : octubre 21, 1993.
----------------------------------------------------------------------------
}
GLOBALS
"isprgb000.4gl"
FUNCTION isprmt036()
DEFINE fecha CHAR(10)
DEFINE hora CHAR(5)
CLEAR SCREEN
OPTIONS
ERROR LINE 24,
FORM LINE 4,
COMMENT LINE 22,
PROMPT LINE 23
LET fecha = today USING "dd/mm/yyyy"
LET hora = time
DISPLAY " R A Y . O . V A C D O M I N I C A N A " AT 1,21
ATTRIBUTE (REVERSE,BLUE)
DISPLAY fecha AT 1,70 ATTRIBUTE (RED)
DISPLAY hora AT 2,73 ATTRIBUTE (RED)
DISPLAY "Requisicion de Suministros" AT 2,27 ATTRIBUTE(BLACK)
DISPLAY "isprmt036" AT 1,3 ATTRIBUTE (RED)
DISPLAY "<Esc> Adiciona Registro" AT 3,2 ATTRIBUTE (RED,REVERSE)
DISPLAY "<Supr> Cancela Operacion" AT 3,56 ATTRIBUTE (RED,REVERSE)
OPEN FORM isfmmt036 FROM "isfmmt036"
DISPLAY FORM isfmmt036
LET actual = "UPDATE istb00002 SET existencia = existencia - ? ",
"WHERE cod_n = ? and ",
"cod_grupo = ? and ",
"cod_tipo = ? and ",
"cod_sec = ? "
CALL isprad036()
END FUNCTION
FUNCTION isprad036()
# WHENEVER ERROR CONTINUE
LET opc = null
LET int_flag = FALSE
INITIALIZE datos1.* TO NULL
PREPARE actualiza FROM actual
LABEL otra_vez:
LABEL vuelve:
IF (OPC = "S" OR OPC = "s") OR opc is null THEN
INITIALIZE datos1.* TO NULL
END IF
INPUT BY NAME datos1.* WITHOUT DEFAULTS
AFTER FIELD cod_mov
IF datos1.cod_mov is null THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD cod_mov
END IF
SELECT @descrip_mov INTO datos1.descrip_mov
FROM istb00005
WHERE @cod_mov = datos1.cod_mov and
status_t is null
IF status = notfound THEN
LET numero_msg = 3
CALL msg(numero_msg)
NEXT FIELD cod_mov
END IF
DISPLAY BY NAME datos1.descrip_mov
BEFORE FIELD bodega
LET datos1.bodega = 1
DISPLAY BY NAME datos1.bodega
AFTER FIELD bodega
SELECT *FROM istb00009 WHERE cod_bodega = datos1.bodega
IF status >= 0 THEN
IF status = NOTFOUND THEN
LET numero_msg = 3
CALL msg(numero_msg)
NEXT FIELD bodega
END IF
ELSE
CALL integridad()
IF bandera = 1 THEN
LET bandera = 0
RETURN
END IF
END IF
BEFORE FIELD num_doc
LET datos1.fecha = today
DISPLAY BY NAME datos1.fecha
# Verifica que el numero del documento de entrada no este en el archivo de
# movimientos.
AFTER FIELD fecha
IF datos1.fecha IS NULL THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD fecha
END IF
LET p_fechas = datos1.fecha using "ddmmyyyy"
CALL prd()
IF bandera = 1 THEN
LET bandera = 0
NEXT FIELD fecha
END IF
AFTER FIELD num_doc
IF datos1.num_doc IS NULL then
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD num_doc
ELSE
SELECT * FROM istb00005 where cod_mov = 36
and status_t is null
IF status >= 0 THEN
IF STATUS = NOTFOUND THEN
LET numero_msg = 34
CALL msg(numero_msg)
NEXT FIELD num_doc
END IF
ELSE
CALL integridad()
if bandera = 1 THEN
LET bandera = 0
RETURN
end if
END IF
SELECT UNIQUE depto_a,fecha INTO datos1.depto_a,datos1.fecha
FROM istb00006 WHERE num_doc = datos1.num_doc and
cod_mov = 36 AND
status_t is null
IF status >= 0 THEN
IF STATUS != NOTFOUND THEN
SELECT UNIQUE nom_dpto INTO datos1.nom_dpto FROM adtb00001
WHERE departamento = datos1.depto_a
and status_t is null
LET numero_msg = 12
CALL msg(numero_msg)
DISPLAY BY NAME datos1.depto_a,datos1.fecha,datos1.nom_dpto
NEXT FIELD num_doc
END IF
ELSE
CALL integridad()
if bandera = 1 THEN
LET bandera = 0
RETURN
end if
END IF
IF OPC = "S" or OPC = "s" or opc is null THEN
INITIALIZE datos1.depto_a,datos1.nom_dpto TO NULL
DISPLAY BY NAME datos1.depto_a,datos1.nom_dpto
END IF
END IF
AFTER FIELD depto_a
IF datos1.depto_a IS NULL THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD depto_a
ELSE
SELECT UNIQUE nom_dpto INTO datos1.nom_dpto FROM adtb00001
WHERE departamento = datos1.depto_a and
status_t is null
IF status >= 0 THEN
IF STATUS = NOTFOUND THEN
LET numero_msg = 3
CALL msg(numero_msg)
NEXT FIELD depto_a
END IF
else
CALL integridad()
if bandera = 1 THEN
LET bandera = 0
RETURN
end if
END IF
END IF
DISPLAY BY NAME datos1.nom_dpto
AFTER INPUT
IF int_flag THEN
LET numero_msg = 2
CALL msg(numero_msg)
LET int_flag = FALSE
FOR idx = 1 to arr_count()
LET movi[idx].cod_n = null
LET movi[idx].cod_grupo = null
LET movi[idx].cod_tipo = null
LET movi[idx].cod_sec = null
LET movi[idx].cantidad_1 = null
LET movi[idx].cantidad_2 = null
LET movi[idx].unidad_med = null
LET movi[idx].descrip_esp = null
END FOR
SLEEP 3
RETURN
END IF
IF datos1.num_doc IS NULL then
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD num_doc
ELSE
SELECT UNIQUE num_doc FROM istb00006
WHERE num_doc = datos1.num_doc and
cod_mov = 36 and
status_t is null
IF status >= 0 THEN
IF STATUS != NOTFOUND THEN
LET numero_msg = 12
CALL msg(numero_msg)
NEXT FIELD num_doc
END IF
else
CALL integridad()
if bandera = 1 THEN
LET bandera = 0
RETURN
end if
END IF
END IF
IF datos1.depto_a IS NULL THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD departamento
ELSE
SELECT UNIQUE nom_dpto INTO datos1.nom_dpto FROM adtb00001
WHERE departamento = datos1.depto_a and
status_t is null
IF status >= 0 THEN
IF STATUS = NOTFOUND THEN
LET numero_msg = 3
CALL msg(numero_msg)
NEXT FIELD departamento
END IF
ELSE
CALL integridad()
if bandera = 1 THEN
LET bandera = 0
RETURN
end if
END IF
END IF
EXIT INPUT
END INPUT
INITIALIZE ant_art.* TO NULL
IF opc = "S" or opc = "s" OR opc IS NULL THEN
FOR idx = 1 to arr_count()
LET movi[idx].cod_n = null
LET movi[idx].cod_grupo = null
LET movi[idx].cod_tipo = null
LET movi[idx].cod_sec = null
LET movi[idx].cantidad_2 = null
LET movi[idx].cantidad_1 = null
LET movi[idx].unidad_med = null
LET movi[idx].descrip_esp = null
END FOR
END IF
CALL integridad()
if bandera = 1 THEN
LET bandera = 0
RETURN
end if
INPUT ARRAY movi WITHOUT DEFAULTS FROM s_movi1.*
BEFORE ROW
LET p_act = arr_curr()
LET scr_l = scr_line()
AFTER ROW
IF movi[p_act].cod_n is not null and
movi[p_act].cod_grupo is not null and
movi[p_act].cod_tipo is not null and
movi[p_act].cod_sec is not null then
LET p_act = arr_curr()
LET ant_art.cod_n = movi[p_act].cod_n
LET ant_art.cod_grupo = movi[p_act].cod_grupo
LET ant_art.cod_tipo = movi[p_act].cod_tipo
LET ant_art.cod_sec = movi[p_act].cod_sec
FOR idx = 1 TO arr_count()
IF idx != p_act THEN
IF movi[idx].cod_n = ant_art.cod_n AND
movi[idx].cod_grupo = ant_art.cod_grupo AND
movi[idx].cod_tipo = ant_art.cod_tipo AND
movi[idx].cod_sec = ant_art.cod_sec THEN
LET numero_msg = 21
CALL msg(numero_msg)
LET p_act = p_act - 1
NEXT FIELD cod_n
END IF
END IF
END FOR
IF movi[p_act].cantidad_1 IS NULL and movi[p_act].cantidad_2 IS NULL THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD cod_n
END IF
END IF
LET ant_art.cod_n = movi[p_act].cod_n
LET ant_art.cod_grupo = movi[p_act].cod_grupo
LET ant_art.cod_tipo = movi[p_act].cod_tipo
LET ant_art.cod_sec = movi[p_act].cod_sec
AFTER FIELD cod_n
LET p_act = arr_curr()
IF movi[p_act].cod_n is not null then
LET ant_art.cod_n = movi[p_act].cod_n
LET ant_art.cod_grupo = movi[p_act].cod_grupo
LET ant_art.cod_tipo = movi[p_act].cod_tipo
LET ant_art.cod_sec = movi[p_act].cod_sec
FOR idx = 1 TO arr_count()
IF idx != p_act THEN
IF movi[idx].cod_n = ant_art.cod_n AND
movi[idx].cod_grupo = ant_art.cod_grupo AND
movi[idx].cod_tipo = ant_art.cod_tipo AND
movi[idx].cod_sec = ant_art.cod_sec THEN
LET p_act = p_act - 1
NEXT FIELD cod_grupo
END IF
END IF
END FOR
END IF
AFTER FIELD cod_grupo
IF movi[p_act].cod_grupo is null THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD cod_n
END IF
LET p_act = arr_curr()
LET ant_art.cod_n = movi[p_act].cod_n
LET ant_art.cod_grupo = movi[p_act].cod_grupo
LET ant_art.cod_tipo = movi[p_act].cod_tipo
LET ant_art.cod_sec = movi[p_act].cod_sec
FOR idx = 1 TO arr_count()
IF idx != p_act THEN
IF movi[idx].cod_n = ant_art.cod_n AND
movi[idx].cod_grupo = ant_art.cod_grupo AND
movi[idx].cod_tipo = ant_art.cod_tipo AND
movi[idx].cod_sec = ant_art.cod_sec THEN
LET p_act = p_act - 1
NEXT FIELD cod_tipo
END IF
END IF
END FOR
AFTER FIELD cod_tipo
IF movi[p_act].cod_tipo is null THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD cod_n
END IF
LET p_act = arr_curr()
LET ant_art.cod_n = movi[p_act].cod_n
LET ant_art.cod_grupo = movi[p_act].cod_grupo
LET ant_art.cod_tipo = movi[p_act].cod_tipo
LET ant_art.cod_sec = movi[p_act].cod_sec
FOR idx = 1 TO arr_count()
IF idx != p_act THEN
IF movi[idx].cod_n = ant_art.cod_n AND
movi[idx].cod_grupo = ant_art.cod_grupo AND
movi[idx].cod_tipo = ant_art.cod_tipo AND
movi[idx].cod_sec = ant_art.cod_sec THEN
LET p_act = p_act - 1
NEXT FIELD cod_sec
END IF
END IF
END FOR
AFTER FIELD cod_sec
LET p_act = arr_curr()
IF movi[p_act].cod_sec is null THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD cod_n
END IF
IF movi[p_act].cod_n is null AND movi[p_act].cod_sec is not null THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD cod_n
END IF
IF movi[p_act].cod_n is not null and
movi[p_act].cod_grupo is not null and
movi[p_act].cod_tipo is not null and
movi[p_act].cod_sec is not null then
SELECT descrip_esp,unidad_med INTO descrip1,descrip2
FROM intb00001
WHERE cod_n = movi[p_act].cod_n and
cod_grupo = movi[p_act].cod_grupo and
cod_tipo = movi[p_act].cod_tipo and
cod_sec = movi[p_act].cod_sec
and status_t is null
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
SELECT * FROM istb00002 WHERE cod_n = movi[p_act].cod_n and
cod_grupo = movi[p_Act].cod_grupo and
cod_tipo = movi[p_act].cod_tipo and
cod_sec = movi[p_act].cod_sec
and status_t is null
IF status >= 0 THEN
IF STATUS = NOTFOUND THEN
LET numero_msg = 35
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
LET movi[p_act].descrip_esp = descrip1
LET movi[p_act].unidad_med = descrip2 clipped
DISPLAY movi[p_act].descrip_esp TO s_movi1[scr_l].descrip_esp
DISPLAY movi[p_act].unidad_med TO s_movi1[scr_l].unidad_med
LET ant_art.cod_n = movi[p_act].cod_n
LET ant_art.cod_grupo = movi[p_act].cod_grupo
LET ant_art.cod_tipo = movi[p_act].cod_tipo
LET ant_art.cod_sec = movi[p_act].cod_sec
FOR idx = 1 TO arr_count()
IF idx != p_act THEN
IF movi[idx].cod_n = ant_art.cod_n AND
movi[idx].cod_grupo = ant_art.cod_grupo AND
movi[idx].cod_tipo = ant_art.cod_tipo AND
movi[idx].cod_sec = ant_art.cod_sec THEN
LET numero_msg = 21
CALL msg(numero_msg)
NEXT FIELD cod_n
END IF
END IF
END FOR
END IF
AFTER FIELD cantidad_1
IF movi[p_act].cantidad_1 IS NULL then
LET numero_msg = 16
CALL msg(numero_msg)
END IF
AFTER FIELD cantidad_2
IF movi[p_act].cod_n is not null and
movi[p_act].cod_grupo is not null and
movi[p_act].cod_tipo is not null and
movi[p_act].cod_sec is not null THEN
SELECT pto_reorden,existencia INTO chequea.* FROM istb00002
WHERE cod_n = movi[p_act].cod_n and
cod_grupo = movi[p_act].cod_grupo and
cod_tipo = movi[p_act].cod_tipo and
cod_sec = movi[p_act].cod_sec
and status_t is null
#Verifica que la cantidad digitada no exceda a la existencia
IF movi[p_act].cantidad_2 > chequea.existe THEN
LET numero_msg = 30
CALL msg(numero_msg)
NEXT FIELD cod_n
END IF
END IF
#Verifica el punto de reorden y da mensaje
LET cant = chequea.existe - movi[p_act].cantidad_2
IF cant < chequea.pto THEN
LET numero_msg = 31
CALL msg(numero_msg)
END IF
IF movi[p_act].cantidad_2 > movi[p_act].cantidad_1 THEN
LET numero_msg = 28
CALL msg(numero_msg)
END IF
IF movi[p_act].cantidad_2 IS NULL then
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD cod_n
END IF
AFTER INPUT
IF int_flag THEN
LET numero_msg = 2
CALL msg(numero_msg)
LET int_flag = false
FOR idx = 1 to arr_count()
LET movi[idx].cod_n = null
LET movi[idx].cod_grupo = null
LET movi[idx].cod_tipo = null
LET movi[idx].cod_sec = null
LET movi[idx].cantidad_1 = null
LET movi[idx].cantidad_2 = null
LET movi[idx].unidad_med = null
LET movi[idx].descrip_esp = null
END FOR
SLEEP 3
RETURN
END IF
IF movi[p_act].cod_n is not null and
movi[p_act].cod_grupo is not null and
movi[p_act].cod_tipo is not null and
movi[p_act].cod_sec is not null then
SELECT descrip_esp,unidad_med INTO descrip1,descrip2
FROM intb00001
WHERE cod_n = movi[p_act].cod_n and
cod_grupo = movi[p_act].cod_grupo and
cod_tipo = movi[p_act].cod_tipo and
cod_sec = movi[p_act].cod_sec
and status_t is null
IF STATUS = NOTFOUND THEN
LET numero_msg = 3
CALL msg(numero_msg)
NEXT FIELD cod_n
END IF
CALL integridad()
if bandera = 1 THEN
LET bandera = 0
RETURN
end if
SELECT * FROM istb00002 WHERE cod_n = movi[p_act].cod_n and
cod_grupo = movi[p_Act].cod_grupo and
cod_tipo = movi[p_act].cod_tipo and
cod_sec = movi[p_act].cod_sec
and status_t is null
IF STATUS = NOTFOUND THEN
LET numero_msg = 35
CALL msg(numero_msg)
NEXT FIELD cod_n
END IF
CALL integridad()
if bandera = 1 THEN
LET bandera = 0
RETURN
end if
LET movi[p_act].descrip_esp = descrip1
LET movi[p_act].unidad_med = descrip2 clipped
DISPLAY movi[p_act].descrip_esp TO s_movi1[scr_l].descrip_esp
DISPLAY movi[p_act].unidad_med TO s_movi1[scr_l].unidad_med
LET ant_art.cod_n = movi[p_act].cod_n
LET ant_art.cod_grupo = movi[p_act].cod_grupo
LET ant_art.cod_tipo = movi[p_act].cod_tipo
LET ant_art.cod_sec = movi[p_act].cod_sec
FOR idx = 1 TO arr_count()
IF idx != p_act THEN
IF movi[idx].cod_n = ant_art.cod_n AND
movi[idx].cod_grupo = ant_art.cod_grupo AND
movi[idx].cod_tipo = ant_art.cod_tipo AND
movi[idx].cod_sec = ant_art.cod_sec THEN
LET numero_msg = 21
CALL msg(numero_msg)
NEXT FIELD cod_n
END IF
END IF
END FOR
IF movi[p_act].cod_n is not null and
movi[p_act].cod_grupo is not null and
movi[p_act].cod_tipo is not null and
movi[p_act].cod_sec is not null THEN
SELECT pto_reorden,existencia INTO chequea.* FROM istb00002
WHERE cod_n = movi[p_act].cod_n and
cod_grupo = movi[p_act].cod_grupo and
cod_tipo = movi[p_act].cod_tipo and
cod_sec = movi[p_act].cod_sec
and status_t is null
#Verifica que la cantidad digitada no exceda a la existencia
IF movi[p_act].cantidad_2 > chequea.existe THEN
LET numero_msg = 30
CALL msg(numero_msg)
NEXT FIELD cod_n
END IF
LET cant = chequea.existe - movi[p_act].cantidad_2
IF cant < chequea.pto THEN
LET numero_msg = 31
CALL msg(numero_msg)
END IF
END IF
IF movi[p_act].cantidad_1 IS NULL and movi[p_act].cantidad_2 IS NULL THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD cod_n
END IF
END IF
IF movi[p_act].cod_n is null THEN
CALL limpia()
END IF
IF movi[p_act].cod_grupo is null THEN
CALL limpia()
END IF
IF movi[p_act].cod_tipo is null THEN
CALL limpia()
END IF
IF movi[p_act].cod_sec is null THEN
CALL limpia()
END IF
EXIT INPUT
END INPUT
PROMPT "Toda la Informacion Esta Correcta? (S/N)" FOR CHAR opc
IF OPC = "S" or OPC = "s" THEN
FOR idx = 1 TO arr_count()
IF movi[idx].cod_n is not null and movi[idx].cod_grupo is not null and
movi[idx].cod_tipo is not null and movi[idx].cod_sec is not null THEN
LET movi[idx].cantidad_2 = movi[idx].cantidad_2 * -1
INSERT INTO istb00006 VALUES
(datos1.num_doc,datos1.fecha,null,
null,null,null,null,null,
36,movi[idx].cod_n,
movi[idx].cod_grupo,movi[idx].cod_tipo,
movi[idx].cod_sec,movi[idx].cantidad_1,
movi[idx].cantidad_2,null,datos1.depto_a,
null,null,datos1.bodega,null,user,current,
null,null)
CALL integridad()
IF bandera = 1 THEN
LET bandera = 0
RETURN
END IF
LET movi[idx].cantidad_2 = movi[idx].cantidad_2 * -1
EXECUTE actualiza USING movi[idx].cantidad_2,
movi[idx].cod_n,movi[idx].cod_grupo,
movi[idx].cod_tipo,movi[idx].cod_sec
CALL integridad()
if bandera = 1 THEN
LET bandera = 0
RETURN
end if
END IF
END FOR
LET numero_msg = 1
CALL msg(numero_msg)
CLEAR FORM
FOR idx = 1 to 6
LET movi[idx].cod_n = null
LET movi[idx].cod_grupo = null
LET movi[idx].cod_tipo = null
LET movi[idx].cod_sec = null
LET movi[idx].cantidad_1 = null
LET movi[idx].cantidad_2 = null
LET movi[idx].unidad_med = null
LET movi[idx].descrip_esp = null
DISPLAY movi[idx].cod_n to s_movi1[idx].cod_n
DISPLAY movi[idx].cod_grupo to s_movi1[idx].cod_grupo
DISPLAY movi[idx].cod_tipo to s_movi1[idx].cod_tipo
DISPLAY movi[idx].cod_sec to s_movi1[idx].cod_sec
DISPLAY movi[idx].descrip_esp to s_movi1[idx].descrip_esp
DISPLAY movi[idx].unidad_med to s_movi1[idx].unidad_med
END FOR
ELSE
GOTO otra_vez
END IF
GOTO vuelve
END FUNCTION
FUNCTION limpia()
LET movi[p_act].cod_n = null
LET movi[p_act].cod_grupo = null
LET movi[p_act].cod_tipo = null
LET movi[p_act].cod_sec = null
LET movi[p_act].cantidad_1 = null
LET movi[p_act].cantidad_2 = null
LET movi[p_act].unidad_med = null
LET movi[p_act].descrip_esp = null
DISPLAY movi[p_act].cod_n to s_movi1[scr_l].cod_n
DISPLAY movi[p_act].cod_grupo to s_movi1[scr_l].cod_grupo
DISPLAY movi[p_act].cod_tipo to s_movi1[scr_l].cod_tipo
DISPLAY movi[p_act].cod_sec to s_movi1[scr_l].cod_sec
DISPLAY movi[p_act].cantidad_1 to s_movi1[scr_l].cantidad_1
DISPLAY movi[p_act].cantidad_2 to s_movi1[scr_l].cantidad_2
DISPLAY movi[p_act].unidad_med to s_movi1[scr_l].unidad_med
DISPLAY movi[p_act].descrip_esp to s_movi1[scr_l].descrip_esp
END FUNCTION