"
LET cuerpo = cuerpo CLIPPED, ""
FOR i = 1 TO movi2.getLength()
# PROCEDIMIENTO ENVIO CORREO PARA LA EXISTENCIA MINIMA
LET existenciaact[i] = (existenciaact[i] - (movi2[i].cantidad_2 * -1))
IF existminima[i] > 0 THEN
LET porcientocontrol[i] = (existminima[i] / existenciaact[i]) * 100
DISPLAY "PORCIENTO ",
existminima[i],
" ",
existenciaact[i],
" ",
porcientocontrol[i],
" ",
status_m
END IF
LET enviaCorreo = "NO"
IF porcientocontrol[i] >= 75
AND status_m = 2
AND existminIma[i] > 0 THEN
# INFORMACION PARA ENVIAR EL CORREO A LOS VENDEDORES
LET enviaCorreo = "SI"
LET cuerpo =
cuerpo CLIPPED,
"| ",
movi2[i].descrip_esp CLIPPED,
" | ",
"",
movi2[i].cantidad_2 USING "##,###.##",
" | ",
"",
existminima[i] USING "##,###.##",
" | ",
"",
existenciaact[i] USING "##,###.##",
" | ",
"
"
LET enviaEmailProd[i] = "SI"
END IF
IF porcientocontrol[i] <= 0 AND status_m = 2 AND existminIma[i] > 0 THEN
# INFORMACION PARA ENVIAR EL CORREO A LOS VENDEDORES
LET enviaCorreo = "SI"
LET cuerpo_correo =
cuerpo_correo CLIPPED,
"",
movi2[i].descrip_esp CLIPPED,
" | ",
"",
movi2[i].cantidad_2 USING "##,###.##",
" | ",
"",
existminima[i] USING "##,###.##",
" | ",
"",
existenciaact[i] USING "##,###.##",
" | ",
""
LET enviaEmailProd[i] = "SI"
END IF
END FOR
IF enviaCorreo = "SI" THEN
LET procedimiento = "{ call cc_avisadespacho(?,?,?,?) }" CLIPPED
# CALL envia_correo(aquienEmail,ccAquien,cuerpo,
# encabezado, procedimiento )
END IF
END FUNCTION
FUNCTION toPDF()
-- configure report engine; the functions prefixed fgl that are called here are part of the GRW API
CALL configureOutput("PDF") RETURNING HANDLER
START REPORT formu4 TO XML HANDLER handler
DECLARE buscapdf CURSOR FOR
SELECT a.area,
c.nombre_area,
a.cod_n,
a.cod_grupo,
a.cod_tipo,
a.cod_sec,
a.cantidad_1,
a.cantidad_2,
'0',
b.unidad_med,
b.descrip_esp
FROM iptb00006 a, iptb00002 b, prtb00016 c
WHERE a.num_doc = otros_mov.num_doc
AND a.cod_mov = otros_mov.cod_mov
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.bodega = otros_mov.bodega
AND a.fech_crea > '01/01/2009 08:00'
AND a.area = c.area_num
ORDER BY a.cod_n, a.cod_grupo, a.cod_tipo, a.cod_sec
LET idx = 1
FOREACH buscapdf INTO movi2[idx].*
IF movi2[idx].cantidad_2 < 0 THEN
LET movi2[idx].cantidad_2 = movi2[idx].cantidad_2 * -1
END IF
SELECT SUM(a.cantidad)
INTO cantidad_conduce
FROM prtb00013 a
WHERE a.cod_n = movi2[idx].cod_n
AND a.cod_grupo = movi2[idx].cod_grupo
AND a.cod_tipo = movi2[idx].cod_tipo
AND a.cod_sec = movi2[idx].cod_sec
AND a.num_oc = ordenx
AND a.status_t IS NULL
LET cantidad_orden = 0
IF otros_mov.cod_mov = 30 AND otros_mov.cod_mov = 31
OR otros_mov.cod_mov = 55 THEN
SELECT SUM(a.cantidad_2 * - 1)
INTO cantidad_orden
FROM iptb00006 a
WHERE a.cod_n = movi2[idx].cod_n
AND a.cod_grupo = movi2[idx].cod_grupo
AND a.cod_tipo = movi2[idx].cod_tipo
AND a.cod_sec = movi2[idx].cod_sec
AND a.conduce_no = otros_mov.conduce_no
AND cod_mov IN (30, 31, 55)
AND a.status_t IS NULL
END IF
IF cantidad_orden IS NULL THEN
LET cantidad_orden = 0
END IF
IF cantidad_conduce IS NULL THEN
LET cantidad_conduce = 0
END IF
LET movi2[idx].cantidad_p = cantidad_conduce - cantidad_orden
OUTPUT TO REPORT formu4(otros_mov.*, movi2[idx].*)
LET idx = idx + 1
END FOREACH
FINISH REPORT formu4
END FUNCTION
FUNCTION adicionaArray()
DEFINE x1, current_length INT
LET current_length = movi10Dest.getLength()
FOR x1 = 1 TO movi10.getLength()
IF movi10[x1].cantidad2 IS NOT NULL THEN
LET current_length = current_length + 1
LET movi10Dest[current_length].* = movi10[x1].*
END IF
END FOR
END FUNCTION
FUNCTION addDespiece()
DEFINE
x1, x2, current_length INT,
flag BOOLEAN
--LET current_length = despieceDest.getLength()
FOR x1 = 1 TO despiece.getLength()
--DISPLAY "DESPIECE: ", despiece[x1].*
LET flag = TRUE
IF despiece[x1].medida IS NOT NULL THEN
FOR x2 = 1 TO despieceDest.getLength()
IF despiece[x1].cod_n = despieceDest[x2].cod_n
AND despiece[x1].cod_grupo = despieceDest[x2].cod_grupo
AND despiece[x1].cod_tipo = despieceDest[x2].cod_tipo
AND despiece[x1].cod_sec = despieceDest[x2].cod_sec
AND despiece[x1].secuencia = despieceDest[x2].secuencia THEN
--DISPLAY "DESPIECEDEST: ", despieceDest[x2].*
LET despieceDest[x2].* = despiece[x1].*
LET flag = FALSE
END IF
END FOR
IF flag THEN
LET current_length = despieceDest.getLength() + 1
LET despieceDest[current_length].* = despiece[x1].*
END IF
END IF
END FOR
END FUNCTION
FUNCTION addUbicacion()
FOR x2 = 1 TO movi10Dest.getLength()
IF movi10Dest[x2].cantidad2 IS NOT NULL THEN
# IF movi10Dest[x2].id_seccion1 IS NOT NULL THEN
IF status_m = "2" THEN
IF movi10Dest[x2].cantidad2 > 0 THEN
LET movi10Dest[x2].cantidad2 = movi10Dest[x2].cantidad2 * -1
END IF
IF movi10Dest[x2].cantidad1 > 0 THEN
LET movi10Dest[x2].cantidad1 = movi10Dest[x2].cantidad1 * -1
END IF
END IF
TRY
DISPLAY otros_mov.num_doc
DISPLAY movi10Dest[x2].area
DISPLAY movi10Dest[x2].cod_n
DISPLAY movi10Dest[x2].cod_Grupo
DISPLAY movi10Dest[x2].cod_tipo
DISPLAY movi10Dest[x2].cod_sec
DISPLAY movi10Dest[x2].cod_mov
DISPLAY movi10Dest[x2].id_bodega
DISPLAY movi10Dest[x2].id_seccion1
DISPLAY movi10Dest[x2].id_tramo1
DISPLAY movi10Dest[x2].id_fila
DISPLAY movi10Dest[x2].id_pos
DISPLAY movi10Dest[x2].cantidad1
DISPLAY movi10Dest[x2].cantidad2
INSERT INTO iptb00062(
num_Doc,
cod_mov,
bodega,
fecha,
cod_seccion,
cod_tramo,
cod_fila,
cod_pos,
area,
cod_n,
cod_grupo,
cod_tipo,
cod_sec,
cantidad,
cantidad2,
us_crea,
fech_crea)
VALUES(otros_mov.num_doc,
otros_mov.cod_mov,
movi10Dest[x2].id_bodega,
otros_mov.fecha,
movi10Dest[x2].id_seccion1,
movi10Dest[x2].id_tramo1,
movi10Dest[x2].id_fila,
movi10Dest[x2].id_pos,
movi10Dest[x2].area,
movi10Dest[x2].cod_n,
movi10Dest[x2].cod_Grupo,
movi10Dest[x2].cod_tipo,
movi10Dest[x2].cod_sec,
movi10Dest[x2].cantidad1,
movi10Dest[x2].cantidad2,
usuarios,
getdate())
CATCH
LET numero_msg = 1663
DISPLAY "ROLLBACK addUbicacion"
EXIT FOR
END TRY
# END IF
END IF
END FOR
RETURN numero_msg
END FUNCTION
FUNCTION controlaDevolucion(
dcodn,
dcodgrupo,
dcodtipo,
dcodsec,
dfactura,
dcontrol_devolucion,
dcantidad)
DEFINE
dcodn, dcodgrupo, dcodtipo, dcodsec, dfactura INT,
dcantidad_factura, dcantidad_devuelta, dcantidad DEC(12, 5),
dcontrol_devolucion VARCHAR(2),
devolucion_correcta BOOLEAN
#CONTROL DEVOLUCION
IF dcontrol_devolucion = "SI" THEN
LET dcantidad_factura = 0
SELECT ISNULL(SUM(a.cantidad), 0)
INTO dcantidad_factura
FROM vetb00003 a
WHERE a.factura = dfactura
AND a.status_t IS NULL
AND a.fech_crea > '2009-01-01 08:00'
AND a.cod_n = dcodn
AND a.cod_grupo = dcodgrupo
AND a.cod_tipo = dcodtipo
AND a.cod_sec = dcodsec
AND a.status_t IS NULL
SELECT ISNULL(SUM(a.cantidad_2), 0)
INTO dcantidad_devuelta
FROM iptb00006 a
WHERE a.factura = dfactura
AND a.status_t IS NULL
AND a.fech_crea > '2009-01-01 08:00'
AND a.cod_n = dcodn
AND a.cod_grupo = dcodgrupo
AND a.cod_tipo = dcodtipo
AND a.cod_sec = dcodsec
AND a.cod_mov IN (12, 13)
DISPLAY "control dev: ",
dcantidad_devuelta,
" t ",
dcantidad,
" f ",
dcantidad_factura
IF dcantidad_devuelta + dcantidad > dcantidad_factura THEN
RETURN FALSE
END IF
END IF
RETURN TRUE
END FUNCTION
FUNCTION loadDespieceMemory(pcodn, pcodgrupo, pcodtipo, pcodsec)
DEFINE i, idx, pcodn, pcodgrupo, pcodtipo, pcodsec INT
LET idx = 1
FOR i = 1 TO despieceMem.getLength()
IF despieceMem[i].cod_n = pcodn
AND despieceMem[i].cod_grupo = pcodgrupo
AND despieceMem[i].cod_tipo = pcodtipo
AND despieceMem[i].cod_sec = pcodsec THEN
LET container[idx].* = despieceMem[i].*
LET idx = idx + 1
END IF
END FOR
RETURN container
END FUNCTION
FUNCTION saveDespieceMemory(pcodn, pcodgrupo, pcodtipo, pcodsec)
DEFINE i, x, pcodn, pcodgrupo, pcodtipo, pcodsec INT
-- borrar registros anteriores del producto
FOR x = despieceMem.getLength() TO 1 STEP -1
IF despieceMem[x].cod_n = pcodn
AND despieceMem[x].cod_grupo = pcodgrupo
AND despieceMem[x].cod_tipo = pcodtipo
AND despieceMem[x].cod_sec = pcodsec THEN
CALL despieceMem.deleteElement(x)
END IF
END FOR
-- guardar nuevos
FOR i = 1 TO despiece.getLength()
IF despiece[i].medida IS NOT NULL THEN
LET x = despieceMem.getLength() + 1
LET despieceMem[x].* = despiece[i].*
END IF
END FOR
END FUNCTION