1. Roland Smith
  2. PowerBuilder
  3. Monday, 14 February 2022 19:10 PM UTC

PB 2019 Build 2170. The following code gives -1 from the RowsCopy. The datawindow ldw_Export has 161 rows with 297 columns. The first 14 columns are string or long, the remainder are decimal(2).

ldw_Export is a reference to a visible DataWindow on a different window that was passed inside a generic references object. Our app suffers from excessive object orientation.

DataWindow ldw_Export, ldw_Filtered

... code to set ldw_Export to a datawindow control ...

ldw_Filtered = Create DataWindow
ldw_Filtered.DataObject = ldw_Export.DataObject


li_rc = ldw_Export.RowsCopy(1, ldw_Export.RowCount(), &
                 Primary!, ldw_Filtered, 1, Primary!)

 

It seems simple enough, why wouldn't this work?

 

Olan Knight Accepted Answer Pending Moderation
  1. Monday, 14 February 2022 23:35 PM UTC
  2. PowerBuilder
  3. # 1

Roland -

   You are not on drugs, the RowsCopy () built-in PowerBuilder function has not worked for me since PBv11.5. I have tried and tried to get it working - all to no avail. This is the case in both PBv11.5 and in PB2019R3. I gave up on this function long ago.

   I simply have to use other methods.


Later -

Olan

Comment
  1. Roland Smith
  2. Tuesday, 15 February 2022 14:33 PM UTC
We give the user the ability to choose which columns are visible or hidden. Unfortunately the updated visible property doesn't carry forward during a rowscopy. Right now I am just using SetFilter/Filter/Sort and then resetting the filter at the end. I might try using GetFullState to make a copy and then use SetFullState to restore it when done. A lot of the datawindow objects have sort order only in the SQL.
  1. Helpful
  1. René Ullrich
  2. Tuesday, 15 February 2022 14:44 PM UTC
I think you have to change from datawindow to datastore for your Filter-DW as Chris already wrote. Problem is that you can't use CREATE for datawindows (without loosing functionality).
  1. Helpful
  1. mike S
  2. Tuesday, 15 February 2022 15:00 PM UTC
do a (dwo) create using the sql syntax instead of .dataobject = .dataobject, then you get the visible and all other properties.
  1. Helpful
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Monday, 14 February 2022 21:11 PM UTC
  2. PowerBuilder
  3. # 2

Maybe another solution would be to do a Get-/SetFullState() ?

 

Comment
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Monday, 14 February 2022 20:46 PM UTC
  2. PowerBuilder
  3. # 3

Hi Roland;

  You cannot do a CREATE on a DataWindow Control.  You can perform an OpenUserObject though for a DWC instantiation. From your code snippet though, you need to use a DataStore for the CREATE.

Regards ... Chris

Comment
  1. mike S
  2. Monday, 14 February 2022 21:05 PM UTC
yeah, the create is probably why it returned -1. and yeah, datastore is what you want for holding you copied data.
  1. Helpful
There are no comments made yet.
mike S Accepted Answer Pending Moderation
  1. Monday, 14 February 2022 19:22 PM UTC
  2. PowerBuilder
  3. # 4

is rowcount() > 0 ?

 

are you 100% sure the dataobject is valid and the datawindow wasn't changed?

 

-----

if you grab/set the syntax instead of the dataobject then you get the current syntax.  very useful if your source is a datawindow syntax stored in database, or if you modify it:

ls_syntax = ldw_Export.object.datawindow.syntax
ldw_Filtered.create( ls_syntax, ls_error)

Comment
  1. Roland Smith
  2. Monday, 14 February 2022 19:47 PM UTC
Yes, 161 rows. I walked through the debugger and the second datawindow appeared to be created properly.



I'll try your idea.
  1. Helpful
  1. Roland Smith
  2. Monday, 14 February 2022 19:59 PM UTC
The create returned -1 and nothing in ls_error.

I realized that I need to filter the main datawindow anyway. I'm doing a EPPlus Excel export where the dataset is broken out into tabs. Making a copy of the data in another datawindow control doesn't preserve all the properties I need. I posted about this last week.
  1. Helpful
There are no comments made yet.
Roland Smith Accepted Answer Pending Moderation
  1. Monday, 14 February 2022 19:12 PM UTC
  2. PowerBuilder
  3. # 5

The reason for the RowsCopy is that I need to filter the data for processing without effecting the original datawindow.

 

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.