Imprimir un rowset con treport (Solucionado)

Imprimir un rowset con treport (Solucionado)

Postby jose_murugosa » Fri Mar 18, 2022 12:25 pm

Hola queridos compañeros del foro.

Descargo de un WS y guardo los datos en una tabla mysql con la clase nativa de FWH
Tiro un browse y veo los datos del recordset maravillosamente.

Con esta función, intento generar un reporte en pdf de dichos datos:

Code: Select all  Expand view

FUNCTION InfDesoaPdf( oRs, wfecha, wHorainic, wHorafin, lpdf )
     LOCAL oReport, oBmp, oPrn
   
     lpdf:=.f.   //pasar a .t.
     
     DEFINE FONT oFont1 NAME "Arial" SIZE 0,-10
     IF lPdf:=.t.
          PRINT oPrn FILE ".\PDFS\" + "Desosado" + Dtos(Date()) + Time() + ".pdf"
         
          REPORT oReport ;
               TITLE  "
*** Informe de Entrada al Desosado ***",;
                    wfecha + "
de las " + wHorainic + " hasta las " + wHoraFin ;
               HEADER "
Fecha: " + dtoc(date()),;
                    "
Hora:  " + time() ;
                    RIGHT ;
                    FOOTER "
Página: " + str(oReport:nPage,4) ;
                    CENTERED ;
                    TO DEVICE oPrn
     ELSE
          REPORT oReport ;
          TITLE  "
*** Informe de Entrada al Desosado ***",;
               wfecha + "
de las " + wHorainic + " hasta las " + wHoraFin ;
          HEADER "
Fecha: " + dtoc(date()), ;
               "
Hora:  " + time() ;
               RIGHT ;
               FOOTER "
Página: " + str(oReport:nPage,4) ;
               PREVIEW ;
               CENTERED          
     ENDIF

     COLUMN TITLE "
Hora"     ;
          DATA oRs:Hora      ;
          PICTURE "
XXXXXXXX" ;
          SIZE 14            ;
          FONT 1

     COLUMN TITLE "
Cantidad" ;
          DATA oRs:Cantidad  ;
          PICTURE "
999"      ;
          SIZE 14            ;
          FONT 1

     COLUMN TITLE "
P. Neto"  ;  
          DATA oRs:PesoNeto  ;
          PICTURE "
999.99"   ;
          SIZE 14            ;
          TOTAL
         
     GROUP ON oRs:ProductoId ;
          HEADER "
Producto: " + oRs:ProductoId
     
     END REPORT
     
     oReport:bInit := {|| oRs:Gotop()}
     oReport:bSkip := {|| oRs:Skip(1)}
     
     ACTIVATE REPORT oReport ON STARTGROUP oReport:NewLine()  ;
                             ON STARTPAGE StartPage()

RETURN NIL


El programa se cierra y en el archivo hb_out.log tengo esto:

Code: Select all  Expand view

