{ -------------------------------------------------------------------------- PROGRAMA : IRPRMT066 OBJETIVO : Programa Para Anular en Forma Logica Movimientos de Inventario de Repuestos. PROGRAMADOR : JOSE ALFREDO PAULINO ALEJO FECHA : Diciembre 4, 18996 -------------------------------------------------------------------------- } GLOBALS "irprgb000.4gl" DEFINE anular RECORD cod_mov SMALLINT, num_doc INTEGER, fecha DATE, cod_sp SMALLINT, cod_sp_sec SMALLINT END RECORD DEFINE descrip_mov CHAR(30) DEFINE opc1 CHAR(1) FUNCTION irprmt066() DEFINE fecha CHAR(8) DEFINE hora CHAR(5) CLEAR SCREEN OPTIONS ERROR LINE 24, FORM LINE 4, COMMENT LINE 22, PROMPT LINE 23 CALL pantalla() DISPLAY "irprmt066" AT 4,2 DISPLAY "JAPA " AT 5,2 DISPLAY "Anular Documentos" AT 6,31 OPEN WINDOW anular AT 8,4 WITH FORM "irfmwd066" ATTRIBUTE (BORDER,FORM LINE FIRST + 1,PROMPT LINE LAST) INPUT BY NAME anular.cod_mov,anular.num_doc ATTRIBUTE (BOLD) AFTER FIELD cod_mov IF anular.cod_mov is null THEN LET numero_msg = 16 CALL msg(numero_msg) NEXT FIELD cod_mov END IF SELECT a.descrip_mov INTO descrip_mov FROM irtb00005 a WHERE a.cod_mov = anular.cod_mov AND a.status_t IS NULL IF STATUS = NOTFOUND THEN LET numero_msg = 3 CALL msg(numero_msg) NEXT FIELD cod_mov END IF DISPLAY BY NAME descrip_mov AFTER FIELD num_doc IF anular.num_doc is null THEN LET numero_msg = 16 CALL msg(numero_msg) NEXT FIELD num_doc END IF SELECT UNIQUE a.num_doc FROM irtb00006 a WHERE a.cod_mov = anular.cod_mov AND a.num_doc = anular.num_doc AND a.status_t IS NULL AND a.fecha > "300394" IF status = notfound THEN LET numero_msg = 3 CALL msg(numero_msg) NEXT FIELD cod_mov END IF SELECT MAX(a.fecha),MAX(a.cod_sp),MAX(a.cod_sp_sec) INTO anular.fecha,anular.cod_sp,anular.cod_sp_sec FROM irtb00006 a WHERE a.cod_mov = anular.cod_mov AND a.num_doc = anular.num_doc AND a.status_t IS NULL DISPLAY BY NAME anular.fecha,anular.cod_sp,anular.cod_sp_sec LET p_fechas = anular.fecha CALL prd() IF bandera = 1 THEN EXIT INPUT END IF END INPUT IF bandera = 1 THEN LET bandera = 0 GOTO salir END IF IF int_flag THEN LET numero_msg = 2 CALL msg(numero_msg) LET int_flag = FALSE CLOSE WINDOW anular RETURN END IF PROMPT "Quiere Proceder Anulacion de Este Dcto. (S/N)? " FOR CHAR opc1 LET opc1 = upshift(opc1) IF opc1 = "S" THEN SELECT status_mov INTO status_m FROM irtb00005 WHERE @cod_mov = anular.cod_mov DECLARE busca CURSOR FOR SELECT cod_n,cod_grupo,cod_tipo,cod_sec,cantidad_2 FROM irtb00006 WHERE num_doc=anular.num_doc and @cod_mov=anular.cod_mov and fecha> "300394" LET decide = "N" LET idx = 1 FOREACH busca INTO movi2[idx].cod_n,movi2[idx].cod_grupo, movi2[idx].cod_tipo,movi2[idx].cod_sec, movi2[idx].cantidad_2 IF status_m = "1" THEN SELECT SUM(cantidad_2) INTO chequea.existe FROM irtb00006 WHERE cod_n = movi2[idx].cod_n and cod_grupo = movi2[idx].cod_grupo and cod_tipo=movi[idx].cod_tipo and cod_sec = movi2[idx].cod_sec and status_t is null LET chequea.existe = chequea.existe - movi2[idx].cantidad_2 IF chequea.existe < 0 THEN LET numero_msg = 225 CALL msg(numero_msg) SLEEP 3 RETURN END IF END IF LET idx = idx + 1 END FOREACH UPDATE irtb00006 set status_t = "E",us_mod = user,fech_mod = current WHERE @cod_mov = anular.cod_mov AND @num_doc = anular.num_doc AND @fecha > "300394" LET numero_msg = 39 CALL msg(numero_msg) END IF LABEL salir: CLOSE WINDOW anular END FUNCTION