{ ------------------------------------------------------------------------- PROGRAMA : COPRMT020 OBJETIVO : Capturar, Modificar, Eliminar registros de la Tabla de Ordenes de Compras PROGRAMADOR : Ing. Betania Guerrero Perez FECHA REALIZACION : Septiembre 07, 1992. MODIFICADO POR : Tadeo A. Ferreras F. FECHA : Septiembre 5, 1994. DESCRIPCION : Agregar el tipo de orden en los UPDATE de la tabla de datos generales de la orden, detalle de la orden y entregas parciales -------------------------------------------------------------------------- } GLOBALS "coprgb000.4gl" DEFINE descr1,descr2,descr3,descr4 CHAR(15) DEFINE c_i_d,c_i_d1,nota,nota1,nombre_mon CHAR(30) DEFINE simb_mon CHAR(4) DEFINE nom_via CHAR(10) DEFINE req_ant ARRAY[100] OF INTEGER DEFINE opc1,opc2,opc4,salir,proce CHAR(1) DEFINE cod_mon,control_linea,control_item,idx2,total_parc INTEGER DEFINE fecha1 DATE DEFINE valor2,total DECIMAL(12,2) DEFINE j RECORD LIKE cotb00025.* DEFINE requis INTEGER DEFINE j1,k1 INTEGER FUNCTION coprmt020() CLEAR SCREEN OPTIONS FORM LINE 8, ERROR LINE 24, COMMENT LINE 22, PROMPT LINE 23, MESSAGE LINE 22 OPEN FORM cofmmt020 FROM "cofmmt009" DISPLAY FORM cofmmt020 CALL pantalla() DISPLAY "coprmt020" AT 4,3 DISPLAY "Ordenes Voluminosas" AT 6,30 SELECT dia INTO dia_aduana FROM cotb00028 MENU "OPCIONES" COMMAND "Adicionar" " Adiciona Registro Cancela Operacion" CLEAR FORM LET opc = "S" LET existe = null LET int_flag = FALSE CALL copcad020() COMMAND "Consultar" " Realiza Busqueda Cancela Operacion" CLEAR FORM LET existe = null LET int_flag = FALSE CALL copcmf020() COMMAND "Salir" "Retorna Menu Anterior" EXIT MENU END MENU END FUNCTION FUNCTION copcad020() #WHENEVER ERROR CONTINUE IF ordenes.num_oc is null THEN LET ordenes.num_oc = 0 END IF CLEAR FORM DISPLAY " " AT 24,1 #LABEL vuelve: #IF opc = "S" THEN INITIALIZE ordenes.* TO NULL LET ordenes.cierre = "N" LET ordenes.enviada = "N" LET ordenes.pago = "N" # END IF # Captura las informaciones generales de la orden de compras INPUT BY NAME ordenes.*,cod_mon WITHOUT DEFAULTS ATTRIBUTE (YELLOW) ON KEY (CONTROL-W) CASE # Control de ventana para la busqueda de los suplidores WHEN INFIELD (cod_sp) LET identifica = "O" CALL busca1_sup1() LET int_flag = FALSE IF existe = "N" then LET numero_msg = 3 CALL msg(numero_msg) LET existe = null NEXT FIELD cod_sp END IF DISPLAY BY NAME ordenes.cod_sp,ordenes.cod_sp_sec, suplidor.nom_sp LET identifica = NULL NEXT FIELD cod_sp_sec WHEN INFIELD (cod_sp_sec) LET identifica = "O" CALL busca1_sup1() IF existe = "N" then LET numero_msg = 3 CALL msg(numero_msg) LET existe = null NEXT FIELD cod_sp END IF DISPLAY BY NAME ordenes.cod_sp,ordenes.cod_sp_sec, suplidor.nom_sp LET identifica = NULL NEXT FIELD cod_sp_sec # Ventana para los terminos de pagos WHEN INFIELD (term_sp) LET identifica = "O" CALL busca1_terminos() IF int_flag THEN LET numero_msg = 2 CALL msg(numero_msg) LET int_flag = false NEXT FIELD term_sp END IF IF existe = "N" THEN LET numero_msg = 3 CALL msg(numero_msg) LET existe = null NEXT FIELD term_sp END IF LET ordenes.term_sp = pagos.term_sp DISPLAY BY NAME pagos.term_sp,pagos.descrip_term LET identifica = NULL NEXT FIELD via # Ventana para la busqueda de los puertos WHEN INFIELD (cod_pt) LET identifica = "O" CALL busca1_puertos() IF int_flag THEN LET numero_msg = 2 CALL msg(numero_msg) LET int_flag = false NEXT FIELD cod_pt END IF IF existe = "N" THEN LET numero_msg = 3 CALL msg(numero_msg) LET existe = null NEXT FIELD cod_pt END IF LET ordenes.cod_pt = puertos.cod_pt DISPLAY BY NAME puertos.cod_pt,nombre_p LET identifica = NULL # Ventana para la busqueda de las monedas WHEN INFIELD (cod_mon) LET identifica = "O" CALL busca1_monedas() IF int_flag THEN LET numero_msg = 2 CALL msg(numero_msg) LET int_flag = false NEXT FIELD cod_mon END IF IF existe = "N" THEN LET numero_msg = 3 CALL msg(numero_msg) LET existe = null NEXT FIELD cod_mon END IF LET cod_mon = monedas.cod_mon DISPLAY BY NAME cod_mon,nombre_mon LET identifica = NULL EXIT INPUT END CASE BEFORE FIELD tipo SELECT MAX(a.num_oc) INTO ordenes.num_oc FROM cotb00030 a IF ordenes.num_oc IS NULL THEN LET ordenes.num_oc = 0 END IF LET ordenes.num_oc = ordenes.num_oc + 1 DISPLAY BY NAME ordenes.num_oc ATTRIBUTE(YELLOW) AFTER FIELD tipo # Chequeo del numero del documento si el usuario elige numeracion manual IF ordenes.tipo IS NULL THEN LET numero_msg = 16 CALL msg(numero_msg) NEXT FIELD tipo END IF BEFORE FIELD fech_oc LET ordenes.fech_oc = today using "dd/mm/yy" DISPLAY BY NAME ordenes.fech_oc AFTER FIELD fech_oc IF ordenes.fech_oc IS NULL THEN LET numero_msg = 16 CALL msg(numero_msg) NEXT FIELD fech_oc END IF ### AQUI CONTROLA LA FECHA DEL DOCUMENTO { LET p_fechas = ordenes.fech_oc using "ddmmyy" CALL prd(p_fechas) IF bandera = 1 THEN LET bandera = 0 NEXT FIELD fech_oc END IF} AFTER FIELD cod_sp IF ordenes.cod_sp IS NULL THEN LET numero_msg = 16 CALL msg(numero_msg) NEXT FIELD cod_sp END IF AFTER FIELD cod_sp_sec # Chequeo del suplidor para el desplegue del nombre IF ordenes.cod_sp_sec IS NULL THEN LET numero_msg = 16 CALL msg(numero_msg) NEXT FIELD cod_sp_sec ELSE SELECT a.nom_sp,a.dir_sp,ciu_sp INTO suplidor.nom_sp,suplidor.dir_sp,suplidor.ciu_sp FROM cotb00001 a WHERE a.cod_sp = ordenes.cod_sp and a.cod_sp_sec = ordenes.cod_sp_sec and a.status_t is null IF status >= 0 THEN IF status = NOTFOUND THEN LET numero_msg = 3 CALL msg(numero_msg) NEXT FIELD cod_sp END IF ELSE CALL integridad() IF bandera = 1 THEN LET bandera = 0 RETURN END IF END IF DISPLAY BY NAME suplidor.nom_sp END IF AFTER FIELD term_sp # Chequeo de los terminos de pagos para desplegue de informacion IF ordenes.term_sp IS NULL THEN LET numero_msg = 16 CALL msg(numero_msg) NEXT FIELD term_sp ELSE IF ordenes.cod_sp = 23 THEN SELECT b.descrip_term INTO pagos.descrip_term FROM cotb00024 b WHERE b.term_sp = ordenes.term_sp and b.status_t is null ELSE SELECT b.descrip_ting INTO pagos.descrip_term FROM cotb00024 b WHERE b.term_sp = ordenes.term_sp and b.status_t is null END IF IF status >= 0 THEN IF status = NOTFOUND THEN LET numero_msg = 3 CALL msg(numero_msg) NEXT FIELD term_sp END IF ELSE CALL integridad() IF bandera = 1 THEN LET bandera = 0 RETURN END IF END IF DISPLAY BY NAME pagos.descrip_term END IF AFTER FIELD via # Validacion de la via para determinar su via IF ordenes.via IS NOT NULL THEN IF ordenes.via = "01" THEN LET nom_via = "MARITIMA" END IF IF ordenes.via = "02" THEN LET nom_via = "AEREA" END IF IF ordenes.via = "03" THEN LET nom_via = "TERRESTRE" END IF ELSE LET numero_msg = 16 CALL msg(numero_msg) NEXT FIELD via END IF DISPLAY BY NAME nom_via AFTER FIELD cod_pt # Chequeo del puerto y busqueda del su descripcion IF ordenes.cod_pt is not null THEN SELECT a.nom_pt,a.duracion INTO nombre_p,m_articulos.dia_llegada FROM cotb00019 a WHERE cod_pt = ordenes.cod_pt IF status = notfound THEN LET numero_msg = 3 CALL msg(numero_msg) NEXT FIELD cod_pt END IF DISPLAY BY NAME nombre_p END IF AFTER FIELD cod_mon # Chequeo del cod_n de la moneda y busqueda del su descripcion IF cod_mon is null THEN LET numero_msg = 16 CALL msg(numero_msg) NEXT FIELD cod_mon END IF SELECT a.descrip_mon,a.simbolo INTO nombre_mon,simb_mon FROM cotb00031 a WHERE a.cod_mon = cod_mon AND a.status_t IS NULL IF status = notfound THEN LET numero_msg = 3 CALL msg(numero_msg) NEXT FIELD cod_mon END IF DISPLAY BY NAME nombre_mon END INPUT IF int_flag THEN LET numero_msg = 2 CALL msg(numero_msg) LET int_flag = FALSE RETURN END IF # Captura de los articulos requeridos LET salir = null IF opc = "S" THEN FOR idx = 1 TO 200 LET arr_ordenes[idx].num_req = null LET arr_ordenes[idx].cod_n = null LET arr_ordenes[idx].cod_grupo = null LET arr_ordenes[idx].cod_tipo = null LET arr_ordenes[idx].cod_sec = null LET arr_ordenes[idx].cantidad = null LET arr_ordenes[idx].precio = null LET arr_ordenes[idx].valor = null END FOR END IF INPUT ARRAY arr_ordenes WITHOUT DEFAULTS FROM consart.* ATTRIBUTE (YELLOW) ON KEY (CONTROL-W) CASE WHEN INFIELD(num_req) IF existe = "N" THEN LET numero_msg = 49 CALL msg(numero_msg) NEXT FIELD num_req END IF LET identifica = "O" LET curr = arr_curr() LET scr_l = scr_line() CALL busca_requi() IF existe = "S" THEN IF int_flag THEN LET numero_msg = 2 CALL msg(numero_msg) LET int_flag = false NEXT FIELD num_req END IF CALL repite3() DISPLAY arr_ordenes[curr].cod_n TO consart[scr_l].cod_n DISPLAY arr_ordenes[curr].cod_grupo TO consart[scr_l].cod_grupo DISPLAY arr_ordenes[curr].cod_tipo TO consart[scr_l].cod_tipo DISPLAY arr_ordenes[curr].cod_sec TO consart[scr_l].cod_sec DISPLAY arr_ordenes[curr].cantidad TO consart[scr_l].cantidad DISPLAY arr_ordenes[curr].precio TO consart[scr_l].precio DISPLAY arr_ordenes[curr].valor TO consart[scr_l].valor DISPLAY BY NAME articulos.descrip_esp DISPLAY BY NAME articulos.unidad_med SELECT a.cod_nab,a.descrip_esp INTO m_articulos.cod_nab,descrip1 FROM cotb00005 a, intb00002 b WHERE b.cod_n=arr_ordenes[curr].cod_n and b.cod_grupo=arr_ordenes[curr].cod_grupo and b.cod_tipo=arr_ordenes[curr].cod_tipo and b.cod_sec=arr_ordenes[curr].cod_sec and a.cod_nab = b.cod_nab DISPLAY BY NAME m_articulos.cod_nab,descrip1 IF verdad = "S" THEN NEXT FIELD num_req END IF UPDATE cotb00008 SET procesada = "S" WHERE @cod_n = arr_ordenes[curr].cod_n AND @cod_grupo = arr_ordenes[curr].cod_grupo AND @cod_tipo = arr_ordenes[curr].cod_tipo AND @cod_sec = arr_ordenes[curr].cod_sec AND @num_req = arr_ordenes[curr].num_req NEXT FIELD num_parte END IF IF existe = "N" THEN NEXT FIELD num_req END IF WHEN INFIELD (num_parte) LET curr = arr_curr() CALL parcial() END CASE BEFORE ROW LET curr = arr_curr() LET scr_l = scr_line() LET ant_req.num_req = arr_ordenes[curr].num_req LET busca_parte[curr].cod_n = arr_ordenes[curr].cod_n LET busca_parte[curr].cod_grupo = arr_ordenes[curr].cod_grupo LET busca_parte[curr].cod_tipo = arr_ordenes[curr].cod_tipo LET busca_parte[curr].cod_sec = arr_ordenes[curr].cod_sec AFTER ROW LET curr = arr_curr() LET valor_total = 0 FOR idx = 1 TO 200 IF valor_total > 0 THEN LET valor_total = valor_total + arr_ordenes[idx].valor END IF END FOR IF arr_ordenes[curr].num_req IS NOT NULL THEN SELECT descrip_esp,unidad_med INTO articulos.descrip_esp, articulos.unidad_med FROM intb00001 WHERE cod_n=arr_ordenes[curr].cod_n and cod_grupo=arr_ordenes[curr].cod_grupo and cod_tipo=arr_ordenes[curr].cod_tipo and cod_sec=arr_ordenes[curr].cod_sec SELECT a.cod_nab,a.descrip_esp INTO m_articulos.cod_nab,descrip1 FROM cotb00005 a,intb00002 b WHERE b.cod_n=arr_ordenes[curr].cod_n and b.cod_grupo=arr_ordenes[curr].cod_grupo and b.cod_tipo=arr_ordenes[curr].cod_tipo and b.cod_sec=arr_ordenes[curr].cod_sec and a.cod_nab = b.cod_nab DISPLAY BY NAME m_articulos.cod_nab,descrip1,articulos.descrip_esp, articulos.unidad_med END IF UPDATE cotb00008 SET procesada = "S" WHERE @cod_n = arr_ordenes[curr].cod_n AND @cod_grupo = arr_ordenes[curr].cod_grupo AND @cod_tipo = arr_ordenes[curr].cod_tipo AND @cod_sec = arr_ordenes[curr].cod_sec AND @num_req = arr_ordenes[curr].num_req BEFORE FIELD num_req IF curr > 1 THEN LET arr_ordenes[curr].num_req = arr_ordenes[curr-1].num_req END IF DISPLAY arr_ordenes[curr].num_req TO consart[scr_l].num_req AFTER FIELD num_req LET curr = arr_curr() IF arr_ordenes[curr].num_req IS NOT NULL THEN LET requi = arr_ordenes[curr].num_req SELECT UNIQUE a.procesada INTO proce FROM cotb00008 a WHERE a.num_req = requi AND a.cod_sp = ordenes.cod_sp AND a.cod_sp_sec = ordenes.cod_sp_sec AND a.procesada = "N" IF status = notfound THEN LET numero_msg = 3 CALL msg(numero_msg) NEXT FIELD num_req END IF IF proce = "S" THEN LET numero_msg = 117 CALL msg(numero_msg) NEXT FIELD num_req END IF END IF SELECT a.descrip_esp,a.unidad_med INTO articulos.descrip_esp, articulos.unidad_med FROM intb00001 a WHERE a.cod_n=arr_ordenes[curr].cod_n AND a.cod_grupo=arr_ordenes[curr].cod_grupo AND a.cod_tipo=arr_ordenes[curr].cod_tipo AND a.cod_sec=arr_ordenes[curr].cod_sec SELECT a.cod_nab,a.descrip_esp INTO m_articulos.cod_nab,descrip1 FROM cotb00005 a, intb00002 b WHERE b.cod_n=arr_ordenes[curr].cod_n and b.cod_grupo=arr_ordenes[curr].cod_grupo and b.cod_tipo=arr_ordenes[curr].cod_tipo and b.cod_sec=arr_ordenes[curr].cod_sec and a.cod_nab = b.cod_nab DISPLAY BY NAME m_articulos.cod_nab,descrip1,articulos.descrip_esp, articulos.unidad_med UPDATE cotb00008 SET procesada = "S" WHERE @cod_n = arr_ordenes[curr].cod_n AND @cod_grupo = arr_ordenes[curr].cod_grupo AND @cod_tipo = arr_ordenes[curr].cod_tipo AND @cod_sec = arr_ordenes[curr].cod_sec AND @num_req = arr_ordenes[curr].num_req # Verifica que el cod_n este en el puerto y via IF ordenes.via != "03" THEN IF arr_ordenes[curr].cod_n is not null AND arr_ordenes[curr].cod_grupo is not null AND arr_ordenes[curr].cod_tipo is not null AND arr_ordenes[curr].cod_sec is not null THEN SELECT UNIQUE *FROM cotb00017 WHERE cod_n=arr_ordenes[curr].cod_n and cod_grupo=arr_ordenes[curr].cod_grupo and cod_tipo=arr_ordenes[curr].cod_tipo and cod_sec=arr_ordenes[curr].cod_sec and cod_pt = ordenes.cod_pt and via_t = ordenes.via IF status = notfound THEN LET numero_msg = 118 CALL msg(numero_msg) NEXT FIELD num_req END IF END IF END IF IF arr_ordenes[curr].num_req IS NOT NULL THEN SELECT a.num_req FROM cotb00006 a WHERE a.num_req = arr_ordenes[curr].num_req and a.status_t is null IF status >= 0 THEN IF status = NOTFOUND THEN LET numero_msg = 3 CALL msg(numero_msg) LET existe = "N" NEXT FIELD num_req END IF ELSE CALL integridad() IF bandera = 1 THEN LET bandera = 0 RETURN END IF END IF CALL repite3() IF verdad = "S" THEN LET verdad = null NEXT FIELD num_req END IF DISPLAY arr_ordenes[curr].cod_n TO consart[scr_l].cod_n DISPLAY arr_ordenes[curr].cod_grupo TO consart[scr_l].cod_grupo DISPLAY arr_ordenes[curr].cod_tipo TO consart[scr_l].cod_tipo DISPLAY arr_ordenes[curr].cod_sec TO consart[scr_l].cod_sec DISPLAY arr_ordenes[curr].cantidad TO consart[scr_l].cantidad DISPLAY arr_ordenes[curr].precio TO consart[scr_l].precio DISPLAY BY NAME articulos.descrip_esp DISPLAY BY NAME articulos.unidad_med DISPLAY BY NAME m_articulos.cod_nab DISPLAY BY NAME descrip1 IF verdad = "S" THEN NEXT FIELD num_req END IF LET identifica = "O" CALL busca_requi() CALL repite3() DISPLAY arr_ordenes[curr].cod_n TO consart[scr_l].cod_n DISPLAY arr_ordenes[curr].cod_grupo TO consart[scr_l].cod_grupo DISPLAY arr_ordenes[curr].cod_tipo TO consart[scr_l].cod_tipo DISPLAY arr_ordenes[curr].cod_sec TO consart[scr_l].cod_sec DISPLAY arr_ordenes[curr].cantidad TO consart[scr_l].cantidad DISPLAY arr_ordenes[curr].precio TO consart[scr_l].precio DISPLAY BY NAME articulos.descrip_esp DISPLAY BY NAME articulos.unidad_med DISPLAY BY NAME m_articulos.cod_nab DISPLAY BY NAME descrip1 IF verdad = "S" THEN NEXT FIELD num_req END IF IF m_articulos.base is not null THEN LET arr_ordenes[curr].valor = (arr_ordenes[curr].precio / m_articulos.base) * arr_ordenes[curr].cantidad ELSE LET arr_ordenes[curr].valor = arr_ordenes[curr].precio * arr_ordenes[curr].cantidad END IF DISPLAY arr_ordenes[curr].valor TO consart[scr_l].valor SELECT a.cod_nab,a.descrip_esp INTO m_articulos.cod_nab,descrip1 FROM cotb00005 a, intb00002 b WHERE b.cod_n=arr_ordenes[curr].cod_n and b.cod_grupo=arr_ordenes[curr].cod_grupo and b.cod_tipo=arr_ordenes[curr].cod_tipo and b.cod_sec=arr_ordenes[curr].cod_sec and a.cod_nab = b.cod_nab DISPLAY BY NAME m_articulos.cod_nab DISPLAY BY NAME descrip1 IF verdad = "N" THEN NEXT FIELD num_parte END IF END IF LET valor_total = 0 FOR idx = 1 TO ARR_COUNT() IF arr_ordenes[idx].valor > 0 THEN LET valor_total = valor_total + arr_ordenes[idx].valor END IF END FOR END INPUT IF int_flag THEN LET numero_msg = 2 CALL msg(numero_msg) LET int_flag = FALSE DELETE FROM cotb00025 WHERE @tipo = ordenes.tipo AND @num_oc = ordenes.num_oc FOR idx = 1 TO ARR_COUNT() UPDATE cotb00008 SET procesada = "N" WHERE @num_req = arr_ordenes[idx].num_req END FOR RETURN END IF LET flete1.total_b = valor_total IF ordenes.cod_sp = 23 THEN PROMPT "Esta Orden Paga ITBI (S/N)?" FOR CHAR opc2 LET opc2 = UPSHIFT(opc2) IF opc2 = "S" THEN LET flete1.valor = flete1.total_b * 0.08 ELSE LET flete1.valor = 0 END IF ELSE LET flete1.valor = 0 END IF LET flete1.ot_valor = 0 LET flete1.total_1 = flete1.total_b + flete1.valor + flete1.ot_valor LET programa = 20 CALL notas20() PROMPT "Toda la informacion esta correcta (S/N)?" FOR CHAR OPC LET OPC = UPSHIFT(OPC) IF OPC = "S" THEN DISPLAY "Estoy actualizando las tablas" AT 24,1 ATTRIBUTE(BOLD) INSERT INTO cotb00014 VALUES (ordenes.*,flete1.valor,flete1.ot_valor, null,null,user,current,null,null) IF ordenes.num_oc = 1 THEN INSERT INTO cotb00030 (num_oc,us_crea,fech_crea) VALUES (1,USER,CURRENT) ELSE UPDATE cotb00030 SET (num_oc,status_t,us_crea,fech_crea) = (ordenes.num_oc,NULL,USER,CURRENT) END IF FOR idx = 1 TO 200 IF arr_ordenes[idx].num_req = 0 THEN LET arr_ordenes[idx].num_req = null END IF IF arr_ordenes[idx].num_req IS NOT NULL THEN IF arr_ordenes[idx].cod_n is not null THEN INSERT INTO cotb00015 VALUES (ordenes.num_oc,arr_ordenes[idx].num_req, ordenes.tipo,arr_ordenes[idx].cod_n,arr_ordenes[idx].cod_grupo, arr_ordenes[idx].cod_tipo,arr_ordenes[idx].cod_sec, arr_ordenes[idx].num_parte,arr_ordenes[idx].cantidad, arr_ordenes[idx].precio,cod_mon,null,user,current,null,null) END IF END IF UPDATE cotb00008 set procesada = "S" WHERE @num_req = arr_ordenes[idx].num_req and @cod_n = arr_ordenes[idx].cod_n and @cod_grupo= arr_ordenes[idx].cod_grupo and @cod_tipo = arr_ordenes[idx].cod_tipo and @cod_sec = arr_ordenes[idx].cod_sec and @status_t is null END FOR DISPLAY " " AT 24,1 LET numero_msg = 1 CALL msg(numero_msg) START REPORT orden20 TO "rpco20" #"%USHOME%\\archivo" DISPLAY "Impresion en Proceso... Espere Por Favor" AT 23,1 ATTRIBUTE(YELLOW) FOR idx = 1 TO arr_count() IF arr_orden20[idx].descripcion IS NOT NULL THEN OUTPUT TO REPORT orden20(ordenes.num_oc, arr_orden20[idx].cantidad, arr_orden20[idx].unidad, arr_orden20[idx].descripcion, arr_orden20[idx].valor1) END IF END FOR FINISH REPORT orden20 CLEAR FORM IF control_linea > 26 THEN LET numero_msg = 218 CALL msg(numero_msg) DECLARE bus_r CURSOR FOR SELECT UNIQUE a.num_req INTO requis FROM cotb00015 a WHERE a.num_oc = ordenes.num_oc AND a.tipo = ordenes.tipo FOREACH bus_r UPDATE cotb00008 SET procesada = NULL WHERE num_req = requis END FOREACH DELETE FROM cotb00014 WHERE @num_oc = ordenes.num_oc AND @tipo = ordenes.tipo DELETE FROM cotb00015 WHERE @num_oc = ordenes.num_oc AND @tipo = ordenes.tipo DELETE FROM cotb00025 WHERE @tipo = ordenes.tipo AND @num_oc = ordenes.num_oc DELETE FROM cotb00029 WHERE @tipo = ordenes.tipo AND @num_oc = ordenes.num_oc UPDATE cotb00030 SET num_oc = ordenes.num_oc - 1 ELSE RUN "cat rpco20|lp -dlpt16" END IF ELSE DISPLAY "Estoy actualizando las tablas" AT 24,1 ATTRIBUTE(BOLD) DELETE FROM cotb00025 WHERE @tipo = ordenes.tipo AND @num_oc = ordenes.num_oc DELETE FROM cotb00029 WHERE @num_oc = ordenes.num_oc UPDATE cotb00030 SET num_oc = ordenes.num_oc - 1 FOR idx = 1 TO 200 IF arr_ordenes[idx].cod_n IS NOT NULL THEN UPDATE cotb00008 SET procesada = "N" WHERE @cod_n = arr_ordenes[idx].cod_n AND @cod_grupo = arr_ordenes[idx].cod_grupo AND @cod_tipo = arr_ordenes[idx].cod_tipo AND @cod_sec = arr_ordenes[idx].cod_sec AND @num_req = arr_ordenes[idx].num_req END IF END FOR END IF FOR idx = 1 to 100 LET arr_orden20[idx].cantidad = NULL LET arr_orden20[idx].unidad = NULL LET arr_orden20[idx].descripcion = NULL LET arr_orden20[idx].valor1 = NULL END FOR #GOTO vuelve END FUNCTION FUNCTION copcmf020() #WHENEVER ERROR CONTINUE # Aqui se prepara para la captura del criterio de seleccion CONSTRUCT criterio ON cotb00014.num_oc,cotb00014.tipo,cotb00014.fech_oc, cotb00014.num_pr,cotb00014.cod_sp, cotb00014.cod_sp_sec,cotb00014.term_sp, cotb00014.enviada,cotb00014.fech_enviada, cotb00014.pago,cotb00014.fech_pago,cotb00014.cierre FROM num_oc,tipo,fech_oc,num_pr,cod_sp,cod_sp_sec,term_sp, enviada,fech_enviada,pago,fech_pago,cierre IF int_flag THEN LET numero_msg = 2 CALL msg(numero_msg) LET int_flag = FALSE RETURN END IF LET selec = " SELECT UNIQUE cotb00014.num_oc,cotb00014.tipo,cotb00014.num_pr, ", " cotb00014.cod_sp,cotb00014.cod_sp_sec,cotb00014.term_sp, ", " cotb00014.via,cotb00014.enviada,cotb00014.fech_enviada, ", " cotb00014.pago,cotb00014.fech_pago,cotb00014.cierre, ", " cotb00014.cod_pt,cotb00015.cod_mon ", " FROM cotb00014,cotb00015 ", " WHERE cotb00014.num_oc = cotb00015.num_oc AND ", " cotb00014.tipo = cotb00015.tipo AND ", " cotb00014.status_t is null AND ",criterio clipped," ORDER BY 1" PREPARE busca1 FROM selec CALL integridad() IF bandera = 1 THEN LET bandera = 0 RETURN END IF DECLARE datos SCROLL CURSOR FOR busca1 OPEN datos CALL integridad() IF bandera = 1 THEN LET bandera = 0 RETURN END IF FETCH FIRST datos INTO ordenes.num_oc,ordenes.tipo,ordenes.num_pr,ordenes.cod_sp, ordenes.cod_sp_sec,ordenes.term_sp,ordenes.via,ordenes.enviada, ordenes.fech_enviada,ordenes.pago,ordenes.fech_pago,ordenes.cierre, ordenes.cod_pt,cod_mon IF status >= 0 THEN IF status = NOTFOUND THEN LET numero_msg = 3 CALL msg(numero_msg) RETURN END IF CALL integridad() IF bandera = 1 THEN LET bandera = 0 RETURN END IF END IF # Funcion para la busqueda de lo suplidores, Terminos ded pago, # descripcion del puesto y la via CALL escoge() DISPLAY BY NAME ordenes.num_oc THRU ordenes.cod_pt, suplidor.nom_sp,pagos.descrip_term, nombre_p,nom_via,cod_mon,nombre_mon IF int_flag THEN LET numero_msg = 2 CALL msg(numero_msg) LET int_flag = FALSE RETURN END IF # Menu para la busqueda de las informaciones en forma direccional MENU "OPCIONES " COMMAND "Siguiente" "Presenta en pantalla el proximo registro encontrado" FETCH NEXT datos INTO ordenes.num_oc,ordenes.tipo,ordenes.num_pr,ordenes.cod_sp, ordenes.cod_sp_sec,ordenes.term_sp,ordenes.via,ordenes.enviada, ordenes.fech_enviada,ordenes.pago,ordenes.fech_pago,ordenes.cierre, ordenes.cod_pt,cod_mon IF status = NOTFOUND THEN LET numero_msg = 4 CALL msg(numero_msg) END IF CALL escoge() DISPLAY BY NAME ordenes.*,suplidor.nom_sp,pagos.descrip_term, nombre_p,nom_via,cod_mon,nombre_mon COMMAND "Anterior" "Presenta en pantalla el registro anterior encontrado" FETCH PREVIOUS datos INTO ordenes.num_oc,ordenes.tipo,ordenes.num_pr,ordenes.cod_sp, ordenes.cod_sp_sec,ordenes.term_sp,ordenes.via,ordenes.enviada, ordenes.fech_enviada,ordenes.pago,ordenes.fech_pago,ordenes.cierre, ordenes.cod_pt,cod_mon IF status = NOTFOUND THEN LET numero_msg = 5 CALL msg(numero_msg) END IF CALL escoge() DISPLAY BY NAME ordenes.*,suplidor.nom_sp,pagos.descrip_term, nombre_p,nom_via,cod_mon,nombre_mon COMMAND "Primero" "Presenta en pantalla el primer registro encontrado" FETCH FIRST datos INTO ordenes.num_oc,ordenes.tipo,ordenes.num_pr,ordenes.cod_sp, ordenes.cod_sp_sec,ordenes.term_sp,ordenes.via,ordenes.enviada, ordenes.fech_enviada,ordenes.pago,ordenes.fech_pago,ordenes.cierre, ordenes.cod_pt,cod_mon CALL escoge() DISPLAY BY NAME ordenes.*,suplidor.nom_sp,pagos.descrip_term, nombre_p,nom_via,cod_mon,nombre_mon LET numero_msg = 5 CALL msg(numero_msg) COMMAND "Ultimo" "Presenta en pantalla el ultimo registro encontrado" FETCH LAST datos INTO ordenes.num_oc,ordenes.tipo,ordenes.num_pr,ordenes.cod_sp, ordenes.cod_sp_sec,ordenes.term_sp,ordenes.via,ordenes.enviada, ordenes.fech_enviada,ordenes.pago,ordenes.fech_pago,ordenes.cierre, ordenes.cod_pt,cod_mon CALL escoge() DISPLAY BY NAME ordenes.*,suplidor.nom_sp,pagos.descrip_term, nombre_p,nom_via,cod_mon,nombre_mon LET numero_msg = 4 CALL msg(numero_msg) { COMMAND "Ver" " Actualiza Registro Cancela Operacion" } # Comando para actualizar registro COMMAND KEY ("N") "aNular" # Actualizacion de la eliminacion logica de las tablas que intervienen el la # orden de compras DECLARE bus_l CURSOR FOR SELECT UNIQUE a.num_req INTO requis FROM cotb00015 a WHERE a.num_oc = ordenes.num_oc AND a.tipo = ordenes.tipo FOREACH bus_l UPDATE cotb00008 SET procesada = NULL WHERE num_req = requis END FOREACH UPDATE cotb00014 set status_t = "N", us_mod = user, fech_mod = current WHERE @num_oc = ordenes.num_oc and @tipo = ordenes.tipo UPDATE cotb00015 set status_t = "N", us_mod = user, fech_mod = current WHERE @num_oc = ordenes.num_oc and @tipo = ordenes.tipo UPDATE cotb00025 set status_t = "N", us_mod = user, fech_mod = current WHERE @num_oc = ordenes.num_oc and @tipo = ordenes.tipo UPDATE cotb00029 set status_t = "N", us_mod = user, fech_mod = current WHERE @num_oc = ordenes.num_oc AND @tipo = ordenes.tipo LET numero_msg = 39 CALL msg(numero_msg) COMMAND "Retornar" "Retorna al menu anterior" CLEAR FORM EXIT MENU END MENU END FUNCTION # Esta funcion no se esta utilizando actualmente al 08/09/93 # Su funcion es de enumerar las ordenes de forma automatica FUNCTION busca1_sup1() OPEN WINDOW busqueda AT 10,10 WITH FORM "cofmwd005" ATTRIBUTE (BORDER,FORM LINE FIRST + 2, comment line last) CONSTRUCT criterio ON cotb00001.nom_sp FROM cotb00001.nom_sp LET selec = "SELECT cod_sp,cod_sp_sec,nom_sp FROM cotb00001 ", " WHERE status_t is null AND ", criterio clipped," ORDER BY 3 " PREPARE busco FROM selec DECLARE local CURSOR FOR busco LET idx = 1 FOREACH local INTO buscar_wd[idx].* IF status = NOTFOUND THEN LET existe = "N" EXIT FOREACH END IF LET despl_wd[idx].codigo = buscar_wd[idx].cod_sp using "&&","-", buscar_wd[idx].cod_sp_sec using "&&&&" LET despl_wd[idx].nom_sp = buscar_wd[idx].nom_sp clipped LET idx = idx + 1 END FOREACH CALL set_count(idx-1) DISPLAY ARRAY despl_wd TO s_muestra.* LET curr = arr_curr() IF identifica = "O" THEN LET ordenes.cod_sp = despl_wd[curr].codigo[1,2] LET ordenes.cod_sp_sec = despl_wd[curr].codigo[4,7] LET suplidor.nom_sp = despl_wd[curr].nom_sp END IF CLOSE WINDOW busqueda END FUNCTION { FUNCTION escoge() SELECT nom_sp INTO suplidor.nom_sp FROM cotb00001 WHERE cod_sp = ordenes.cod_sp AND cod_sp_sec = ordenes.cod_sp_sec AND status_t is null SELECT descrip_term INTO pagos.descrip_term FROM cotb00024 WHERE term_sp = ordenes.term_sp AND status_t is null LET nombre_mon = null LET simb_mon = null SELECT a.descrip_mon,a.simbolo INTO nombre_mon,simb_mon FROM cotb00031 a WHERE a.cod_mon = cod_mon AND a.status_t is null LET nombre_p = null IF ordenes.cod_pt IS NOT NULL THEN SELECT nom_pt INTO nombre_p FROM cotb00019 WHERE cod_pt = ordenes.cod_pt AND status_t is null END IF IF ordenes.via = "01" THEN LET nom_via = "MARITIMA" END IF IF ordenes.via = "02" THEN LET nom_via = "AEREA" END IF IF ordenes.via = "03" THEN LET nom_via = "TERRESTRE" END IF END FUNCTION } FUNCTION busca1_requi() OPEN WINDOW busqueda1 AT 10,3 WITH FORM "cofmwd007" ATTRIBUTE (BORDER,FORM LINE FIRST + 1, comment line last) LET selec = "SELECT a.cod_n,a.cod_grupo,a.cod_tipo,a.cod_sec,b.descrip_esp,", " b.unidad_med,a.cantidad, a.precio,c.base ", "FROM cotb00008 a,intb00001 b, OUTER intb00002 c ", "WHERE 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.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 and ", " a.status_t is null AND a.num_req=? AND a.cod_sp_sec= ? ", " AND (a.procesada IS NULL OR a.procesada='N') ORDER BY 1,2,3,4 " PREPARE origen FROM selec DECLARE proximo CURSOR FOR origen OPEN proximo USING arr_ordenes[curr].num_req,ordenes.cod_sp_sec IF status = notfound THEN LET existe = "N" ELSE LET existe = "S" END IF LET idx2= 0 LET idx = 1 WHILE STATUS != NOTFOUND FETCH proximo INTO localiza_wd[idx].* IF status = notfound THEN EXIT WHILE END IF LET idx2 = idx2 + 1 LET mostrar_wd[idx].cod_n = localiza_wd[idx].cod_n LET mostrar_wd[idx].cod_grupo=localiza_wd[idx].cod_grupo LET mostrar_wd[idx].cod_tipo =localiza_wd[idx].cod_tipo LET mostrar_wd[idx].cod_sec =localiza_wd[idx].cod_sec LET mostrar_wd[idx].descrip_esp = localiza_wd[idx].descrip_esp LET mostrar_wd[idx].unidad_med = localiza_wd[idx].unidad_med LET mostrar_wd[idx].cantidad = localiza_wd[idx].cantidad LET mostrar_wd[idx].precio = localiza_wd[idx].precio LET m_articulos.base = localiza_wd[idx].base LET idx = idx + 1 END WHILE CALL set_count(idx-1) IF idx2 = 0 THEN LET existe = "N" END IF DISPLAY ARRAY mostrar_wd TO muestra.* LET curr1 = arr_curr() IF identifica = "O" THEN LET arr_ordenes[curr].cod_n = mostrar_wd[curr1].cod_n LET articulos.descrip_esp = mostrar_wd[curr1].descrip_esp LET articulos.unidad_med = mostrar_wd[curr1].unidad_med LET arr_ordenes[curr].cantidad = mostrar_wd[curr1].cantidad LET arr_ordenes[curr].precio = mostrar_wd[curr1].precio IF m_articulos.base is null THEN LET arr_ordenes[curr].valor = arr_ordenes[curr].precio * arr_ordenes[curr].cantidad END IF IF m_articulos.base is not null THEN LET arr_ordenes[curr].valor = (arr_ordenes[curr].precio / m_articulos.base) * arr_ordenes[curr].cantidad END IF END IF CLOSE WINDOW busqueda1 END FUNCTION { FUNCTION repite3() LET verdad = null LET num_req_a = arr_ordenes[curr].num_req LET codigo = arr_ordenes[curr].cod_n USING "&","-", arr_ordenes[curr].cod_grupo USING "&","-", arr_ordenes[curr].cod_tipo USING "&&","-", arr_ordenes[curr].cod_sec USING "&&&" FOR idx = 1 TO curr LET codigo1 = arr_ordenes[idx].cod_n USING "&","-", arr_ordenes[idx].cod_grupo USING "&","-", arr_ordenes[idx].cod_tipo USING "&&","-", arr_ordenes[idx].cod_sec USING "&&&" IF idx != curr THEN IF codigo = codigo1 AND num_req_a = arr_ordenes[idx].num_req THEN LET verdad = "S" LET numero_msg = 21 CALL msg(numero_msg) ELSE IF verdad != "S" THEN LET verdad = "N" END IF END IF END IF END FOR END FUNCTION } FUNCTION busca1_terminos() OPEN WINDOW busqueda AT 10,10 WITH FORM "cofmwd008" ATTRIBUTE (BORDER,FORM LINE FIRST + 1, comment line last -1) CONSTRUCT criterio ON cotb00024.descrip_term FROM cotb00024.descrip_term IF int_flag THEN LET numero_msg = 2 CALL msg(numero_msg) LET int_flag = false RETURN END IF LET selec = "SELECT term_sp,descrip_term FROM cotb00024 ", "WHERE status_t is null AND ",criterio clipped, "ORDER BY 1 " PREPARE localiza FROM selec DECLARE pagar CURSOR FOR localiza LET idx = 1 FOREACH pagar INTO termino_wd[idx].* IF status = NOTFOUND THEN LET existe = "N" EXIT FOREACH END IF LET term_pago_wd[idx].term_sp = termino_wd[idx].term_sp LET term_pago_wd[idx].descrip_term = termino_wd[idx].descrip_term clipped LET idx = idx + 1 END FOREACH CALL set_count(idx-1) DISPLAY ARRAY term_pago_wd TO consart.* LET curr1 = arr_curr() IF identifica = "O" THEN LET pagos.term_sp = term_pago_wd[curr1].term_sp LET pagos.descrip_term = term_pago_wd[curr1].descrip_term END IF CLOSE WINDOW busqueda END FUNCTION FUNCTION busca1_puertos() OPEN WINDOW busqueda_p AT 10,10 WITH FORM "cofmwd010" ATTRIBUTE (BORDER,FORM LINE FIRST + 1, comment line last -1) CONSTRUCT criterio ON cotb00019.nom_pt FROM cotb00019.nom_pt IF int_flag THEN LET numero_msg = 2 CALL msg(numero_msg) LET int_flag = false RETURN END IF LET selec = "SELECT cod_pt,nom_pt FROM cotb00019 ", " WHERE ", " status_t is null AND ", criterio clipped, "ORDER BY 1 " PREPARE localiza_p FROM selec DECLARE puerto CURSOR FOR localiza_p LET idx = 1 FOREACH puerto INTO puerto_wd[idx].* IF status = NOTFOUND THEN LET existe = "N" EXIT FOREACH END IF LET puertos_wd[idx].cod_pt = puerto_wd[idx].cod_pt LET puertos_wd[idx].nom_pt = puerto_wd[idx].nom_pt clipped LET idx = idx + 1 END FOREACH CALL set_count(idx-1) DISPLAY ARRAY puertos_wd TO consart.* LET curr1 = arr_curr() IF identifica = "O" THEN LET puertos.cod_pt = puertos_wd[curr1].cod_pt LET puertos.nom_pt = puertos_wd[curr1].nom_pt END IF LET nombre_p = puertos_wd[curr1].nom_pt CLOSE WINDOW busqueda_p END FUNCTION FUNCTION busca1_monedas() OPEN WINDOW busqueda_mon AT 10,10 WITH FORM "cofmwd013" ATTRIBUTE (BORDER,FORM LINE FIRST + 1, comment line last -1) CONSTRUCT criterio ON a.cod_mon FROM cod_mon IF int_flag THEN LET numero_msg = 2 CALL msg(numero_msg) LET int_flag = false RETURN END IF LET selec = "SELECT a.cod_mon,a.descrip_mon FROM cotb00031 a ", " WHERE a.status_t is null AND ", criterio clipped," ORDER BY 1 " PREPARE localiza_mon FROM selec DECLARE moneda CURSOR FOR localiza_mon LET idx = 1 FOREACH moneda INTO monedas_wd[idx].* IF status = NOTFOUND THEN LET existe = "N" EXIT FOREACH END IF LET monedas_wd[idx].cod_mon = monedas_wd[idx].cod_mon LET monedas_wd[idx].nombre_mon = monedas_wd[idx].nombre_mon clipped LET idx = idx + 1 END FOREACH CALL set_count(idx-1) DISPLAY ARRAY monedas_wd TO consart_mon.* LET curr1 = arr_curr() IF identifica = "O" THEN LET monedas.cod_mon = monedas_wd[curr1].cod_mon LET nombre_mon = monedas_wd[curr1].nombre_mon END IF LET cod_mon = monedas_wd[curr1].cod_mon LET nombre_mon = monedas_wd[curr1].nombre_mon CLOSE WINDOW busqueda_mon END FUNCTION FUNCTION notas20() OPEN WINDOW apl1_notas AT 2,3 WITH FORM "cofmwd014" ATTRIBUTE (BORDER,FORM LINE FIRST + 1, comment line last -1) IF programa = 20 THEN INPUT BY NAME notas.ship_to,notas.n_a_b,c_i_d,c_i_d1,nota,nota1, desc1,flete1.total_b,desc2,flete1.valor,desc3,flete1.ot_valor, desc4 WITHOUT DEFAULTS BEFORE FIELD ship_to IF ordenes.cod_sp = 23 THEN LET notas.ship_to = "RAY.O.VAC DOMINICANA, S. A." LET notas.n_a_b = NULL LET c_i_d = NULL LET c_i_d1 = NULL DISPLAY BY NAME notas.ship_to NEXT FIELD nota ELSE LET notas.ship_to = "RAY.O.VAC DOMINICANA, S. A." DISPLAY BY NAME notas.ship_to END IF AFTER FIELD ship_to IF ordenes.cod_sp != 23 THEN IF notas.ship_to IS NULL THEN LET numero_msg = 16 CALL msg(numero_msg) NEXT FIELD ship_to END IF ELSE LET notas.ship_to = "RAY.O.VAC DOMINICANA, S. A." LET notas.n_a_b = NULL LET c_i_d = NULL LET c_i_d1 = NULL DISPLAY BY NAME notas.ship_to NEXT FIELD nota END IF BEFORE FIELD n_a_b IF ordenes.cod_sp = 23 THEN LET notas.ship_to = "RAY.O.VAC DOMINICANA, S. A." LET notas.n_a_b = NULL LET c_i_d = NULL LET c_i_d1 = NULL DISPLAY BY NAME notas.ship_to NEXT FIELD nota END IF AFTER FIELD n_a_b IF ordenes.cod_sp != 23 THEN IF notas.n_a_b IS NULL THEN LET numero_msg = 16 CALL msg(numero_msg) NEXT FIELD n_a_b END IF ELSE LET notas.ship_to = "RAY.O.VAC DOMINICANA, S. A." LET notas.n_a_b = NULL LET c_i_d = NULL LET c_i_d1 = NULL DISPLAY BY NAME notas.ship_to NEXT FIELD nota END IF BEFORE FIELD c_i_d IF ordenes.cod_sp = 23 THEN LET notas.ship_to = "RAY.O.VAC DOMINICANA, S. A." LET notas.n_a_b = NULL LET c_i_d = NULL LET c_i_d1 = NULL DISPLAY BY NAME notas.ship_to NEXT FIELD nota END IF AFTER FIELD c_i_d IF ordenes.cod_sp != 23 THEN IF c_i_d IS NULL THEN LET numero_msg = 16 CALL msg(numero_msg) NEXT FIELD c_i_d END IF ELSE LET notas.ship_to = "RAY.O.VAC DOMINICANA, S. A." LET notas.n_a_b = NULL LET c_i_d = NULL LET c_i_d1 = NULL DISPLAY BY NAME notas.ship_to NEXT FIELD nota END IF IF ordenes.cod_sp = 23 THEN EXIT INPUT END IF AFTER INPUT LET notas.nota = nota,nota1 LET notas.c_i_d= c_i_d,c_i_d1 EXIT INPUT END INPUT END IF IF programa = 9 THEN DISPLAY BY NAME flete1.total_b,flete1.valor,flete1.ot_valor,flete1.total_1 INPUT BY NAME notas.ship_to,notas.n_a_b,c_i_d,c_i_d1,nota,nota1, desc1,desc2,flete1.valor,desc3,flete1.ot_valor,desc4 WITHOUT DEFAULTS BEFORE FIELD ship_to IF ordenes.cod_sp = 23 THEN LET notas.ship_to = "RAY.O.VAC DOMINICANA, S. A." LET notas.n_a_b = NULL LET c_i_d = NULL LET c_i_d1 = NULL DISPLAY BY NAME notas.ship_to NEXT FIELD nota ELSE LET notas.ship_to = "RAY.O.VAC DOMINICANA, S. A." DISPLAY BY NAME notas.ship_to END IF AFTER FIELD ship_to IF ordenes.cod_sp != 23 THEN IF notas.ship_to IS NULL THEN LET numero_msg = 16 CALL msg(numero_msg) NEXT FIELD ship_to END IF ELSE LET notas.ship_to = "RAY.O.VAC DOMINICANA, S. A." LET notas.n_a_b = NULL LET c_i_d = NULL LET c_i_d1 = NULL DISPLAY BY NAME notas.ship_to NEXT FIELD nota END IF BEFORE FIELD n_a_b IF ordenes.cod_sp = 23 THEN LET notas.ship_to = "RAY.O.VAC DOMINICANA, S. A." LET notas.n_a_b = NULL LET c_i_d = NULL LET c_i_d1 = NULL DISPLAY BY NAME notas.ship_to NEXT FIELD nota END IF AFTER FIELD n_a_b IF ordenes.cod_sp != 23 THEN IF notas.n_a_b IS NULL THEN LET numero_msg = 16 CALL msg(numero_msg) NEXT FIELD n_a_b END IF ELSE LET notas.ship_to = "RAY.O.VAC DOMINICANA, S. A." LET notas.n_a_b = NULL LET c_i_d = NULL LET c_i_d1 = NULL DISPLAY BY NAME notas.ship_to NEXT FIELD nota END IF BEFORE FIELD c_i_d IF ordenes.cod_sp = 23 THEN LET notas.ship_to = "RAY.O.VAC DOMINICANA, S. A." LET notas.n_a_b = NULL LET c_i_d = NULL LET c_i_d1 = NULL DISPLAY BY NAME notas.ship_to NEXT FIELD nota END IF AFTER FIELD c_i_d IF ordenes.cod_sp != 23 THEN IF c_i_d IS NULL THEN LET numero_msg = 16 CALL msg(numero_msg) NEXT FIELD c_i_d END IF ELSE LET notas.ship_to = "RAY.O.VAC DOMINICANA, S. A." LET notas.n_a_b = NULL LET c_i_d = NULL LET c_i_d1 = NULL DISPLAY BY NAME notas.ship_to NEXT FIELD nota END IF BEFORE FIELD valor IF flete1.valor IS NULL THEN LET flete1.valor = 0 END IF { Esto se puso en comentario porque el usuario desea cargarle otros gastos a las ordenes de los suplidores locales (Laura fue el usuario. Fecha: 9/2/96 IF ordenes.cod_sp = 23 THEN EXIT INPUT END IF } AFTER FIELD valor IF flete1.valor IS NULL THEN LET flete1.valor = 0 END IF AFTER FIELD ot_valor IF flete1.ot_valor IS NULL THEN LET flete1.ot_valor = 0 END IF AFTER INPUT IF int_flag THEN LET int_flag = FALSE END IF EXIT INPUT END INPUT END IF LET notas.nota = nota,nota1 LET notas.c_i_d= c_i_d,c_i_d1 IF flete1.total_b IS NULL THEN LET flete1.total_b = 0 END IF IF flete1.valor IS NULL THEN LET flete1.valor = 0 END IF IF flete1.ot_valor IS NULL THEN LET flete1.ot_valor = 0 END IF LET flete1.total_1 = flete1.total_b + flete1.valor + flete1.ot_valor DISPLAY BY NAME flete1.total_1 SLEEP 2 IF programa = 20 THEN INPUT ARRAY arr_orden20 FROM sc_orden20.* BEFORE ROW LET j1 = ARR_CURR() LET k1 = SCR_LINE() AFTER FIELD valor1 IF arr_orden20[j1].cantidad IS NULL OR arr_orden20[j1].valor1 IS NULL THEN LET numero_msg = 16 CALL msg(numero_msg) NEXT FIELD cantidad END IF { LET flete1.total_b = 0 FOR idx = 1 TO ARR_COUNT() IF flete1.valor > 0 THEN LET flete1.total_b = flete1.total_b + arr_orden20[idx].valor1 END IF END FOR LET flete1.total_1 = flete1.total_b + flete1.valor + flete1.ot_valor DISPLAY BY NAME flete1.total_1 } END INPUT IF int_flag THEN LET int_flag = FALSE END IF END IF DELETE FROM cotb00029 WHERE num_oc = 0 OR num_oc IS NULL INSERT INTO cotb00029 VALUES (ordenes.num_oc,ordenes.tipo,ordenes.cod_sp, ordenes.cod_sp_sec,notas.ship_to,notas.n_a_b, notas.c_i_d,notas.nota,NULL,USER,CURRENT, NULL,NULL) CLOSE WINDOW apl1_notas END FUNCTION REPORT orden20(x) DEFINE x RECORD num_oc LIKE cotb00014.num_oc, cantidad DECIMAL(12,2), unidad CHAR(10), descripcion CHAR(50), valor DECIMAL(12,2) END RECORD DEFINE doble_on CHAR(2) DEFINE doble_off CHAR(2) DEFINE negrillas_on CHAR(2) DEFINE negrillas_off CHAR(2) DEFINE comp_on CHAR(2) DEFINE comp_off CHAR(2) DEFINE cuarto_off CHAR(2) DEFINE cuarto CHAR(2) DEFINE cuarto1 CHAR(2) DEFINE cuarto2 CHAR(2) DEFINE doce CHAR(2) DEFINE hora CHAR(5) DEFINE l SMALLINT DEFINE varia CHAR(10) DEFINE desc_tipo CHAR(11) OUTPUT PAGE LENGTH 50 TOP MARGIN 0 LEFT MARGIN 0 BOTTOM MARGIN 7 ORDER BY x.num_oc 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 cuarto = ASCII 27, ASCII 49 LET cuarto1= ASCII 27, ASCII 48 LET cuarto2= ASCII 27, ASCII 50 LET cuarto_off = ASCII 27, ASCII 50 LET comp_on = ASCII 15 LET comp_off = ASCII 18 LET doce = ASCII 27, ASCII 77 LET hora = time BEFORE GROUP OF x.num_oc LET control_linea = 0 LET notas.c_i_d = notas.c_i_d CLIPPED LET l = LENGTH(notas.c_i_d) IF ordenes.tipo = "01" THEN LET desc_tipo = "GENERALES" END IF IF ordenes.tipo = "02" THEN LET desc_tipo = "ROV-LTD" END IF IF ordenes.tipo = "03" THEN LET desc_tipo = "LOCALES" END IF IF ordenes.tipo = "04" THEN LET desc_tipo = "MISCELANEAS" END IF PRINT COLUMN 1,comp_off,cuarto PRINT COLUMN 67, "-",ordenes.tipo, COLUMN 130,comp_on IF ordenes.cod_sp = 23 THEN PRINT COLUMN 80,ordenes.fech_oc USING "dd/mm/yy"; ELSE PRINT COLUMN 80,ordenes.fech_oc USING "mmm dd/yy"; END IF PRINT COLUMN 110,ordenes.num_oc USING "##&&&&" SKIP 1 LINE PRINT COLUMN 80,notas.ship_to CLIPPED,cuarto1 SKIP 3 LINE PRINT COLUMN 80,nom_via CLIPPED,cuarto SKIP 1 LINE LET fecha1 = ordenes.fech_enviada IF ordenes.cod_sp = 23 THEN PRINT COLUMN 81,fecha1 USING "dd/mm/yy" ELSE PRINT COLUMN 81,fecha1 USING "mmm dd/yy" END IF SKIP 4 LINE PRINT COLUMN 5, suplidor.nom_sp CLIPPED," (", ordenes.cod_sp USING "&&","-", ordenes.cod_sp_sec USING "&&&&",") ", COLUMN 72, notas.n_a_b,cuarto_off PRINT COLUMN 5, suplidor.dir_sp CLIPPED; IF l <= 20 THEN PRINT COLUMN 92,notas.c_i_d {ELSE PRINT COLUMN 05, " "} END IF PRINT COLUMN 5, suplidor.ciu_sp CLIPPED, COLUMN 72,pagos.descrip_term,cuarto PRINT COLUMN 98," " PRINT COLUMN 98," " SKIP 2 LINE LET total = 0 ON EVERY ROW IF control_linea IS NULL THEN LET control_linea = 0 END IF PRINT COLUMN 1, x.cantidad USING "###,###,###.##", COLUMN 18, x.unidad CLIPPED," ",x.descripcion CLIPPED, COLUMN 102, x.valor USING "###,###,###.##" LET total = total + x.valor LET control_linea = control_linea + 1 AFTER GROUP OF x.num_oc PRINT COLUMN 102, "--------------" LET control_linea = control_linea + 1 IF ordenes.cod_sp = 23 THEN PRINT COLUMN 40, "MONTO BRUTO ",desc1 CLIPPED, COLUMN 102, flete1.total_b USING "###,###,###.##" LET control_linea = control_linea + 1 IF flete1.ot_valor IS NOT NULL AND flete1.ot_valor > 0 THEN PRINT COLUMN 40, "ITBIS ",desc2 CLIPPED, COLUMN 102, flete1.ot_valor USING "###,###,###.##" LET control_linea = control_linea + 1 END IF PRINT COLUMN 102, "--------------" LET control_linea = control_linea + 1 PRINT COLUMN 40, "MONTO NETO ",desc4 CLIPPED, COLUMN 97, simb_mon CLIPPED, COLUMN 102, flete1.total_1 USING "###,###,###.##" LET control_linea = control_linea + 1 PRINT COLUMN 102, "==============" LET control_linea = control_linea + 1 SKIP 1 LINE LET control_linea = control_linea + 1 ELSE PRINT COLUMN 40, "FOB ",desc1 CLIPPED, COLUMN 102, flete1.total_b USING "###,###,###.##" LET control_linea = control_linea + 1 IF flete1.valor IS NOT NULL AND flete1.valor > 0 THEN PRINT COLUMN 40, "FREIGHT ",desc2 CLIPPED, COLUMN 102, flete1.valor USING "###,###,###.##" LET control_linea = control_linea + 1 END IF IF flete1.ot_valor IS NOT NULL AND flete1.ot_valor > 0 THEN PRINT COLUMN 40, "OTHERS CHARGES ",desc3 CLIPPED, COLUMN 102, flete1.ot_valor USING "###,###,###.##" LET control_linea = control_linea + 1 END IF PRINT COLUMN 102, "--------------" LET control_linea = control_linea + 1 PRINT COLUMN 40, "C&F ",desc4 CLIPPED, COLUMN 97, simb_mon CLIPPED, COLUMN 102, flete1.total_1 USING "###,###,###.##" LET control_linea = control_linea + 1 PRINT COLUMN 102, "==============" LET control_linea = control_linea + 1 END IF SKIP 1 LINE LET control_linea = control_linea + 1 IF l > 20 THEN IF notas.c_i_d IS NOT NULL THEN PRINT COLUMN 15,"C. I. D.: ",notas.c_i_d CLIPPED END IF LET control_linea = control_linea + 1 END IF IF notas.nota IS NOT NULL AND notas.nota != " " THEN SKIP 1 LINE LET control_linea = control_linea + 1 IF ordenes.cod_sp = 23 THEN PRINT COLUMN 17,"NOTA: ",notas.nota LET control_linea = control_linea + 1 ELSE PRINT COLUMN 17,"NOTE: ",notas.nota LET control_linea = control_linea + 1 END IF END IF PRINT comp_off,cuarto_off PAGE TRAILER PRINT COLUMN 1,negrillas_off END REPORT