Files

326 lines
10 KiB
Plaintext

{
-------------------------------------------------------------------------------
PROGRAMA : IRPRRP018
OBJETIVO : REPORTE EXISTENCIAS
Con Entradas y Salidas.
PROGRAMADOR : Ing. Juan F. Soto
FECHA REALIZACION : Agosto 17, 1994.
-------------------------------------------------------------------------------
}
GLOBALS "irprgb000.4gl"
DEFINE valor_total DECIMAL (12,2)
MAIN
DEFER INTERRUPT
SELECT * INTO p_companias.* FROM companias
CALL irprrp018()
END MAIN
FUNCTION irprrp018()
DEFINE mes CHAR(2)
DEFINE p_mes,idx_ant,idx_cos,idx_act INTEGER
DEFINE ano_c,ano_act CHAR(4)
DEFINE salir,opt10 CHAR(1)
DEFINE balance_in DECIMAL(12,2)
DEFINE existe RECORD
cod_n LIKE intb00001.cod_n,
cod_grupo LIKE intb00001.cod_grupo,
cod_tipo LIKE intb00001.cod_tipo,
cod_sec LIKE intb00001.cod_sec,
descrip_esp LIKE intb00001.descrip_esp,
unidad_med LIKE intb00001.unidad_med,
existe_ant DECIMAL(10,2),
existe_act DECIMAL(10,2),
costo LIKE intb00013.costo_st
END RECORD
DEFINE costos RECORD
cod_n SMALLINT,
cod_grupo SMALLINT,
cod_tipo SMALLINT,
cod_sec SMALLINT,
fecha CHAR(2),
costo_st LIKE intb00013.costo_st
END RECORD
DEFINE actual RECORD
cod_n SMALLINT,
cod_grupo SMALLINT,
cod_tipo SMALLINT,
cod_sec SMALLINT,
balance LIKE intb00006.cantidad_2
END RECORD
DEFINE anterior RECORD
cod_n SMALLINT,
cod_grupo SMALLINT,
cod_tipo SMALLINT,
cod_sec SMALLINT,
balance LIKE intb00006.cantidad_2
END RECORD
DEFINE select_cost,select_act,select_ant CHAR(1000)
# WHENEVER ERROR CONTINUE
OPTIONS
FORM LINE 8,
ERROR LINE 23,
PROMPT LINE 10,
COMMENT LINE 21
OPEN FORM irfmrp018 FROM "irfmrp018"
DISPLAY FORM irfmrp018
CALL pantalla()
DISPLAY "irprrp018" AT 4,3
DISPLAY "Existencia Anterior y Actual " AT 6,26
LET tipo_papel = 1
CALL msgrp000(tipo_papel)
INPUT BY NAME ano_c,p_mes
AFTER FIELD ano_c
IF ano_c IS NULL THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD ano_c
END IF
AFTER FIELD p_mes
IF p_mes IS NULL THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD p_mes
END IF
SELECT a.fecha_inicio,a.fecha_corte INTO datos_cons.fech_in,datos_cons.fech_fi
FROM prdtable a WHERE a.mes = p_mes AND a.ano = ano_c
END INPUT
IF int_flag THEN
LET numero_msg = 2
CALL msg(numero_msg)
LET int_flag = false
RETURN
END IF
CONSTRUCT criterio ON d.cod_n,d.cod_grupo,d.cod_tipo,d.cod_sec
FROM cod_n,cod_grupo,cod_tipo,cod_sec
DISPLAY " "
AT 19,14
LET SELEC =
"SELECT d.cod_n,d.cod_grupo,d.cod_tipo,d.cod_sec,d.descrip_esp,d.unidad_med ",
"FROM intb00001 d, irtb00002 b ",
"WHERE d.cod_n = b.cod_n AND d.cod_grupo = b.cod_grupo AND ",
" d.cod_tipo = b.cod_tipo AND d.cod_sec = b.cod_sec AND ",
" d.status_t is null AND ", criterio clipped, " ORDER BY 1,2,3,4"
DISPLAY "<< Estoy Buscando Las Materias Primas >>"
AT 19,14 ATTRIBUTE (REVERSE,BOLD)
PREPARE busca FROM selec
IF bandera = 1 THEN
LET bandera = 0
RETURN
END IF
DECLARE accion CURSOR FOR busca
OPEN accion
DISPLAY " "
AT 19,14
DISPLAY "<< Reporte Generandose ... Por Favor Espere. >>"
AT 19,14 ATTRIBUTE (REVERSE)
START REPORT prt_exist TO "rpir18"
LET idx_ant = 1
LET idx_act = 1
LET idx_cos = 1
WHILE status != notfound
FETCH accion INTO existe.*
IF status = notfound THEN
EXIT WHILE
END IF
IF int_flag THEN
LET numero_msg = 2
CALL msg(numero_msg)
LET int_flag = false
RETURN
END IF
# Busqueda de los costos actuales
LET existe.costo = 0
SELECT UNIQUE a.costo_st INTO existe.costo FROM irtb00013 a
WHERE a.mes_ini <= p_mes AND a.mes_fin >= p_mes AND a.ano = ano_c AND
a.cod_n = existe.cod_n AND a.cod_grupo = existe.cod_grupo AND
a.cod_tipo = existe.cod_tipo AND a.cod_sec = existe.cod_sec AND
a.status_t is null
IF existe.costo IS NULL THEN
LET existe.costo = 0
END IF
LET existe.existe_ant = 0
SELECT sum(a.cantidad_2) INTO existe.existe_ant FROM irtb00006 a
WHERE a.fecha <= datos_cons.fech_in AND a.cod_n = existe.cod_n AND
a.cod_grupo = existe.cod_grupo AND a.cod_tipo = existe.cod_tipo AND
a.cod_sec = existe.cod_sec AND status_t is null
IF existe.existe_ant IS NULL THEN
LET existe.existe_ant = 0
END IF
LET existe.existe_act = 0
OUTPUT TO REPORT prt_exist(existe.*)
END WHILE
FINISH REPORT prt_exist
DISPLAY BY NAME valor_total
PROMPT "Desea Imprimir este reporte (S/N)?" FOR CHAR OPT10
IF opt10 = "S" THEN
RUN "lp -dlpt12 $HOME/rpir18"
END IF
CLEAR SCREEN
RUN "type C:\\archivo > %USPRINT%" END FUNCTION
REPORT prt_exist(x)
DEFINE x RECORD
cod_n LIKE intb00001.cod_n,
cod_grupo LIKE intb00001.cod_grupo,
cod_tipo LIKE intb00001.cod_tipo,
cod_sec LIKE intb00001.cod_sec,
descrip_esp LIKE intb00001.descrip_esp,
unidad_med LIKE intb00001.unidad_med,
existe_ant DECIMAL(10,2),
existe_act DECIMAL(10,2),
costo LIKE intb00013.costo_st
END RECORD
DEFINE entradas,salidas,total_c,total_p DECIMAL (12,2)
DEFINE normal,doble_on CHAR(2)
DEFINE doble_off CHAR(2)
DEFINE negrillas_on CHAR(2)
DEFINE negrillas_off CHAR(2)
DEFINE comp_on CHAR(3)
DEFINE comp_off CHAR(3)
DEFINE doce CHAR(3)
DEFINE hora CHAR(5)
OUTPUT
TOP MARGIN 0
LEFT MARGIN 0
BOTTOM MARGIN 2
FORMAT
PAGE HEADER
LET doble_on = ASCII 14
LET doble_off = ASCII 20
LET negrillas_on = ASCII 27, ASCII 69
LET negrillas_off = ASCII 27, ASCII 70
LET comp_on = ASCII 15
LET comp_off = ASCII 18
LET doce = ASCII 27,ASCII 77
LET hora = time
LET normal = ASCII 27, ASCII 80
PRINT COLUMN 1,comp_on
PRINT COLUMN 1, "irprrp018",
COLUMN 47, " M A R M O T E C H S. A.",
COLUMN 132, "Pag. ",pageno using "###"
PRINT COLUMN 47, " SISTEMA DE INVENTARIO DE REPUESTOS",
COLUMN 132, today using "dd/mm/yy"
PRINT COLUMN 47, " EXISTENCIA ANTERIOR Y ACTUAL",
COLUMN 135, hora
PRINT COLUMN 1,
"Movimientos: Del ",datos_cons.fech_in using "dd/mm/yy",
" AL ",datos_cons.fech_fi using "dd/mm/yy"
PRINT COLUMN 1, "--------------------------------------------------",
"--------------------------------------------------" ,
"----------------------------------------"
PRINT COLUMN 60, "| MOVIMIENTOS |"
PRINT COLUMN 48, "EXISTENCIA",
COLUMN 60, "|---------------------------|",
COLUMN 93, "EXISTENCIA",
COLUMN 115, "COSTO",
COLUMN 130, "TOTAL"
PRINT COLUMN 1, "CODIGO",
COLUMN 12, "DESCRIPCION",
COLUMN 48, "AL ",datos_cons.fech_in - 1 using "dd/mm/yy",
COLUMN 60, "| ENTRADAS",
COLUMN 76 , " SALIDAS |",
COLUMN 93, "AL ", datos_cons.fech_fi using "dd/mm/yy",
COLUMN 115, "STANDARD",
COLUMN 130, "AL ",datos_cons.fech_fi using "dd/mm/yy"
PRINT COLUMN 1, "--------------------------------------------------",
"--------------------------------------------------",
"----------------------------------------"
SKIP 1 LINE
ON EVERY ROW
# Busqueda de las entradas en el rango
SELECT SUM(a.cantidad_2) INTO entradas
FROM irtb00006 a
WHERE a.cod_n = x.cod_n and a.cod_grupo = x.cod_grupo and
a.cod_tipo = x.cod_tipo and a.cod_sec = x.cod_sec and
a.fecha between datos_cons.fech_in and datos_cons.fech_fi and
a.cantidad_2 > 0 and a.status_t is null
IF entradas is null THEN
LET entradas = 0
END IF
# Busqueda de las salidas en el rango
SELECT SUM(a.cantidad_2) * -1 INTO salidas
FROM irtb00006 a
WHERE a.cod_n = x.cod_n and a.cod_grupo = x.cod_grupo and
a.cod_tipo = x.cod_tipo and a.cod_sec = x.cod_sec and
a.fecha between datos_cons.fech_in and datos_cons.fech_fi and
a.cantidad_2 < 0 and a.status_t is null
IF salidas is null THEN
LET salidas = 0
END IF
IF total_p is null THEN
LET total_p = 0
END IF
LET x.existe_act = x.existe_ant + entradas - salidas
LET total_c = x.existe_act * x.costo
LET total_p = total_c + total_p
PRINT COLUMN 1, x.cod_n USING "&","-", x.cod_grupo USING "&","-",
COLUMN 5, x.cod_tipo USING "&&","-",x.cod_sec USING "&&&"," ",
x.descrip_esp," ",x.unidad_med,
COLUMN 45, x.existe_ant USING "---,---,---.##",
COLUMN 60, entradas using "##,###,###.##",
COLUMN 74, salidas using "##,###,###.##",
COLUMN 90, x.existe_act USING "---,---,---.##",
COLUMN 108, x.costo USING "#,###,###.####",
COLUMN 127, total_c USING "##,###,###.##"
ON LAST ROW
PRINT COLUMN 127, "-------------"
PRINT COLUMN 127, total_p USING "##,###,###.##"
LET valor_total = total_p
LET total_p = 0
SKIP 2 LINES
PRINT COLUMN 1, "==================================================",
"==================================================",
"========================================"
PRINT COLUMN 4, "Total Registros Impresos =", count(*) USING "<<<<"
PRINT COLUMN 4, ASCII 27, ASCII 80
END REPORT