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

330 lines
12 KiB
Plaintext

{
------------------------------------------------------------------
PROGRAMA : COPRRP012
OBJETIVO : Reporte Plan de Produccion
PROGRAMADOR : Ing. Juan Soto
FECHA REALIZACION : Diciembre 22, 1992.
------------------------------------------------------------------
}
GLOBALS "coprgb000.4gl"
FUNCTION coprrp012()
DEFINE meses_py SMALLINT,
limpia_linea CHAR(79),
fecha_final CHAR(6)
DEFINE mes_ini SMALLINT,
mes_fin SMALLINT,
mes1 SMALLINT,
mes2 SMALLINT,
mes3 SMALLINT,
posicion SMALLINT,
posicion1 SMALLINT,
posicion2 SMALLINT,
mes_proceso SMALLINT,
ano_fin CHAR(4),
dia_ini SMALLINT,
rango_p CHAR(4),
total_registros SMALLINT
DEFINE plan RECORD
cod_n SMALLINT,
cod_grupo SMALLINT,
cod_tipo SMALLINT,
cod_sec SMALLINT,
fecha_ini DATE,
fecha_fin DATE,
cantiad DECIMAL(10,2),
descripcion CHAR(30),
unidad CHAR(4)
END RECORD
#WHENEVER ERROR CONTINUE
CLEAR SCREEN
OPTIONS
FORM LINE 9,
ERROR LINE 23,
COMMENT LINE 21
LET formulario = formulario CLIPPED,"cofmrp012"
OPEN FORM coprrp012 FROM formulario
DISPLAY FORM coprrp012
CALL pantalla()
DISPLAY "coprrp012" AT 4,3
DISPLAY "Plan de Produccion" AT 6,31
LET tipo_papel = 1
CALL msgrp000(tipo_papel)
LET int_flag = FALSE
INPUT BY NAME meses_py,
fecha_inicial_py
AFTER FIELD meses_py
IF meses_py IS NULL OR
meses_py = 0 THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD meses_py
END IF
AFTER FIELD fecha_inicial_py
IF fecha_inicial_py IS NULL THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD fecha_inicial_py
END IF
LET mes_fin = MONTH(fecha_inicial_py)
LET ano_fin = YEAR(fecha_inicial_py)
FOR idx = 1 TO meses_py
LET mes_fin = mes_fin + 1
IF mes_fin > 12 THEN
LET mes_fin = 1
LET ano_fin = ano_fin + 1
END IF
END FOR
LET dia_ini = DAY(fecha_inicial_py)
LET mes_ini = MONTH(fecha_inicial_py)
IF dia_ini > 15 THEN
LET mes2 = mes_fin
LET mes_fin = mes_fin + 1
IF mes_fin > 12 THEN
LET mes_fin = 1
END IF
END IF
LET rango_p = MONTH(fecha_inicial_py) using "&&",
mes_fin using "&&"
IF dia_ini > 15 THEN
LET mes_fin = mes2
LET mes2 = 0
END IF
LET fecha_final = DAY(fecha_inicial_py) using "&&",
mes_fin using "&&",
ano_fin[3,4] using "&&"
LET fecha_final_py = fecha_final
LET total_registros = null
SELECT count(*) INTO total_registros FROM cotb00026
WHERE rango_plan=rango_p AND fecha_ini=fecha_inicial_py AND
status_t is NULL
IF total_registros = 0 OR
total_registros IS NULL THEN
LET numero_msg = 48
CALL msg(numero_msg)
NEXT FIELD meses_py
END IF
AFTER INPUT
IF int_flag THEN
LET int_flag = FALSE
LET numero_msg = 2
CALL msg(numero_msg)
RETURN
END IF
EXIT INPUT
LET dia_ini = DAY(fecha_inicial_py)
LET mes_ini = MONTH(fecha_inicial_py)
LET mes_fin = MONTH(fecha_inicial_py) + meses_py
IF dia_ini > 15 THEN
LET mes2 = mes_fin
LET mes_fin = mes_fin + 1
IF mes_fin > 12 THEN
LET mes_fin = 1
END IF
END IF
LET rango_p = MONTH(fecha_inicial_py) using "&&",
mes_fin using "&&"
IF dia_ini > 15 THEN
LET mes_fin = mes2
LET mes2 = 0
END IF
LET total_registros = null
SELECT count(*) INTO total_registros FROM cotb00026
WHERE rango_plan=rango_p AND fecha_ini=fecha_inicial_py AND
status_t is NULL
IF total_registros = 0 OR
total_registros IS NULL THEN
LET numero_msg = 48
CALL msg(numero_msg)
NEXT FIELD meses_py
END IF
END INPUT
CONSTRUCT criterio ON x.cod_n,x.cod_grupo,x.cod_tipo,x.cod_Sec
FROM cod_n,cod_grupo,cod_tipo,cod_sec
IF int_flag THEN
LET numero_msg = 2
CALL msg(numero_msg)
LET int_flag = FALSE
RETURN
END IF
LET total_registros = 0
LET limpia_linea = " ",
" ",
" ",
" "
DISPLAY limpia_linea AT 15,1
DISPLAY limpia_linea AT 16,1
DISPLAY limpia_linea AT 18,1
LET selec =
"SELECT x.cod_n,x.cod_grupo,x.cod_tipo,x.cod_sec,x.fecha_ini, ",
" x.fecha_fin,x.cantidad ",
"FROM cotb00026 x ",
"WHERE ",criterio clipped," and x.rango_plan=? and x.fecha_ini >= ? ",
"ORDER BY 1,2,3,4,5 "
DISPLAY "<< Estoy Buscando Informacion ... Espere Por Favor>>"
AT 19,14 ATTRIBUTE (REVERSE)
PREPARE busca_plan FROM selec
DECLARE curs_plan SCROLL CURSOR FOR busca_plan
OPEN curs_plan USING rango_p,fecha_inicial_py
DISPLAY " "
AT 19,14
DISPLAY "<< Reporte Generandose ... Por Favor Espere>>"
AT 19,14 ATTRIBUTE (REVERSE)
START REPORT planes TO "C:\\archivo"
WHILE STATUS != NOTFOUND
FETCH curs_plan INTO plan.*
IF status = notfound THEN
EXIT WHILE
END IF
OUTPUT TO REPORT planes(plan.*)
END WHILE
FINISH REPORT planes
RUN "type C:\\archivo > %USPRINT%" END FUNCTION
REPORT planes(x)
DEFINE x RECORD
cod_n SMALLINT,
cod_grupo SMALLINT,
cod_tipo SMALLINT,
cod_sec SMALLINT,
fecha_ini DATE,
fecha_fin DATE,
cantidad DECIMAL(10,2),
descripcion CHAR(30),
unidad CHAR(4)
END RECORD,
bandera CHAR(1),
negras_on,negras_of CHAR(2),
hora CHAR(5)
DEFINE total_cantidad DECIMAL(12,2)
OUTPUT
LEFT MARGIN 2
TOP MARGIN 1
FORMAT
PAGE HEADER
LET negras_on = ASCII 27, ASCII 69
LET negras_of = ASCII 27, ASCII 70
LET hora = time
LET l = (80 - LENGTH(p_companias.nombre CLIPPED))/2
PRINT negras_on
PRINT COLUMN 1, "coprrp012",
COLUMN l,p_companias.nombre CLIPPED
COLUMN 73, "Pag. ",pageno using "###"
PRINT COLUMN 30, "Sistema de Compras",
COLUMN 73, today using "dd/mm/yy"
PRINT COLUMN 30, "Plan de Produccion",
COLUMN 76, hora
SKIP 1 LINES
PRINT COLUMN 1, "Del ",
COLUMN 5, fecha_inicial_py using "dd/mmm/yy",
COLUMN 12, " Al ",
COLUMN 16, fecha_final_py using "dd/mmm/yy"
PRINT COLUMN 1,
"-----------------------------------",
"-----------------------------------",
"----------"
PRINT COLUMN 1, negras_on,
COLUMN 51, "Fecha",
COLUMN 61, "Fecha"
PRINT COLUMN 14, "P i l a s ",
COLUMN 49, "Inicial",
COLUMN 59, "Final",
COLUMN 73, "Cantidad",negras_of
PRINT COLUMN 1,
"-----------------------------------",
"-----------------------------------",
"----------"
BEFORE GROUP OF x.cod_n
LET total_cantidad = null
BEFORE GROUP OF x.cod_grupo
LET bandera = "S"
BEFORE GROUP OF x.cod_tipo
LET bandera = "S"
BEFORE GROUP OF x.cod_sec
LET bandera = "S"
ON EVERY ROW
NEED 4 LINES
SELECT descrip_esp,unidad_med INTO x.descripcion,x.unidad
FROM intb00001
WHERE cod_n = x.cod_n and cod_grupo = x.cod_grupo and
cod_tipo = x.cod_tipo and cod_sec = x.cod_sec
IF bandera = "S" THEN
IF total_cantidad is not null THEN
PRINT COLUMN 69, "-------------"
PRINT COLUMN 49, "Total Periodo ",
COLUMN 69, total_cantidad using "##,###,###.##"
LET total_cantidad = 0
END IF
IF total_cantidad is null THEN
LET total_cantidad = 0
END IF
SKIP 1 LINE
PRINT COLUMN 2, x.cod_n using "&","-",
COLUMN 4, x.cod_grupo using "&","-",
COLUMN 6, x.cod_tipo using "&&","-",
COLUMN 9, x.cod_sec using "&&&",
COLUMN 14, x.descripcion,
COLUMN 45, x.unidad;
END IF
PRINT COLUMN 49, x.fecha_ini using "dd/mm/yy",
COLUMN 59, x.fecha_fin using "dd/mm/yy",
COLUMN 69, x.cantidad using "##,###,###.##"
LET bandera = "N"
LET total_cantidad = total_cantidad + x.cantidad
ON LAST ROW
PRINT COLUMN 69, "-------------"
PRINT COLUMN 49, "Total Periodo ",
COLUMN 69, total_cantidad using "##,###,###.##"
END REPORT