Files
MBS/PROYECTO/acdir/acprrp010.4gl
T

404 lines
14 KiB
Plaintext

{
================================================================
PROGRAMA :ACPRRP010
OBJETIVO :IMPRIMIR LAS ETIQUETAS DE LOS ACTIVOS EN MASA
FECHA :AGOSTO 20,2010
}
GLOBALS
"acprgb000.4gl"
DEFINE codigo_dp INT,
descripcion_dp CHAR(50),
inventario,bloque char(50),
kcantidad DEC(12,4),
codlista,cia_logo SMALLINT,
xnum_emp,xnum_oc INT,
cliente,nombre_empleado,nom1,nom2,apell1,apell2 VARCHAR(100)
MAIN
DEFER INTERRUPT
CALL ARG_VAL(1) RETURNING usuarios
CALL ARG_VAL(2) RETURNING clave
CONNECT to "smarmotech" user usuarios USING clave
SELECT a.* INTO p_companias.* FROM companias a
CALL acprrp010()
END MAIN
FUNCTION acprrp010()
DEFINE factor DYNAMIC ARRAY OF DEC(12,5)
DEFINE codigo_act INT,
descripcion_act char(180),
fecha_compra DATE,
kprecio DEC(12,2),
moneda SMALLINT,
simbolo CHAR(4),
codigo CHAR(25),
pcodn,pcodgrupo,pcodtipo,pcodsec,valor INT,
cantidad,lado1,lado2,lado3,valor_medida DEC(12,4),
punidadmed CHAR(3),
pcodid INTEGER,
despiece DYNAMIC ARRAY OF RECORD
imp CHAR(3),
pcodid INT,
codigo CHAR(25),
descripcion CHAR(180),
unidad CHAR(4),
cantidad DEC(12,4),
lado1 DEC(12,4),
lado2 DEC(12,4),
lado3 DEC(12,4),
medida DEC(12,4)
END RECORD
DEFINE handler om.SaxDocumentHandler, -- return value from fgl_report_commitCurrentSettings()
salida,r_filename STRING, -- filename of Report Design Document including .4rp extension
r_output STRING, -- output format option
preview INTEGER -- TRUE/FALSE, to set preview option
OPEN WINDOW w1 AT 10,1 WITH FORM "acfmrp010"
DIALOG ATTRIBUTE(UNBUFFERED)
INPUT BY NAME inventario,salida,cia_logo,moneda,valor,codlista,r_output
BEFORE INPUT
CALL despiece.clear()
AFTER INPUT
IF codlista IS NULL THEN
CALL msg(16)
NEXT FIELD codlista
END IF
END INPUT
ON ACTION cancel
CALL msg(2)
EXIT DIALOG
ON ACTION busca
CALL despiece.clear()
IF inventario = "ACTIVOS FIJOS" THEN
CONSTRUCT criterio ON a.codigo,a.descripcion,a.departamento
FROM codigo_act,descripcion_act,codigo_dp
END IF
IF inventario = "PRODUCTOS TERMINADOS" THEN
INPUT BY NAME xnum_oc,xnum_emp,bloque
ON ACTION busca_emp
CALL busca_empleado1() RETURNING Xnum_emp,nom1,nom2,apell1,apell2
LET nombre_empleado = xnum_emp USING "<<<<<","-",nom1 CLIPPED,apell1 CLIPPED
DISPLAY BY NAME nombre_empleado
AFTER INPUT
IF INT_FLAG THEN
LET INT_FLAG = FALSE
EXIT INPUT
END IF
IF xnum_oc IS NOT NULL THEN
SELECT CAST(b.tipo_cliente AS VARCHAR(4))+'-'+
CAST(b.sec_cliente AS VARCHAR(10)) + ' '+RTRIM(b.nombre)
INTO cliente
FROM prtb00012 a,vetb00004 b
WHERE a.num_oc = xnum_oc AND a.tipo_cliente = b.tipo_cliente AND
a.sec_cliente = b.sec_cliente AND
a.status_t IS NULL
IF STATUS = NOTFOUND THEN
CALL fgl_winmessage("INFO","ORDEN NO EXISTE O ESTA NULA","INFO")
NEXT FIELD xnum_oc
END IF
DISPLAY BY NAME cliente
LET selec =
" SELECT a.codid,a.descrip_esp,'1','NO TIENE','01/01/2001','0','NO', ",
" a.cod_n,a.cod_grupo,a.cod_tipo,a.cod_Sec,a.unidad_med,a.codid,d.factor_conv ",
"FROM iptb00002 a,iptb00001 d,prtb00013 c ",
"WHERE a.status_t IS NULL AND c.num_oc ='",xnum_oc,"' ",
" and a.cod_n = d.cod_n AND a.cod_grupo = d.cod_grupo and ",
" a.cod_tipo = d.cod_tipo and a.cod_Sec = d.cod_Sec AND ",
" a.cod_n = c.cod_n AND a.cod_grupo = c.cod_grupo AND a.cod_tipo = c.cod_tipo AND a.cod_sec = c.cod_Sec ",
" ORDER BY a.codid"
END IF
IF xnum_emp IS NOT NULL THEN
SELECT CAST(a.num_emp AS varchar(4))+'-'+ RTRIM(a.nom1_emp)+' '+RTRIM(a.apell1_emp)
INTO nombre_empleado
FROM adtb00003 a
WHERE a.num_emp = xnum_emp AND a.status_t IS NULL
IF STATUS = NOTFOUND THEN
CALL fgl_Winmessage("INFO","EMPLEADO NO EXISTE","INFO")
NEXT FIELD xnum_emp
END IF
DISPLAY BY NAME nombre_empleado
END IF
EXIT INPUT
END INPUT
IF xnum_oc IS NULL THEN
CONSTRUCT criterio ON a.cod_n,a.cod_grupo,a.cod_tipo,a.cod_sec,
a.descrip_esp
FROM cod_n,cod_grupo,cod_tipo,cod_Sec,descripcion_act
IF valor = 1 THEN
LET selec =
" SELECT a.codid,a.descrip_esp,'1','NO TIENE','01/01/2001',b.precio,c.simbolo, ",
" a.cod_n,a.cod_grupo,a.cod_tipo,a.cod_Sec,a.unidad_med,a.codid,d.factor_conv ",
"FROM iptb00002 a,vetb00025 b,vetb00061 c,iptb00001 d ",
"WHERE a.status_t IS NULL AND ",criterio clipped," 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 ",
"b.ventas = ",moneda," and b.ventas = c.ventas AND ",
" b.cod_lista = ",codlista,
" and a.cod_n = d.cod_n AND a.cod_grupo = d.cod_grupo and ",
" a.cod_tipo = d.cod_tipo and a.cod_Sec = d.cod_Sec ",
" ORDER BY a.codid"
ELSE
LET selec =
" SELECT a.codid,a.descrip_esp,'1','NO TIENE','01/01/2001','0','NO', ",
" a.cod_n,a.cod_grupo,a.cod_tipo,a.cod_Sec,a.unidad_med,a.codid,d.factor_conv ",
"FROM iptb00002 a,iptb00001 d ",
"WHERE a.status_t IS NULL AND ",criterio clipped,
" and a.cod_n = d.cod_n AND a.cod_grupo = d.cod_grupo and ",
" a.cod_tipo = d.cod_tipo and a.cod_Sec = d.cod_Sec ",
" ORDER BY a.codid"
END IF
END IF
END IF
IF inventario = "MATERIA PRIMA" THEN
CONSTRUCT criterio ON a.cod_n,a.cod_grupo,a.cod_tipo,a.cod_sec,
a.descrip_esp
FROM cod_n,cod_grupo,cod_tipo,cod_Sec,descripcion_act
END IF
IF inventario = "REPUESTOS" THEN
CONSTRUCT criterio ON a.cod_n,a.cod_grupo,a.cod_tipo,a.cod_sec,
a.descrip_esp
FROM cod_n,cod_grupo,cod_tipo,cod_Sec,descripcion_act
END IF
IF inventario = "ACTIVOS FIJOS" THEN
LET selec = "SELECT a.codigo,a.descripcion,a.departamento,b.nom_dpto,",
"CONVERT(CHAR(10),a.fech_compra,103) ",
" FROM actb00001 a,adtb00001 b ",
" WHERE a.status_t IS NULL AND ",criterio CLIPPED,
" AND a.departamento = b.departamento "
END IF
IF inventario = "MATERIA PRIMA" THEN
LET selec =
" SELECT '1',a.descrip_esp,'1','NO TIENE','01/01/2001','0','NO', ",
" a.cod_n,a.cod_grupo,a.cod_tipo,a.cod_Sec,a.unidad_med ",
"FROM intb00001 a ",
"WHERE a.status_t IS NULL AND ",criterio clipped,
" ORDER BY a.cod_Sec"
END IF
IF inventario = "REPUESTOS" THEN
LET selec =
" SELECT '1',a.descrip_esp,'1','NO TIENE','01/01/2001','0','NO', ",
" a.cod_n,a.cod_grupo,a.cod_tipo,a.cod_Sec,a.unidad_med ",
"FROM irtb00002 a ",
"WHERE a.status_t IS NULL AND ",criterio clipped,
" ORDER BY a.cod_Sec"
END IF
IF INT_FLAG THEN
LET int_flag = FALSE
EXIT PROGRAM
END IF
PREPARE comando FROM selec
DECLARE busca CURSOR FOR comando
LET idx = 1
FOREACH busca INTO codigo_act,descripcion_act,codigo_dp,
descripcion_dp ,fecha_compra,
kprecio,simbolo,pcodn,pcodgrupo,pcodtipo,pcodsec,
punidadmed,pcodid,factor[idx]
IF factor[idx] IS NULL THEN
LET factor[idx] = 1
END IF
LET codigo = pcodn USING "<<<&","-",pcodgrupo USING "<<<<&","-",
pcodtipo USING "<<<<&","-",pcodsec USING "<<<<<&"
LET despiece[idx].imp = 'NO'
LET despiece[idx].codigo = codigo
LET despiece[idx].descripcion = descripcion_act
LET despiece[idx].unidad = punidadmed
LET despiece[idx].cantidad = cantidad
LET despiece[idx].lado1=kprecio
LET despiece[idx].pcodid = pcodid
LET idx = idx + 1
END FOREACH
CALL set_count(idx-1)
INPUT ARRAY despiece WITHOUT DEFAULTS FROM smedida.*
AFTER FIELD lado3
LET idx = arr_curr()
IF despiece[idx].unidad= "M2" THEN
LET despiece[idx].medida =
despiece[idx].cantidad * (despiece[idx].lado1 * despiece[idx].lado2)
END IF
IF despiece[idx].unidad= "M3" THEN
LET despiece[idx].medida =
despiece[idx].cantidad * (despiece[idx].lado1 * despiece[idx].lado2 * despiece[idx].lado3)
END IF
IF despiece[idx].unidad= "ML" THEN
LET despiece[idx].medida =
despiece[idx].cantidad * despiece[idx].lado1
LET despiece[idx].lado2 = 0
END IF
IF despiece[idx].unidad= "UD" OR despiece[idx].unidad= "GL" THEN
LET despiece[idx].medida = despiece[idx].cantidad
END IF
AFTER FIELD cantidad
LET idx = arr_curr()
LET scr_l = scr_line()
LET despiece[idx].medida = factor[idx] * despiece[idx].cantidad
DISPLAY despiece[idx].medida TO smedida[scr_l].medida
ON ACTION imprime
LET r_filename = salida
IF fgl_report_loadCurrentSettings(r_filename) THEN -- load the .4rp file
# LET r_output='SVG'
LET preview=1
CALL fgl_report_selectDevice(r_output) -- changing default
CALL fgl_report_selectPreview(preview) -- changing default
LET handler = fgl_report_commitCurrentSettings() -- commit changes
END IF
-- report engine was configured ok
IF handler IS NOT NULL THEN
START REPORT activos TO XML HANDLER handler
FOR idx = 1 TO arr_count()
IF despiece[idx].imp='SI' THEN
IF despiece[idx].medida IS NULL THEN
LET despiece[idx].medida = despiece[idx].cantidad
END IF
LET kcantidad = despiece[idx].medida
OUTPUT TO REPORT activos(codigo_act,despiece[idx].descripcion,fecha_compra,despiece[idx].lado1,simbolo,
despiece[idx].codigo,despiece[idx].unidad, despiece[idx].cantidad,
despiece[idx].lado1,despiece[idx].lado2,despiece[idx].lado3,despiece[idx].medida,
despiece[idx].pcodid)
INSERT INTO actb00010
(fecha
,tipo_inenvatio
,codigo
,cantidad
,lado_1
,lado_2
,lado_3
,medida
,us_crea
,fech_crea
,codid)
VALUES
(getdate()
,inventario
,despiece[idx].codigo
,despiece[idx].cantidad
,despiece[idx].lado1
,despiece[idx].lado2
,despiece[idx].lado3
,despiece[idx].medida
,usuarios
,getdate()
,despiece[idx].pcodid)
END IF
END FOR
FINISH REPORT activos
END IF
AFTER INPUT
IF int_flag THEN
LET int_flag = FALSE
CALL Msg(2)
RETURN
END IF
LET idx = arr_curr()
IF despiece[idx].imp='SI' THEN
IF despiece[idx].medida IS NULL and despiece[idx].cantidad IS NULL THEN
IF despiece[idx].codigo IS NOT NULL THEN
CALL fgl_winmessage("ERROR","NO PUEDES DEJAR LA CANTIDAD Y MEDIDA EN BLANCO, EN PRODUCTO SELECCIONADO","STOP")
NEXT FIELD cantidad
END IF
END IF
END IF
EXIT INPUT
END INPUT
END DIALOG
END FUNCTION
REPORT activos(x,descripcion,xfecha_compra,xprecio,xsimbolo,xcodigo,xunidadmed,
xcantidad,xlado1,xlado2,xlado3,xvalor_medida,xcodid)
DEFINE x,xcodid INT,
fecha,xfecha_compra DATE,
barcodigo_act CHAR(128),
descripcion VARCHAR(180),
xprecio DEC(12,2),
xsimbolo CHAR(4),
xcodigo CHAR(25),
xunidadmed CHAR(3),
xcantidad,xlado1,xlado2,xlado3,xvalor_medida DEC(12,4)
ORDER BY xcodigo
FORMAT
FIRST PAGE HEADER
LET fecha = TODAY
BEFORE GROUP OF xcodigo
#ON EVERY ROW
IF inventario = "PRODUCTOS TERMINADOS" THEN
LET barcodigo_act = "STARTB",codigo_128(xcodid,xvalor_medida)
ELSE
LET barcodigo_act = "STARTB",codigo_128(xcodigo,xvalor_medida)
END IF
PRINTX x,codigo_dp,descripcion,descripcion_dp,fecha,barcodigo_act,
Xfecha_compra,xprecio,xsimbolo,xcodigo,xvalor_medida,xcantidad,
xlado1,xlado2,xlado3,xunidadmed,cia_logo,xnum_emp,xnum_oc,cliente,nombre_empleado,bloque
END REPORT
FUNCTION codigo_128(cod_val,pcantidad)
DEFINE x INT,
cod_val CHAR(25),
aux_str,barcode STRING,
pcantidad DEC(12,4)
LET aux_str=cod_val clipped ,"+",Pcantidad using "<<<<<.##"
LET barcode=""
FOR x=1 TO LENGTH(aux_str)
LET barcode=barcode,",",aux_str.getCharAt(x)
END FOR
IF inventario = "ACTIVOS FIJOS" THEN
LET barcode=barcode CLIPPED,",+,1"
END IF
RETURN barcode
END FUNCTION