Files
MBS/PROYECTO/codir/coprmt021.4gl
T

245 lines
8.4 KiB
Plaintext

{
-------------------------------------------------------------------------
PROGRAMA : COPRMT021
REALIZADO POR : Tadeo A. Ferreras F.
FECHA : Noviembre 17, 1994.
DESCRIPCION : Modificar Ordenes de Compras Guardando Original
--------------------------------------------------------------------------
}
GLOBALS "coprgb000.4gl"
DEFINE c_i_d,c_i_d1,nota,nota1,nombre_mon CHAR(30)
DEFINE simb_mon CHAR(4)
DEFINE nom_via CHAR(10)
DEFINE req_ant ARRAY[100] OF INTEGER
DEFINE opc1,opc2,opc4,salir,proce CHAR(1)
DEFINE cod_mon,control_linea,control_item,idx2,total_parc INTEGER
DEFINE fecha1 DATE
DEFINE valor2,total DECIMAL(12,2)
DEFINE j RECORD LIKE cotb00025.*
DEFINE idx1,arr_1,requis INTEGER
FUNCTION coprmt021()
DEFINE p_cantidad DECIMAL(12,2),
p_precio DECIMAL(10,2)
CLEAR SCREEN
OPTIONS
FORM LINE 8,
ERROR LINE 24,
COMMENT LINE 22,
PROMPT LINE 23,
MESSAGE LINE 22
OPEN FORM cofmmt021 FROM "cofmmt021"
DISPLAY FORM cofmmt021
CALL pantalla()
DISPLAY "coprmt021" AT 4,3
DISPLAY "Actualizacion de Ordenes" AT 6,28
#WHENEVER ERROR CONTINUE
SELECT dia INTO dia_aduana FROM cotb00028
# Aqui se prepara para la captura del criterio de seleccion
LET modifica = "S"
INPUT BY NAME ordenes.num_oc,ordenes.tipo,ordenes.cierre
AFTER FIELD num_oc
IF ordenes.num_oc IS NULL THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD num_oc
END IF
AFTER FIELD tipo
IF ordenes.tipo IS NULL THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD tipo
END IF
SELECT UNIQUE a.cod_sp,a.cod_sp_sec,b.nom_sp,a.fech_oc,a.cierre,a.cod_pt
INTO ordenes.cod_sp,ordenes.cod_sp_sec,suplidor.nom_sp,ordenes.fech_oc,
ordenes.cierre,ordenes.cod_pt
FROM cotb00014 a,cotb00001 b
WHERE a.cod_sp = b.cod_sp AND a.cod_sp_sec = b.cod_sp_sec AND
a.num_oc = ordenes.num_oc AND a.tipo = ordenes.tipo AND
a.status_t IS NULL
IF STATUS = NOTFOUND THEN
LET numero_msg = 3
CALL msg(numero_msg)
NEXT FIELD num_oc
END IF
IF ordenes.cod_pt is not null THEN
SELECT a.nom_pt,a.duracion INTO nombre_p,m_articulos.dia_llegada
FROM cotb00019 a
WHERE cod_pt = ordenes.cod_pt
END IF
SELECT UNIQUE a.cod_mon INTO cod_mon FROM cotb00015 a
WHERE a.tipo = ordenes.tipo AND a.num_oc = ordenes.num_oc
DISPLAY BY NAME ordenes.cod_sp,ordenes.cod_sp_sec,suplidor.nom_sp,
ordenes.fech_oc,ordenes.cierre,nombre_p
AFTER FIELD cierre
IF ordenes.cierre IS NULL THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD cierre
END IF
END INPUT
IF int_flag THEN
LET numero_msg = 2
CALL msg(numero_msg)
LET int_flag = FALSE
RETURN
END IF
DECLARE busca CURSOR FOR
SELECT UNIQUE a.num_req,a.cod_n,a.cod_grupo,a.cod_tipo,a.cod_sec,
a.cantidad,a.num_parte,a.precio,b.base * 1.0
FROM cotb00015 a,OUTER intb00002 b
WHERE a.tipo = ordenes.tipo AND a.num_oc = ordenes.num_oc AND
a.status_t IS NULL AND b.cod_n = a.cod_n AND
b.cod_grupo = a.cod_grupo AND b.cod_tipo = a.cod_tipo AND
b.cod_sec = a.cod_sec ORDER BY 1,2,3,4,5
LET idx = 1
LET idx1 = 0
FOREACH busca INTO arr_ordenes[idx].*
LET idx1= idx1+ 1
IF arr_ordenes[idx].valor IS NULL THEN
LET arr_ordenes[idx].valor = 1
END IF
LET arr_ordenes[idx].valor = (arr_ordenes[idx].cantidad/
arr_ordenes[idx].valor)*
arr_ordenes[idx].precio
SELECT a.cantidad,a.precio INTO
p_cantidad,p_precio
FROM cotb00015 a
WHERE a.cod_n=arr_ordenes[idx].cod_n and
a.cod_grupo=arr_ordenes[idx].cod_grupo and
a.cod_tipo=arr_ordenes[idx].cod_tipo and
a.cod_sec=arr_ordenes[idx].cod_sec AND
a.num_req= arr_ordenes[idx].num_req AND
a.num_oc = ordenes.num_oc AND
a.tipo = ordenes.tipo
LET arr_ordenes[idx1].cantidad = p_cantidad
LET arr_ordenes[idx1].precio = p_precio
LET arr_ordenes[idx].valor = arr_ordenes[idx].cantidad *
arr_ordenes[idx].precio
LET arr_ordenes21[idx1].num_req = arr_ordenes[idx].num_req
LET arr_ordenes21[idx1].cod_n = arr_ordenes[idx].cod_n
LET arr_ordenes21[idx1].cod_grupo = arr_ordenes[idx].cod_grupo
LET arr_ordenes21[idx1].cod_tipo = arr_ordenes[idx].cod_tipo
LET arr_ordenes21[idx1].cod_sec = arr_ordenes[idx].cod_sec
LET arr_ordenes21[idx1].cantidad = arr_ordenes[idx].cantidad
LET arr_ordenes21[idx1].precio = arr_ordenes[idx].precio
LET idx = idx + 1
END FOREACH
CALL SET_COUNT(idx -1)
INPUT ARRAY arr_ordenes WITHOUT DEFAULTS FROM consart.* ATTRIBUTE (YELLOW)
BEFORE ROW
LET curr = arr_curr()
LET scr_l = scr_line()
BEFORE FIELD num_req
SELECT a.descrip_esp,a.unidad_med
INTO articulos.descrip_esp,articulos.unidad_med
FROM intb00001 a
WHERE a.cod_n=arr_ordenes[curr].cod_n and
a.cod_grupo=arr_ordenes[curr].cod_grupo and
a.cod_tipo=arr_ordenes[curr].cod_tipo and
a.cod_sec=arr_ordenes[curr].cod_sec
SELECT a.cod_nab,a.descrip_esp INTO m_articulos.cod_nab,descrip1
FROM cotb00005 a,intb00002 b
WHERE b.cod_n=arr_ordenes[curr].cod_n and
b.cod_grupo=arr_ordenes[curr].cod_grupo and
b.cod_tipo=arr_ordenes[curr].cod_tipo and
b.cod_sec=arr_ordenes[curr].cod_sec and
a.cod_nab = b.cod_nab
DISPLAY BY NAME m_articulos.cod_nab,descrip1,articulos.descrip_esp,
articulos.unidad_med
DISPLAY arr_ordenes[curr].cantidad,arr_ordenes[curr].precio,
arr_ordenes[curr].valor
TO consart[scr_l].cantidad,consart[scr_l].precio,
consart[scr_l].valor
NEXT FIELD num_parte
END INPUT
IF int_flag THEN
LET numero_msg = 2
CALL msg(numero_msg)
LET int_flag = FALSE
RETURN
END IF
LET opc = "N"
PROMPT "Toda la informacion esta correcta (S/N)?" FOR CHAR OPC
LET opc = UPSHIFT(opc)
IF opc = "S" THEN
INSERT INTO cotb00032 SELECT *FROM cotb00015
WHERE @tipo = ordenes.tipo AND @num_oc = ordenes.num_oc
UPDATE cotb00014 set (cierre,us_mod,fech_mod) =
(ordenes.cierre,USER,CURRENT)
WHERE @num_oc = ordenes.num_oc AND @tipo = ordenes.tipo
{ FOR idx = 1 TO idx1
INSERT INTO cotb00032 VALUES (ordenes.num_oc,arr_ordenes21[idx].num_req,
ordenes.tipo,arr_ordenes21[idx].cod_n,arr_ordenes21[idx].cod_grupo,
arr_ordenes21[idx].cod_tipo, arr_ordenes21[idx].cod_sec,
arr_ordenes21[idx].num_parte, arr_ordenes21[idx].cantidad,
arr_ordenes21[idx].precio,cod_mon,null,user,current,user,current)
END FOR
}
DELETE FROM cotb00015 WHERE tipo = ordenes.tipo AND
num_oc = ordenes.num_oc
FOR idx = 1 TO ARR_COUNT()
IF arr_ordenes[idx].num_req = 0 THEN
LET arr_ordenes[idx].num_req = null
END IF
IF arr_ordenes[idx].num_req IS NOT NULL THEN
IF arr_ordenes[idx].cod_n is not null THEN
INSERT INTO cotb00015 VALUES (ordenes.num_oc,arr_ordenes[idx].num_req,
ordenes.tipo,arr_ordenes[idx].cod_n,arr_ordenes[idx].cod_grupo,
arr_ordenes[idx].cod_tipo, arr_ordenes[idx].cod_sec,
arr_ordenes[idx].cantidad,
arr_ordenes[idx].precio,cod_mon,null,user,current,null,null)
END IF
END IF
END FOR
LET numero_msg = 13
CALL msg(numero_msg)
END IF
END FUNCTION