Exception Handling: Overview
Exception Handling: Overview
Day 16
Exception Handling:
Overview:
This module enables the student to understand the concept of Exception handling.
Outline:
Topics covered,
Input Specication !I"DS, I"#$, I"%&
Data structure
'ile information data structure
"rogram status data structure
Objective:
(y the end of this module, the student should be able to understand)
Data structure
I%'DS, I%'S* and +"SS* data structure
, Du-eStar Technologies "vt. .td. 1/16
No part of this document can be copied, reproduced in any form, complete or partial without written consent from DukeStar Technologies Pvt.
Ltd.
Exception Handling
Day 16
Data Structure:
The *"0/122 program allo3s you to dene an area in storage and the layout of the elds,
called subelds, 3ithin the area. This area in storage is called a data structure.
4ou can use a data structure to)
Dene the same internal area multiple times using di5erent data formats
6perate on a eld and change its contents
Divide a eld into subelds 3ithout using the 768E or 768E. operation codes
Dene a data structure and its subelds in the same 3ay a record is dened
Dene multiple occurrences of a set of data
0roup non9contiguous data into contiguous internal storage locations.
In addition, there are three special data structures, each 3ith a specic purpose)
: data area data structure !identied by a ; in position 1< of the data structure
statement&
: le information data structure !referred to by the -ey3ord I%'DS on a le
description specications continuation line&
: program9status data structure !identied by an S in position 1< of the data
structure statement&.
Data structures can be program9described or externally described.
Data Structure Statement Specifications
Data structure statements are dened on the input specications and must follo3 all input
specications for records. The specications for data structure statements are)
Position Entry
6 I
=91>
Name of the data structure being defined. This entry is optional for a program-described data
structure, and is required for an externally described data structure, a file information data
structure (INFD!, and a data area data structure.
1?916
"lan#
1=
"lan#$ %rogram-described data structure.
&$ &xternally described data structure. The data structure subfields definitions are retrie'ed
from an externally described record format.
1<
"lan#$ (ther than a program status, data area or initiali)ed data structure.
I ) *lobally initiali)ed data structure.
$ %rogram-status data structure.
+ $ Data area data structure.
, Du-eStar Technologies "vt. .td. >/16
No part of this document can be copied, reproduced in any form, complete or partial without written consent from DukeStar Technologies Pvt.
Ltd.
Exception Handling
Day 16
,--./ DS
.,-0/ "lan#$ The data structure is program described.
&ntry$ This is the name of the file 1hose first record format contains the field descriptions used
as the subfields descriptions for this data structure.
0,-20 "lan#
22-23 "lan#$ 4 single occurrence data structure.
nnnn$ 4 number (right-ad5usted! indicating the number of occurrences
(f the data structure.
Note: This entry must be blan# for a data area data structure, a file
Information data structure, and a program-status data structure.
26-7, 8ength of data structure (optional!. This entry must be right ad5usted.
7.-32 "lan#
Rules for Specifying Data Structure Statements
Remember the following when you specify data structure statements:
The data structure name must be a symbolic name 3ith a maximum of six
characters. The name can appear on only one data structure specication, cannot
be a loo- ahead eld, and can be specied any3here a character eld is allo3ed.
:ll entries for one data structure and its subelds must appear together@ they
cannot be mixed 3ith entries for other data structures.
The data structure length is determined by the rst specication in the program
that denes a length in one of the preceding 3ays. SubseAuent conBicting lengths
are incorrect. The length of a data structure is one of the follo3ing)
o The length specied in the input9eld specications if the data structure
name is an input eld
o The length specied in positions 1< through C1 of the data structure
statement
o The highest To position of a subeld 3ithin a data structure if the data
structure name is not an input eld.
: compile9time or prerun9time array cannot be used in a data area data structure or
in a multiple9occurrence data structure.
Data structures are character data and can be from 1 to DDDD characters in length.
: data structure and a subeld of a data structure cannot have the same name.
Special Data Structures
Special data structures include)
, Du-eStar Technologies "vt. .td. ?/16
No part of this document can be copied, reproduced in any form, complete or partial without written consent from DukeStar Technologies Pvt.
Ltd.
Exception Handling
Day 16
Data area data structures
'ile information data structures !I%'DS&
"rogram9status data structures
Data !rea Data Structure
: data area data structure, identied by a ; in position 1< of the data structure statement,
indicates to the *"0/122 program that it should read in and loc- the data area of the same
name at program initialiEation and should 3rite out and unloc- the same data area at the
end of the program. Data area data structures, as in all other data structures, have the
type character. : data area read into a data area data structure must also be character.
The data area and data area data structure must have the same name unless you rename
the data area 3ithin the *"0/122 program by using the +%:78:* DE'% statement.
4ou can specify the data area operations !I%, 6;T, and ;%.FG& and have the type for a
data area that is implicitly read in and 3ritten out. (efore you use a data area data
structure 3ith these operations, you must specify that data area in the result eld of the
+%:78:* DE'% statement. : data area data structure cannot be specied in the result
eld of a ":*7 operation. If you specify blan-s for the data area data structure !positions =
through 1> of the input specications line that contains a " in position 1<&, the *"0/122
program uses a local data area. To provide a name for a local data area, use the +%:78:*
DE'% operation, 3ith +.D: in factor > and the name in the result eld. If data structure
name entry is blan- then the local data area is used.
This data area either you can create using F*TDT::*: command or if not created by you
then system 3ill create it in HTE7" library at the start of Iob and 3ill delete it at the end of
the Iob.
'ollo3ing example sho3s ho3 3e divide elds using subelds using Data :rea Data
Structure)
Step #:
Freate data area using F*TDT::*: command on command line and press '1)
Create Data Area (CRTDTAARA)
Type choices, press Enter.
Data area . . . . . . . . . . . *DTA1 Name
Library . . . . . . . . . . . *CURLI Name, *CURLI
Type . . . . . . . . . . . . . . *DEC, *C!AR, *L"L, *DD#
ottom
$%&E'it $(&)rompt $*&Re+resh $1,&A--itiona. parameters $1/&Cance.
$1%&!o0 to 1se this -isp.ay $/(&#ore 2eys
Step $:
Jrite data area as KDT:1L 3hich is data area name, library name and provide data area
type +FM:*.
Data area is having % types)
, Du-eStar Technologies "vt. .td. 1/16
No part of this document can be copied, reproduced in any form, complete or partial without written consent from DukeStar Technologies Pvt.
Ltd.
Exception Handling
Day 16
Decimal !+DEF&
Fharacter !+FM:*&
.ogical !+.0.&
Step%: after inserting above information press '12 to ll additional attributes li-e data
areas length as sho3n belo3)
Create Data Area (CRTDTAARA)
Type choices, press Enter.
Data area . . . . . . . . . . . 3 DTA1 Name
Library . . . . . . . . . . . 3 PB01U010 Name, *CURLI
Type . . . . . . . . . . . . . . 3 *CHAR *DEC, *C!AR, *L"L, *DD#
Len4th5
Len4th . . . . . . . . . . . . 20 16/,,,
Decima. positions . . . . . . ,67
Initia. 8a.1e . . . . . . . . .
Te't 9-escription9 . . . . . . . *LAN:
A--itiona. )arameters
A1thority . . . . . . . . . . . *LICRTAUT Name, *LICRTAUT, *C!AN"E...
ottom
$%&E'it $(&)rompt $*&Re+resh $1/&Cance. $1%&!o0 to 1se this -isp.ay
$/(&#ore 2eys
"ress enter to create dta1 in library pb21u21o.
Step &:
Jrite simple *"0 program to see ho3 Data :rea DS is dene or use in *"0.
To dene Data :rea DS use the prompt as given belo3)
Co.1mns . . . 5 1 ;1 E-it ),1U,1<=#>R)"
<EU&&3 DAD<1
$#T D< .....IDsname....N?DsE't6+i.e@@.............?ccrLen@....................
*************** e4innin4 o+ -ata *************************************
,,,,.,1 * U<E I)D< )R?#)T !AAIN" BUC AT BOPTIONC T? DE$INE DATA AREA D<.
,,,1.,, IDTA1 UDS
)rompt type . . . D< <eD1ence n1mber . . . ,,,1.,,
Data <tr1ct E'terna.
Name N1mber ?ption D< $i.e Name ?cc1rs Len4th
DTA1 U DS
$%&E'it $(&)rompt $*&Re+resh $11&)re8io1s recor-
$1/&Cance. $/%&<e.ect prompt $/(&#ore 2eys
See the follo3ing KI"#L prompt 3here to dene the attributes of subeld.
, Du-eStar Technologies "vt. .td. C/16
No part of this document can be copied, reproduced in any form, complete or partial without written consent from DukeStar Technologies Pvt.
Ltd.
K;L is for Data :rea DS
Data area name created using KF*TDT::*:L
command
Exception Handling
Day 16
'() )
"ositions %ame Entry
=91> (lan-
1? Data format (lan-
"
(
.
*
1191= 'rom 19DDDD
1<9C1 To 19DDDD
C> Decimal positions (lan-
29D
C?9C< 'ield name Symbolic name
CD962 Fontrol .evel (lan-
.19.D
6196> 7atch elds (lan-
7197D
6?961 'ield record relation (lan-
219DD
.19.D
7*
;19;<
M19MD
*T
6C9=2 'ield indicators (lan-
219DD
M19MD
;19;<
*T
=19=1 (lan-
=C9<2 Fomments 6ptional
Co.1mns . . . 5 1 ;1 E-it ),1U,1<=#>R)"
<EU&&3 DAD<1
$#T D< .....IDsname....N?DsE't6+i.e@@.............?ccrLen@....................
*************** e4innin4 o+ -ata *************************************
,,,,.,1 * U<E I)D< )R?#)T !AAIN" BUC AT BOPTIONC T? DE$INE DATA AREA D<.
,,,1.,, IDTA1 UD<
,,,,.1, * U<E I)E )R?#)T T? DE$INE <U$IELD< ?$ DATA AREA D<.
,,,/.,, I 1 F/A#T1
)rompt type . . . J <eD1ence n1mber . . . ,,,/.,,
Decima. $ie.- Contro. #atchin4
)==L=R $rom To )ositions Name Le8e. $ie.-s
1 6 2 AMT1
$ie.- Recor- )ositi8e Ne4ati8e Gero =
Re.ation $ie.- $ie.- .an2
$%&E'it $(&)rompt $*&Re+resh $11&)re8io1s recor-
$1/&Cance. $/%&<e.ect prompt $/(&#ore 2eys
, Du-eStar Technologies "vt. .td. 6/16
No part of this document can be copied, reproduced in any form, complete or partial without written consent from DukeStar Technologies Pvt.
Ltd.
Exception Handling
Day 16
Dene other elds K:7T>L and KS;7L using same prompt KI"#L as sho3n belo3. ;se
+%:78:* dene data area KDT:1L and initialiEe values 122 and >22.>2 to elds :7T1 and
:7T> respectively. :dd this amount to variable or subeld S;7.
Co.1mns . . . 5 1 ;1 E-it ),1U,1<=#>R)"
<EU&&3 DAD<1
$#T D< .....IDsname....N?DsE't6+i.e@@.............?ccrLen@....................
*************** e4innin4 o+ -ata *************************************
,,,,.,1 * U<E I)D< )R?#)T !AAIN" BUC AT BOPTIONC T? DE$INE DATA AREA D<.
,,,1.,, IDTA1 UD<
,,,,.1, * U<E I)E )R?#)T T? DE$INE <U$IELD< ?$ DATA AREA D<.
,,,/.,, I 1 F/A#T1
,,,%.,, I ; 1//A#T/
,,,(.,, I 1% /,/<U#
,,,*.,, C *NA#AAR DE$N DTA1
,,,F.,, C G6ADD1,, A#T1
,,,;.,, C G6ADD/,,./, A#T/
,,,H.,, C A#T1 ADD A#T/ <U#
,,,7.,, C *L?C: ?UT DTA1
,,1,.,, C UNLC:DTA1
,,11.,, C <U# D<)L>
,,1/.,, C <ET?N LR
****************** En- o+ -ata ****************************************
$%&E'it $(&)rompt $*&Re+resh $7&Retrie8e $1,&C1rsor $11&To44.e
$1F&Repeat +in- $1;&Repeat chan4e $/(&#ore 2eys
Exception or error handling:
In any application development exception/error handling plays a very important role. The
errors can occur at any time 3hile running the application program. Therefore, you as a
programmer should be capable of handling such errors rather than allo3ing them to
abnormally end the program itself. The term exception tells about the study of various
error conditions and error handling implies detecting and correcting errors.
*"0/122 provides 'ile Information Data Structure !I%'DS&, le exception/error subroutine
!I%'S*&, program status data structure and program exception/error subroutine !+"SS*& for
exception/error handling.
I%'S* is used 3ith +"SS* is used to nd le level exception and only program level
exception are handle by "rogram Status Data Structure using +"SS*.
Jhen error code is greater than DD then user can able to use +"SS* routine. 6ther 3ise
user have to use simple subroutine to handle the exception.
*hese are some error codes which are use to handle the error
*!+,E 'I.E E**6* F6DES
-OR.!, /O-D'*'O-S
/ODES .E!-'-0
22222 %o exception/error occurred.
2222> 'unction -ey used to end display.
22211 End of le on a read !input&.
2221> %o record found on a FM:I%, SET0T, SET.. operation.
2221? Suble is full on a 3rite operation.
E1/E(*'O-2ERROR /O-D'*'O-S
21211 ;ndened record type !input record does not match
record9identifying indicator&.
, Du-eStar Technologies "vt. .td. =/16
No part of this document can be copied, reproduced in any form, complete or partial without written consent from DukeStar Technologies Pvt.
Ltd.
Exception Handling
Day 16
212>1 Tried to 3rite a record that already exists!le being used
has uniAue -eys and -ey duplicate, or attempted to use
duplicate relative record number to a suble&.
212?1 7atch eld out of seAuence.
21211 :rray/table load seAuence error.
212C1 Excess entries in array/table le.
212=1 %umeric seAuence error.
211>1 %o indicator on the DDS -ey3ord for "rint Gey
211>> %o indicator on the DDS -ey3ord for *oll ;p Gey.
211>? %o indicator on the DDS -ey3ord for *oll Do3n -ey.
211>1 %o indicator on the DDS -ey3ord for Flear Gey.
211>C %o indicator on the DDS -ey3ord for Melp Gey.
211>6 %o indicator on the DDS -ey3ord for Mome Gey.
21>21 *ecord mismatch detected on input.
21>11 I/6 operation to a closed le.
21>1C 6"E% issued to a le already open.
21>16 Error on an implicit 6"E%/F.6SE operation.
21>1= Error on an explicit 6"E%/F.6SE operation.
21>1< *ecord already loc-ed.
21>>1 ;pdate operation attempted 3ithout a prior read.
21>?1 Error on S"EFI:. le.
21>?C Error in "*TFT. space or s-ip entries.
21>11 *ecord number not found. !*ecord number specied in
record address le is not present in le being processed.&
21>C1 "ermanent I/6 error occurred.
21>CC Session or device error occurred. *ecovery may be
possible.
21>61 :ttempt to exceed maximum number of acAuired devices.
21><1 6peration to un acAuired device.
21><> #ob ending 3ith controlled option.
21><C :ttempt to acAuire a device already acAuired.
21><6 :ttempt to open shared le 3ith S:8DS or I%D options
21><= *esponses to indicators overlap I%D indicators.
21>DD 6ther I/6 error detected.
21??1 Jait time exceeded for *E:D from J6*GST% le.
"rogram status Fodes
%6*7:. F6%DITI6%S
/ODES .E!-'-0
22222 %o exception error occurred.
22221 Falled program returns 3ith the .* indicator on.
E1/E(*'O-2ERROR /O-D'*'O-S
F6DES 7E:%I%0
22122 8alue out of range for string operation
22121 %egative sAuare root.
2212> Divide by Eero
221>1 Invalid array index.
221>> 6FF;* outside of range.
221>? *ESET attempted during initialiEation subroutine.
22>2> Falled program failed, halt indicator !M1 through MD& not
on.
22>11 "rogram specied on F:.. or '*EE not found
22>>1 Falled program tried to use a parameter not passed to it.
22>?1 Falled program returned 3ith halt indicator on.
22>?> Malt indicator on in this program.
22>?? Malt indicator on 3hen *ET*% operation run.
22>DD *"0 formatted dump failed.
22??? Error on DS".4 operation.
, Du-eStar Technologies "vt. .td. </16
No part of this document can be copied, reproduced in any form, complete or partial without written consent from DukeStar Technologies Pvt.
Ltd.
Exception Handling
Day 16
22121 Data area specied on I% or 6;T not found
2212> +"D: not valid for non9restart Iob.
22111 Data area types or lengths do not match.
2211> Data area not loc-ed for output
2211? Errors on I% or 6;T operation.
22111 ;ser not authoriEed to use data area.
2211C ;ser not authoriEed to change data area.
221>1 Error on ;%.FG operation
221?1 Data area previously loc-ed by another program.
221?> Data area loc-ed by program in the same process.
Fharacter eld not entirely enclosed by S6 and SI.
22D2= Decimal data error !invalid digit or sign&.
22D=2 The level numbers of the generating compiler and the run9
time subroutines do not match.
8irtual storage exceeded.
2DDD< Internal failure in *"0 compiler or in run9time subroutines.
2DDDD "rogram exception in system routine.
The follo3ing reserved 3ords dene symbolic locations 3ithin the le information data
structure !I%'DS& and the program status data structure.
+'I.E
+6"F6DE
+":*7S
+"*60*:7
+*EF6*D
+*6;TI%E
+ST:T;S
See the follo3ing example 3here 3e use +ST:T;S opcode 3ith '-3DS
3ile2 'nformation Data Structure 4'-3DS5
The purpose of a le information data structure is to identify exception/error for a le in
the program. It must be uni6ue for each le. : le information data structure contains
predened subelds that give information about the type of exception or error that
occurred, the operation that the program 3as running 3hen the exception/error occurred
and the status of various conditions. The I%'DS data structure is specied either on the le
description line itself or on a continuation line for that le on position C19CD !option entry&
and position 6296= !here the name of entry is entry only&. 6ption entry is used to 3rite
I%'DS -ey3ord and eld entry is used for 3riting the name of the le information data
structure.
3ollowing example shows how to handle duplicate record error
Step #2
3ollowing is the (hysical 3ile
, Du-eStar Technologies "vt. .td. D/16
No part of this document can be copied, reproduced in any form, complete or partial without written consent from DukeStar Technologies Pvt.
Ltd.
Exception Handling
Day 16
Co.1mns . . . 5 1 ;1 E-it ),1U,1D=#>DD<
<EU&&3 E#)#<T
$#T )$ .....A..........T.Name@@@@@@RLen@@TDp......$1nctions@@@@@@@@@@@@@@@@@@
*************** e4innin4 o+ -ata *************************************
,,,1.,, A UNIIUE
,,,/.,, A R E#)#<TR
,,,%.,, A E#)N? %< ,
,,,(.,, A ENA#E 1,A
,,,*.,, A <AL ;< ,
,,,F.,, A DE)T ;A D$T(9A9)
,,,;.,, A CIT> *A D$T(9)UNE9)
,,,H.,, A : E#)N?
****************** En- o+ -ata ****************************************
$%&E'it $(&)rompt $*&Re+resh $7&Retrie8e $1,&C1rsor $11&To44.e
$1F&Repeat +in- $1;&Repeat chan4e $/(&#ore 2eys
3ollowing is the display 7le
Co.1mns . . . 5 1 ;1 E-it ),1U,1D=#><CR
<EU&&3 #AIN
$#T A* .....A*. 1 ...@... / ...@... % ...@... ( ...@... * ...@... F ...@... ;
*************** e4innin4 o+ -ata *************************************
,,,,.1, A*JJT< <D /,,(,7/H 1%,(%H ),1U,1 REL6A*R/#, *;//6KD<
,,,,./, A*JJEC
,,,,.%, A D<)<IG(/( H, *D<%)
,,,,.(, A R #AIN1
,,,,.*, A*JJT< <D /,,(,7/H 1%,(%H ),1U,1 REL6A*R/#, *;//6KD<
,,,,.F, A C$,%(,%)
,,,,.;, A % %*9IN)UT9
,,,,.H, A ; /(9E#)N?9
,,,,.7, A 1* /79$%6T?ELIT9
,,,1.,, A E#)N? R ; %%RE$$LD(E#)#<TR=E#)N? ),1U,1D=
,,,1.1, A #<" /, ? 1/ %%
****************** En- o+ -ata ****************************************
$%&E'it $(&)rompt $*&Re+resh $7&Retrie8e $1,&C1rsor $11&To44.e
$1F&Repeat +in- $1;&Repeat chan4e $/(&#ore 2eys
!bove is the DDS 4Data description speci7cation5 for display 7le and layout of
this screen 8.!'-9 is as follows
, Du-eStar Technologies "vt. .td.
12/16
No part of this document can be copied, reproduced in any form, complete or partial without written consent from DukeStar Technologies Pvt.
Ltd.
Exception Handling
Day 16
<I#)LE IN)UT <CREEN
E#)N? 7776
????????????????????
$%6T?ELIT
Step %: start with R(0
De7ne physical 7le with information data structure
Co.1mns . . . 5 1 ;1 E-it ),1U,1<=#>R)"
<EU&&3 ELCE)1
$#T $L .....$$i.enameI)EA$........L..I........De8ice@......:E'it@@[email protected]
*************** e4innin4 o+ -ata *************************************
,,,1.,, $E#)#<T I$ E DI<: :IN$D< D< A
)rompt type . . . $L <eD1ence n1mber . . . ,,,1.,,
$i.e $i.e En- o+ $i.e
$i.ename Type Desi4nation $i.e <eD1ence $ormat
EMPMST I F E
#o-e o+ Recor-
)rocessin4 A--ress Type De8ice Contin1ation
DISK K
$i.e $i.e
E'it Entry A--ition Con-ition
INFDS DS A
$%&E'it $(&)rompt $*&Re+resh $11&)re8io1s recor-
$1/&Cance. $/%&<e.ect prompt $/(&#ore 2eys
!bove is 839 speci7cation where we de7ne 8'-3DS9 :e de7ne 8E.(9 physical 7le
-ow we will move our control to SR# subroutine for that we have to write the
following information in 8'(3;9 or 8'(3/9 prompt
Entries to De7ne and -ame a 3ile 'nformation Data Structure
, Du-eStar Technologies "vt. .td.
11/16
No part of this document can be copied, reproduced in any form, complete or partial without written consent from DukeStar Technologies Pvt.
Ltd.
Exception Handling
Day 16
Position Entry
9 '
3-7. "lan# (if the information is specified on a separate continuation
line!
70 : (indicates a continuation line!
72-7- I%'D (identifies this data structure as the file information data
structure!
9/-97 Name of the file information data structure
Co.1mns . . . 5 1 ;1 E-it ),1U,1<=#>R)"
<EU&&3 ELCE)1
$#T $L .....$$i.enameI)EA$........L..I........De8ice@......:E'it@@[email protected]
*************** e4innin4 o+ -ata *************************************
,,,1.,, $E#)#<T I$ E DI<: KINFDS DS A
,,,/.,, $ :IN$<R <R1
)rompt type . . . FC <eD1ence n1mber . . . ,,,/.,,
E'terna. Recor- N1mber
Recor- Name $ie.- Contin1ation ?ption Entry
: INFSR SR1
$%&E'it $(&)rompt $*&Re+resh $11&)re8io1s recor-
$1/&Cance. $/%&<e.ect prompt $/(&#ore 2eys
%o3 3e 3ill insert 3or-station le then dene data structure having name KDSL using
K'(DSL prompt.
'(DS:
DS Specication line is bro-en into follo3ing parts
"ositions %ame Entry
19> "age "age number
?9C .ine .ine number
6 'orm type 1
=91> Data structure name (lan-
Data structure name
1?916 (lan-
1= External description (lan-
E
, Du-eStar Technologies "vt. .td.
1>/16
No part of this document can be copied, reproduced in any form, complete or partial without written consent from DukeStar Technologies Pvt.
Ltd.
Subroutine
name
Exception Handling
Day 16
1< 6ption (lan-
I
S
;
1D9>2 *ecord identifying
indictors
DS
>19?2 External le name External name or data
Structure
?191? (lan-
1191= 6ccurrences (lan-
19DDDD
1<9C1 Data structure length (lan-
19DDDD
C>9=1 (lan-
=C9<2 comments 6ptional
Record name: Type the external name of the record format.
*ecord Identifying indicators) *ype a value from <# to == to represent a general
indicator
Co.1mns . . . 5 1 ;1 E-it ),1U,1<=#>R)"
<EU&&3 ELCE)1
$#T $L .....$$i.enameI)EA$........L..I........De8ice@......:E'it@@[email protected]
*************** e4innin4 o+ -ata *************************************
,,,1.,, $E#)#<T I$ E DI<: :IN$D< D< A
,,,/.,, $ :IN$<R <R1
,,,%.,, $#AIN C$ E K?R:<TN
,,,(.,, ID< D<
)rompt type . . . D< <eD1ence n1mber . . . ,,,(.,,
Data <tr1ct E'terna.
Name N1mber ?ption D< $i.e Name ?cc1rs Len4th
DS DS
$%&E'it $(&)rompt $*&Re+resh $11&)re8io1s recor-
$1/&Cance. $/%&<e.ect prompt $/(&#ore 2eys
Then insert eld name K!!L and 8>S*!*"S9 at C> position as sho3n belo3 using '()1
prompt.
, Du-eStar Technologies "vt. .td.
1?/16
No part of this document can be copied, reproduced in any form, complete or partial without written consent from DukeStar Technologies Pvt.
Ltd.
Exception Handling
Day 16
'()1:
"ositions %ame Entry
"ositions %ame Entry
=9>2 (lan-
>19?2 External eld name 'ield name
?19C> (lan-
C?9C< *"0 eld name 'ield name
CD962 Fontrol level (lan-
.19.D
6196> 7atch elds (lan-
7197D
6?961 (lan-
6C9=2 'ield indictors (lan-
219DD
M19MD
;19;<
*T
=19=1 (lan-
=C9<2 Fomments 6ptional
Co.1mns . . . 5 1 ;1 E-it ),1U,1<=#>R)"
<EU&&3 ELCE)1
$#T $L .....$$i.enameI)EA$........L..I........De8ice@......:E'it@@[email protected]
*************** e4innin4 o+ -ata *************************************
,,,1.,, $E#)#<T I$ E DI<: :IN$D< D< A
,,,/.,, $ :IN$<R <R1
,,,%.,, $#AIN C$ E K?R:<TN
,,,(.,, ID< D<
,,,*.,, I *<TATU< AA
)rompt type . . . JX <eD1ence n1mber . . . ,,,*.,,
E'terna. $ie.- Contro. #atchin4
$ie.- Name Name Le8e. $ie.-s
AA
)ositi8e Ne4ati8e Gero =
$ie.- $ie.- .an2
$%&E'it $(&)rompt $*&Re+resh $11&)re8io1s recor-
$1/&Cance. $/%&<e.ect prompt $/(&#ore 2eys
%o3 simply insert message KDuplicateL using K'(-L prompt and do the coding as given
belo3.
Co.1mns . . . 5 1 ;1 E-it ),1U,1<=#>R)"
<EU&&3 ELCE)1
$#T $L .....$$i.enameI)EA$........L..I........De8ice@......:E'it@@[email protected]
*************** e4innin4 o+ -ata *************************************
,,,1.,, $E#)#<T I$ E DI<: :IN$D< D< A
,,,/.,, $ :IN$<R SR1
,,,%.,, $#AIN C$ E K?R:<TN
,,,(.,, ID< D<
,,,*.,, I *<TATU< AA
,,,F.,, I 9DU)LICATE9 C #<"1
,,,;.,, C READ E#)#<TR *,
,,,H.,, C *IN,% D?KEI*?$$
,,,7.,, C EE TA"
, Du-eStar Technologies "vt. .td.
11/16
No part of this document can be copied, reproduced in any form, complete or partial without written consent from DukeStar Technologies Pvt.
Ltd.
Error Status
Exception Handling
Day 16
,,1,.,, C EL$#T#AIN1
,,11.,, C ,% LEAAE
,,1/.,, C KRITEE#)#<TR
,,1%.,, C CLEAR#<"
,,1(.,, C ENDD?
,,1*.,, C <ET?N LR
,,1F.,, *************************************************************
,,1;.,, C SR1 E"<R
,,1H.,, C AA I$EI ,1,/1
,,17.,, C #?AE #<"1 #<"
,,/,.,, C "?T? EE
,,/1.,, C ENDI$
,,//.,, C END<R
****************** En- o+ -ata ****************************************
$%&E'it $(&)rompt $*&Re+resh $7&Retrie8e $1,&C1rsor $11&To44.e
$1F&Repeat +in- $1;&Repeat chan4e $/(&#ore 2eys
:bove example sho3s you ho3 to handle the le related error.
%o3 in next example see ho3 to handle the program related error.
(rogram Exception?Errors
The exception/errors that occurred during program execution time are -no3n as program
exception error. i.e. an error on a F:.. operation code, division by Eero, SAuare root of a
negative number etc. Therefore if you are doing above operations in a program itLs al3ays
a good programming practice to provide logic to handle these errors.
: program9status data structure, identied by an S in position 1< of the data structure
statement, provides program exception/error information to the program. 4ou can handle
these errors in one of follo3ing 3ays.
;se error indicator in position C69C= of those operations that allo3s such an entry. If
error occurs than the indicator sets on. 4ou can determine the action to be ta-en by
testing the indicator for on condition.
: program exception/error subroutine +"SS* can be used. This subroutine 3ill
automatically receive control 3hen a program exception /error occurs. Information
regarding the program exception/error is made available through a program status
data structure that 3ill be described in next section
If the error indicator or the program exception/error subroutine is not present than
the *"0/122 default error handler handles program exception/error.
Je use a subroutine 8>(SSR9 to handle the error, 3hen error occurs program starts
execution of this subroutine.
+"SS* (E0S*
99999999999
99999999999
99999999999
E%DS*
:bove is the syntax for subroutine.
So ho3 to implement it in our program is in the follo3ing example.
, Du-eStar Technologies "vt. .td.
1C/16
No part of this document can be copied, reproduced in any form, complete or partial without written consent from DukeStar Technologies Pvt.
Ltd.
Exception Handling
Day 16
Co.1mns . . . 5 1 ;1 E-it ),1U,1<=#>R)"
<EU&&3 EL#)1,
$#T * ..... *. 1 ...@... / ...@... % ...@... ( ...@... * ...@... F ...@... ;
*************** e4innin4 o+ -ata *************************************
,,,,.,1 * )R?"RA# $?R )R?"RA# <TATU< D< DE$INE #E<<A"E U<IN" IPN )R?#)T.
,,,1.,, I 9?EECT N?T $?UND9 C #<"1
,,,1.,1 * DE$INE D< U<IN" IPDS )R?#)T.
,,,/.,, ID</ <D<
,,,1.,1 * DE$INE $IELD NA#E AND *STATUS AT 52 )?<ITI?N U<IN" IPJX.
,,,%.,, I *<TATU< <T
,,,(.,, C CALL 9RL"9
,,,*.,, C A TA"
,,,F.,, C <ET?N LR
,,,F.,1 * <UR?UTINE $?R ERR?R !ANDLIN"
,,,;.,, C *)<<R E"<R
,,,H.,, C <T I$EI 211
,,,7.,, C #<"1 D<)L>
,,1,.,, C "?T? A
,,11.,, C ENDI$
,,1/.,, C END<R
****************** En- o+ -ata ****************************************
$%&E'it $(&)rompt $*&Re+resh $7&Retrie8e $1,&C1rsor $11&To44.e
$1F&Repeat +in- $1;&Repeat chan4e $/(&#ore 2eys
(C) C?)>RI"!T I# C?R). 17H1, /,,/.
In above example 3e use to nd out the 3hether the obIect of program is existing or not. If
program obIect is exist then KFallL command execute or call that particular program. If the
obIect of the program does not exist then error message 3ill gets displayed K6bIect %ot
'oundL. So the code for that chec-ing is >11.
, Du-eStar Technologies "vt. .td.
16/16
No part of this document can be copied, reproduced in any form, complete or partial without written consent from DukeStar Technologies Pvt.
Ltd.