740 lines
23 KiB
Plaintext
740 lines
23 KiB
Plaintext
{
|
|
-------------------------------------------------------------------------
|
|
PROGRAMA : COPRCS011
|
|
OBJETIVO : Programa Estatus Ordenes De Compras
|
|
PROGRAMADOR : Ing. Juan F. Soto
|
|
FECHA REALIZACION : Marzo 18, 1997.
|
|
--------------------------------------------------------------------------
|
|
}
|
|
GLOBALS "coprgb000.4gl"
|
|
|
|
DEFINE st_orden RECORD
|
|
num_oc LIKE cotb00014.num_oc,
|
|
tipo LIKE cotb00014.tipo,
|
|
fech_oc LIKE cotb00014.fech_oc,
|
|
cod_sp LIKE cotb00014.cod_sp,
|
|
cod_sp_sec LIKE cotb00014.cod_sp_sec,
|
|
cierre LIKE cotb00014.cierre,
|
|
cod_pt LIKE cotb00014.cod_pt,
|
|
cod_mon LIKE cotb00015.cod_mon
|
|
END RECORD
|
|
DEFINE detalles ARRAY[70] OF CHAR(70)
|
|
|
|
DEFINE st_emb ARRAY[50] OF RECORD
|
|
cod_emb LIKE cotb00037.cod_emb,
|
|
cod_st LIKE cotb00037.cod_st,
|
|
nomb_st CHAR(20),
|
|
fecha_salida LIKE cotb00037.fecha_salida
|
|
END RECORD,
|
|
s_idx SMALLINT,
|
|
descrip_st CHAR(20)
|
|
|
|
DEFINE nombre_mon CHAR(30)
|
|
DEFINE p_cod_emb,dias_tran,cod_mon INTEGER
|
|
DEFINE dia_faltan,fecha_con,fech_s_pa,fech_pa,fecha_e_salida,fecha_e DATE
|
|
DEFINE dia_planta,emb_rec,emb_no INTEGER,
|
|
usuario LIKE cotb00037.us_crea,
|
|
fecha_c LIKE cotb00037.fech_crea,
|
|
base_m,cif,p_fletes,p_impuesto,p_acarreo,recibir DECIMAL(12,2),
|
|
ch_fecha CHAR(8),
|
|
numero_pr,numero_ft CHAR(15)
|
|
|
|
DEFINE informe ARRAY[20] OF RECORD
|
|
cod_n SMALLINT,
|
|
cod_grupo SMALLINT,
|
|
cod_tipo SMALLINT,
|
|
cod_sec SMALLINT,
|
|
descripcion CHAR(30),
|
|
unidad CHAR(4),
|
|
cantidad DECIMAL(12,2),
|
|
recibido DECIMAL(12,2)
|
|
END RECORD
|
|
|
|
FUNCTION coprcs011()
|
|
|
|
CLEAR SCREEN
|
|
OPTIONS
|
|
FORM LINE 8,
|
|
COMMENT LINE 23,
|
|
MESSAGE LINE 23,
|
|
ERROR LINE 24
|
|
|
|
LET formulario = formulario CLIPPED,"cofmcs011"
|
|
OPEN FORM cofmcs011 FROM formulario
|
|
DISPLAY FORM cofmcs011
|
|
CALL pantalla()
|
|
DISPLAY "coprcs011" AT 4,3
|
|
DISPLAY "Estatus Ordenes De Compras" AT 6,26
|
|
|
|
SELECT dia INTO dia_aduana FROM cotb00028
|
|
|
|
MENU "OPCIONES"
|
|
COMMAND "Consultar"
|
|
"<Esc> Busca Registro <Delete> Cancela Operacion"
|
|
CLEAR FORM
|
|
LET opc = "S"
|
|
LET int_flag = FALSE
|
|
CALL copcmf025()
|
|
COMMAND "Salir" "Retorna Menu Anterior"
|
|
EXIT MENU
|
|
END MENU
|
|
END FUNCTION
|
|
|
|
FUNCTION copcmf025()
|
|
#WHENEVER ERROR CONTINUE
|
|
|
|
# Aqui se prepara para la captura del criterio de seleccion
|
|
|
|
CONSTRUCT BY NAME criterio ON a.num_oc,
|
|
a.tipo,a.fech_oc,
|
|
a.cod_sp,
|
|
a.cod_sp_sec,
|
|
a.cierre
|
|
|
|
IF int_flag THEN
|
|
LET numero_msg = 2
|
|
CALL msg(numero_msg)
|
|
LET int_flag = FALSE
|
|
RETURN
|
|
END IF
|
|
|
|
LET selec =
|
|
" SELECT UNIQUE a.num_oc,a.tipo,a.fech_oc,",
|
|
" a.cod_sp,a.cod_sp_sec,",
|
|
" a.cierre, ",
|
|
" a.cod_pt,b.cod_mon ",
|
|
" FROM cotb00014 a,cotb00015 b ",
|
|
" WHERE ",
|
|
" a.num_oc = b.num_oc AND ",
|
|
" a.status_t is null AND ",criterio clipped," ORDER BY 1"
|
|
|
|
PREPARE busca FROM selec
|
|
CALL integridad()
|
|
IF bandera = 1 THEN
|
|
LET bandera = 0
|
|
RETURN
|
|
END IF
|
|
|
|
DECLARE datos SCROLL CURSOR FOR busca
|
|
OPEN datos
|
|
|
|
CALL integridad()
|
|
IF bandera = 1 THEN
|
|
LET bandera = 0
|
|
RETURN
|
|
END IF
|
|
|
|
FETCH FIRST datos INTO st_orden.*
|
|
|
|
IF status >= 0 THEN
|
|
IF status = NOTFOUND THEN
|
|
LET numero_msg = 3
|
|
CALL msg(numero_msg)
|
|
RETURN
|
|
END IF
|
|
|
|
CALL integridad()
|
|
IF bandera = 1 THEN
|
|
LET bandera = 0
|
|
RETURN
|
|
END IF
|
|
END IF
|
|
|
|
# Funcion para la busqueda de lo suplidores, Terminos ded pago,
|
|
# descripcion del puesto y la via
|
|
|
|
CALL escoge25()
|
|
|
|
DISPLAY BY NAME st_orden.*,suplidor.nom_sp,
|
|
nombre_p,st_orden.cod_mon,nombre_mon,
|
|
st_orden.fech_oc
|
|
|
|
IF int_flag THEN
|
|
LET numero_msg = 2
|
|
CALL msg(numero_msg)
|
|
LET int_flag = FALSE
|
|
RETURN
|
|
END IF
|
|
|
|
# Menu para la busqueda de las informaciones en forma direccional
|
|
MENU "OPCIONES "
|
|
COMMAND "Siguiente"
|
|
"Presenta en pantalla el proximo registro encontrado"
|
|
FETCH NEXT datos INTO st_orden.*
|
|
|
|
IF status = NOTFOUND THEN
|
|
LET numero_msg = 4
|
|
CALL msg(numero_msg)
|
|
END IF
|
|
CALL escoge25()
|
|
|
|
DISPLAY BY NAME st_orden.*,suplidor.nom_sp,
|
|
nombre_p,st_orden.cod_mon,nombre_mon,
|
|
st_orden.fech_oc
|
|
CALL busca_detalle()
|
|
|
|
COMMAND "Anterior"
|
|
"Presenta en pantalla el registro anterior encontrado"
|
|
FETCH PREVIOUS datos INTO st_orden.*
|
|
|
|
IF status = NOTFOUND THEN
|
|
LET numero_msg = 5
|
|
CALL msg(numero_msg)
|
|
END IF
|
|
CALL escoge25()
|
|
|
|
DISPLAY BY NAME st_orden.*,suplidor.nom_sp,
|
|
nombre_p,st_orden.cod_mon,nombre_mon,
|
|
st_orden.fech_oc
|
|
CALL busca_detalle()
|
|
|
|
COMMAND "Primero"
|
|
"Presenta en pantalla el primer registro encontrado"
|
|
FETCH FIRST datos INTO st_orden.*
|
|
|
|
CALL escoge25()
|
|
|
|
DISPLAY BY NAME st_orden.*,suplidor.nom_sp,
|
|
nombre_p,st_orden.cod_mon,nombre_mon,
|
|
st_orden.fech_oc
|
|
CALL busca_detalle()
|
|
|
|
LET numero_msg = 5
|
|
CALL msg(numero_msg)
|
|
|
|
COMMAND "Ultimo"
|
|
"Presenta en pantalla el ultimo registro encontrado"
|
|
FETCH LAST datos INTO st_orden.*
|
|
|
|
CALL escoge25()
|
|
|
|
DISPLAY BY NAME st_orden.*,suplidor.nom_sp,
|
|
nombre_p,st_orden.cod_mon,nombre_mon,
|
|
st_orden.fech_oc
|
|
|
|
CALL busca_detalle()
|
|
LET numero_msg = 4
|
|
CALL msg(numero_msg)
|
|
|
|
COMMAND "Detalles"
|
|
"<Delete> Cancela Operacion"
|
|
MESSAGE "<Ctrl-P> Busca Embarques <Ctrl-B> Busca Descripcion Items"
|
|
|
|
CALL busca_detalle()
|
|
IF int_flag THEN
|
|
LET numero_msg = 2
|
|
CALL msg(numero_msg)
|
|
LET int_flag = FALSE
|
|
EXIT MENU
|
|
END IF
|
|
CALL set_count(idx -1)
|
|
DISPLAY ARRAY arr_ordenes2 TO consart.*
|
|
ON KEY (CONTROL-B)
|
|
LET curr = arr_curr()
|
|
SELECT a.descrip_esp,a.unidad_med
|
|
INTO articulos.descrip_esp,articulos.unidad_med
|
|
FROM intb00001 a
|
|
WHERE
|
|
a.cod_n = arr_ordenes2[curr].cod_n AND
|
|
a.cod_grupo = arr_ordenes2[curr].cod_grupo AND
|
|
a.cod_tipo = arr_ordenes2[curr].cod_tipo AND
|
|
a.cod_sec = arr_ordenes2[curr].cod_sec
|
|
|
|
IF STATUS = NOTFOUND THEN
|
|
LET articulos.descrip_esp = "ITEM NO EXISTE"
|
|
LET numero_msg = 13
|
|
CALL msg(numero_msg)
|
|
END IF
|
|
DISPLAY BY NAME articulos.descrip_esp,articulos.unidad_med
|
|
|
|
|
|
ON KEY (CONTROL-P)
|
|
LET curr = arr_curr()
|
|
|
|
# BUSCA NUMERO DE EMBARQUES DE LA ORDEN
|
|
DECLARE busca_no CURSOR FOR
|
|
SELECT COUNT(*),a.FECH_EMB FROM cotb00025 a
|
|
WHERE a.num_oc = st_orden.num_oc AND
|
|
a.tipo = st_orden.tipo AND
|
|
a.cod_n = arr_ordenes2[curr].cod_n AND
|
|
a.cod_grupo = arr_ordenes2[curr].cod_grupo AND
|
|
a.cod_tipo = arr_ordenes2[curr].cod_tipo AND
|
|
a.cod_sec = arr_ordenes2[curr].cod_sec
|
|
|
|
GROUP BY 2
|
|
|
|
LET emb_no = 0
|
|
LET emb_rec = 0
|
|
FOREACH busca_no INTO emb_no,fecha_e
|
|
LET emb_no = emb_no + 1
|
|
LET ch_fecha = fecha_e
|
|
LET p_cod_emb = ch_fecha[1,6]
|
|
|
|
SELECT UNIQUE cod_n FROM cotb00038 a
|
|
WHERE a.num_oc = st_orden.num_oc AND
|
|
a.cod_emb = p_cod_emb AND
|
|
a.cod_n = arr_ordenes2[curr].cod_n AND
|
|
a.cod_grupo = arr_ordenes2[curr].cod_grupo AND
|
|
a.cod_tipo = arr_ordenes2[curr].cod_tipo AND
|
|
a.cod_sec = arr_ordenes2[curr].cod_sec
|
|
|
|
IF STATUS != NOTFOUND THEN
|
|
LET emb_rec= emb_rec + 1
|
|
END IF
|
|
END FOREACH
|
|
|
|
DISPLAY BY NAME emb_no,emb_rec
|
|
|
|
IF int_flag THEN
|
|
LET numero_msg = 2
|
|
CALL msg(numero_msg)
|
|
EXIT DISPLAY
|
|
END IF
|
|
|
|
|
|
# BUSCA LOS EMBARQUES
|
|
DECLARE busca_emb CURSOR FOR
|
|
|
|
SELECT a.cod_emb,a.cod_st,b.descripcion,a.fecha_salida,a.us_crea,
|
|
a.fech_crea
|
|
FROM cotb00037 a, OUTER cotb00041 b
|
|
WHERE a.cod_st = b.cod_st AND
|
|
a.num_oc = st_orden.num_oc AND
|
|
a.tipo = st_orden.tipo AND
|
|
a.cod_n = arr_ordenes2[curr].cod_n AND
|
|
a.cod_grupo = arr_ordenes2[curr].cod_grupo AND
|
|
a.cod_tipo = arr_ordenes2[curr].cod_tipo AND
|
|
a.cod_sec = arr_ordenes2[curr].cod_sec
|
|
|
|
ORDER BY 1
|
|
|
|
LET idx = 1
|
|
FOREACH busca_emb INTO st_emb[idx].*,usuario,fecha_c
|
|
|
|
LET idx = idx + 1
|
|
LET st_emb[idx].nomb_st = NULL
|
|
END FOREACH
|
|
CALL set_count(idx -1)
|
|
|
|
INPUT ARRAY st_emb WITHOUT DEFAULTS FROM emb.*
|
|
ON KEY (CONTROL-N)
|
|
LET idx = arr_curr()
|
|
IF st_emb[idx].cod_emb IS NOT NULL THEN
|
|
LET p_cod_emb = st_emb[idx].cod_emb
|
|
CALL inform_emb()
|
|
END IF
|
|
IF int_flag THEN
|
|
LET numero_msg = 2
|
|
CALL msg(numero_msg)
|
|
EXIT DISPLAY
|
|
END IF
|
|
AFTER FIELD cod_st
|
|
LET idx = arr_curr()
|
|
LET s_idx = scr_line()
|
|
IF st_emb[idx].cod_st IS NOT NULL THEN
|
|
SELECT a.descripcion INTO descrip_st
|
|
FROM cotb00041 a
|
|
WHERE a.cod_st = st_emb[idx].cod_st AND
|
|
a.status_t IS NULL
|
|
IF STATUS = NOTFOUND THEN
|
|
LET numero_msg = 3
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD cod_st
|
|
END IF
|
|
LET st_emb[idx].nomb_st = descrip_st
|
|
|
|
DISPLAY st_emb[idx].nomb_st TO emb[s_idx].nomb_st
|
|
END IF
|
|
AFTER INPUT
|
|
END INPUT
|
|
|
|
# ACTUALIZACION TABLA DE EMBARQUES
|
|
IF int_flag THEN
|
|
LET numero_msg = 2
|
|
CALL msg(numero_msg)
|
|
LET int_flag = false
|
|
RETURN
|
|
END IF
|
|
FOR idx = 1 TO arr_count()
|
|
|
|
IF st_emb[idx].cod_emb IS NOT NULL THEN
|
|
UPDATE cotb00037 SET cod_st = st_emb[idx].cod_st,
|
|
fecha_salida = st_emb[idx].fecha_salida,
|
|
us_mod = USER,
|
|
fech_mod = CURRENT
|
|
WHERE num_oc = st_orden.num_oc AND
|
|
cod_n = arr_ordenes2[curr].cod_n AND
|
|
cod_grupo = arr_ordenes2[curr].cod_grupo AND
|
|
cod_tipo = arr_ordenes2[curr].cod_tipo AND
|
|
cod_sec = arr_ordenes2[curr].cod_sec AND
|
|
cod_emb = st_emb[idx].cod_emb
|
|
|
|
LET numero_msg = 13
|
|
CALL msg(numero_msg)
|
|
END IF
|
|
END FOR
|
|
|
|
MESSAGE "<Ctrl-P> Busca Embarques <Ctrl-B> Busca Descripcion Items"
|
|
LET numero_msg = 13
|
|
CALL msg(numero_msg)
|
|
END DISPLAY
|
|
IF int_flag THEN
|
|
LET numero_msg = 2
|
|
CALL msg(numero_msg)
|
|
LET int_flag = false
|
|
EXIT MENU
|
|
END IF
|
|
|
|
COMMAND "Retornar"
|
|
"Retorna al menu anterior"
|
|
CLEAR FORM
|
|
EXIT MENU
|
|
END MENU
|
|
|
|
END FUNCTION
|
|
|
|
FUNCTION escoge25()
|
|
SELECT nom_sp INTO suplidor.nom_sp FROM cotb00001
|
|
WHERE cod_sp = st_orden.cod_sp AND
|
|
cod_sp_sec = st_orden.cod_sp_sec AND
|
|
status_t is null
|
|
|
|
IF st_orden.cod_pt IS NOT NULL THEN
|
|
SELECT nom_pt INTO nombre_p FROM cotb00019
|
|
WHERE cod_pt = st_orden.cod_pt AND
|
|
status_t is null
|
|
END IF
|
|
|
|
IF st_orden.cod_mon IS NOT NULL THEN
|
|
LET nombre_mon = "MONEDA NO EXISTE"
|
|
SELECT descrip_mon INTO nombre_mon FROM cotb00031
|
|
WHERE cod_mon = st_orden.cod_mon AND
|
|
status_t is null
|
|
END IF
|
|
END FUNCTION
|
|
|
|
FUNCTION inform_emb()
|
|
OPEN WINDOW informa AT 3,3 WITH FORM "cofmwd018" ATTRIBUTE
|
|
( BORDER,COMMENT LINE LAST ,FORM LINE FIRST,MESSAGE LINE LAST -1)
|
|
|
|
DISPLAY BY NAME p_cod_emb
|
|
|
|
DECLARE busca_inf CURSOR FOR
|
|
SELECT a.cod_n,a.cod_grupo,a.cod_tipo,a.cod_sec,b.descrip_esp,b.unidad_med,
|
|
a.cantidad,c.cantidad
|
|
FROM cotb00037 a,intb00001 b,OUTER cotb00038 c
|
|
WHERE a.cod_emb = p_cod_emb AND
|
|
a.num_oc = st_orden.num_oc 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 a.status_t IS NULL AND
|
|
a.cod_n = arr_ordenes2[curr].cod_n AND
|
|
a.cod_grupo = arr_ordenes2[curr].cod_grupo AND
|
|
a.cod_tipo = arr_ordenes2[curr].cod_tipo AND
|
|
a.cod_sec = arr_ordenes2[curr].cod_sec AND a.status_t IS NULL AND
|
|
c.cod_n = a.cod_n AND
|
|
c.cod_grupo = b.cod_grupo AND
|
|
c.cod_tipo = b.cod_tipo AND
|
|
c.cod_sec = b.cod_sec AND
|
|
c.num_oc = a.num_oc AND
|
|
c.cod_emb = a.cod_emb
|
|
ORDER BY 1,2,3,4
|
|
|
|
LET idx = 1
|
|
FOREACH busca_inf INTO informe[idx].*
|
|
LET idx = idx + 1
|
|
END FOREACH
|
|
|
|
IF int_flag THEN
|
|
LET numero_msg = 2
|
|
CALL msg(numero_msg)
|
|
LET int_flag = false
|
|
RETURN
|
|
END IF
|
|
IF idx = 1 THEN
|
|
LET numero_msg = 3
|
|
CALL msg(numero_msg)
|
|
RETURN
|
|
END IF
|
|
|
|
MESSAGE "<Esc> Se Dirige A Datos Generales Del Embarque"
|
|
DISPLAY ARRAY informe TO informa.*
|
|
MESSAGE " "
|
|
IF int_flag THEN
|
|
LET numero_msg = 2
|
|
CALL msg(numero_msg)
|
|
LET int_flag = false
|
|
GOTO sale
|
|
END IF
|
|
|
|
LET ch_fecha = p_cod_emb USING "&&&&&&"
|
|
LET ch_fecha = ch_fecha CLIPPED
|
|
|
|
LET fecha_e_salida = ch_fecha CLIPPED
|
|
DISPLAY BY NAME fecha_e_salida
|
|
|
|
SELECT UNIQUE a.fecha_confirm INTO fecha_con
|
|
FROM cotb00037 a
|
|
WHERE a.cod_emb = p_cod_emb AND
|
|
a.cod_n = arr_ordenes2[curr].cod_n AND
|
|
a.cod_grupo = arr_ordenes2[curr].cod_grupo AND
|
|
a.cod_tipo = arr_ordenes2[curr].cod_tipo AND
|
|
a.cod_sec = arr_ordenes2[curr].cod_sec
|
|
|
|
INPUT BY NAME fecha_con WITHOUT DEFAULTS
|
|
AFTER FIELD fecha_con
|
|
IF fecha_con < fecha_e_salida THEN
|
|
LET numero_msg = 365
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD fecha_con
|
|
END IF
|
|
END INPUT
|
|
|
|
IF int_flag THEN
|
|
LET numero_msg = 2
|
|
CALL msg(numero_msg)
|
|
LET int_flag = false
|
|
GOTO sale
|
|
END IF
|
|
|
|
# ACTUALIZACION FECHA CONFIRMADA
|
|
UPDATE cotb00037 SET fecha_confirm = fecha_con,
|
|
us_crea = user,
|
|
fech_mod = current
|
|
WHERE cod_emb = p_cod_emb
|
|
|
|
|
|
# BUSCA EL DIA DE LLEGADA MAYOR EN LOS ITEMS QUE TIENE LA ORDEN
|
|
SELECT MAX(a.dia_llegada),MAX(a.base) INTO m_articulos.dia_llegada,base_m
|
|
FROM intb00002 a, cotb00037 b
|
|
WHERE 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
|
|
a.cod_n = arr_ordenes2[curr].cod_n AND
|
|
a.cod_grupo = arr_ordenes2[curr].cod_grupo AND
|
|
a.cod_tipo = arr_ordenes2[curr].cod_tipo AND
|
|
a.cod_sec = arr_ordenes2[curr].cod_sec AND
|
|
b.cod_emb = p_cod_emb
|
|
|
|
# BUSCA LOS DIAS QUE DURA UN ITEM EN ADUANA
|
|
SELECT dia INTO dia_aduana
|
|
FROM cotb00028
|
|
|
|
LET dias_tran = m_articulos.dia_llegada
|
|
LET dia_faltan = fecha_con + m_articulos.dia_llegada
|
|
LET dia_planta = dia_faltan - TODAY + dia_aduana
|
|
|
|
DISPLAY BY NAME dias_tran,dia_planta,fecha_con,dia_faltan
|
|
|
|
# BUSCA EL NUMERO DE LA PROFORMA EN LA ORDEN
|
|
|
|
SELECT UNIQUE a.num_pr INTO numero_pr
|
|
FROM cotb00014 a,cotb00037 b
|
|
WHERE a.num_oc = b.num_oc AND
|
|
a.num_oc = st_orden.num_oc AND
|
|
b.cod_emb = p_cod_emb
|
|
|
|
DISPLAY BY NAME numero_pr
|
|
|
|
# CALCULA EL VALOR FOB,CIF,IMPUESTO ADUANA,FLETE
|
|
|
|
SELECT a.c_flete,SUM(c.cantidad*c.precio)
|
|
INTO cif,fob
|
|
FROM cotb00014 a,cotb00037 b,cotb00015 c
|
|
WHERE
|
|
b.cod_n = c.cod_n AND
|
|
b.cod_grupo = c.cod_grupo AND
|
|
b.cod_tipo = c.cod_tipo AND
|
|
b.cod_sec = c.cod_sec AND
|
|
a.num_oc = c.num_oc AND
|
|
a.num_oc = b.num_oc AND
|
|
b.cod_emb = p_cod_emb AND
|
|
a.num_oc = st_orden.num_oc
|
|
|
|
GROUP BY 1
|
|
IF base_m IS NULL OR base_m = 0 THEN
|
|
LET base_m = 1
|
|
END IF
|
|
LET fob = fob / base_m
|
|
|
|
DISPLAY BY NAME fob,cif
|
|
|
|
SELECT a.num_fact,a.num_pr,a.fletes,a.impuesto,a.acarreo,a.fech_sol_pa,
|
|
a.fecha_pago
|
|
INTO numero_ft,numero_pr,p_fletes,p_impuesto,p_acarreo,fech_s_pa,
|
|
fech_pa
|
|
FROM cotb00039 a
|
|
WHERE a.cod_emb = p_cod_emb AND
|
|
a.num_oc = st_orden.num_oc AND
|
|
a.tipo = st_orden.tipo
|
|
INPUT BY NAME numero_pr,numero_ft,p_fletes,p_impuesto,p_acarreo,fech_s_pa,
|
|
fech_pa WITHOUT DEFAULTS
|
|
AFTER FIELD fech_s_pa
|
|
IF fech_s_pa < st_orden.fech_oc THEN
|
|
LET numero_msg = 366
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD fech_s_pa
|
|
END IF
|
|
IF fech_s_pa < fecha_con THEN
|
|
LET numero_msg = 367
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD fech_s_pa
|
|
END IF
|
|
IF fech_s_pa < fecha_e_salida THEN
|
|
LET numero_msg = 367
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD fech_s_pa
|
|
END IF
|
|
AFTER FIELD fech_pa
|
|
IF fech_pa < st_orden.fech_oc THEN
|
|
LET numero_msg = 366
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD fech_s_pa
|
|
END IF
|
|
IF fech_pa < fecha_con THEN
|
|
LET numero_msg = 367
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD fech_s_pa
|
|
END IF
|
|
IF fech_pa < fecha_e_salida THEN
|
|
LET numero_msg = 367
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD fech_s_pa
|
|
END IF
|
|
AFTER INPUT
|
|
END INPUT
|
|
IF int_flag THEN
|
|
LET numero_msg = 2
|
|
CALL msg(numero_msg)
|
|
LET int_flag = FALSE
|
|
RETURN
|
|
END IF
|
|
DECLARE busca_de CURSOR FOR
|
|
SELECT a.detalle,a.us_crea,a.fech_crea,a.no_linea FROM cotb00040 a
|
|
WHERE a.cod_emb = p_cod_emb AND
|
|
a.num_oc = st_orden.num_oc
|
|
ORDER BY 4
|
|
LET idx = 1
|
|
FOREACH busca_de INTO detalles[idx],usuario,fecha_c
|
|
LET idx = idx + 1
|
|
END FOREACH
|
|
CALL set_count(idx-1)
|
|
INPUT ARRAY detalles WITHOUT DEFAULTS FROM detalla.*
|
|
|
|
IF int_flag THEN
|
|
LET numero_msg = 2
|
|
CALL msg(numero_msg)
|
|
LET int_flag = FALSE
|
|
RETURN
|
|
END IF
|
|
|
|
# Actualizacion de la Tabla - Comentarios Del Estatus De La Oren -
|
|
DELETE FROM cotb00040 WHERE cod_emb = p_cod_emb AND
|
|
num_oc = st_orden.num_oc
|
|
FOR idx = 1 TO arr_count()
|
|
IF detalles[idx] IS NOT NULL THEN
|
|
IF usuario IS NULL THEN
|
|
INSERT INTO cotb00040 VALUES (idx,p_cod_emb,st_orden.num_oc,
|
|
detalles[idx],
|
|
user,current,NULL,NULL)
|
|
ELSE
|
|
INSERT INTO cotb00040 VALUES (idx,p_cod_emb,st_orden.num_oc,
|
|
detalles[idx],
|
|
usuario,fecha_c,user,current)
|
|
END IF
|
|
END IF
|
|
END FOR
|
|
|
|
SELECT UNIQUE a.cod_emb FROM cotb00039 a
|
|
WHERE a.cod_emb = p_cod_emb
|
|
|
|
IF STATUS = NOTFOUND THEN
|
|
INSERT INTO cotb00039 VALUES
|
|
(st_orden.num_oc,st_orden.tipo,p_cod_emb,numero_ft,numero_pr,
|
|
p_fletes,p_impuesto,p_acarreo,fech_s_pa,fech_pa,
|
|
user,current,null,null)
|
|
ELSE
|
|
UPDATE cotb00039 SET num_fact = numero_ft,
|
|
num_pr = numero_pr,
|
|
fletes = p_fletes,
|
|
impuesto = p_impuesto,
|
|
acarreo = p_acarreo,
|
|
fech_sol_pa = fech_s_pa,
|
|
fecha_pago = fech_pa,
|
|
us_mod = user,
|
|
fech_mod = current
|
|
WHERE cod_emb = p_cod_emb AND
|
|
num_oc = st_orden.num_oc AND
|
|
tipo = st_orden.tipo
|
|
END IF
|
|
LET numero_msg = 13
|
|
CALL msg(numero_msg)
|
|
LABEL sale:
|
|
CLOSE WINDOW informa
|
|
END FUNCTION
|
|
|
|
FUNCTION busca_detalle()
|
|
FOR idx = 1 TO 3
|
|
LET arr_ordenes2[idx].num_req = NULL
|
|
LET arr_ordenes2[idx].cod_n = NULL
|
|
LET arr_ordenes2[idx].cod_grupo = NULL
|
|
LET arr_ordenes2[idx].cod_tipo = NULL
|
|
LET arr_ordenes2[idx].cod_sec = NULL
|
|
LET arr_ordenes2[idx].cantidad = NULL
|
|
LET arr_ordenes2[idx].precio = NULL
|
|
LET arr_ordenes2[idx].valor = NULL
|
|
END FOR
|
|
DECLARE busca20 CURSOR FOR
|
|
SELECT a.num_req,a.cod_n,a.cod_grupo,a.cod_tipo,a.cod_Sec,a.cantidad,
|
|
a.precio
|
|
FROM cotb00015 a
|
|
WHERE (a.num_oc = st_orden.num_oc AND
|
|
a.tipo = st_orden.tipo) AND
|
|
a.status_t is null
|
|
|
|
LET idx = 1
|
|
FOREACH busca20 INTO arr_ordenes2[idx].*
|
|
|
|
LET recibir = 0
|
|
SELECT SUM(a.cantidad) INTO recibir
|
|
FROM cotb00038 a
|
|
WHERE a.cod_n = arr_ordenes2[idx].cod_n AND
|
|
a.cod_grupo = arr_ordenes2[idx].cod_grupo AND
|
|
a.cod_tipo = arr_ordenes2[idx].cod_tipo AND
|
|
a.cod_sec = arr_ordenes2[idx].cod_sec AND
|
|
a.num_oc = st_orden.num_oc AND
|
|
a.status_t IS NULL
|
|
|
|
SELECT a.base INTO m_articulos.base FROM intb00002 a
|
|
WHERE a.cod_n = arr_ordenes2[idx].cod_n AND
|
|
a.cod_grupo = arr_ordenes2[idx].cod_grupo AND
|
|
a.cod_tipo = arr_ordenes2[idx].cod_tipo AND
|
|
a.cod_sec = arr_ordenes2[idx].cod_sec AND
|
|
a.status_t IS NULL
|
|
|
|
IF m_articulos.base IS NULL OR m_articulos.base = 0 THEN
|
|
LET m_articulos.base = 1
|
|
END IF
|
|
LET arr_ordenes2[idx].valor=(arr_ordenes2[idx].cantidad/m_articulos.base)
|
|
* arr_ordenes2[idx].precio
|
|
|
|
IF recibir IS NULL THEN
|
|
LET recibir = 0
|
|
END IF
|
|
LET arr_ordenes2[idx].recibido = recibir
|
|
LET idx = idx + 1
|
|
END FOREACH
|
|
FOR idx = 1 TO 3
|
|
DISPLAY arr_ordenes2[idx].num_req TO consart[idx].num_req
|
|
DISPLAY arr_ordenes2[idx].cod_n TO consart[idx].cod_n
|
|
DISPLAY arr_ordenes2[idx].cod_grupo TO consart[idx].cod_grupo
|
|
DISPLAY arr_ordenes2[idx].cod_tipo TO consart[idx].cod_tipo
|
|
DISPLAY arr_ordenes2[idx].cod_sec TO consart[idx].cod_sec
|
|
DISPLAY arr_ordenes2[idx].cantidad TO consart[idx].cantidad
|
|
DISPLAY arr_ordenes2[idx].precio TO consart[idx].precio
|
|
DISPLAY arr_ordenes2[idx].valor TO consart[idx].valor
|
|
END FOR
|
|
END FUNCTION
|