Application Internal Error - D:\XBase-Proyectos\Rendimientos\Rendimientos.exe
Terminated at: 2022-03-18 09:23:14
Error irrecuperable 6005: Exception error:

    Exception Code:C0000005 ACCESS_VIOLATION
    Exception Address:005C0C9C
    EAX:00000001  EBX:00000000  ECX:0000000A  EDX:00000000
    ESI:0000000A  EDI:0019E81C  EBP:0019E7E8
    CS:EIP:0023:005C0C9C  SS:ESP:002B:0019E7D8
    DS:002B  ES:002B  FS:0053  GS:002B
    Flags:00210246
    Exception Parameters: 00000000 00000012
    CS:EIP: F6 43 12 08 74 36 89 75 FC 83 7D FC 00 74 21 53
    SS:ESP: 00000000 006F31D5 0019E81C 0000000A 0019E804 005C1CE7 0019E81C 0000000A 00000000 00000001 00898700 0019ED40 005C2727 0019E81C 006F1F3E 00000000

    C stack:
    EIP:     EBP:       Frame: OldEBP, RetAddr, Params...
    005C0C9C 0019E7E8   0019E804 005C1CE7 0019E81C 0000000A 00000000 00000001 00898700
    005C1CE7 0019E804   0019ED40 005C2727 0019E81C 006F1F3E 00000000 00898768 46445025 332E312D 00000A0D 00000000
    005C2727 0019ED40   0019ED60 005C0C85 005C0C8C 00000000 006F31D0 00000000 00000000 0019ED74
    005C0C85 0019ED60   0019ED74 00411434 00000000 006F31D0 006F31D5
    00411434 0019ED74   0019ED90 004D2CFC 00000080 00000003 00A2BE6C 00000000 00000000
    004D2CFC 0019ED90   0019EEA4 004CCB06 00000001 006F1A28 00000000 006F1190 00898768 00898A84 00000130 00BC0000
    004CCB06 0019EEA4   0019EEB4 00411294 006F1EAF 006F1060
    00411294 0019EEB4   0019EED4 004D2EB9 00898768 00000078 00000003 00A2BE6C 00030025 000000C6
    004D2EB9 0019EED4   0019EFE8 004CCBC4 00000002 006EFC8F 00000000 00898768 00000000 00000000 00000000 80000000
    004CCBC4 0019EFE8   0019EFF8 0041121C 006F18B4 006F1060
    0041121C 0019EFF8   0019F014 004D2CFC 00000071 00000003 00A2BE6C 00000000 0000003E
    004D2CFC 0019F014   0019F128 004CCA83 00000003 0070083E 00000000 00898768 00898768 069F4C7C 00000003 005D1573
    004CCA83 0019F128   0019F138 0041114C 006EFBB1 006E955C
    0041114C 0019F138   0019F154 004D2CFC 0000005E 00000003 00000000 00000000 000007CA
    004D2CFC 0019F154   0019F268 004CCA83 00000000 005D18EE 00000000 005D1070 00898768 00110000 00A1F3C4 005D1661
    004CCA83 0019F268   0019F278 00412038 007001BC 006FC3C0
    00412038 0019F278   0019F298 004D2EB9 00898768 00000055 00000002 00000000 00DF001D 00000395
    004D2EB9 0019F298   0019F3AC 004CCBC4 0000000E 005D14F6 00000000 00898768 77C34B02 FFFFFFFF 005D1328 0266F0C4
    004CCBC4 0019F3AC   0019F3BC 00401A45 005D150A 005D0D60
    00401A45 0019F3BC   0019F3D8 004D2CFC 00000040 00000000 00000000 00000000 00000094


