1. Aron Cox
  2. PowerBuilder
  3. Thursday, 19 May 2022 10:32 AM UTC

PowerBuilder 2019 R3 build 2728

Windows 10

 

I am having a silly isue that is probably all my fault, but I can't seem to work it out. I am exporting four datastores to an XML file using this command

 

   ads.SaveAs(as_file, XML!, true, EncodingUTF16LE!)

 

and then importing them back into the same datastore at later date using this command

 

   ll_ret = ads.ImportFile(XML!, as_file)

 

Three of them work just fine but one of them returns -4 in ll_ret. So I turned on XML import tracing in the datawindow properties and got a log file that has this at the top (Note, I am not using XML templates anywhere)


/*---------------------------------------------------*/
/* 19/05/2022 10:52 */
/*---------------------------------------------------*/
CREATING SAX PARSER.
NO XML IMPORT TEMPLATE SET - STARTING XML DEFAULT IMPORT.
DATAWINDOW ROWSIZE USED FOR IMPORT: 42

and then lists every element in the file with no error messages that I can see. The last item in the list appears to match the list item in the XML.

 

Anyone have any idea what I'm doing wrong? The file has been exported, not toucjed and then is imported, surely that should be safe to do???

 

Thanks!

Accepted Answer
Aron Cox Accepted Answer Pending Moderation
  1. Wednesday, 15 June 2022 16:09 PM UTC
  2. PowerBuilder
  3. # Permalink

Well I've got it working by not using XML but instead saving the data using dw_1.object.datawindow.data the loading it in using ImportFile with Text!

No idea why it didn't work with XML formatted data but at least it's working now.

Comment
  1. Miguel Leeuwe
  2. Wednesday, 15 June 2022 17:47 PM UTC
Thanks for sharing the solution!
  1. Helpful
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Thursday, 19 May 2022 13:02 PM UTC
  2. PowerBuilder
  3. # 1

Hi Aaron;

   Try this instead ...  ads.SaveAs ( as_file, XML!, False, EncodingUTF16LE! )

HTH

Regards ... Chris

Comment
  1. Aron Cox
  2. Thursday, 19 May 2022 15:10 PM UTC
Yeah it didn;t make any difference :(
  1. Helpful
  1. Chris Pollach @Appeon
  2. Thursday, 19 May 2022 15:27 PM UTC
Weird ... I do this XML Export/Import in my framework all the time wit no issues. However, if you create a DWO and also store some test data within it - then export the DWO syntax for us to test with. Maybe we can spot the issue that you are having. ;-)
  1. Helpful 1
  1. Aron Cox
  2. Friday, 20 May 2022 15:00 PM UTC
Thanks Chris, Unforunately I have been given some urgent work to do, I'll be back in a few days or so!
  1. Helpful
There are no comments made yet.
Aron Cox Accepted Answer Pending Moderation
  1. Thursday, 19 May 2022 15:16 PM UTC
  2. PowerBuilder
  3. # 2

I'm now thinking it has something to do with the datawindow being grouped. There are 5 groups. Perhapos I need to export and improt usiang a template, if I can work out how that works.

Comment
  1. Brad Mettee
  2. Friday, 20 May 2022 14:50 PM UTC
Grouping shouldn't make any difference. That's a visual display type option, the data in the individual rows stays the same.



Have you checked to see that there's not another DW in the app, in a diff pbl, with the same name?



For testing, when you get the -4 error, insert a row into the DW, and export it immediately after. Compare the column list with the one that fails.
  1. Helpful 1
  1. Aron Cox
  2. Friday, 20 May 2022 14:59 PM UTC
Thanks, I've create a new workspace with just a new window and the datawindow in question and it's failing to import but as it's now a datawindow and not a datastore I'm getting a bunch of validation errors. I checked the dataobject on export and import match, but now I have an urgent bunch of coding to do as real life makes it's way back in.



Thanks for your help, I'll be back in a few days or so to try again.
  1. Helpful
There are no comments made yet.
Aron Cox Accepted Answer Pending Moderation
  1. Wednesday, 15 June 2022 11:15 AM UTC
  2. PowerBuilder
  3. # 3

Well I finally have some time to look at this again. This time I saved the datawindow syntax just before the SaveAs and just before the ImportFile. The syntax is identical, so at least I'm not making the rookie mistake of having two different dataobjects :-)

I will do some more experimenting, but can anyone think of a reason why a SaveAs to XML shouldn't import to the same dataobject with an ImportFile?

Thanks.

Comment
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.