Skip to main content

Working with IBM i Exit Programs

What is an Exit Program?

An Exit program is a named unit of programming code that is executed when a particular condition occurs, such as one that requires some screening for authorization.

This may be part of an operating system or part of an application program.

In IBM i OS, an exit program is a supplemental security measure that controls user access to applications, and prevents access outside of authorized applications.

An AS/400 exit program (so called because the system exits to the program in the middle of a request from the user) is not used - as might be expected - to exit from a program, but to process user requests: it monitors user activity, checks to see if user requests comply with installation rules, and rejects those requests that contravene those rules.

How to Register Exit Programs?

To register an exit program with the registration facility, use the Work with Registration Information (WRKREGINF) command.

In addition to registering an exit program, it is necessary to restart the prestart jobs for a particular server.

+-------------------------------------------------------------------------------+
|                     Work with Registration Info (WRKREGINF)                   |
|                                                                               |
| Type choices, press Enter.                                                    |
|                                                                               |
| Exit point . . . . . . . . . . .   *REGISTERED                                |
| Exit point format  . . . . . . .   *ALL          Name, generic*, *ALL         |
| Output . . . . . . . . . . . . .   *             *, *PRINT                    |
|                                                                               |
+-------------------------------------------------------------------------------+

Press Enter to view the registered exit points.

+-------------------------------------------------------------------------------+
|                       Work with Registration Information                      |
|                                                                               |
| Type options, press Enter.                                                    |
|   5=Display exit point   8=Work with exit programs                            |
|                                                                               |
|                            Exit                                               |
|      Exit                  Point                                               
| Opt  Point                 Format    Registered  Text                         |
|  _   QIBM_QCA_CHG_COMMAND  CHGC0100     *YES     Change command exit programs |
|  _   QIBM_QCA_RTV_COMMAND  RTVC0100     *YES     Retrieve command exit progra |
|  _   QIBM_QHQ_DTAQ         DTAQ0100     *YES     Original data queue server   |
|  _   QIBM_QIMG_TRANSFORMS  XFRM0100     *YES                                  |
|  _   QIBM_QJO_DLT_JRNRCV   DRCV0100     *YES     Delete Journal Receiver      |
|  _   QIBM_QLZP_LICENSE     LICM0100     *YES     Original License Mgmt Server |
|  _   QIBM_QMF_MESSAGE      MESS0100     *YES     Original Message Server      |
|  _   QIBM_QMH_REPLY_INQ    RPYI0100     *YES     Handle reply to inquiry mess |
|  8   QIBM_QNPS_ENTRY       ENTR0100     *YES     Network Print Server - entry |
|  _   QIBM_QNPS_SPLF        SPLF0100     *YES     Network Print Server - spool |
|  _   QIBM_QOE_OV_USR_ADM   UADM0100     *YES     OfficeVision/400 Administrat |
|                                                                               |
| Command                                                                       |
| ===>                                                                          |
|                                                                               |
+-------------------------------------------------------------------------------+

Choose option 8 to work with the exit programs for the exit point defined for the server you would like to work with.

+-------------------------------------------------------------------------------+
|                            Work with Exit Programs                            |
|                                                                               |
| Exit point:   QIBM_QNPS_ENTRY            Format:   ENTR0100                   |
|                                                                               |
| Type options, press Enter.                                                    |
|   1=Add   4=Remove   5=Display   10=Replace                                   |
|                                                                               |
|               Exit                                                            |
|             Program     Exit                                                  |
| Opt          Number     Program        Library                                |
| 1_                      __________     __________                             |
|                                                                               |
|   (No exit programs found)                                                    |
|                                                                               |
+-------------------------------------------------------------------------------+

Use option 1 to add an exit program to an exit point.

Notes:

If an exit program is already defined, you must remove it before you can change the name of the program.
Even though the registration facility can support multiple user exits for a specific exit point and format name, the servers always retrieve exit program 1.
You must end and restart the prestart jobs for the change to go into affect.
+-------------------------------------------------------------------------------+
|                          Add exit program (ADDEXITPGM)                        |
|                                                                               |
| Type choices, press Enter.                                                    |
|                                                                               |
|Exit point . . . . . . . . . . . > QIBM_QNPS_ENTRY                             |
|Exit point format  . . . . . . . > ENTR0100      Name                          |
|Program number . . . . . . . . . > 1             1-2147483647, *LOW, *HIGH     |
| Program  . . . . . . . . . . . .  MYPGM         Name                          |
|   Library  . . . . . . . . . . .    MYLIB       Name, *CURLIB                 |
|THREADSAFE . . . . . . . . . . .   *UNKNOWN      *UNKNOWN, *NO, *YES           |
|Multithreaded job action . . . .   *SYSVAL       *SYSVAL, *RUN, *MSG,          |
|Text 'description' . . . . . . .   *BLANK                                      |
|                                                                               |
+-------------------------------------------------------------------------------+

Enter your program name and library for the program at this exit point.

Comments

Popular posts from this blog

All about READ in RPGLE & Why we use it with SETLL/SETGT?

READ READ is one of the most used Opcodes in RPGLE. As the name suggests main purpose of this Opcode is to read a record from Database file. What are the different READ Opcodes? To list, Below are the five Opcodes.  READ - Read a Record READC - Read Next Changed Record READE - Read Equal Key Record READP - Read Prior Record READPE - Read Prior Equal Record We will see more about each of these later in this article. Before that, We will see a bit about SETLL/SETGT .  SETLL (Set Lower Limit) SETLL accepts Key Fields or Relative Record Number (RRN) as Search Arguments and positions the file at the Corresponding Record (or Next Record if exact match isn't found).  SETGT (Set Greater Than) SETGT accepts Key Fields or Relative Record Number (RRN) as Search Arguments and positions the file at the Next Record (Greater Than the Key value). Syntax: SETLL SEARCH-ARGUMENTS/KEYFIELDS FILENAME SETGT  SEARCH-ARGUMENTS/KEYFIELDS FILENAME One of the below can be passed as Search Arguments. Key Fiel

What we need to know about CHAIN (RPGLE) & How is it different from READ?

CHAIN READ & CHAIN, These are one of the most used (& useful) Opcodes by any RPG developer. These Opcodes are used to read a record from file. So, What's the difference between CHAIN & READ?   CHAIN operation retrieves a record based on the Key specified. It's more like Retrieving Random record from a Database file based on the Key fields.  READ operation reads the record currently pointed to from a Database file. There are multiple Opcodes that start with READ and all are used to read a record but with slight difference. We will see more about different Opcodes and How they are different from each other (and CHAIN) in another article. Few differences to note.  CHAIN requires Key fields to read a record where as READ would read the record currently pointed to (SETLL or SETGT are used to point a Record).  If there are multiple records with the same Key data, CHAIN would return the same record every time. READE can be used to read all the records with the specified Ke

Extract a portion of a Date/Time/Timestamp in RPGLE - IBM i

%SUBDT Extracting Year, Month, Day, Hour, Minutes, Seconds or Milli seconds of a given Date/Time/Timestamp is required most of the times.  This can be extracted easily by using %SUBDT. BIF name looks more similar to %SUBST which is used to extract a portion of string by passing from and two positions of the original string. Instead, We would need to pass a value (i.e., Date, Time or Timestamp ) and Unit (i.e., *YEARS, *MONTHS, *DAYS, *HOURS, *MINUTES, *SECONDS or *MSECONDS) to %SUBDT.  Valid unit should be passed for the type of the value passed. Below are the valid values for each type. Date - *DAYS, *MONTHS, *YEARS Time - *HOURS, *MINUTES, *SECONDS Timestamp - *DAYS, *MONTHS, *YEARS, *HOURS, *MINUTES, *SECONDS, *MSECONDS Syntax: %SUBDT(value : unit { : digits { : decpos} }) Value and Unit are the mandatory arguments.  Digits and Decimal positions are optional and can only be used with *SECONDS for Timestamp. We can either pass the full form for the unit or use the short form. Below i