Modules:
00400000 004DE000 D:\XBase-Proyectos\Rendimientos\Rendimientos.exe
77D40000 001A3000 C:\Windows\SYSTEM32\ntdll.dll
76D80000 000F0000 C:\Windows\System32\KERNEL32.DLL
77B10000 00214000 C:\Windows\System32\KERNELBASE.dll
748E0000 0009F000 C:\Windows\SYSTEM32\apphelp.dll
76810000 0007B000 C:\Windows\System32\ADVAPI32.DLL
76550000 000BF000 C:\Windows\System32\msvcrt.dll
77080000 00076000 C:\Windows\System32\sechost.dll
77100000 000BE000 C:\Windows\System32\RPCRT4.dll
76AA0000 000AF000 C:\Windows\System32\COMDLG32.DLL
771F0000 00280000 C:\Windows\System32\combase.dll
76F60000 00120000 C:\Windows\System32\ucrtbase.dll
75E50000 00087000 C:\Windows\System32\shcore.dll
76B50000 0019C000 C:\Windows\System32\USER32.dll
77530000 00018000 C:\Windows\System32\win32u.dll
774C0000 00024000 C:\Windows\System32\GDI32.dll
76470000 000DC000 C:\Windows\System32\gdi32full.dll
76CF0000 0007B000 C:\Windows\System32\msvcp_win.dll
77470000 00045000 C:\Windows\System32\SHLWAPI.dll
77550000 005B5000 C:\Windows\System32\SHELL32.dll
75C10000 000E3000 C:\Windows\System32\OLE32.DLL
76890000 00096000 C:\Windows\System32\OLEAUT32.DLL
68630000 002CA000 D:\XBase-Proyectos\Rendimientos\LIBMYSQL.DLL
75DE0000 00063000 C:\Windows\System32\WS2_32.dll
749A0000 0001A000 C:\Windows\SYSTEM32\MPR.DLL
75BF0000 00008000 C:\Windows\SYSTEM32\VERSION.DLL
73FC0000 00072000 C:\Windows\SYSTEM32\WINSPOOL.DRV
759E0000 00210000 C:\Windows\WinSxS\x86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.19041.1110_none_a8625c1886757984\COMCTL32.DLL
75C00000 00006000 C:\Windows\SYSTEM32\MSIMG32.DLL
75970000 00028000 C:\Windows\SYSTEM32\WINMM.DLL
6D0B0000 0002C000 C:\Windows\SYSTEM32\OLEDLG.DLL
74050000 00167000 C:\Windows\WinSxS\x86_microsoft.windows.gdiplus_6595b64144ccf1df_1.1.19041.1566_none_d951c72fe1040d0f\GDIPLUS.DLL
771C0000 00025000 C:\Windows\System32\IMM32.DLL
6FD10000 00079000 C:\Program Files\ESET\ESET Security\x86\ebehmoni.dll
725C0000 00074000 C:\Windows\system32\uxtheme.dll
74FF0000 00021000 C:\Windows\SYSTEM32\SspiCli.dll
75D00000 000D4000 C:\Windows\System32\MSCTF.dll
73D20000 00011000 C:\Windows\system32\napinsp.dll
73D00000 00016000 C:\Windows\system32\pnrpnsp.dll
73CF0000 00010000 C:\Windows\system32\wshbth.dll
73CD0000 00016000 C:\Windows\system32\NLAapi.dll
74CA0000 00032000 C:\Windows\SYSTEM32\IPHLPAPI.DLL
74B60000 00052000 C:\Windows\System32\mswsock.dll
746D0000 00090000 C:\Windows\SYSTEM32\DNSAPI.dll
76E70000 00007000 C:\Windows\System32\NSI.dll
73CC0000 0000E000 C:\Windows\System32\winrnr.dll
74240000 00008000 C:\Windows\System32\rasadhlp.dll
74250000 00058000 C:\Windows\System32\fwpuclnt.dll
76680000 00019000 C:\Windows\System32\bcrypt.dll
6D230000 00171000 C:\Windows\SYSTEM32\WindowsCodecs.dll
6F5D0000 00094000 C:\Windows\SYSTEM32\TextShaping.dll
75680000 0000F000 C:\Windows\SYSTEM32\kernel.appcore.dll
76380000 0005F000 C:\Windows\System32\bcryptPrimitives.dll
6CC60000 000B9000 C:\Windows\SYSTEM32\textinputframework.dll
6C940000 0027E000 C:\Windows\System32\CoreUIComponents.dll
6CBC0000 0009B000 C:\Windows\System32\CoreMessaging.dll
75690000 00029000 C:\Windows\SYSTEM32\ntmarta.dll
6C860000 000DB000 C:\Windows\SYSTEM32\wintypes.dll
76EE0000 0007E000 C:\Windows\System32\clbcatq.dll
6F7A0000 0014F000 C:\Windows\System32\msxml3.dll
73790000 00454000 C:\Windows\System32\WININET.dll
742D0000 0022C000 C:\Windows\System32\iertutil.dll
74500000 001A8000 C:\Windows\System32\urlmon.dll
74980000 0001D000 C:\Windows\System32\srvcli.dll
74E60000 0000B000 C:\Windows\System32\netutils.dll
75070000 0060C000 C:\Windows\SYSTEM32\windows.storage.dll
75040000 00024000 C:\Windows\System32\Wldp.dll
75020000 00018000 C:\Windows\SYSTEM32\profapi.dll
6FE40000 00012000 C:\Windows\SYSTEM32\ondemandconnroutehelper.dll
74BD0000 000C9000 C:\Windows\SYSTEM32\winhttp.dll
742C0000 00008000 C:\Windows\SYSTEM32\WINNSI.DLL
70B20000 0000D000 C:\Program Files (x86)\Common Files\Microsoft Shared\OFFICE14\MSOXMLMF.DLL
74D00000 000A3000 C:\Windows\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.9625_none_508ef7e4bcbbe589\MSVCR90.dll
70BE0000 00088000 C:\Windows\SYSTEM32\sxs.dll

