1. Julian I.
  2. PowerBuilder
  3. Wednesday, 3 November 2021 10:59 AM UTC

Hi,

Powerbuilder 2019 Build 2170.

We are getting problems on exports DW to XLSX! format, sometimes the application crash, we have included TRY..CATCH blocks and we don´t know how to catch the error.

A simple Test.

- Create a external DW with only a field:

- And I run the following code (we are assigning a directory that does not exist):

int li_ret

datastore lds_exp

lds_exp = create datastore
lds_exp.DataObject = "d_prueba_xlsx"

TRY
    li_ret = lds_exp.saveas("c:\directory_not_exists\test.xlsx", XLSX!, true)
CATCH (runtimeError e)
    messagebox("Atención", "RuntimeError")
END TRY

if li_ret < 0 then
    MessageBox("Error", "Error al exportar en formato XLSX")
end if

- RESULT: The app CRASHES, and I can´t catch the error.

if I use TEXT! or EXCEL8! saveas format,  the app works OK, returns -1 and doesn´t CRASH.

¿Is there any way to capture errors on DW SaveAs to XLSX! exceptions?

Regards,

Julian.

 

 

René Ullrich Accepted Answer Pending Moderation
  1. Wednesday, 3 November 2021 12:08 PM UTC
  2. PowerBuilder
  3. # 1

Hi Julian,

I've tested your code with PB 2019 R3 Build 2703 and I was not able to reproduce the problem.

You could try to catch "throwable". That catches all exception. But if Powerbuilder crashes I guess it wouldn't help. Reasons for are crash are often problems in runtime DLLs.

René

 

Comment
There are no comments made yet.
Julian I. Accepted Answer Pending Moderation
  1. Wednesday, 3 November 2021 13:12 PM UTC
  2. PowerBuilder
  3. # 2

Hi Rene,

I am testing with PB 2019 Build 2170. I test with Throwable exception and it doesn't catch the error either.

In the test you are running, ¿are you asigning a directory that not exists on saveas parameter?

I don't know if it could be a bug of my version, but when i run this, the app crash.

The following is logged in the Event Viewer:


Thanks for your answerd !
Regards,

Julian
Comment
  1. René Ullrich
  2. Wednesday, 3 November 2021 13:55 PM UTC
Yes, I tested with "c:\directory_not_exists\test.xlsx". :-)

In my case SaveAs returns -1.
  1. Helpful
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Wednesday, 3 November 2021 13:59 PM UTC
  2. PowerBuilder
  3. # 3

If I understood well, what you want to know is whether you can use try catch to intercept a non existing directory when doing fileSaveAs. Not sure if there's such a thing for SaveAs()

I would recommend to simply call the function DirectoryExists() before trying to save. You can also use FileExists() (that one also works for directories).

Besides that, the code that you show here would fail: Your "lds_exp" lacks a call to SetTransobject() and retrieval of the data (but maybe in your "real" code that's not the case.  (corrected, I didn't realize you were using an external dw).

Please upgrade to pb 2019 R3 build 2703 or higher.

regards

Comment
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Wednesday, 3 November 2021 14:13 PM UTC
  2. PowerBuilder
  3. # 4

I have also tested your application with an external dw which has 3 fixed rows, using your exact code.

I'm not getting any crash (build 2703). I'm getting the error message "Error al exportar en formato XLSX".

The reason why the try catch doesn't do anything is because the saveas function return -1. It's not an exception.

You should really try to upgrade your build in my opinion and then try again.

regards.

Comment
  1. Chris Pollach @Appeon
  2. Wednesday, 3 November 2021 14:23 PM UTC
Hi Miguel ... The XLSX feature is dependent on the .NET framework which the SaveAs() command calls in order to accomplish this task. It could be possible that Julian is just running an old .Net framework runtime (distributable). My .Net Frameworks on my PC's unde W10 is v4.8. Food for thought.
  1. Helpful
  1. Miguel Leeuwe
  2. Wednesday, 3 November 2021 14:31 PM UTC
Hi Chris,

Yes, could be. The image of the event viewer shows he's using .net 4.0.30319 (which dates from 2010 if I'm not mistaken), but ... that version has been updated until last year 4.0.30319.1

So maybe a windows update would fix his problems, but I do seem to vaguely remember there were some bugs with the excel12 stuff, so that's why I'm recommending to upgrade his build.

regards

  1. Helpful
  1. Miguel Leeuwe
  2. Wednesday, 3 November 2021 14:32 PM UTC
It's also mentioned that the app crashes sometimes, but not all the time, so it's unclear to me when it does and when it doesn't crash.
  1. Helpful
There are no comments made yet.
Julian I. Accepted Answer Pending Moderation
  1. Wednesday, 3 November 2021 15:15 PM UTC
  2. PowerBuilder
  3. # 5

Hi,

This was only a simple sample to reproduze the problems we have with SaveAs XLSX that are crashing the app. It is not the real problem. We think we have problems due to memory management on XLSX format export. Exporting using saveAs XLSX! format crash!, but the same DW with Excel!, CSV! or Text! works fine... As we didn't know how to correct, we were trying to catch the error.

 

We have a procces that retrieves a great amount of data on a DW, and exports blocks of data on XLSX files using DW SAVEAS

We reset DW and execute GarbageCollect on each iteration but memory is not freed. So this make crash the app in later iterations of saveas


We will update version of  .Net framework and PB19

Thanks !


Comment
  1. Julian I.
  2. Wednesday, 3 November 2021 15:53 PM UTC
Microsoft (R) Build Engine, versión 4.8.4084.0

[Microsoft .NET Framework, versión 4.0.30319.42000]

Copyright (C) Microsoft Corporation. Todos los derechos reservados.



4.8.4084.0
  1. Helpful
  1. Miguel Leeuwe
  2. Wednesday, 3 November 2021 16:02 PM UTC
Aha, that makes more sense. You have a memory problem then.

How much memory RAM is there on the PC and how many rows and columns do you have on the datawindow that you're trying to export?

The older formats probably use less memory. Also the older formats don't have do any data compression. Basically an xlsX is a zipped file.

Even if your machine has lots of RAM, you might still run out of memory if you run a 32 bit executable or from the IDE.

You COULD try to build a 64 bit executable which would be able to address the bigger amount of RAM.

regards.
  1. Helpful
  1. Miguel Leeuwe
  2. Wednesday, 3 November 2021 16:06 PM UTC
I now also realize that you're running things in a repeated process. You say you reset the dw and do reset, but that it doesn't clear the memory. You might be "lucky" if it's some kind of bug / memory leak which might have been improved with later bug fixes in appeon.
  1. Helpful
There are no comments made yet.
Julian I. Accepted Answer Pending Moderation
  1. Thursday, 4 November 2021 08:25 AM UTC
  2. PowerBuilder
  3. # 6

DW.RESET()

After datawindow reset , including dataobject initialitation seems to freed memory

DW.DATAOBJECT = ""

Comment
  1. Miguel Leeuwe
  2. Thursday, 4 November 2021 09:32 AM UTC
Yes, that's one way of freeing up memory. Chris has mentioned this on various other posts.

So, if this has fixed your problems, please mark as resolved.

regards.
  1. Helpful 1
  1. Julian I.
  2. Thursday, 4 November 2021 17:57 PM UTC
Yes, I saw it on this forum.

Thanks !

  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.