Tuesday, October 22, 2013

Understanding Oracle Forms timeout parameters (or should I say FORMS_TIMEOUT) FRM-92102 – A network error has occured

Alternate title: Why does my Oracle Form keep randomly disconnecting

Today I was at a client who was having trouble since there forms where disconnecting randomly after 15 minutes. They had tried to play around with the TIMEOUT  settings but they got bogged down in too many documents that pointed to more documents. I decided to post a quick guide to Oracle Forms timeout parameters. To help the community configure Forms sessions to time out after a specified period of user inactivity. Here I discuss the specific timeout parameters of Oracle Forms. For general web server timeout parameters you should look at note  294749.1  on Oracle Support – Troubleshooting WebForms Tuning / Performance /Time out Problems
Basically Oracle Forms 10g relies on 3 settings to control inactivity timeout.
1) FORMS_TIMEOUT environment variable:
This is an environment variable that is set in the env file found $ORACLE_HOME/forms/server/default.env. The default is et to use a file called default.env file  but this can be customized in the formsweb.cfg found in $ORACLE_HOME/forms/server/formsweb.cfg  to use .env files for each configuration in which case these should be modified instead of default.env.
Please note: The Forms environment variable FORMS_TIMEOUT is refered to as FORMS90_TIMEOUT in version IAS 9i and 10g R1 (9.0.4) it is in OAS 10g R2 (10.0.1.2) it is FORMS_TIMEOUT.
Add a row to the end of the file such as:
FORMS_TIMEOUT=30
The default value for forms timeout is 15 and Valid Values range from  3 to 1440 (1 day)
This parameter specifies the amount of time in elapsed minutes before the Form Services process is terminated when there is no client communication with the Form Services. Client communication can come from the user doing some work, or from the Forms Client heartbeat if the user is not actively using the form.
2) heartBeat applet parameter:
The heartBeat parameter is a feature of the applet and it is set in the formsweb.cfg file found in $ORACLE_HOME/forms/server/formsweb.cfg
This parameter is used to set the frequency at which a client sends a packet to the server to indicate that it is still running. We can define this integer value in minutes or in fractions of minutes, for example, 0.5 for 30 seconds. The default is two minutes.
Please note: If the heartbeat is less than FORMS_TIMEOUT, the user’s session will be kept alive, even if they are not actively using the form. HeartBeat is recommended to be at least 2 beats smaller than FORMS_TIMEOUT
In the formweb.cfg file add the following line to the configuration of your choise:
heartBeat=12
The default value for heartBeat is 2 and Valid Values range from  1 to 1440 (1 day)
3)The session-timeout  parameter of the forms servlet in the web.xml configuration file
This file defines the OC4J forms & listener servlet definitions, including servlet parameters and session configuration. The file is found
$ORACLE_HOME/j2ee/OC4J_BI_Forms/applications/formsapp/formsweb/WEB-INF/web.xml
The value of session-timeout refers to the maximum amount of inactivity that a single session can have before it is automatically invalidated by the server.
Please note: The value of should be the same as FORMS_TIMEOUT.
The following lines must be added to web.xml.
<web-app>
……
……
<session-config>
<!– Session timeout in minutes –>
<session-timeout>60

</session-config>
</web-app>
networkRetries applet parameter
Besides the above timeout parameters there are additional reasons that forms maybe disconnecting that are not timeout based but network related. Ususally they are prefaced by error FRM-92102: A network error has occurred. The Forms Client has attempted to reestablish its connection to the Server 5  time(s) without success.  This parameter specifies the number of times the Forms client should try reconnecting to the middle-tier before finally timing out. The Oracle Forms network connection to the server is a little picky it does not like being ignored. So as such if it tries to reach the server more than 5 times without response it dies. Although this would seem logical most of the time 5 seconds is just too little if we take into consideration that there maybe database performance issues or network waits.
To add tolerance to Forms patience thay have added a great parameter called ‘networkRetries’ to the forms configuration file $ORACLE_HOME/forms/server/formsweb.cfg.  Set the value of the networkretries parameter to a suitable number according your  network characteristics needed. For example, networkRetries=30.  If the error continues to occur even after setting up an appropriate value for networkRetries, you should check firewall and proxies that maybe blocking the applications server ports.
Some interesting links about this topic are:
Known Causes of FRM-92101 Error In Forms [Note: 604633.1 on Metalink]
Understanding How networkRetries Works [ID 332942.1]
Master note on Known Causes of FRM-92102 Error in Forms [ID 756369.1]

Adding an Exit All Button to Your Forms Menu / Toolbar

Alternative title: Eject me from the forms system fast! Close all forms without all those pesky validations.

This week a need arose at a customer site to exit all open forms (with one button click ) and return to the first form with the main menu.
This need may also arise when the user creates a large workflow of different forms calling each other but then wants to close all called forms with one button.
The steps are quite simple:
1) You begin by putting the following code in the WHEN-NEW-FORM-INSTANCE trigger of all the forms in the application
DEFAULT_VALUE(‘false’,'GLOBAL.closing’);
This will create a new global variable called “closing” in your forms system. This value will be false by default and it will be changed to true when the process to exit all has been triggered.
If you do not have a global program unit in your WHEN-NEW-FORM-INSTANCE trigger for all forms, then you will want to use one of the methods to update forms in batch that are available.   You can use either JDAPI or convert all forms to XML and add this code in Notepad++  ( for more information you can check out Blog posts: JDAPIConverting Forms to XML)
2) Next step is to check each form when the window is activated if we are in the process of exiting all or if we have reached the main form yet.  Here we want to test
(a) Is the global called “closing” set to true? If so we are in the middle of the exit all process
(b) Have we reached a form called . If so we have already arrived to the main navigation form.
To do this we put the following code in WHEN-WINDOW-ACTIVATED trigger of all system forms. Again this may be done in batch (see above)
:IF :GLOBAL.closing = ‘true’ AND GET_APPLICATION_PROPERTY (CURRENT_FORM_NAME) <> ‘
THEN
EXIT_FORM(NO_VALIDATE);
ELSE
:GLOBAL.closing := ‘false’;
END IF;
We do an exit all without form validation here. This means that if the form has not yet been saved, all changes that were done will be automatically saved. If this is not appropriate for your system then simply replaces the  EXIT_FORM (NO_VALIDATE) with EXIT_FORM(NO_VALIDATE,FULL_ROLLBACK) This will be the only way that the forms can close without user intervention. Since if the forms have outstanding changes that require validation it will prompt the users to correct or commit the changes.
Also in the above code don’t forget to replace with the name of the main menu or navigation form.
3) The final step in the process is of course how we start the exit all domino effect. This can be done by simply adding an exit all or close all button in the main menu or toolbar.
This button should appear on all forms so anywhere that is seen globally in all forms should be fine.
The code of the button should look like this:
:IF GET_APPLICATION_PROPERTY (CURRENT_FORM_NAME) <> ‘
THEN
:GLOBAL.closing := ‘true’;
EXIT_FORM(NO_VALIDATE);
END IF;
Again you can replace the exit_form command with what's appropriate for your system.
So that's it! As you can see, this is so simple the most time consuming part will be deciding what icon to put on the exit all button. Even here I can help. Check out the links below. :)