Creating User Exits in Forms 11G on Unix

Creating User Exits in Forms 11G on Unix

Creating User Exits in Forms 11G on Unix

Titleimage

Posted by Patrick Hamou on 2017:09:06 14:30:55

APPLIES TO:

Oracle Forms - Version 11.0.0 and later
Information in this document applies to any platform.

SCOPE

Developer

DETAILS

Starting with Forms 11G, the implementation of User Exits has changed and has been simplified. We now support dynamic library linking on Unix platforms and there is no need to relink the Forms executable. In previous versions the iapxtb table/array was used to hold pointers to the user exits and the ue_xtb.c file was updated with the list of user exits. However, with dynamic linking the iapxtb[] mechanism is deprecated and we now use the FORMS_USEREXITS parameter to point to the shared library. Below are the steps for setting up a sample User Exit on Unix. The sample code adds two numbers and returns the sum.

1) To set up the sample user exit on Unix we need the following files all copied into the same directory:

UE.H

UE_SAMP.PC

UE_SAMP.FMB

ue.h is the header file and defines the failure and success return codes (FATAL_ERR, FAILURE, and SUCCESS) that the user exit returns.

ue_samp.pc contains sample user exit code which contains a function that takes two numbers from the form, adds them and returns the result.

ue_samp.fmb is the sample user exit form.

These files can be downloaded from OTN at this location:

11g User Exit Files


2) Precompile and compile the user exit code.

NOTE:  The proc precompiler version used should match the Required Support File (RSF) version of Forms.  For 11gR1 and 11gR2 this is 11.1.0.7.  The appropriate proc precompiler for Forms can be found in the Forms ORACLE_HOME/bin.



Example commands for Linux 32bit to precompile and compile:

proc ue_samp.pc 
  -- This creates the ue_samp.c file which needs to be compiled
gcc -c ue_samp.c 
  -- This creates the ue_samp.o file

Example commands for Linux 64bit to precompile and compile:

proc ue_samp.pc 
  -- This creates the ue_samp.c file which needs to be compiled
gcc -c -fPIC -o ue_samp.o ue_samp.c 
  -- This creates the ue_samp.o file

3) Create the shared library.

Example command for Linux 32bit to create the shared library:

ld -shared -o ue_samp.so ue_samp.o 
  -- This creates the ue_samp.so shared library

Example command for Linux 64bit to create the shared library:

gcc -shared -o ue_samp.so -L. ue_samp.o 
  -- This creates the ue_samp.so shared library


4) Set the FORMS_USEREXITS parameter in the default.env to point to the ue_samp.so shared library.

5) Compile the UE_SAMP.FMB and run the form.

--The UE_SAMP.FMB file contains code in the POST-TEXT-ITEM trigger that calls the 'addtwo' function.


Enter a number in the first item, tab to the second item, enter a number and then tab to the third item to get the sum of the two numbers.

 

Note: While upgrading ancient code, usage of sqliem is no longer possible, linking will fail: oraSQX11.LIB(sqliem.obj) :error LNK2001: unable to resolve symbol _exiterr
 

Instead, use the EXEC TOOLS MESSAGE statement to pass a message from a user exit to Oracle Forms. The message is displayed on the Oracle Forms message line after the user exit returns control to the form. To code the EXEC TOOLS MESSAGE statement, you use the syntax

EXEC TOOLS MESSAGE message_text [severity_code]; 

where message_text is a quoted string or a character host variable (prefixed with a colon), and the optional severity_code is an integer constant or an integer host variable (prefixed with a colon). The MESSAGE statement does not accept indicator variables. In the following examples, your user exit passes error messages to Oracle Forms:

.../...
exec sql begin declare section;
   .../...
   static char MsgToForms [ 200 ];
exec sql end declare section;
.../...
  strcpy(:MsgToForms , "A Message" );
  EXEC TOOLS MESSAGE :MsgToForms;
  EXEC TOOLS MESSAGE 'Another message';
.../...

Posted by Patrick Hamou on 2017:09:06 14:30:55

Return to Blog