In
externally described data structure the structure of the data structure is
decided by the external definition used in the program. e.g. In the program
below file CUST has been used as a referenced external definition for the data
structure DS1. Also the data structure has further been modified with the
prefix ‘P’.

A program
status data structure (PSDS) can be defined to make program exception/error
information available to the program so that the necessary action can be taken
for the unhandled exception. The exception /errors can be Divide by zero, array index out-of-bound, Invalid Date,
Time or Timestamp value. The PSDS must be defined in the main source
section; therefore, there is only one PSDS per module.

We can see all the program/file related system messages
using the command below:

DSPMSGD RANGE(*FIRST *LAST) MSGF(QRNXMSG)
DETAIL(*BASIC)

The below table lists some of the commonly used
Status Codes.

MSG ID MESSAGE DETAIL
00100 Value out of range for string operation
00102 Divide by zero
00112 Invalid Date, Time or Timestamp value.
00121 Array index not valid
00122 OCCUR outside of range
00202 Called program or procedure failed
00211 Error calling program or procedure
00222 Pointer or parameter error
00401 Data area specified on IN/OUT not found
00413 Error on IN/OUT operation
00414 User not authorized to use data area
00415 User not authorized to change data area
00907 Decimal data error (digit or sign not valid)
01021 Tried to write a record that already exists (file being used has unique keys
and key is duplicate, or attempted to write duplicate relative record number to
a subfile).
01211 File not open.
01218 Record already locked.
01221 Update operation attempted without a prior read.

Status codes

*STATUSprovides a five-digit
status code that identifies the error. Program status codes are in the range
00100 to 00999 and File status codes are in the range 01000 to 01999. Status
codes in the range 00000 to 00050 are considered to be normal (i.e., they are
not set by an exception/error condition).

Here if
we don't use GOTO, the control will go to the same error statement and *pssr
will get executed again and again.To avoid looping we can use GOTO or can avoid
the *pssr to get executed for the 2nd time by using some count variable. If
count=1, don't execute the *pssr again.

*GETIN ==> *GETIN
(that is, the start of the mainline). Equivalent to 'G'

*CANCL ==>
equivalent to 'C'

VII.File information
data structure

A file information data
structure (INFDS) can be defined for each file to make file exception/error and
file feedback information available to the program.

0006.00 FLOAD_DSP CF E WORKSTN
0007.00 F SFILE(EXPD_SFL:RRN)
0008.00 F INFDS(infds)
0009.00 *
0010.00 Dinfds DS
0011.00 DRECNO 378 379I 0
0012.00 *____________________________________________________________________
0013.00 *______ In load-All subfile if we do PAGEDOWN and then press ENTER on
0014.00 *______ the page, by-default ENTER bring the display screen to the very
0015.00 *______ first page irrespective of the current page number. To avoid
0015.01 *______ this situation, we use file information data structure to get the
0015.02 *______ the current page RRN number and pass it to the SFLRCDNBR hidden
0015.02 *______ field defined in the display file DDS.
0016.00 *____________________________________________________________________

It is used in expandable subfile as illustrated below:

0006.00 FEXPD_DSP CF E WORKSTN
0007.00 F SFILE(EXPD_SFL:RRN)
0008.00 F INFDS(infds)
0009.00 *
0010.00 Dinfds DS
0011.00 DRECNO 378 379I 0
0012.00 *________________________________________________________________________
0013.00 *______ In Expandable subfile after PAGE UP if we press ENTER, then
0014.00 *______ the page displayed on the screen is the page that we had at our last
0015.00 *______ PAGEDOWN activity. E.g.- Suppose we are on page-3 after pressing 2
0015.01 *______ PAGEDOWN. From page-3 if we press 1 PAGEUP and then press ENTER, the
0015.02 *______ page to be displayed should be the 2nd page, but it is not the case.
0015.03 *______ In this case, the page that is displayed after pressing ENTER is 3rd
0015.04 *______ page which is the page no. that we got after the latest PAGEDOWN
0015.05 *______ activity. To avoid this situation, we use file information data
0015.06 *______ to get the current page RRN number and pass it to the SFLRCDNBR
0015.07 *______ hidden field defined in the display file DDS.
0016.00 *________________________________________________________________________