Called from PDFBEGIN(0) in .\source\function\PRV2PDF.PRG
Called from TFW_PDF:NEW(198) in .\source\function\PRV2PDF.PRG
Called from FWSAVEPREVIEWTOPDF(62) in .\source\function\PRV2PDF.PRG
Called from PRINTEND(1994) in .\source\classes\PRINTER.PRG
Called from TREPORT:ACTIVATE(917) in .\source\classes\REPORT.PRG
Called from INFDESOAPDF(148) in d:\xbase-proyectos\rendimientos\source\Ws-entradadesosado.prg
Called from WSENTRADADESOSADO(85) in d:\xbase-proyectos\rendimientos\source\Ws-entradadesosado.prg
Called from (b)HAGOMENU(83) in d:\xbase-proyectos\rendimientos\source\Main.prg
Called from TMENU:COMMAND(1563) in .\source\classes\MENU.PRG
Called from TWINDOW:COMMAND(1141) in .\source\classes\WINDOW.PRG
Called from TWINDOW:HANDLEEVENT(0)
Called from _FWH(3560) in .\source\classes\WINDOW.PRG
Called from WINRUN(0)
Called from TWINDOW:ACTIVATE(1097) in .\source\classes\WINDOW.PRG
Called from MAIN(59) in d:\xbase-proyectos\rendimientos\source\Main.prg
------------------------------------------------------------------------
 


Quizá puedan ayudarme, porque no me doy cuenta que está mal.
Last edited by jose_murugosa on Fri Mar 18, 2022 5:26 pm, edited 1 time in total.
Saludos/Regards,
José Murugosa
FWH + Harbour + Bcc7. Una seda!
User avatar
jose_murugosa
 
Posts: 1144
Joined: Mon Feb 06, 2006 4:28 pm
Location: Uruguay

Re: Imprimir un rowset con treport

Postby hmpaquito » Fri Mar 18, 2022 12:47 pm

Hola,

Así a ojo y de lejos, sospecho que el problema son los dobles dos puntos (:) que inserta Time() en el nombre del archivo .pdf

La solucion es "limpiar" el nombre del archivo de caracteres no soportados por el sistema operativo.

Te pègo aqui una funcion arcaica pero eficaz para mi, que limpia de caracteres invalido el nombre de los archivos. Igual Harbour tiene algo mejor. Lo desconozco; seria interesante saberlo

Code: Select all  Expand view

//-------------------------------------------------------------------------//
FUNCTION FileCarValidos(cPathFile, lEquivalenciasPuedenSerIguales)
Local nRAt:= RAt("\", cPathFile)
Local cPath, cFile, cRet
Local aCar, aEqui
*
DEFAULT lEquivalenciasPuedenSerIguales:= .T.
*
aCar:= {"
/", ":", "*", "<", ">", '"', "?", "|" }
IF lEquivalenciasPuedenSerIguales
   // Equivalencias tienen que ser iguales !!
   aEqui:= {"-", "-", "-", "-", "-", "-", "-", "-" }
ELSE
   // Equivalencias han de ser distintas entre si.
   aEqui:= {"-", "+", "_", "§", "¦", "!", "­", ")" }
ENDIF
*
cPath:= Left(cPathFile, nRAt- 1)
cFile:= SubStr(cPathFile, nRAt+ 1)
cFile:= StrTranMultiple(cFile, aCar,;   // Caracteres de nombre de
                               aEqui)                // fichero no permitidos

cFile:= StrTran(cFile, CRLF, "")
*
cRet:= If(!Empty(cPath), cPath+ "\", "")+ cFile
RETURN cRet
*
//-------------------------------------------------------------------------//
FUNCTION StrTranMultiple(cStr, aSeek, aReplace)
Local nI
Local cSeek
FOR nI:= 1 TO Len(aReplace)
   IF nI > Len(aSeek)
      IF Len(aSeek) == 1
         cSeek:= aSeek[nI]
      ELSE
         MERROR_("O aSeek es parejo a aReplace o tiene una sola posicion",;
                 cStr, aSeek, aReplace)
      ENDIF
   ELSE
      cSeek:= aSeek[nI]
   ENDIF
   cStr:= StrTran(cStr, cSeek, aReplace[nI])
NEXT
RETURN cStr
*
hmpaquito
 
Posts: 1482
Joined: Thu Oct 30, 2008 2:37 pm

Re: Imprimir un rowset con treport

Postby jose_murugosa » Fri Mar 18, 2022 2:47 pm

Muuuuuchas gracias hmpaquito !!!!

Efectivamente era eso.

Quedó resuelto ese problema.
Saludos/Regards,
José Murugosa
FWH + Harbour + Bcc7. Una seda!
User avatar
jose_murugosa
 
Posts: 1144
Joined: Mon Feb 06, 2006 4:28 pm
Location: Uruguay


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 65 guests