1. Karan Panchal
  2. PowerBuilder
  3. Monday, 30 September 2024 09:28 AM UTC
I have application whose Line of Code is around 4.5 million times. 
There is one column named as office_id whose value is getting changed to random value randomly. I am not able to find the exact sequence of the same.
I have tried putting logs in the code everywhere, but still not able to find the root cause.
I think it might be due to type conversion from long to double or decimal etc..

One thing which I am sure is that it is not being entered from the frontend by the user.
It is happening due to some code like setitem written in some function or passing of datawindow reference to other non visual objects. *Reproduce Steps: Can you provide me a quick way to deduce this? I am looking for a event/function which will be called automatically each time a setitem occurs,
So that I can backtrack it from there. Previously I used Messagebox as function_object to create a global function which will be invoked each time
a messagebox is called & there I had wrote custom logic. Now Is there any way I can customly code the setitem event/function?
Andreas Mykonios Accepted Answer Pending Moderation
  1. Monday, 30 September 2024 10:43 AM UTC
  2. PowerBuilder
  3. # 1

Hi.

Are you using inheritance for your datawindow controls? If yes, then you can modify setitem functions (there are 3 variants) in the (some) ancestor! If you are not using inheritance then this won't be an easy task.

But, are you sure you are always using setitem when setting a value? There is no possibility you used dot notation in some parts of your code?

Andreas.

Comment
  1. Karan Panchal
  2. Monday, 30 September 2024 10:58 AM UTC
Hello Andreas,



I don't know main root cause yet. (i.e. from where the value is being set, one thing I am sure about is that it is not being done from frontend.), I have a base object of type u_dw & from there I have inherited datawindows. For now value is being set anonymously & randomly thorugh code behaviour. I need a way such that whenever anywhere setitem is called, my custom function should also be called. Previously I have done the same for messagebox.



For Example: consider below code block



Decimal le_temp



dw_data.SetItem(row, 'office_id', le_temp)



I need a way that whenever such type of setitem is invoked there shall also be a custom function/event which should be triggered and from there I can decide whether to execute this call or not.





Previous example of Messagebox;

global type messagebox from function_object

end type



forward prototypes

global function integer messagebox (string as_title, string as_msg)

end prototypes



global function integer messagebox (string as_title, string as_msg);//supress message for silent mode

If gnv_app.ib_silent Then

gnv_app.of_set_errorlog(as_msg)

Else

Return MessageBox(as_title, as_msg, Information!, OK!, 1)

End If

end function





Whenever I write messagebox the above function gets called and from there the execution of the messagebox is defined. I need same way for setitem if possible
  1. Helpful
  1. Andreas Mykonios
  2. Monday, 30 September 2024 12:10 PM UTC
You can do that in the ancestor datawindow control. In it's object functions you should find 3 variants for setitem... You can write your own code there. To extend it (make it at some point call the original code) use:

super::setitem(<here you should pass arguments depending on variant>)

You can get the return value from parent with:

return ancestorreturnvalue

Andreas.
  1. Helpful
  1. Chris Pollach @Appeon
  2. Monday, 30 September 2024 13:51 PM UTC
Hi Andreas;

The primary buffer column could also be modified via a DOT Notation, Row Copy, Data share, etc mechanism as well as a SetItem(). The cause of the data change could be very hard to track down as all of the above do not trigger an event.

The only way that might work in narrowing down the timing of the column change might be to use a "Timing" object that runs a timer on the DC/DS for that holds the column in question & checks it's value - say on a 1 second time interval - until the corrupt value is found. Then at least that might give you an idea "when" the value gets corrupted. From there, correlate that to the process being performed at that time. Hopefully, narrowing down "where" in the App to look for the offending code

The caveate though could be an inline SQL command operating on that column operating in the DB directly.

HTH

Regards ... Chris
  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.