1. Tracy Lamb
  2. PowerBuilder
  3. Monday, 26 September 2022 22:51 PM UTC

My again... this is still giving me trouble I didn't notice before...

When I drag/drop from one SalesOrder to another, I have to change the sales_order in the database, and assign a new line number.  After that, I update both the current dw and the source dw.  But for some reason the updates aren't happening... WorkOrders don't move to new SalesOrder.  On the screen, everything seems to have worked just fine.  If I close both SalesOrder windows and re-open them, the original WorkOrders are still there (ie: They didn't move).  Must be something wrong with my logic... but I can't figure it out.

CHOOSE CASE drag_dw
	CASE this
                ... Do stuff
		this.Drag(End!)
	CASE ELSE
//		 Move the Work Order from the source Sales Order to this one...
		ll_DragRow = drag_dw.GetSelectedRow( 0 )
		ll_DropRow = this.RowCount() + 1
		drag_dw.RowsCopy( ll_DragRow, ll_DragRow, Primary!, this, ll_DropRow, Primary! )
		
		this.SetItem( ll_DropRow, "sales_order", il_FormID )
		//	Add line_nbr to new row
		this.SetItem( ll_DropRow,"line_nbr", ll_DropRow)
		this.SetItemStatus( ll_DropRow, 0, Primary!, DataModified! )
		this.SelectRow(0, FALSE)
		this.ScrollToRow(ll_DropRow)
		this.SelectRow(ll_DropRow, TRUE)

//		 Renumber the lines on the Source DW
		drag_dw.RowsDiscard( ll_DragRow, ll_DragRow, Primary! )
		ll_LastRow = drag_dw.RowCount()
		ll_ThisRow = ll_DragRow
		do while ll_ThisRow <= ll_LastRow
			drag_dw.SetItem( ll_ThisRow, "line_nbr", ll_ThisRow )
			ll_ThisRow ++
		loop
		drag_dw.SelectRow(0, FALSE)
		drag_dw.Drag(End!)
END CHOOSE

this.Update(TRUE,TRUE)
drag_dw.Update(TRUE,TRUE)

Any help is greatly appreciated.

~~~Tracy

 

Accepted Answer
Tracy Lamb Accepted Answer Pending Moderation
  1. Wednesday, 28 September 2022 17:07 PM UTC
  2. PowerBuilder
  3. # Permalink

Ok, this was getting a little hairy.  My MDI app allows several instances of the SalesOrder window to be opened at once.  Made tracing virtually impossible.  I just went back to the old way of doing things, that's worked for 20+ years.

1. Removed the ue_mouse_move event , tied to the pbm_dwnmousemove event
2. Copied the old code to the Other, DragDrop and DragWithin events.

Thanks all for your assistance and great ideas.  

~~~Tracy

Comment
  1. Tracy Lamb
  2. Friday, 30 September 2022 13:08 PM UTC
FWIW: I made another change/improvement. I put the original ue_mouse_move event back in, and took out the Other event. And, I changed the code/process so if a user wants to re-arrange the rows, he just uses the up/down arrow keys. And the dragdrop event only fires if the source dw is different from the destination dw (same data object). This way, the dragdrop event is only used to move a WorkOrder between different SalesOrders.

~~~Tracy
  1. Helpful
There are no comments made yet.
Mark Goldsmith Accepted Answer Pending Moderation
  1. Tuesday, 27 September 2022 01:23 AM UTC
  2. PowerBuilder
  3. # 1

Hi Tracy,

I'm thinking that the title of your question should be "DragWithin event doesn't update database", but we'll see lol. Am I correct to assume that each datawindow is tied to a separate table, those being WorkOrders and SalesOrder? Regardless, why are you changing the ItemStatus to DataModified!? Upon first doing a RowsCopy() the ItemStatus is set to NewModified! and, assuming this record will be new to the SalesOrder table, which would be consistent with your code comment "// Add line_nbr to new row", the ItemStatus should stay as NewModified!. The record does not yet exist in that table and as such there is no record to update yet, it needs to be inserted first. That might explain things for the SalesOrder table...now, what's going on with the WorkOrders table!?

When you issue a RowsDiscard() it does not move the row to the Delete buffer...the row is actually not in any buffer and gone forever from the datawindow (unless you re-retrieve it from the table). Therefore, there will be no equivalent SQL generated in order to delete that record from the WorkOrders table in the database. RowsDiscard() should be replaced with a DeleteRow() call which will place it in the Delete buffer and then will update the database table correctly.

Some of my assumptions may be wrong but HTH...regards,

Mark

Comment
  1. Roland Smith
  2. Tuesday, 27 September 2022 17:38 PM UTC
In the registry:

HKEY_CURRENT_USER\SOFTWARE\Sybase\PowerBuilder\21.0

Value InitPath: c:\users\<youruserid>\appdata\local\appeon\powerbuilder 21.0
  1. Helpful 2
  1. Tracy Lamb
  2. Tuesday, 27 September 2022 18:05 PM UTC
Thank you Roland! That fixed it! Never thought to look under Sybase. Will update my other question with the solution.
  1. Helpful
  1. Chris Pollach @Appeon
  2. Tuesday, 27 September 2022 18:21 PM UTC
FYI: Sorry Tracy ... Appeon has not yet revised the key high level registry folder from Sybase to Appeon as Engineering initially found that the Sybase registry path was used all over the PB IDE and PB runtime DLL's.
  1. Helpful
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Monday, 26 September 2022 23:41 PM UTC
  2. PowerBuilder
  3. # 2

Hi Tracy;

  May I suggest using an SQL Trace.

The debugger is your friend.  ;-)

Regards ... Chris 

Comment
  1. Tracy Lamb
  2. Tuesday, 27 September 2022 19:38 PM UTC
I created a trace file, trace.pbp... How can I view a pbp file? I tried Notepad, but it's all gibberish.
  1. Helpful
  1. John Fauss
  2. Tuesday, 27 September 2022 20:03 PM UTC
I believe you created a Profiling trace instead of a database activity (SQL) trace. To create a SQL trace, simply preface the value assigned to SQLCA.DBMS with the keyword "TRACE". For example, SQLCA.DBMS = "TRACE SNC".

To view a Profiling trace, you can use one of the three Profiling xxx View" tools listed in the Tool tab of the dialog that appears when you click the "New" toolbar button in the PB IDE.
  1. Helpful 1
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.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.