*********************** * PNewOCOB *********************** PARAMETERS AV17DocuTi , AV11DocuNr , AV12Cli , AV28VtoFch , AV19AsoTip , AV20AsoNro , AV40AsoFch , AV37VTip , AV39Mon , AV38Monto , AV32ok , AV49obs * Program generated by GeneXus Version 9_0_3-127 * Description: Crea Orden de Cobranza * Xbase: FOXPRO * Interface: WINDOWS * Client/Server related information * API: odbc * Driver: qeinfrmx * Server: N/A * Data Base: N/A #INCLUDE gxdatain.prg IF TYPE("GXToReadEvents") = "U" PUBLIC GXToReadEvents ENDIF GXToReadEvents = .T. LOCAL GXReadEvObj IF TYPE("GXReadEvents") = "U" PRIVATE GXReadEvents GXReadEvObj = .T. ELSE GXReadEvObj = GXReadEvents ENDIF GXReadEvents = .F. IF GXReadEvObj ENDIF PRIVATE gxHDC, GX_XPage, GX_YPage, GXPrn_Flag gxHDC = 0 GX_XPage = 96 GX_YPage = 96 GXPrn_Flag = 0 ON KEY LABEL ENTER IF ! GXReadEvObj SET SAFETY OFF SET BELL OFF SET REPROCESS TO 1 IF SET("DATE") != "BRITISH" SET DATE BRITISH ENDIF SET CONFIRM ON DO GX_YrLmt WITH 19, 40 IF SET("HOURS") != 24 SET HOURS TO 24 ENDIF SET READBORDER OFF IF SET("POINT") != "," SET POINT TO "," SET SEPARATOR TO "." ENDIF DO GX_DSSet ENDIF PRIVATE HStmt_P21768 HStmt_P21768 = -1 PRIVATE HStmt_P21767 HStmt_P21767 = -1 PRIVATE HStmt_P21766 HStmt_P21766 = -1 PRIVATE Buf_P21765_381DocuAdenda Buf_P21765_381DocuAdenda = SPACE(2500) PRIVATE Buf_P21765_1075DocuTotal Buf_P21765_1075DocuTotal = 0.00 PRIVATE Buf_P21765_1073DocuMerca Buf_P21765_1073DocuMerca = 0.00 PRIVATE Buf_P21765_1071DocuNeto Buf_P21765_1071DocuNeto = 0.00 PRIVATE Buf_P21765_384DocuTip Buf_P21765_384DocuTip = SPACE(7) PRIVATE Buf_P21765_385DocuNro Buf_P21765_385DocuNro = 0 PRIVATE HStmt_P21765 HStmt_P21765 = -1 PRIVATE HStmt_P21764 HStmt_P21764 = -1 PRIVATE HStmt_P21763 HStmt_P21763 = -1 PRIVATE Buf_P21762_2154DocuAsoTip Buf_P21762_2154DocuAsoTip = SPACE(7) PRIVATE Buf_P21762_2155DocuAsoNro Buf_P21762_2155DocuAsoNro = 0 PRIVATE Buf_P21762_2156VencTipo Buf_P21762_2156VencTipo = SPACE(3) PRIVATE Buf_P21762_2148VencPlazCo Buf_P21762_2148VencPlazCo = 0 PRIVATE Buf_P21762_2150VencOrden Buf_P21762_2150VencOrden = 0.00 PRIVATE Buf_P21762_2146DocuMonto Buf_P21762_2146DocuMonto = 0.00 PRIVATE Buf_P21762_2147DocuPagado Buf_P21762_2147DocuPagado = 0.00 PRIVATE Buf_P21762_384DocuTip Buf_P21762_384DocuTip = SPACE(7) PRIVATE Buf_P21762_385DocuNro Buf_P21762_385DocuNro = 0 PRIVATE Buf_P21762_2153DocuFchVto Buf_P21762_2153DocuFchVto = CTOD(" / / ") PRIVATE HStmt_P21762 HStmt_P21762 = -1 PRIVATE UserCancel, GX_newwin, GX_eject, GX_prn_defa, GX_env_def, GX_retp UserCancel = .F. GX_newwin = "GXDummyWin" GX_eject = .T. GX_XProp = 1 gx_prn_defa = "" gx_env_def = .f. GX_retp = 0 PRIVATE gx_oldDVal gx_oldDVal = CTOD(" / / ") PRIVATE currSoapErr, currSoapErrmsg currSoapErr = 0 currSoapErrmsg = "" PRIVATE GX_pg_started GX_pg_started = .F. * Variables Definition PRIVATE AV17DocuTi PRIVATE AV11DocuNr PRIVATE AV12Cli PRIVATE AV28VtoFch PRIVATE AV19AsoTip PRIVATE AV20AsoNro PRIVATE AV40AsoFch PRIVATE AV37VTip PRIVATE AV39Mon PRIVATE AV38Monto PRIVATE AV32ok PRIVATE AV49obs PRIVATE Gx_out Gx_out = 'SCR' PRIVATE R377DocuAt R377DocuAt = 0 PRIVATE R378DocuPa R378DocuPa = 0 PRIVATE R379DocuCa R379DocuCa = 0 PRIVATE R382DocuEn R382DocuEn = SPACE(80) PRIVATE R383DocuCo R383DocuCo = 0.0000 PRIVATE R1032PediF R1032PediF = CTOD(" / / ") PRIVATE R1033PediN R1033PediN = 0 PRIVATE R1066DocuD R1066DocuD = 0 PRIVATE R1067DocuF R1067DocuF = 0 PRIVATE R1069DocuD R1069DocuD = 0.00 PRIVATE R1070DocuD R1070DocuD = 0.00 PRIVATE R1074DocuP R1074DocuP = 0.00 PRIVATE R1076DocuR R1076DocuR = 0.00 PRIVATE R1077LinTU R1077LinTU = 0 PRIVATE R1078DocuC R1078DocuC = 0 PRIVATE R1079DocuS R1079DocuS = 0 PRIVATE R323Cod_se R323Cod_se = 0 PRIVATE R324Cod_se R324Cod_se = 0 PRIVATE R179CarpTi R179CarpTi = SPACE(4) PRIVATE R180CarpNr R180CarpNr = 0 PRIVATE R1080DocuR R1080DocuR = SPACE(6) PRIVATE R1527DocuD R1527DocuD = SPACE(10) PRIVATE R1528DocuB R1528DocuB = SPACE(10) PRIVATE R1529DocuN R1529DocuN = 0 PRIVATE R1530DocuC R1530DocuC = SPACE(14) PRIVATE R1531DocuS R1531DocuS = 0 PRIVATE R1703DocuT R1703DocuT = 0 PRIVATE R1704DocuF R1704DocuF = SPACE(25) PRIVATE R1705DocuF R1705DocuF = CTOD(" / / ") PRIVATE R1706DocuI R1706DocuI = 0 PRIVATE R1707DocuF R1707DocuF = 0 PRIVATE R1708DocuS R1708DocuS = SPACE(40) PRIVATE R1709DocuV R1709DocuV = 0 PRIVATE R1710DocuM R1710DocuM = 0 PRIVATE R1711DocuD R1711DocuD = 0 PRIVATE R1712DocuS R1712DocuS = 0 PRIVATE R1713DocuS R1713DocuS = 0 PRIVATE R1714DocuP R1714DocuP = 0 PRIVATE R1715DocuD R1715DocuD = SPACE(30) PRIVATE R1716DocuX R1716DocuX = SPACE(120832) PRIVATE R2372DocuC R2372DocuC = 0 PRIVATE R2374DocuP R2374DocuP = 0.00 PRIVATE R2151VencD R2151VencD = 0.00 PRIVATE R2152VencE R2152VencE = 0.00 PRIVATE R384DocuTi R384DocuTi = SPACE(7) PRIVATE R385DocuNr R385DocuNr = 0 PRIVATE R370DocuFc R370DocuFc = CTOD(" / / ") PRIVATE R372DocuAf R372DocuAf = 0 PRIVATE R371DocuAf R371DocuAf = SPACE(7) PRIVATE R373DocuAf R373DocuAf = CTOD(" / / ") PRIVATE R203Nro_de R203Nro_de = 0 PRIVATE R374DocuMo R374DocuMo = 0 PRIVATE R1068DocuU R1068DocuU = 0 PRIVATE R376DocuSt R376DocuSt = 0 PRIVATE R31SucuCod R31SucuCod = 0 PRIVATE R380DocuCo R380DocuCo = SPACE(60) PRIVATE R1072DocuI R1072DocuI = 0.00 PRIVATE R381DocuAd R381DocuAd = SPACE(2500) PRIVATE R1071DocuN R1071DocuN = 0.00 PRIVATE R1073DocuM R1073DocuM = 0.00 PRIVATE R1075DocuT R1075DocuT = 0.00 PRIVATE Gx_date Gx_date = DATE() PRIVATE R2153DocuF R2153DocuF = CTOD(" / / ") PRIVATE R2147DocuP R2147DocuP = 0.00 PRIVATE R2146DocuM R2146DocuM = 0.00 PRIVATE R2150VencO R2150VencO = 0.00 PRIVATE R2148VencP R2148VencP = 0 PRIVATE R2156VencT R2156VencT = SPACE(3) PRIVATE R2155DocuA R2155DocuA = 0 PRIVATE R2154DocuA R2154DocuA = SPACE(7) PRIVATE Gx_emsg Gx_emsg = SPACE(70) PRIVATE Gx_err Gx_err = 0 PRIVATE RV50Perfil RV50Perfil = 0 PRIVATE RV48plazco RV48plazco = 0 PRIVATE RV47ordena RV47ordena = 0.00 PRIVATE RV46pagado RV46pagado = 0.00 PRIVATE RV45avence RV45avence = 0.00 PRIVATE RV44MyMsg RV44MyMsg = SPACE(80) PRIVATE RV43r RV43r = 0 PRIVATE RV42Posibl RV42Posibl = 0.00 PRIVATE RV41Puesto RV41Puesto = SPACE(10) PRIVATE RV36SectAb RV36SectAb = SPACE(1) PRIVATE RV31UNom RV31UNom = SPACE(10) PRIVATE RV30UCod RV30UCod = 0 PRIVATE RV23Error RV23Error = SPACE(1) PRIVATE RV22Mensaj RV22Mensaj = SPACE(1) PRIVATE RV21SCod RV21SCod = 0 PRIVATE RV13tope RV13tope = 0 * Level Flags PRIVATE LEVEL2 LEVEL2 = .F. PRIVATE LEVEL4 LEVEL4 = .F. PRIVATE LEVEL3 LEVEL3 = .F. PRIVATE LEVEL5 LEVEL5 = .F. PRIVATE LEVEL7 LEVEL7 = .F. PRIVATE LEVEL6 LEVEL6 = .F. PRIVATE LEVEL1 LEVEL1 = .F. * Cursors Definition PRIVATE GX_REC233 GX_REC233 = 0 PRIVATE GX_REC39 GX_REC39 = 0 * Gx formulas Gx_date = DATE() Gx_err = 0 * Device settings PRIVATE old_area, rpt_name, RptView old_area = 0 rpt_name = " " RptView = .F. LEVEL1 = .T. RV42Posibl = 0 RV45avence = 0 RV46pagado = 0 RV47ordena = 0 LEVEL2 = .T. IF .NOT. GX_DB_StmtIsDef( HConn_Default , "P21762" , @HStmt_P21762 ) Gx_Err = Gx_odbc_mrc( GX_DB_Declare_StmtEx( HConn_Default,"PNEWOCOB","P21762","",GX_CURSOR_TYPE_READONLY,@HStmt_P21762) , , , , CS_INFORM , ) cmdbuf= "SELECT DocuFchVto, DocuNro, DocuTip, DocuPagado, DocuMonto, VencOrden, VencPlazCo," cmdbuf=cmdbuf + " VencTipo, DocuAsoNro, DocuAsoTip FROM VENCIM WHERE (DocuTip = ? and DocuNro = ?)" cmdbuf=cmdbuf + " AND (DocuFchVto <= ?) ORDER BY DocuTip, DocuNro " Gx_err = GX_DB_Set_StmtCmdText( HStmt_P21762,cmdbuf) Gx_err = GX_DB_Set_StmtFetchSize( HStmt_P21762,10) GX_DB_BindColsP21762_01 () GX_DB_BindParmP21762_01 () ENDIF Gx_err = GX_DB_SetStr( HStmt_P21762,1,AV19AsoTip,7,0) Gx_err = GX_DB_SetLong( HStmt_P21762,2,@AV20AsoNro,0) Gx_err = GX_DB_SetDate( HStmt_P21762,3,@AV28VtoFch,0) Gx_eop = 1 DO WHILE Gx_eop != 0 Gx_Err = Gx_odbc_mrc( GX_DB_StmtFetchFirst( HStmt_P21762) , , , , CS_INFORM , ) ENDDO P21762 = Gx_err GX_DB_GetP21762_01 () DO WHILE P21762 <> 101 R2153DocuF = Buf_P21762_2153DocuFchVto R385DocuNr = Buf_P21762_385DocuNro R384DocuTi = Buf_P21762_384DocuTip R2147DocuP = Buf_P21762_2147DocuPagado n2147DocuP = 0 R2146DocuM = Buf_P21762_2146DocuMonto n2146DocuM = 0 R2150VencO = Buf_P21762_2150VencOrden n2150VencO = 0 R2148VencP = Buf_P21762_2148VencPlazCo n2148VencP = 0 R2156VencT = Buf_P21762_2156VencTipo R2155DocuA = Buf_P21762_2155DocuAsoNro R2154DocuA = Buf_P21762_2154DocuAsoTip IF R2153DocuF < AV28VtoFch RV42Posibl = RV42Posibl + R2146DocuM - R2147DocuP ELSE RV45avence = RV45avence + R2146DocuM RV46pagado = RV46pagado + R2147DocuP RV47ordena = RV47ordena + R2150VencO RV48plazco = R2148VencP IF R2154DocuA = AV19AsoTip .AND. R2155DocuA = AV20AsoNro .AND. ( R2156VencT = AV37VTip .OR. empty( AV37VTip ) ) AV37VTip = R2156VencT ENDIF ENDIF DO GX_RPTCW WITH "¿Cancela el programa? (S/N)" , "Programa cancelado por el usuario" , UserCancel IF UserCancel EXIT ENDIF Gx_eop = 1 DO WHILE Gx_eop != 0 Gx_Err = Gx_odbc_mrc( GX_DB_StmtFetchNext( HStmt_P21762) , , , , CS_INFORM , ) ENDDO P21762 = Gx_err GX_DB_GetP21762_01 () IF UserCancel EXIT ENDIF ENDDO Gx_Err = Gx_odbc_mrc( GX_DB_SetClosable( HStmt_P21762) , , , , CS_INFORM , ) IF RV47ordena > 0 RV42Posibl = RV42Posibl + RV45avence - RV47ordena ELSE RV42Posibl = RV42Posibl + RV45avence - RV46pagado ENDIF IF RV42Posibl + 1 >= AV38Monto AV32ok = 1 RV44MyMsg = "" ELSE AV32ok = 0 RV44MyMsg = AV19AsoTip + str( AV20AsoNro , 8 ) + GXDTOC( AV28VtoFch ) + "Aborta. Posible = " + str( RV42Posibl , 12 , 2 ) + " y Monto = " + str( AV38Monto , 12 , 2 ) AV38Monto = 0 ENDIF IF AV19AsoTip = "PEDI" AV28VtoFch = Gx_date ENDIF IF AV11DocuNr = 0 DO PUsPuSu WITH RV30UCod , RV31UNom , RV41Puesto , RV21SCod , " " , " " DO PkGetNro WITH AV17DocuTi , AV11DocuNr , RV21SCod IF empty( AV49obs ) AV49obs = "Creado por " + alltrim( RV31UNom ) ENDIF LEVEL3 = .T. * INSERT RECORD ON TABLE DOCUME GX_INS39 = 0 R384DocuTi = AV17DocuTi R385DocuNr = AV11DocuNr R370DocuFc = Gx_date n370DocuFc = 0 R372DocuAf = AV20AsoNro n372DocuAf = 0 R371DocuAf = AV19AsoTip n371DocuAf = 0 R373DocuAf = AV40AsoFch n373DocuAf = 0 R203Nro_de = AV12Cli n203Nro_de = 0 R374DocuMo = AV39Mon n374DocuMo = 0 R1068DocuU = 0 n1068DocuU = 0 R376DocuSt = 0 n376DocuSt = 0 R31SucuCod = RV21SCod n31SucuCod = 0 R380DocuCo = AV49obs n380DocuCo = 0 R1072DocuI = 0 n1072DocuI = 0 R1073DocuM = AV38Monto n1073DocuM = 0 R1071DocuN = AV38Monto n1071DocuN = 0 R1075DocuT = AV38Monto n1075DocuT = 0 R381DocuAd = RV44MyMsg n381DocuAd = 0 IF .NOT. GX_DB_StmtIsDef( HConn_Default , "P21763" , @HStmt_P21763 ) Gx_Err = Gx_odbc_mrc( GX_DB_Declare_StmtEx( HConn_Default,"PNEWOCOB","P21763","",GX_CURSOR_TYPE_FORUPDATE,@HStmt_P21763) , , , , CS_INFORM , ) cmdbuf= "INSERT INTO DOCUME (DocuTip, DocuNro, DocuFchEmi, DocuAfcTip, DocuAfcNro, DocuAfcFch," cmdbuf=cmdbuf + " DocuMoneda, Nro_deudor, DocuStatus, DocuComent, SucuCod, DocuUltLin, DocuNeto, DocuIva," cmdbuf=cmdbuf + " DocuMerca, DocuTotal, DocuAdenda, DocuXML, DocuAtados, DocuPaquet, DocuCajas, DocuEntrDi," cmdbuf=cmdbuf + " DocuCotiza, PediFch, PediNro, DocuDeposi, DocuForm, DocuDto1, DocuDto2, DocuPend," cmdbuf=cmdbuf + " DocuRecarg, LinTUltNro, DocuCorr, DocuSCli, Cod_sector, Cod_seccio, CarpTipo, CarpNro," cmdbuf=cmdbuf + " DocuRango, DocuDUA, DocuBROU, DocuNAsie, DocuCedula, DocuStatDG, DocuTipoRe, DocuFirmaT," cmdbuf=cmdbuf + " DocuFirmaF, DocuIdResp, DocuFmaPag, DocuSobre, DocuViaTra, DocuModVen, DocuDepoDe," cmdbuf=cmdbuf + " DocuSector, DocuSeccD, DocuProvee, DocuDigest, DocuCodIva, DocuPorIva) VALUES (?," cmdbuf=cmdbuf + " ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 0, 0, 0, '', 0, DATETIME( 0001-01-01)" cmdbuf=cmdbuf + " YEAR TO DAY, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '', 0, '', '', '', 0, '', 0, 0," cmdbuf=cmdbuf + " '', DATETIME( 0001-01-01) YEAR TO DAY, 0, 0, '', 0, 0, 0, 0, 0, 0, '', 0, 0)" Gx_err = GX_DB_Set_StmtCmdText( HStmt_P21763,cmdbuf) GX_DB_BindParmP21763_01 () ENDIF Gx_err = GX_DB_SetStr( HStmt_P21763,1,R384DocuTi,7,0) Gx_err = GX_DB_SetLong( HStmt_P21763,2,@R385DocuNr,0) Gx_err = GX_DB_SetDate( HStmt_P21763,3,@R370DocuFc,0) Gx_err = GX_DB_SetStr( HStmt_P21763,4,R371DocuAf,7,0) Gx_err = GX_DB_SetLong( HStmt_P21763,5,@R372DocuAf,0) Gx_err = GX_DB_SetDate( HStmt_P21763,6,@R373DocuAf,0) Gx_err = GX_DB_SetInt( HStmt_P21763,7,@R374DocuMo,0) Gx_err = GX_DB_SetLong( HStmt_P21763,8,@R203Nro_de,0) Gx_err = GX_DB_SetInt( HStmt_P21763,9,@R376DocuSt,0) Gx_err = GX_DB_SetStr( HStmt_P21763,10,R380DocuCo,60,0) Gx_err = GX_DB_SetInt( HStmt_P21763,11,@R31SucuCod,0) Gx_err = GX_DB_SetInt( HStmt_P21763,12,@R1068DocuU,0) Gx_err = GX_DB_SetDouble( HStmt_P21763,13,@R1071DocuN,0) Gx_err = GX_DB_SetDouble( HStmt_P21763,14,@R1072DocuI,0) Gx_err = GX_DB_SetDouble( HStmt_P21763,15,@R1073DocuM,0) Gx_err = GX_DB_SetDouble( HStmt_P21763,16,@R1075DocuT,0) Gx_err = GX_DB_SetStr( HStmt_P21763,17,R381DocuAd,2500,0) Gx_err = GX_DB_SetStr( HStmt_P21763,18,R1716DocuX,120832,0) Gx_eop = 1 DO WHILE Gx_eop != 0 Gx_Err = Gx_odbc_mrc( GX_DB_StmtExecute( HStmt_P21763) , , , , CS_INFORM , ) ENDDO P21763 = Gx_err Gx_Err = Gx_odbc_mrc( GX_DB_SetClosable( HStmt_P21763) , , , , CS_INFORM , ) IF P21763 = 1 Gx_err = 1 Gx_emsg = "Ya existe el registro" LEVEL4 = .T. * Optimized UPDATE. IF .NOT. GX_DB_StmtIsDef( HConn_Default , "P21764" , @HStmt_P21764 ) Gx_Err = Gx_odbc_mrc( GX_DB_Declare_StmtEx( HConn_Default,"PNEWOCOB","P21764","",GX_CURSOR_TYPE_FORUPDATE,@HStmt_P21764) , , , , CS_INFORM , ) cmdbuf= "UPDATE DOCUME SET DocuNeto=DocuNeto + ?, DocuMerca=DocuMerca + ?, DocuTotal=DocuTotal" cmdbuf=cmdbuf + " + ? WHERE DocuTip = ? and DocuNro = ?" Gx_err = GX_DB_Set_StmtCmdText( HStmt_P21764,cmdbuf) GX_DB_BindParmP21764_01 () ENDIF Gx_err = GX_DB_SetDouble( HStmt_P21764,1,@AV38Monto,0) Gx_err = GX_DB_SetDouble( HStmt_P21764,2,@AV38Monto,0) Gx_err = GX_DB_SetDouble( HStmt_P21764,3,@AV38Monto,0) Gx_err = GX_DB_SetStr( HStmt_P21764,4,R384DocuTi,7,0) Gx_err = GX_DB_SetLong( HStmt_P21764,5,@R385DocuNr,0) Gx_eop = 1 DO WHILE Gx_eop != 0 Gx_Err = Gx_odbc_mrc( GX_DB_StmtExecute( HStmt_P21764) , , , , CS_INFORM , ) ENDDO P21764 = Gx_err Gx_Err = Gx_odbc_mrc( GX_DB_SetClosable( HStmt_P21764) , , , , CS_INFORM , ) * End optimized UPDATE. LEVEL4 = .F. ELSE Gx_err = 0 Gx_emsg = "" ENDIF * End Insert ELSE LEVEL5 = .T. IF .NOT. GX_DB_StmtIsDef( HConn_Default , "P21765" , @HStmt_P21765 ) Gx_Err = Gx_odbc_mrc( GX_DB_Declare_StmtEx( HConn_Default,"PNEWOCOB","P21765","",GX_CURSOR_TYPE_FORUPDATE,@HStmt_P21765) , , , , CS_INFORM , ) cmdbuf= "SELECT DocuNro, DocuTip, DocuNeto, DocuMerca, DocuTotal, DocuAdenda FROM DOCUME WHERE" cmdbuf=cmdbuf + " (DocuTip = ? AND DocuNro = ?) AND (DocuTip = ? and DocuNro = ?) FOR UPDATE OF DocuNeto," cmdbuf=cmdbuf + " DocuMerca, DocuTotal, DocuAdenda" Gx_err = GX_DB_Set_StmtCmdText( HStmt_P21765,cmdbuf) GX_DB_BindColsP21765_01 () GX_DB_BindParmP21765_01 () ENDIF Gx_err = GX_DB_SetStr( HStmt_P21765,1,AV17DocuTi,7,0) Gx_err = GX_DB_SetLong( HStmt_P21765,2,@AV11DocuNr,0) Gx_err = GX_DB_SetStr( HStmt_P21765,3,AV17DocuTi,7,0) Gx_err = GX_DB_SetLong( HStmt_P21765,4,@AV11DocuNr,0) Gx_eop = 1 DO WHILE Gx_eop != 0 Gx_Err = Gx_odbc_mrc( GX_DB_StmtFetchFirst( HStmt_P21765) , , , , CS_INFORM , ) ENDDO P21765 = Gx_err GX_DB_GetP21765_01 () DO WHILE P21765 <> 101 R385DocuNr = Buf_P21765_385DocuNro R384DocuTi = Buf_P21765_384DocuTip R1071DocuN = Buf_P21765_1071DocuNeto n1071DocuN = 0 R1073DocuM = Buf_P21765_1073DocuMerca n1073DocuM = 0 R1075DocuT = Buf_P21765_1075DocuTotal n1075DocuT = 0 R381DocuAd = Gx_lvchar_to_char( Buf_P21765_381DocuAdenda ) n381DocuAd = 0 IF empty( RV44MyMsg ) R1071DocuN = R1071DocuN + AV38Monto n1071DocuN = 0 R1073DocuM = R1073DocuM + AV38Monto n1073DocuM = 0 R1075DocuT = R1075DocuT + AV38Monto n1075DocuT = 0 ELSE R381DocuAd = alltrim( R381DocuAd ) + chr( 13 ) + RV44MyMsg n381DocuAd = 0 ENDIF IF .NOT. GX_DB_StmtIsDef( HConn_Default , "P21766" , @HStmt_P21766 ) Gx_Err = Gx_odbc_mrc( GX_DB_Declare_StmtEx( HConn_Default,"PNEWOCOB","P21766","",GX_CURSOR_TYPE_FORUPDATE,@HStmt_P21766) , , , , CS_INFORM , ) cmdbuf= "UPDATE DOCUME SET DocuNeto=?, DocuMerca=?, DocuTotal=?, DocuAdenda=? WHERE DocuTip" cmdbuf=cmdbuf + " = ? AND DocuNro = ?" Gx_err = GX_DB_Set_StmtCmdText( HStmt_P21766,cmdbuf) GX_DB_BindParmP21766_01 () ENDIF Gx_err = GX_DB_SetDouble( HStmt_P21766,1,@R1071DocuN,0) Gx_err = GX_DB_SetDouble( HStmt_P21766,2,@R1073DocuM,0) Gx_err = GX_DB_SetDouble( HStmt_P21766,3,@R1075DocuT,0) Gx_err = GX_DB_SetStr( HStmt_P21766,4,R381DocuAd,2500,0) Gx_err = GX_DB_SetStr( HStmt_P21766,5,R384DocuTi,7,0) Gx_err = GX_DB_SetLong( HStmt_P21766,6,@R385DocuNr,0) Gx_eop = 1 DO WHILE Gx_eop != 0 Gx_Err = Gx_odbc_mrc( GX_DB_StmtExecute( HStmt_P21766) , , , , CS_INFORM , ) ENDDO P21766 = Gx_err Gx_Err = Gx_odbc_mrc( GX_DB_SetClosable( HStmt_P21766) , , , , CS_INFORM , ) DO GX_RPTCW WITH "¿Cancela el programa? (S/N)" , "Programa cancelado por el usuario" , UserCancel IF UserCancel EXIT ENDIF * Exiting from a For First loop. EXIT IF UserCancel EXIT ENDIF ENDDO Gx_Err = Gx_odbc_mrc( GX_DB_SetClosable( HStmt_P21765) , , , , CS_INFORM , ) ENDIF IF .NOT. empty( RV44MyMsg ) DO EP0 RETURN ENDIF LEVEL6 = .T. * INSERT RECORD ON TABLE VENCIM GX_INS233 = 0 R384DocuTi = AV19AsoTip R385DocuNr = AV20AsoNro R2153DocuF = AV28VtoFch R2154DocuA = AV17DocuTi R2155DocuA = AV11DocuNr R2156VencT = AV37VTip R2150VencO = AV38Monto n2150VencO = 0 R2148VencP = RV48plazco n2148VencP = 0 IF .NOT. GX_DB_StmtIsDef( HConn_Default , "P21767" , @HStmt_P21767 ) Gx_Err = Gx_odbc_mrc( GX_DB_Declare_StmtEx( HConn_Default,"PNEWOCOB","P21767","",GX_CURSOR_TYPE_FORUPDATE,@HStmt_P21767) , , , , CS_INFORM , ) cmdbuf= "INSERT INTO VENCIM (DocuTip, DocuNro, DocuFchVto, DocuAsoTip, DocuAsoNro, VencTipo," cmdbuf=cmdbuf + " VencPlazCo, VencOrden, DocuMonto, DocuPagado, VencDocum, VencEfect) VALUES (?, ?," cmdbuf=cmdbuf + " ?, ?, ?, ?, ?, ?, 0, 0, 0, 0)" Gx_err = GX_DB_Set_StmtCmdText( HStmt_P21767,cmdbuf) GX_DB_BindParmP21767_01 () ENDIF Gx_err = GX_DB_SetStr( HStmt_P21767,1,R384DocuTi,7,0) Gx_err = GX_DB_SetLong( HStmt_P21767,2,@R385DocuNr,0) Gx_err = GX_DB_SetDate( HStmt_P21767,3,@R2153DocuF,0) Gx_err = GX_DB_SetStr( HStmt_P21767,4,R2154DocuA,7,0) Gx_err = GX_DB_SetLong( HStmt_P21767,5,@R2155DocuA,0) Gx_err = GX_DB_SetStr( HStmt_P21767,6,R2156VencT,3,0) Gx_err = GX_DB_SetInt( HStmt_P21767,7,@R2148VencP,0) Gx_err = GX_DB_SetDouble( HStmt_P21767,8,@R2150VencO,0) Gx_eop = 1 DO WHILE Gx_eop != 0 Gx_Err = Gx_odbc_mrc( GX_DB_StmtExecute( HStmt_P21767) , , , , CS_INFORM , ) ENDDO P21767 = Gx_err Gx_Err = Gx_odbc_mrc( GX_DB_SetClosable( HStmt_P21767) , , , , CS_INFORM , ) IF P21767 = 1 Gx_err = 1 Gx_emsg = "Ya existe el registro" LEVEL7 = .T. * Optimized UPDATE. IF .NOT. GX_DB_StmtIsDef( HConn_Default , "P21768" , @HStmt_P21768 ) Gx_Err = Gx_odbc_mrc( GX_DB_Declare_StmtEx( HConn_Default,"PNEWOCOB","P21768","",GX_CURSOR_TYPE_FORUPDATE,@HStmt_P21768) , , , , CS_INFORM , ) cmdbuf= "UPDATE VENCIM SET VencOrden=VencOrden + ? WHERE DocuTip = ? and DocuNro = ? and" cmdbuf=cmdbuf + " DocuFchVto = ? and DocuAsoTip = ? and DocuAsoNro = ? and VencTipo = ?" Gx_err = GX_DB_Set_StmtCmdText( HStmt_P21768,cmdbuf) GX_DB_BindParmP21768_01 () ENDIF Gx_err = GX_DB_SetDouble( HStmt_P21768,1,@AV38Monto,0) Gx_err = GX_DB_SetStr( HStmt_P21768,2,R384DocuTi,7,0) Gx_err = GX_DB_SetLong( HStmt_P21768,3,@R385DocuNr,0) Gx_err = GX_DB_SetDate( HStmt_P21768,4,@R2153DocuF,0) Gx_err = GX_DB_SetStr( HStmt_P21768,5,R2154DocuA,7,0) Gx_err = GX_DB_SetLong( HStmt_P21768,6,@R2155DocuA,0) Gx_err = GX_DB_SetStr( HStmt_P21768,7,R2156VencT,3,0) Gx_eop = 1 DO WHILE Gx_eop != 0 Gx_Err = Gx_odbc_mrc( GX_DB_StmtExecute( HStmt_P21768) , , , , CS_INFORM , ) ENDDO P21768 = Gx_err Gx_Err = Gx_odbc_mrc( GX_DB_SetClosable( HStmt_P21768) , , , , CS_INFORM , ) * End optimized UPDATE. LEVEL7 = .F. ELSE Gx_err = 0 Gx_emsg = "" ENDIF * End Insert DO EP0 RETURN GX_retp = 0 * End Program *********************** PROCEDURE EP0 *********************** IF TYPE( "HConn_Default" ) = "N" IF GXCONNECTED Gx_Err = Gx_odbc_mrc( GX_DB_ConnCommit(HConn_Default) , , , , CS_INFORM , ) ENDIF ENDIF DO CD0 IF WEXIST( GX_newwin ) RELEASE WINDOW (GX_newwin) IF !EMPTY( LastWin ) ACTIVATE WINDOW (LastWin) MODIFY WINDOW (LastWin) CLOSE ENDIF ENDIF RETURN PROCEDURE GX_DB_GetP21765_01 Gx_err = GX_DB_GetColLong( HStmt_P21765,1,@Buf_P21765_385DocuNro,0) Gx_err = GX_DB_GetColStr( HStmt_P21765,2,@Buf_P21765_384DocuTip,0) Gx_err = GX_DB_GetColDouble( HStmt_P21765,3,@Buf_P21765_1071DocuNeto,0) Gx_err = GX_DB_GetColDouble( HStmt_P21765,4,@Buf_P21765_1073DocuMerca,0) Gx_err = GX_DB_GetColDouble( HStmt_P21765,5,@Buf_P21765_1075DocuTotal,0) Gx_err = GX_DB_GetColStr( HStmt_P21765,6,@Buf_P21765_381DocuAdenda,0) ENDPROC PROCEDURE GX_DB_GetP21762_01 Gx_err = GX_DB_GetColDate( HStmt_P21762,1,@Buf_P21762_2153DocuFchVto,0) Gx_err = GX_DB_GetColLong( HStmt_P21762,2,@Buf_P21762_385DocuNro,0) Gx_err = GX_DB_GetColStr( HStmt_P21762,3,@Buf_P21762_384DocuTip,0) Gx_err = GX_DB_GetColDouble( HStmt_P21762,4,@Buf_P21762_2147DocuPagado,0) Gx_err = GX_DB_GetColDouble( HStmt_P21762,5,@Buf_P21762_2146DocuMonto,0) Gx_err = GX_DB_GetColDouble( HStmt_P21762,6,@Buf_P21762_2150VencOrden,0) Gx_err = GX_DB_GetColInt( HStmt_P21762,7,@Buf_P21762_2148VencPlazCo,0) Gx_err = GX_DB_GetColStr( HStmt_P21762,8,@Buf_P21762_2156VencTipo,0) Gx_err = GX_DB_GetColLong( HStmt_P21762,9,@Buf_P21762_2155DocuAsoNro,0) Gx_err = GX_DB_GetColStr( HStmt_P21762,10,@Buf_P21762_2154DocuAsoTip,0) ENDPROC PROCEDURE GX_DB_BindColsP21765_01 Gx_err = GX_DB_BindColLong( HStmt_P21765,1,0) Gx_err = GX_DB_BindColCharEx( HStmt_P21765,2,0,7,0) Gx_err = GX_DB_BindColDouble( HStmt_P21765,3,0) Gx_err = GX_DB_BindColDouble( HStmt_P21765,4,0) Gx_err = GX_DB_BindColDouble( HStmt_P21765,5,0) Gx_err = GX_DB_BindColCharEx( HStmt_P21765,6,0,2500,0) ENDPROC PROCEDURE GX_DB_BindColsP21762_01 Gx_err = GX_DB_BindColDate( HStmt_P21762,1,0) Gx_err = GX_DB_BindColLong( HStmt_P21762,2,0) Gx_err = GX_DB_BindColCharEx( HStmt_P21762,3,0,7,0) Gx_err = GX_DB_BindColDouble( HStmt_P21762,4,0) Gx_err = GX_DB_BindColDouble( HStmt_P21762,5,0) Gx_err = GX_DB_BindColDouble( HStmt_P21762,6,0) Gx_err = GX_DB_BindColShort( HStmt_P21762,7,0) Gx_err = GX_DB_BindColCharEx( HStmt_P21762,8,0,3,0) Gx_err = GX_DB_BindColLong( HStmt_P21762,9,0) Gx_err = GX_DB_BindColCharEx( HStmt_P21762,10,0,7,0) ENDPROC PROCEDURE GX_DB_BindParmP21768_01 Gx_err = GX_DB_BindParmDouble( HStmt_P21768,1,GX_CS_DOUBLE,GX_SQL_NUMERIC,12,2,GX_PARAM_INPUT,0,0) Gx_err = GX_DB_BindParmCharEx( HStmt_P21768,2,GX_CS_STRING,GX_SQL_CHAR,GX_PARAM_INPUT,0,7,0) Gx_err = GX_DB_BindParmLong( HStmt_P21768,3,GX_CS_LONG,GX_SQL_NUMERIC,7,GX_PARAM_INPUT,0,0) Gx_err = GX_DB_BindParmDate( HStmt_P21768,4,GX_CS_DATE,GX_SQL_DATE,GX_PARAM_INPUT,0,0) Gx_err = GX_DB_BindParmCharEx( HStmt_P21768,5,GX_CS_STRING,GX_SQL_CHAR,GX_PARAM_INPUT,0,7,0) Gx_err = GX_DB_BindParmLong( HStmt_P21768,6,GX_CS_LONG,GX_SQL_NUMERIC,7,GX_PARAM_INPUT,0,0) Gx_err = GX_DB_BindParmCharEx( HStmt_P21768,7,GX_CS_STRING,GX_SQL_CHAR,GX_PARAM_INPUT,0,3,0) ENDPROC PROCEDURE GX_DB_BindParmP21767_01 Gx_err = GX_DB_BindParmCharEx( HStmt_P21767,1,GX_CS_STRING,GX_SQL_CHAR,GX_PARAM_INPUT,0,7,0) Gx_err = GX_DB_BindParmLong( HStmt_P21767,2,GX_CS_LONG,GX_SQL_NUMERIC,7,GX_PARAM_INPUT,0,0) Gx_err = GX_DB_BindParmDate( HStmt_P21767,3,GX_CS_DATE,GX_SQL_DATE,GX_PARAM_INPUT,0,0) Gx_err = GX_DB_BindParmCharEx( HStmt_P21767,4,GX_CS_STRING,GX_SQL_CHAR,GX_PARAM_INPUT,0,7,0) Gx_err = GX_DB_BindParmLong( HStmt_P21767,5,GX_CS_LONG,GX_SQL_NUMERIC,7,GX_PARAM_INPUT,0,0) Gx_err = GX_DB_BindParmCharEx( HStmt_P21767,6,GX_CS_STRING,GX_SQL_CHAR,GX_PARAM_INPUT,0,3,0) Gx_err = GX_DB_BindParmShort( HStmt_P21767,7,GX_CS_SHORT,GX_SQL_NUMERIC,3,GX_PARAM_INPUT,0,0) Gx_err = GX_DB_BindParmDouble( HStmt_P21767,8,GX_CS_DOUBLE,GX_SQL_NUMERIC,12,2,GX_PARAM_INPUT,0,0) ENDPROC PROCEDURE GX_DB_BindParmP21766_01 Gx_err = GX_DB_BindParmDouble( HStmt_P21766,1,GX_CS_DOUBLE,GX_SQL_NUMERIC,12,2,GX_PARAM_INPUT,0,0) Gx_err = GX_DB_BindParmDouble( HStmt_P21766,2,GX_CS_DOUBLE,GX_SQL_NUMERIC,12,2,GX_PARAM_INPUT,0,0) Gx_err = GX_DB_BindParmDouble( HStmt_P21766,3,GX_CS_DOUBLE,GX_SQL_NUMERIC,12,2,GX_PARAM_INPUT,0,0) Gx_err = GX_DB_BindParmCharEx( HStmt_P21766,4,GX_CS_LONGVARCHAR,GX_SQL_LONGVARCHAR,GX_PARAM_INPUT,0,2500,0) Gx_err = GX_DB_BindParmCharEx( HStmt_P21766,5,GX_CS_STRING,GX_SQL_CHAR,GX_PARAM_INPUT,0,7,0) Gx_err = GX_DB_BindParmLong( HStmt_P21766,6,GX_CS_LONG,GX_SQL_NUMERIC,7,GX_PARAM_INPUT,0,0) ENDPROC PROCEDURE GX_DB_BindParmP21765_01 Gx_err = GX_DB_BindParmCharEx( HStmt_P21765,1,GX_CS_STRING,GX_SQL_CHAR,GX_PARAM_INPUT,0,7,0) Gx_err = GX_DB_BindParmLong( HStmt_P21765,2,GX_CS_LONG,GX_SQL_NUMERIC,7,GX_PARAM_INPUT,0,0) Gx_err = GX_DB_BindParmCharEx( HStmt_P21765,3,GX_CS_STRING,GX_SQL_CHAR,GX_PARAM_INPUT,0,7,0) Gx_err = GX_DB_BindParmLong( HStmt_P21765,4,GX_CS_LONG,GX_SQL_NUMERIC,7,GX_PARAM_INPUT,0,0) ENDPROC PROCEDURE GX_DB_BindParmP21764_01 Gx_err = GX_DB_BindParmDouble( HStmt_P21764,1,GX_CS_DOUBLE,GX_SQL_NUMERIC,12,2,GX_PARAM_INPUT,0,0) Gx_err = GX_DB_BindParmDouble( HStmt_P21764,2,GX_CS_DOUBLE,GX_SQL_NUMERIC,12,2,GX_PARAM_INPUT,0,0) Gx_err = GX_DB_BindParmDouble( HStmt_P21764,3,GX_CS_DOUBLE,GX_SQL_NUMERIC,12,2,GX_PARAM_INPUT,0,0) Gx_err = GX_DB_BindParmCharEx( HStmt_P21764,4,GX_CS_STRING,GX_SQL_CHAR,GX_PARAM_INPUT,0,7,0) Gx_err = GX_DB_BindParmLong( HStmt_P21764,5,GX_CS_LONG,GX_SQL_NUMERIC,7,GX_PARAM_INPUT,0,0) ENDPROC PROCEDURE GX_DB_BindParmP21763_01 Gx_err = GX_DB_BindParmCharEx( HStmt_P21763,1,GX_CS_STRING,GX_SQL_CHAR,GX_PARAM_INPUT,0,7,0) Gx_err = GX_DB_BindParmLong( HStmt_P21763,2,GX_CS_LONG,GX_SQL_NUMERIC,7,GX_PARAM_INPUT,0,0) Gx_err = GX_DB_BindParmDate( HStmt_P21763,3,GX_CS_DATE,GX_SQL_DATE,GX_PARAM_INPUT,0,0) Gx_err = GX_DB_BindParmCharEx( HStmt_P21763,4,GX_CS_STRING,GX_SQL_CHAR,GX_PARAM_INPUT,0,7,0) Gx_err = GX_DB_BindParmLong( HStmt_P21763,5,GX_CS_LONG,GX_SQL_NUMERIC,7,GX_PARAM_INPUT,0,0) Gx_err = GX_DB_BindParmDate( HStmt_P21763,6,GX_CS_DATE,GX_SQL_DATE,GX_PARAM_INPUT,0,0) Gx_err = GX_DB_BindParmShort( HStmt_P21763,7,GX_CS_SHORT,GX_SQL_NUMERIC,2,GX_PARAM_INPUT,0,0) Gx_err = GX_DB_BindParmLong( HStmt_P21763,8,GX_CS_LONG,GX_SQL_NUMERIC,6,GX_PARAM_INPUT,0,0) Gx_err = GX_DB_BindParmShort( HStmt_P21763,9,GX_CS_SHORT,GX_SQL_NUMERIC,2,GX_PARAM_INPUT,0,0) Gx_err = GX_DB_BindParmCharEx( HStmt_P21763,10,GX_CS_STRING,GX_SQL_CHAR,GX_PARAM_INPUT,0,60,0) Gx_err = GX_DB_BindParmShort( HStmt_P21763,11,GX_CS_SHORT,GX_SQL_NUMERIC,3,GX_PARAM_INPUT,0,0) Gx_err = GX_DB_BindParmShort( HStmt_P21763,12,GX_CS_SHORT,GX_SQL_NUMERIC,3,GX_PARAM_INPUT,0,0) Gx_err = GX_DB_BindParmDouble( HStmt_P21763,13,GX_CS_DOUBLE,GX_SQL_NUMERIC,12,2,GX_PARAM_INPUT,0,0) Gx_err = GX_DB_BindParmDouble( HStmt_P21763,14,GX_CS_DOUBLE,GX_SQL_NUMERIC,12,2,GX_PARAM_INPUT,0,0) Gx_err = GX_DB_BindParmDouble( HStmt_P21763,15,GX_CS_DOUBLE,GX_SQL_NUMERIC,12,2,GX_PARAM_INPUT,0,0) Gx_err = GX_DB_BindParmDouble( HStmt_P21763,16,GX_CS_DOUBLE,GX_SQL_NUMERIC,12,2,GX_PARAM_INPUT,0,0) Gx_err = GX_DB_BindParmCharEx( HStmt_P21763,17,GX_CS_LONGVARCHAR,GX_SQL_LONGVARCHAR,GX_PARAM_INPUT,0,2500,0) Gx_err = GX_DB_BindParmCharEx( HStmt_P21763,18,GX_CS_LONGVARCHAR,GX_SQL_LONGVARCHAR,GX_PARAM_INPUT,0,120832,0) ENDPROC PROCEDURE GX_DB_BindParmP21762_01 Gx_err = GX_DB_BindParmCharEx( HStmt_P21762,1,GX_CS_STRING,GX_SQL_CHAR,GX_PARAM_INPUT,0,7,0) Gx_err = GX_DB_BindParmLong( HStmt_P21762,2,GX_CS_LONG,GX_SQL_NUMERIC,7,GX_PARAM_INPUT,0,0) Gx_err = GX_DB_BindParmDate( HStmt_P21762,3,GX_CS_DATE,GX_SQL_DATE,GX_PARAM_INPUT,0,0) ENDPROC *********************** PROCEDURE CD0 *********************** IF GXCONNECTED ENDIF RETURN *********************** PROCEDURE HL2 *********************** PARAMETERS Key_read, Attrinum PRIVATE GXLToBD GXLToBD = GXToBeDone GXToBeDone = "" DO CASE CASE Key_read <> 7 .AND. Key_read <> 8 RETURN OTHERWISE SET TOPIC TO [PNewOCOB] HELP ENDCASE RETURN