Sunday, January 28, 2018

Behavior of think-time Functions in PeopleSoft

Some issues are uncommon, weird and hard to understand what exactly went wrong. One such weird issue in peoplesoft is related to Think-time functions. I know many of my colleagues who were stressed to the core and said ‘Its time to leave this planet’ because of this peculiar issue in Peoplesoft. Come!! Let’s sort this one out.

Think-time PeopleCode event (<think-time event>), but a SQL update has occurred in the commit interval.

In this article, let’s see what think-time functions are, and some of the limitations that require our attention when dealing with such functions.


Basically, any function that waits for user input or external process to complete is a think time function. Messagebox, for instance, waits for user to click Ok or Cancel button… Exec() function running in synchronous mode which suspends processing until the triggered process is complete.

Listed below are the think-time function in PS

  • DoCancel
  • DoModal
  • DoModalComponent
  • Exec(Only when it runs in Synchronous Mode)
  • AddAttachment, MAddAttachment, ViewAttachment, DetachAttachment
  • InsertImage, CropImage
  • CreateObject, ObjectDoMethod, ObjectSetProperty, ObjectGetProperty(When object Required User- action)
  • Prompt
  • RemoteCall
  • RevalidatePassword
  • WinExec(Only in Synchronous mode)
  • Winmessage and Messagebox(Depending on Style Parameter)
  • Calls to an External DLL

Think-time functions in Application Engine

Are you using Exec() or RemoteCall() in AE to run a batch file or a remote process? You should consider the following then:

Exec(&unixCmd, %Exec_Asynchronous + %FilePath_Absolute); /*Running in Asynchronous mode*/
&ExitCode = Exec(&unixCmd, %Exec_Synchronous + %FilePath_Absolute); /*Running in Synchronous mode*/

Running Exec() in Asynchronous mode is not a think-time function, as the AE process does not wait for the invoked command to complete. With Synchronous mode it is different, because the AE process needs to wait for the invoked command to complete. OH!! That’s Pathetic.. Don’t expect it to wait for you if you haven’t committed pending transactions, you will end up in think-time event error. 

The simple solution here is to issue a Commit before Exec() is invoked. If AE was written to be Restartable, then make sure that the previous step is committed before the step executing Exec. For AE with ‘Disable Restart’ checked, a CommitWork() has to be issued before Exec(). Easy right?

Think-time functions in Component Interface

Think-time functions are usually suppressed and ignored in CI. So, in such cases better to write a separate logic for CI.

If %CompIntfc then
/*Logic for CI*/
Else
/*Get user Input*/
End-if;

Think-time Functions in Peoplecode

Winmessage() and MessageBox() behaves as a think-time function only when the style parameter specifies more than one button. When you make the style parameter to show only Ok Button(0), then it behaves like a normal function. If style is neglected, Winmessage() displays both Ok and Cancel Button which acts as a think-time function. Hence you must always specify with style parameter like Winmessage(“Test Message”, 0) to show only Ok button.

Sometimes you would have noticed that your MessageBox or Winmessage does not work before call to a Transfer or TransferExact function. If you want to display your message, then change the style to show OK and Cancel Button.

It’s not so hard to debug when you receive error in peoplecode related to think-time functions. PeopleBooks suggests us not to use think-time functions in SavePreChange, Workflow, RowSelect, SavePostChange, and any peoplecode event that executes as a result of ScrollSelect, ScrollSelectNew, RowScrollSelect, or RowScrollSelectNew function call, and any peoplecode event that executes as a result of Rowset class Select or SelectNew method. If you are using think-time functions in one of the above events, just get red of it.



2 comments: