483 lines
16 KiB
Plaintext
483 lines
16 KiB
Plaintext
{
|
|
-----------------------------------------------------------------------------
|
|
PROGRAMA : COPRCS009
|
|
FUNCION : CONSULTA ORDENES DE COMPRA
|
|
PROGRAMADOR : Ing. Juan Fco. Soto
|
|
FECHA : Diciembre 1997
|
|
DIRECTOR PROYECTO : JOSE ALFREDO PAULINO ALEJO
|
|
------------------------------------------------------------------------------
|
|
}
|
|
GLOBALS "coprgb000.4gl"
|
|
|
|
DEFINE nota, nota1, c_i_d, c_i_d1 CHAR(30)
|
|
MAIN
|
|
DEFER INTERRUPT
|
|
CALL ARG_VAL(1) RETURNING usuarios
|
|
CALL ARG_VAL(2) RETURNING clave
|
|
|
|
CONNECT TO "smarmotech" AS "SQL_C" USER usuarios USING clave
|
|
SELECT a.* INTO p_companias.* FROM companias a
|
|
|
|
CALL coprcs009()
|
|
END MAIN
|
|
FUNCTION coprcs009()
|
|
|
|
DEFINE
|
|
fecha CHAR(8),
|
|
hora CHAR(5)
|
|
CLEAR SCREEN
|
|
OPTIONS FORM LINE 8, ERROR LINE 24, MESSAGE LINE 23
|
|
|
|
LET fecha = TODAY USING "dd/mm/yy"
|
|
LET hora = TIME
|
|
DISPLAY "E L E C T R O D O M E S T I C O S J U V I A R "
|
|
AT 3, 17
|
|
ATTRIBUTE(REVERSE, YELLOW)
|
|
DISPLAY fecha AT 3, 70 ATTRIBUTE(YELLOW)
|
|
DISPLAY "Sistema de Compras" AT 4, 31
|
|
DISPLAY hora AT 5, 73 ATTRIBUTE(YELLOW)
|
|
DISPLAY "<Esc> Busca Todas Las Ordenes" AT 6, 1
|
|
DISPLAY "<Delete> Cancela Operacion" AT 6, 55
|
|
OPEN FORM cofmcs009 FROM "cofmcs009"
|
|
DISPLAY FORM cofmcs009
|
|
DISPLAY "coprcs009" AT 3, 3
|
|
DISPLAY "Ordenes de Compras" AT 5, 31 ATTRIBUTE(BOLD)
|
|
|
|
#WHENEVER ERROR CONTINUE
|
|
|
|
# Aqui se prepara para la captura del criterio de seleccion
|
|
|
|
LABEL volver:
|
|
CLEAR FORM
|
|
DISPLAY " "
|
|
AT 23, 1
|
|
CONSTRUCT criterio
|
|
ON cotb00014.num_oc,
|
|
cotb00014.tipo,
|
|
cotb00014.fech_oc,
|
|
cotb00014.cod_sp,
|
|
cotb00014.cod_sp_sec
|
|
FROM cotb00014.num_oc,
|
|
cotb00014.tipo,
|
|
cotb00014.fech_oc,
|
|
cotb00014.cod_sp,
|
|
cotb00014.cod_sp_sec
|
|
|
|
IF int_flag THEN
|
|
LET numero_msg = 2
|
|
CALL msg(numero_msg)
|
|
LET int_flag = FALSE
|
|
RETURN
|
|
END IF
|
|
|
|
LET selec =
|
|
"SELECT UNIQUE num_oc,tipo,fech_oc,cod_sp,cod_sp_sec,via,enviada, ",
|
|
" fech_enviada,pago,fech_pago,cierre,cod_pt ",
|
|
"FROM cotb00014 ",
|
|
"WHERE status_t is null AND ",
|
|
criterio CLIPPED,
|
|
" ORDER BY 1"
|
|
|
|
PREPARE busca FROM selec
|
|
|
|
IF bandera = 1 THEN
|
|
LET bandera = 0
|
|
RETURN
|
|
END IF
|
|
|
|
DECLARE datos SCROLL CURSOR FOR busca
|
|
OPEN datos
|
|
|
|
IF bandera = 1 THEN
|
|
LET bandera = 0
|
|
RETURN
|
|
END IF
|
|
|
|
FETCH FIRST datos
|
|
INTO ordenes.num_oc,
|
|
ordenes.tipo,
|
|
ordenes.fech_oc,
|
|
ordenes.cod_sp,
|
|
ordenes.cod_sp_sec,
|
|
ordenes.via,
|
|
ordenes.enviada,
|
|
ordenes.fech_enviada,
|
|
ordenes.pago,
|
|
ordenes.fech_pago,
|
|
ordenes.cierre,
|
|
ordenes.cod_pt
|
|
|
|
IF status >= 0 THEN
|
|
IF status = NOTFOUND THEN
|
|
LET numero_msg = 3
|
|
CALL msg(numero_msg)
|
|
GOTO volver
|
|
END IF
|
|
|
|
IF bandera = 1 THEN
|
|
LET bandera = 0
|
|
RETURN
|
|
END IF
|
|
END IF
|
|
SELECT nom_pt INTO descrip3 FROM cotb00019 WHERE cod_pt = ordenes.cod_pt
|
|
IF ordenes.cod_pt IS NULL THEN
|
|
LET descrip3 = NULL
|
|
END IF
|
|
|
|
LET p_programa = "CS"
|
|
#CALL escoge()
|
|
DISPLAY BY NAME suplidor.nom_sp,
|
|
ordenes.num_oc,
|
|
ordenes.tipo,
|
|
ordenes.fech_oc,
|
|
ordenes.cod_sp,
|
|
ordenes.cod_sp_sec,
|
|
ordenes.via,
|
|
ordenes.enviada,
|
|
ordenes.fech_enviada,
|
|
ordenes.pago,
|
|
ordenes.fech_pago,
|
|
ordenes.cierre,
|
|
ordenes.cod_pt,
|
|
descrip3
|
|
ATTRIBUTE(BOLD)
|
|
|
|
MENU "OPCIONES "
|
|
COMMAND "Siguiente"
|
|
"Presenta en pantalla el proximo registro encontrado"
|
|
FETCH NEXT datos
|
|
INTO ordenes.num_oc,
|
|
ordenes.tipo,
|
|
ordenes.fech_oc,
|
|
ordenes.cod_sp,
|
|
ordenes.cod_sp_sec,
|
|
ordenes.via,
|
|
ordenes.enviada,
|
|
ordenes.fech_enviada,
|
|
ordenes.pago,
|
|
ordenes.fech_pago,
|
|
ordenes.cierre,
|
|
ordenes.cod_pt
|
|
IF status = NOTFOUND THEN
|
|
LET numero_msg = 4
|
|
CALL msg(numero_msg)
|
|
END IF
|
|
SELECT nom_pt
|
|
INTO descrip3
|
|
FROM cotb00019
|
|
WHERE cod_pt = ordenes.cod_pt
|
|
IF ordenes.cod_pt IS NULL THEN
|
|
LET descrip3 = NULL
|
|
END IF
|
|
LET p_programa = "CS"
|
|
CALL escoge()
|
|
DISPLAY BY NAME suplidor.nom_sp,
|
|
ordenes.num_oc,
|
|
ordenes.tipo,
|
|
ordenes.fech_oc,
|
|
ordenes.cod_sp,
|
|
ordenes.cod_sp_sec,
|
|
ordenes.via,
|
|
ordenes.enviada,
|
|
ordenes.fech_enviada,
|
|
ordenes.pago,
|
|
ordenes.fech_pago,
|
|
ordenes.cierre,
|
|
ordenes.cod_pt,
|
|
descrip3
|
|
ATTRIBUTE(BOLD)
|
|
|
|
COMMAND "Anterior"
|
|
"Presenta en pantalla el registro anterior encontrado"
|
|
FETCH PREVIOUS datos
|
|
INTO ordenes.num_oc,
|
|
ordenes.tipo,
|
|
ordenes.fech_oc,
|
|
ordenes.cod_sp,
|
|
ordenes.cod_sp_sec,
|
|
ordenes.via,
|
|
ordenes.enviada,
|
|
ordenes.fech_enviada,
|
|
ordenes.pago,
|
|
ordenes.fech_pago,
|
|
ordenes.cierre,
|
|
ordenes.cod_pt
|
|
IF status = NOTFOUND THEN
|
|
LET numero_msg = 5
|
|
CALL msg(numero_msg)
|
|
END IF
|
|
SELECT nom_pt
|
|
INTO descrip3
|
|
FROM cotb00019
|
|
WHERE cod_pt = ordenes.cod_pt
|
|
LET p_programa = "CS"
|
|
CALL escoge()
|
|
IF ordenes.cod_pt IS NULL THEN
|
|
LET descrip3 = NULL
|
|
END IF
|
|
DISPLAY BY NAME suplidor.nom_sp,
|
|
ordenes.num_oc,
|
|
ordenes.tipo,
|
|
ordenes.fech_oc,
|
|
ordenes.cod_sp,
|
|
ordenes.cod_sp_sec,
|
|
ordenes.via,
|
|
ordenes.enviada,
|
|
ordenes.fech_enviada,
|
|
ordenes.pago,
|
|
ordenes.fech_pago,
|
|
ordenes.cierre,
|
|
ordenes.cod_pt,
|
|
descrip3
|
|
ATTRIBUTE(BOLD)
|
|
|
|
COMMAND "Primero" "Presenta en pantalla el primer registro encontrado"
|
|
FETCH FIRST datos
|
|
INTO ordenes.num_oc,
|
|
ordenes.tipo,
|
|
ordenes.fech_oc,
|
|
ordenes.cod_sp,
|
|
ordenes.cod_sp_sec,
|
|
ordenes.via,
|
|
ordenes.enviada,
|
|
ordenes.fech_enviada,
|
|
ordenes.pago,
|
|
ordenes.fech_pago,
|
|
ordenes.cierre,
|
|
ordenes.cod_pt
|
|
LET p_programa = "CS"
|
|
CALL escoge()
|
|
SELECT nom_pt
|
|
INTO descrip3
|
|
FROM cotb00019
|
|
WHERE cod_pt = ordenes.cod_pt
|
|
IF ordenes.cod_pt IS NULL THEN
|
|
LET descrip3 = NULL
|
|
END IF
|
|
DISPLAY BY NAME suplidor.nom_sp,
|
|
ordenes.num_oc,
|
|
ordenes.tipo,
|
|
ordenes.fech_oc,
|
|
ordenes.cod_sp,
|
|
ordenes.cod_sp_sec,
|
|
ordenes.via,
|
|
ordenes.enviada,
|
|
ordenes.fech_enviada,
|
|
ordenes.pago,
|
|
ordenes.fech_pago,
|
|
ordenes.cierre,
|
|
ordenes.cod_pt,
|
|
descrip3
|
|
ATTRIBUTE(BOLD)
|
|
|
|
LET numero_msg = 5
|
|
CALL msg(numero_msg)
|
|
|
|
COMMAND "Ultimo" "Presenta en pantalla el ultimo registro encontrado"
|
|
FETCH LAST datos
|
|
INTO ordenes.num_oc,
|
|
ordenes.tipo,
|
|
ordenes.fech_oc,
|
|
ordenes.cod_sp,
|
|
ordenes.cod_sp_sec,
|
|
ordenes.via,
|
|
ordenes.enviada,
|
|
ordenes.fech_enviada,
|
|
ordenes.pago,
|
|
ordenes.fech_pago,
|
|
ordenes.cierre,
|
|
ordenes.cod_pt
|
|
LET p_programa = "CS"
|
|
CALL escoge()
|
|
SELECT nom_pt
|
|
INTO descrip3
|
|
FROM cotb00019
|
|
WHERE cod_pt = ordenes.cod_pt
|
|
IF ordenes.cod_pt IS NULL THEN
|
|
LET descrip3 = NULL
|
|
END IF
|
|
DISPLAY BY NAME suplidor.nom_sp,
|
|
ordenes.num_oc,
|
|
ordenes.tipo,
|
|
ordenes.fech_oc,
|
|
ordenes.cod_sp,
|
|
ordenes.cod_sp_sec,
|
|
ordenes.via,
|
|
ordenes.enviada,
|
|
ordenes.fech_enviada,
|
|
ordenes.pago,
|
|
ordenes.fech_pago,
|
|
ordenes.cierre,
|
|
ordenes.cod_pt,
|
|
descrip3
|
|
ATTRIBUTE(BOLD)
|
|
LET numero_msg = 4
|
|
CALL msg(numero_msg)
|
|
|
|
COMMAND "Ver"
|
|
DISPLAY "Buscando Detalle del La Orden... Espere Por Favor"
|
|
AT 23, 1
|
|
ATTRIBUTE(BOLD)
|
|
|
|
DECLARE buscate CURSOR FOR
|
|
SELECT a.num_req,
|
|
a.cod_n,
|
|
a.cod_grupo,
|
|
a.cod_tipo,
|
|
a.cod_sec,
|
|
a.cantidad,
|
|
a.precio,
|
|
1
|
|
FROM cotb00015 a
|
|
WHERE a.num_oc = ordenes.num_oc
|
|
AND a.tipo = ordenes.tipo
|
|
AND a.status_t IS NULL
|
|
|
|
LET idx = 1
|
|
FOREACH buscate INTO detalle1.*
|
|
|
|
LET cs_ordena[idx].num_req = detalle1.num_req
|
|
LET cs_ordena[idx].codigo =
|
|
detalle1.cod_n USING "&",
|
|
"-",
|
|
detalle1.cod_grupo USING "&",
|
|
"-",
|
|
detalle1.cod_tipo USING "&&",
|
|
"-",
|
|
detalle1.cod_sec USING "&&&"
|
|
LET cs_ordena[idx].cantidad =
|
|
detalle1.cantidad USING "##########.##"
|
|
LET cs_ordena[idx].precio =
|
|
detalle1.precio USING "##########.##"
|
|
|
|
IF detalle1.base IS NOT NULL THEN
|
|
IF detalle1.base > 0 THEN
|
|
LET cantidad_total =
|
|
(detalle1.cantidad * detalle1.precio)
|
|
/ detalle1.base
|
|
LET cs_ordena[idx].valor =
|
|
cantidad_total USING "#########.##"
|
|
ELSE
|
|
LET cantidad_total =
|
|
(detalle1.cantidad * detalle1.precio)
|
|
LET cs_ordena[idx].valor =
|
|
cantidad_total USING "#########.##"
|
|
END IF
|
|
ELSE
|
|
LET cantidad_total = (detalle1.cantidad * detalle1.precio)
|
|
LET cs_ordena[idx].valor =
|
|
cantidad_total USING "#########.##"
|
|
END IF
|
|
|
|
LET idx = idx + 1
|
|
END FOREACH
|
|
|
|
DISPLAY " " AT 23, 1
|
|
MESSAGE "Precione Ctrl-B Busca Descripcion"
|
|
|
|
CALL set_count(idx - 1)
|
|
DISPLAY ARRAY cs_ordena TO cs_orden.*
|
|
ON KEY(CONTROL-B)
|
|
LET scr_l = arr_curr()
|
|
LET detalle1.cod_n = cs_ordena[scr_l].codigo[1, 1]
|
|
LET detalle1.cod_grupo = cs_ordena[scr_l].codigo[3, 3]
|
|
LET detalle1.cod_tipo = cs_ordena[scr_l].codigo[5, 6]
|
|
LET detalle1.cod_sec = cs_ordena[scr_l].codigo[8, 10]
|
|
LET descrip5 = NULL
|
|
LET articulos.descrip_esp = NULL
|
|
LET articulos.unidad_med = NULL
|
|
|
|
IF ordenes.tipo = "01" THEN
|
|
SELECT a.descrip_esp, a.unidad_med
|
|
INTO articulos.descrip_esp, articulos.unidad_med
|
|
FROM intb00001 a
|
|
WHERE a.cod_n = detalle1.cod_n
|
|
AND a.cod_grupo = detalle1.cod_grupo
|
|
AND a.cod_tipo = detalle1.cod_tipo
|
|
AND a.cod_sec = detalle1.cod_sec
|
|
END IF
|
|
IF ordenes.tipo = "02" THEN
|
|
SELECT a.descrip_esp, a.unidad_med
|
|
INTO articulos.descrip_esp, articulos.unidad_med
|
|
FROM iptb00002 a
|
|
WHERE a.cod_n = detalle1.cod_n
|
|
AND a.cod_grupo = detalle1.cod_grupo
|
|
AND a.cod_tipo = detalle1.cod_tipo
|
|
AND a.cod_sec = detalle1.cod_sec
|
|
END IF
|
|
IF ordenes.tipo = "03" THEN
|
|
SELECT a.descrip_esp, a.unidad_med
|
|
INTO articulos.descrip_esp, articulos.unidad_med
|
|
FROM irtb00001 a
|
|
WHERE a.cod_n = detalle1.cod_n
|
|
AND a.cod_grupo = detalle1.cod_grupo
|
|
AND a.cod_tipo = detalle1.cod_tipo
|
|
AND a.cod_sec = detalle1.cod_sec
|
|
END IF
|
|
LET descrip5 =
|
|
articulos.unidad_med, " ", articulos.descrip_esp CLIPPED
|
|
DISPLAY BY NAME descrip5 ATTRIBUTE(BOLD)
|
|
|
|
ON KEY(CONTROL-W)
|
|
LET scr_l = arr_curr()
|
|
LET detalle1.cod_n = cs_ordena[scr_l].codigo[1, 1]
|
|
LET detalle1.cod_grupo = cs_ordena[scr_l].codigo[3, 3]
|
|
LET detalle1.cod_tipo = cs_ordena[scr_l].codigo[5, 6]
|
|
LET detalle1.cod_sec = cs_ordena[scr_l].codigo[8, 10]
|
|
|
|
END DISPLAY
|
|
FOR idx = 1 TO 4
|
|
LET cs_ordena[idx].num_req = NULL
|
|
LET cs_ordena[idx].codigo = NULL
|
|
LET cs_ordena[idx].cantidad = NULL
|
|
LET cs_ordena[idx].precio = NULL
|
|
LET cs_ordena[idx].valor = NULL
|
|
|
|
DISPLAY cs_ordena[idx].num_req TO cs_orden[idx].num_req
|
|
DISPLAY cs_ordena[idx].codigo TO cs_orden[idx].codigo
|
|
DISPLAY cs_ordena[idx].cantidad TO cs_orden[idx].cantidad
|
|
DISPLAY cs_ordena[idx].precio TO cs_orden[idx].precio
|
|
DISPLAY cs_ordena[idx].valor TO cs_orden[idx].valor
|
|
DISPLAY BY NAME descrip5
|
|
END FOR
|
|
|
|
IF int_flag THEN
|
|
LET numero_msg = 2
|
|
CALL msg(numero_msg)
|
|
LET int_flag = FALSE
|
|
RETURN
|
|
END IF
|
|
COMMAND "Comentario"
|
|
CALL notascs()
|
|
|
|
COMMAND "Retornar"
|
|
LET p_programa = NULL
|
|
GOTO volver
|
|
END MENU
|
|
END FUNCTION
|
|
|
|
FUNCTION notascs()
|
|
DEFINE opcion2 CHAR(1)
|
|
OPEN WINDOW aplcs_notas
|
|
AT 10, 5
|
|
WITH FORM "cofmwd016"
|
|
ATTRIBUTE(BORDER, FORM LINE FIRST + 1, COMMENT LINE LAST - 1)
|
|
|
|
SELECT UNIQUE a.ship_to,
|
|
a.n_a_b,
|
|
a.c_i_d[1, 30],
|
|
a.c_i_d[31, 60],
|
|
a.nota[1, 30],
|
|
a.nota[31, 60]
|
|
INTO notas.ship_to, notas.n_a_b, c_i_d, c_i_d1, nota, nota1
|
|
FROM cotb00029 a
|
|
WHERE a.num_oc = ordenes.num_oc
|
|
AND a.tipo = ordenes.tipo
|
|
AND a.status_t IS NULL
|
|
|
|
DISPLAY BY NAME notas.ship_to, notas.n_a_b, c_i_d, c_i_d1, nota, nota1
|
|
|
|
PROMPT "Presione Cualquier Tecla para Continuar" FOR CHAR opcion2
|
|
CLOSE WINDOW aplcs_notas
|
|
END FUNCTION
|