Mainframes Refresher Part2
Mainframes Refresher Part2
No Particulars Page No
1 TSO Commands 2
2 COBOL Tutorial 9
3 COBOL File status Code 43
4 COBOL Coding Standard 46
5 JCL 49
6 JCL Utilities 73
7 JCL FAQ’s 83
8 CICS Tutorial 92
9 CICS Abend Codes 116
10 CICS FAQ’s 121
11 DB2 Tutorial 126
12 DB2 Utilities 144
13 DB2 FAQ’s 146
14 Change man Tool 154
15 File-Aid Tool 172
16 Endevor Tool 207
17 Domain – Banking and Finance 214
18 Domain – Telecom 232
19 PL/I 252
TSO Commands
• Message-id = MSGID
These allow you to pull back datasets without seeing the intermediate lists.
Commands to quickly add names to your personal lists. These are REFOPEND,
REFOPENL, REFADDD, and REFADDL
• RETP - View the stack of your typed commands.
• RETF - Pull back commands in reverse order.
• RETRIEVE - Pop up the most recent typed commands from the stack.
• CRETRIEV - Pop up the most recent typed commands from the stack.
• ISRDDN - Shows the current data sets allocation for our ISPF session.
• XMIT
The TSO/E Interactive Data Transmission Facility TRANSMIT command allows you to
send data sets or messages to persons on other MVS systems via Network Job Entry or
directly to persons on your own system.
• RECEIVE
The TSO/E Interactive Data Transmission Facility RECEIVE command allows you to
obtain files transmitted to your userid. The RECEIVE command queries the Job Entry
Subsystem
• DSLIST
• SAVE /VDL
• QPRINT
• TSO PROFILE
The profile command is used either to specify to the system certain user characteristics
which are to be used to control the flow of information to and from the terminal or to list
the user profile. The user profile is retained throughout each terminal session unless the
user wishes to change it by issuing the profile command again and specifying the
appropriate operands.
• CUT DISPLAY
This command when given while a member is opened in view/edit mode will show the
Clipboard manager. The Clipboard can then be browsed or deleted.
• KEYLIST
Displays the Keylist utility. Invoking KEYLIST OFF can disable it.
• KEYS
2
oIf the KEYLIST is ON, it displays the keys of current Keylist.
oIf the KEYLIST is OFF, it displays the Primary keys definition.
• PFSHOW
• SCRNAME ON
Displays the screen name of the Top Left corner. We can give our own screen name to
any screen by writing "SCRNAME myscrname"
• SWAP LIST
• ASM
• CALC
• COBOL
• FORT
• CALL
• LINK
• LOADGO
3
• RUN
• TEST
• TESTAUTH
• ALLOCATE
• ALTLIB
• ATTRIB
• CONVERT
• COPY
• DELETE
• EDIT
• FORMAT
4
FORMAT AND PRINT A TEXT DATA SET. (SEE NOTE BELOW.)
• FREE
• LIST
• LISTALC
• LISTBC
• LISTCAT
• LISTDS
• MERGE
• PRINTDS
• PROTECT
• RENAME
• TSOLIB
5
• ACCOUNT
• CONSOLE
• OPERATOR
• PARMLIB
• RACONVRT
• SYNC
SYNCHRONIZE THE BROADCAST DATA SET WITH USER IDS FROM THE
UADS AND RACF DATA BASE.
SESSION CONTROL
• CONSPROF
• EXEC
• EXECUTIL
• HELP
• LOGOFF
• LOGON
6
START TERMINAL SESSION.
• PROFILE
• SEND
• TERMINAL
• TIME
• TSOEXEC
• WHEN
• CANCEL
• OUTPUT
• STATUS
• SUBMIT
• INTERACTIVE
7
• RECEIVE
• TRANSMIT
COBOL Tutorial
Computer Programming
A Program is a set of instructions that enables a computer to process data, there are two types of
computer programs which are 1- Operating system programs, which control the overall operation
of the system and 2- Applications programs, it is the actuall program tasks requried by the users.
The term used to descriebe all type of programs is called software in general application program
reads input , process it, and produce information or out put the user neads. A set of computerized
business procedures in an application area is called an information systems.
History of Cobol.
Developed by 1959 by a group called COnference on Data Systems Language (CODASYL). First
COBOL compiler was released by December 1959.
Interduction to Cobol
The word COBOL is an acronym that stands for COmmon Business Oriented Language. As the
the expanded acronym indicates, COBOL is designed for developing business, typically file-
oriented, applications. It is not designed for writing systems programs. For instance you would
not develop an operating system or a compiler using COBOL
8
Coding Sheet.
1-6 Page/line numbers - Optional (automatically assigned by compiler)
7 Continuity (-), Comment (*), Starting a new page (/), Debugging lines (D)
8-11 Column A -Division, Section, Paragraph, 01,77 declarations must begin here.
12-72 Column B -All the other declarations/statements begin here.
73-80 Identification field. It will be ignored by the compiler but visible in the source listing.
Language Structure.
Digits (0-9), Alphabets (A-Z), Space (b), Special Characters (+ - * / ( ) = $ ; " > <
Character Set :-
. ,)
Word :- One or more characters- User defined or Reserved.
Clause :- One or more words. It specifies an attribute for an entry.
Statement :- One or more valid words and clauses.
Sentence :- One or more statements terminated by a period.
Paragraph :- One or more sentences.
Section :- One or more paragraphs.
Division :- One or more sections or paragraphs.
Program :- Made up of four divisions.
Divisions in COBOL.
There are four divisions in a COBOL program and Data division is optional.
1. Identification Division.
2. Environment Division.
3. Data Division.
4. Procedure Division.
Identification Division.
This is the first division and the program is identified here. Paragraph PROGRAM-ID followed
by user-defined name is mandatory. All other paragraphs are optional and used for
documentation. The length of user-defined name for IBM COBOL is EIGHT.
IDENTIFICATION DIVISION.
PROGRAM-ID. PROGRAM NAME.
AUTHOR. COMMENT ENTRY.
INSTALLATION. COMMENT ENTRY.
DATE-WRITTEN. COMMENT ENTRY.
DATE-COMPILED. COMMENT ENTRY.
SECURITY. COMMENT ENTRY.
Security does not pertain to the operating system security, but the information that is passed to the
user of the program about the security features of the program.
9
Environment Division.
Only machine dependant division of COBOL program. It supplies information about the
hardware or computer equipment to be used on the program. When your program moves from
one computer to another computer, the only section that may need to be changed is
ENVIRONMENT division.
Data Division.
Data division is used to define the data that need to be accessed by the program. It has three
sections.
10
Literals, Constants, Identifier,
Declaration of variable
Level# $ {Variable/Filler} $ Picture clause $ Value clause $ Usage Clause $ Sync clause.
Level#
It specifies the hierarchy of data within a record. It can take a value from the set of integers
between 01-49 or from one of the special level-numbers 66 77 88
Specifies the record itself. It may be either a group item or an Elementary item. It
01 level :-
must begin in Area A.
02-49 Specify group or elementary items within a record. Group level items must not have
:-
levels picture clause.
66 level :- Identify the items that contain the RENAMES clause.
77 level :- Identify independent data item.
88 level :- Condition names.
Variable name can have 1-30 characters with at least one alphabet in it. Hyphen is the only
allowed special character but it cannot be first or last letter of the name. Name should be unique
within the record. If two variables with same name are there, then use OF qualifier of high level
grouping to refer a variable uniquely.
Ex: MOVE balance OF record-1 TO balance OF record-2.
FILLER
When the program is not intended to use selected fields in a record structure, define them as
FILLER. FILLER items cannot be initialized or used in any operation of the procedure division.
11
PICTURE Clause
DBCS (Double Byte Character Set) is used in the applications that support large character sets. 16
bits are used for one character. Ex: Japanese language applications.
Refreshing Basics
Nibble :- 4 Bits is one nibble. In packed decimal, each nibble stores one digit.
Byte :- 8 Bits is one byte. By default, every character is stored in one byte.
Half word :- 16 bits or 2 bytes is one half word. (MVS)
Full word :- 32 bits or 4 bytes is one full word. (MVS)
Double word :- 64 bits or 8 bytes is one double word. (MVS)
Usage Clause
DISPLAY :- Default. Number of bytes required equals to the size of the data item.
Binary representation of data item.
PIC clause can contain S and 9 only.
VALUE Clause
It is used for initializing data items in the working storage section. Value of item must not exceed
picture size. It cannot be specified for the items whose size is variable.
12
VALUE IS literal.
Syntax: VALUES ARE literal-1 THRU | THROUGH literal-2
VALUES ARE literal-1, literal-2
Literal can be numeric without quotes OR non-numeric within quotes OR figurative constant.
SIGN Clause
SYNC clause is specified with COMP, COMP-1 and COMP-2 items. These items are expected to
start at half/full/double word boundaries for faster address resolution. SYNC clause does this but
it may introduce slack bytes (unused bytes) before the binary item.
01 WS-TEST.
10 WS-VAR1 PIC X(02).
10 WS-VAR2 PIC S9(6) COMP SYNC.
Assumes WS-TEST starts at relative location 0 in the memory, WS-VAR1 occupies zero and first
byte. WS-VAR2 is expected to start at second byte. As the comp item in the example needs one
word and it is coded with SYNC clause, it will start only at the next word boundary that is 4th
byte. So this introduces two slack bytes between WS-VAR1 and WS-VAR2.
REDEFINES
The REDEFINES clause allows you to use different data description entries to describe the same
computer storage area. Redefining declaration should immediately follow the redefined item and
should be done at the same level. Multiple redefinitions are possible. Size of redefined and
redefining need not be the same.
Example:
01 WS-DATE PIC9(06).
01 WS-REDEF-DATE WS-DATE.
05 WS-YEAR PIC9(02).
05 WS-MON PIC9(02).
13
05 WS-DAY PIC9(02).
RENAMES
It is used for regrouping of elementary data items in a record. It should be declared at 66 level. It
need not immediately follows the data item, which is being renamed. But all RENAMES entries
associated with one logical record must immediately follow that record's last data description
entry. RENAMES cannot be done for a 01, 77, 88 or another 66 entry.
01 WS-REPSONSE.
05 WS-CHAR143 PICX(03).
05 WS-CHAR4 PICX(04).
66 ADD-REPSONSE RENAMES WS-CHAR143.
CONDITION name
It is identified with special level '88'. A condition name specifies the value that a field can contain
and used as abbreviation in condition checking.
01 SEX PIC X.
88 MALE VALUE '1'
88 FEMALE VALUE '2' '3'.
JUSTIFIED RIGHT
This clause can be specified with alphanumeric and alphabetic items for right justification. It
cannot be used with 66 and 88 level items.
OCCURS Clause
OCCURS Clause is used to allocate physically contiguous memory locations to store the table
values and access them with subscript or index. Detail explanation is given in Table Handling
section.
LINKAGE SECTION
It is used to access the data that are external to the program. JCL can send maximum 100
characters to a program thru PARM. Linkage section MUST be coded with a half word binary
field, prior to actual field. If length field is not coded, the first two bytes of the field coded in the
linkage section will be filled with length and so there are chances of 2 bytes data truncation in the
actual field.
14
01 LK-DATA.
05 LK-LENGTH PIC S9(04) COMP.
05 LK-VARIABLE PIC X(08).
Procedure Division.
This is the last division and business logic is coded here. It has user-defined sections and
paragraphs. Section name should be unique within the program and paragraph name should be
unique within the section.
Procedure division statements are broadly classified into following categories.
MOVE Statement
It is used to transfer data between internal storage areas defined in either file section or working
storage section.
Syntax:
A numeric or numeric-edited item receives data in such a way that the decimal point is aligned
first and then filling of the receiving field takes place. Unfilled positions are filled with zero. Zero
suppression or insertion of editing symbols takes places according to the rules of editing pictures.
If the receiving field width is smaller than sending field then excess digits, to the left and/or to the
right of the decimal point are truncated.
Alphabetic, alphanumeric or alphanumeric-edited data field receives the data from left to right.
Any unfilled field of the receiving filed is filled with spaces. When the length of receiving field is
15
shorter than that of sending field, then receiving field accepts characters from left to right until it
is filled. The unaccomodated characters on the right of the sending field are truncated. When an
alphanumeric field is moved to a numeric or numeric-edited field, the item is moved as if it were
in an unsigned numeric integer mode. CORRESPONDING can be used to transfer data between
items of the same names belonging to different group-items by specifying the names of group-
items to which they belong.
MOVE CORRESPONDING group-1 TO group-2
When MOVE statement is used to move information at group level, the movement of data takes
place as if both sending and receiving fields are specified as alphanumeric items. This is
regardless of the description of the elementary items constituting the group item.
Samples for understanding MOVE statement (MOVE A TO B)
ARITHMETIC VERBS
All the possible arithmetic operations in COBOL using ADD, SUBTRACT, MULTIPLY and
DIVIDE are given below:
Arithmetic Operation A B C D
ADD A TO B A A+B
ADD A B C TO D A B C A+B+C+D
ADD A B C GIVING D A B C A+B+C
ADD A TO B C A A+B A+C
SUBTRACT A FROM B A B-A
SUBTRACT A B FROM C A B C-(A+B)
SUBTRACT A B FROM C GIVING D A B C C-(A+B)
MULTIPLY A BY B A A*B
MULTIPLY A BY B GIVING C A B A*B
DIVIDE A INTO B A B/A
DIVIDE A INTO B GIVING C A B B/A
DIVIDE A BY B GIVING C A B A/B
DIVIDE A INTO B GIVING C REMAINDER D A B Integer (B/A) Integer remainder
16
GIVING is used in the following cases:
1.To retain the values of operands participating in the operation.
2.The resultant value of operation exceeds any of the operand size.
ROUNDED option
With ROUNDED option, the computer will always round the result to the PICTURE clause
specification of the receiving field. It is usually coded after the field to be rounded. It is prefixed
with REMAINDER keyword ONLY in DIVIDE operation.
ADD A B GIVING C ROUNDED.
Caution: Don't use for intermediate computation.
ON SIZE ERROR
If A=20 (PIC 9(02)) and B=90 (PIC 9(02)), ADD A TO B will result 10 in B where the expected
value in B is 110. ON SIZE ERROR clause is coded to trap such size errors in arithmetic
operation.
If this is coded with arithmetic statement, any operation that ended with SIZE error will not be
carried out but the statement follows ON SIZE ERROR will be executed.
ADD A TO B ON SIZE ERROR DISPLAY 'ERROR!'.
COMPUTE
Complex arithmetic operations can be carried out using COMPUTE statement. We can use
arithmetic symbols than keywords and so it is simple and easy to code.
+ For ADD, - for SUBTRACT, * for MULTIPLY, / for DIVIDE and ** for exponentiation.
Rule: Left to right -
1.Parentheses
2.Exponentiation
3.Multiplication and Division
4.Addition and Subtraction
Caution: When ROUNDED is coded with COMPUTE, some compiler will do rounding for every
arithmetic operation and so the final result would not be precise. 77 A PIC 999 VALUE 10
COMPUTE A ROUNDED = (A+2.95) *10.99
Result: (ROUNDED(ROUNDED(12.95) * ROUNDED(10.99)) =120 or ROUNDED(142.3205)
= 142 So the result can be 120 or 142.
Be cautious when using ROUNDED keyword with COMPUTE statement.
All arithmetic operators have their own explicit scope terminators. (END-ADD, END-
SUBTRACT, END-MULTIPLY, END-DIVIDE, END-COMPUTE). It is suggested to use them.
CORRESPONDING is available for ADD and SUBTRACT only.
INITIALIZE
VALUE clause is used to initialize the data items in the working storage section whereas
INITIALIZE is used to initialize the data items in the procedure division. INITIALIZE sets the
alphabetic, alphanumeric and alphanumeric-edited items to SPACES and numeric and numeric-
17
edited items to ZERO. This can be overridden by REPLACING option of INITIALIZE. FILLER,
OCCURS DEPENDING ON items are not affected.
ACCEPT
ACCEPT can transfer data from input device or system information contain in the reserved data
items like DATE, TIME, DAY.
ACCEPT WS-VAR1 (FROM DATE/TIME/DAY/OTHER SYSTEM VARS).
If FROM Clause is not coded, then the data is read from terminal. At the time of execution, batch
program will ABEND if there is no in-stream data from JCL and there is no FROM clause in the
ACCEPT clause. DATE option returns six digit current date in YYYYMMDD
DAY returns 5 digit current date in YYDDD
TIME returns 8 digit RUN TIME in HHMMSSTT
DAY-OF-WEEK returns single digit whose value can be 1-7 (Monday-Sunday respectively)
DISPLAY
STOP RUN is the last executable statement of the main program. It returns control back to OS.
EXIT PROGRAM is the last executable statement of sub-program. It returns control back to main
program.
GOBACK can be coded in main program as well as sub-program as the last statement. It just
gives the control back from where it received the control.
Collating Sequence
There are two famous Collating Sequence available in computers. IBM and IBM Compatible
machine use EBCDIC collating sequence whereas most micro and many mainframe systems use
ASCII collating sequence. The result of arithmetic and alphabetic comparison would be same in
both collating sequences whereas the same is not true for alphanumeric comparison
18
Default collating sequence can be overridden by an entry in OBJECT-COMPUTER and
SPECIAL NAMES paragraphs.
1. Code the PROGRAM COLLATING SEQUENCE Clause in the Object computer paragraph.
PROGRAM COLLATING SEQUENCE IS alphabet-name
2. Map the alphabet-name in the SPECIAL-NAMES paragraph as follows:
ALPHABET alphabet-name is STANDARD-1 | NATIVE
NATIVE stands for computer's own collating sequence whereas STANDARD-1 stands for ASCII
collating sequence.
IF/THEN/ELSE/END-IF
The most famous decision making statement in all language is 'IF'. The syntax of IF statement is
given below: IF can be coded without any ELSE statement. THEN is a noise word and it is
optional.
If ORs & ANDs are used in the same sentence, ANDs are evaluated first from left to right,
followed by ORs.
This rule can be overridden by using parentheses. The permitted relation conditions are =, <, >,
<=, >=, <>
CONTINUE is no operation statement. The control is just passed to next STATEMENT.
NEXT SENTENCE passes the control to the next SENTENCE.
If you forgot the difference between statement and sentence, refer the first page. It is advised to
use END-IF, explicit scope terminator for the IF statements than period, implicit scope terminator.
IF condition1 AND condition2 THEN
Statement-Block-1
ELSE
IF condition3 THEN
CONTINUE
ELSE
IF condition4 THEN
Statement-Block-2
ELSE
NEXT SENTENCE
END-IF
END-IF
END-IF
Statement-Block-2 will be executed only when condition 1, 2 and 4 are TRUE and condition 3 is
FALSE.
Implied operand: In compound conditions, it is not always necessary to specify both operands for
each condition.
IF TOTAL=7 or 8 is acceptable. Here TOTAL=8 is implied operation.
SIGN test is used to check the sign of a data item. It can be done as follows -
IF identifier is POSITIVE/NEGATIVE/ZERO
CLASS test is used to check the content of data item against pre-defined range of values. It can
be done as follows -
19
IF identifier is NUMERIC/ALPHABETIC/ALPHABETIC-HIGHER/ALPHABETIC-LOWER
You can define your own classes in the special names paragraph. We have defined a class DIGIT
in our special names paragraph. It can be used in the following way. IF identifier is DIGIT
Negated conditions.
Any simple, relational, class, sign test can be negated using NOT.
But it is not always true that NOT NEGATIVE is equal to POSITIVE. (Example ZERO)
EVALUATE
With COBOL85, we use the EVALUATE verb to implement the case structure of other
languages. Multiple IF statements can be efficiently and effectively replaced with EVALUATE
statement. After the execution of one of the when clauses, the control is automatically come to the
next statement after the END-EVALUATE. Any complex condition can be given in the WHEN
clause. Break statement is not needed, as it is so in other languages.
General Syntax
PERFORM STATEMENTS
PERFORM will be useful when you want to execute a set of statements in multiple places of the
program. Write all the statements in one paragraph and invoke it using PERFORM wherever
needed. Once the paragraph is executed, the control comes back to next statement following the
PERFORM.
20
1.SIMPLE PERFORM.
PERFORM PARA-1.
DISPLAY 'PARA-1 executed'
STOP RUN.
PARA-1.
Statement1.
Statement2.
It executes all the instructions coded in PARA-1 and then transfers the control to the next
instruction in sequence.
2. INLINE PERFORM.
When set of statements are used only in one place then we can group all of them within
PERFORM END-PERFORM structure. This is called INLINE PERFORM. This is equal to
DO..END structure of other languages.
PERFORM
ADD A TO B
MULTIPLE B BY C
DISPLAY 'VALUE OF A+B*C ' C
END-PERFORM
All the paragraphs between PARA-1 and PARA-N are executed once.
The identifiers used in the UNTIL condition(s) must be altered within the paragraph(s) being
performed; otherwise the paragraphs will be performed indefinitely. If the condition in the
UNTIL clause is met at first time of execution, then named paragraph(s) will not be executed at
all.
N can be literal defined as numeric item in working storage or hard coded constant.
FROM identifier2 BY identifier3 UNTIL condition(s) Initialize identifier1 with identifier2 and
test the condition(s). If the condition is false execute the statements in PARA-1 thru PARA-N and
increment identifier1 BY identifier3 and check the condition(s) again. If the condition is again
false, repeat this process till the condition is satisfied.
21
7.PERFORM PARA-1 WITH TEST BEFORE/AFTER UNTIL condition(s).
With TEST BEFORE, Condition is checked first and if it found false, then PARA-1 is executed
and this is the default. (Functions like DO- WHILE) With TEST AFTER, PARA-1 is executed
once and then the condition is checked. (Functions like DO-UNTIL)
EXIT statement.
COBOL reserved word that performs NOTHING. It is used as a single statement in a paragraph
that indicate the end of paragraph(s) execution. EXIT must be the only statement in a paragraph
in COBOL74 whereas it can be used with other statements in COBOL85.
GO TO Usage:
Here GO TO used within the range of PERFORM. This kind of Controlled GO TO is fine with
structured programming also!
TABLES
An OCCURS clause is used to indicate the repeated occurrences of items of the same format in a
structure. OCCURS clause is not valid for 01, 77, 88 levels.
It can be defined as elementary or group item. Initialization of large table occurrences with
specific values are usually done using perform loops in procedure division. Simple tables can be
initialized in the following way.
22
Dynamic array is the array whose size is decided during runtime just before the access of first
element of the array.
01 WS-MONTH-DAY-CAL.
05 WS-DAYS OCCURS 31 TIMES DEPENDING ON WS-OCCURENCE.
Sl
Subscript Index
#
1 Working Storage item Internal Item-No need to declare it.
2 It means occurrence It means displacement
Occurrence, in turn translated to displacement to
3 Faster and efficient.
access elements and so slower than INDEX access.
It can be used in any arithmetic operations or for It cannot be used for arithmetic operation
4
display. or for display purpose.
Subscripts can be modified by any arithmetic INDEX can only be modified with SET,
5
statement. SEARCH and PERFORM statements.
Sometimes, you may face a question like how to randomly access the information in the
sequential file of 50 records that contains all the designation and the respective lower and higher
salary information.
Obviously, OS does not allow you to randomly access the sequence file. You have to do by
yourself and the best way is, load the file into a working storage table in the first section of the
program and then access as you wish.
The table look-up can be done in two ways.
-Sequential search.
-Binary search.
Sequential SEARCH
During SERIAL SEARCH, the first entry of the table is searched. If the condition is met, the
table look-up is completed. If the condition is not met, then index or subscript is incremented by
one and the next entry is searched and the process continues until a match is found or the table
has been completely searched.
SET indexname-1 TO 1.
SEARCH identifier-1 AT END display 'match not found:'
WHEN condition-1 imperative statement-1 /NEXT SENTENCE
WHEN condition-2 imperative statement-2 /NEXT SENTENCE
END-SEARCH
Identifier-1 should be OCCURS item and not 01 item.
23
Condition-1, Condition-2 compares an input field or search argument with a table argument.
Though AT END Clause is optional, it is highly recommended to code that. Because if it is not
coded and element looking for is not found, then the control simply comes to the next statement
after SEARCH where an invalid table item can be referred and that may lead to incorrect results /
abnormal ends.
SET statement Syntax:
SET index-name-1 TO/UP BY/DOWN BY integer-1.
Binary SEARCH
When the size of the table is large and it is arranged in some sequence -either ascending or
descending on search field, then BINARY SEARCH would be the efficient method.
SEARCH ALL identifier-1 AT END imperative-statement-1
WHEN dataname-1 = identifier-2/literal-1/arithmetic expression-1
AND dataname-2 = identifier-3/literal-2/arithmetic expression-2
END-SEARCH.
Identifier-2 and identifier-3 are subscripted items and dataname-1 and dataname-2 are working
storage items that are not subscripted.
Compare the item to be searched with the item at the center. If it matches fine, else repeat the
process with the left or right half depending on where the item lies.
Sl
Sequential SEARCH Binary SEARCH
#
1 SEARCH SEARCH ALL
2 Table should have INDEX. Table should have INDEX.
Table need not be in Table should be in sorted order of the searching argument. There
3
SORTED order. should be ASCENDING/DESCENDING Clause.
Multiple WHEN
4 Only one WHEN condition can be coded.
conditions can be coded.
Any logical comparison is
5 Only = is possible. Only AND is possible in compound conditions.
possible.
Index should be set to 1
6 Index need not be set to 1 before SEARCH ALL.
before using SEARCH
Prefer when the table size
7 Prefer when the table size is significantly large.
is small
24
SEARCH example for multi level tables:
01 EMP-TABLE.
05 DEPTNUMBER OCCURS 10 TIMES INDEXED BY I1.
10 EMP-DETAIL OCCURS 50 TIMES INDEXED BY I2.
15 EMP-NUMBER PIC 9(04).
15 EMP-SALARY PIC 9(05).
77 EMPNUMBER-IN PIC 9(04) VALUE '2052'.
One program may contain other program(s). The contained program(s) may themselves contain
yet other program(s). All the contained and containing programs should end with END
PROGRAM statement. PGMB is nested a program in the example below:
IDENTIFICATION DIVISION.
Example: PROGRAM-ID. PGMA
.....
IDENTIFICATION DIVISION.
PROGRAM-ID. PGMB
.....
END PROGRAM PGMB.
....
END PROGRAM PGMA.
If you want access any working storage variable of PGMA in PGMB, then declare them with the
clause 'IS GLOBAL' in PGMA. If you want to access any working storage variable of PGMB in
PGMA, declare them with the clause 'IS EXTERNAL' in PGMB. Nested Programs are supported
only in COBOL85.
If there is a program PGMC inside PGMB, it cannot be called from PGMA unless it's program id
is qualified with keyword COMMON.
The programming SORT is called as internal sort whereas the sort in JCL is called external sort. If
you want to manipulate the data before feeding to sort, prefer internal sort. In all other cases,
25
external sort is the good choice. Internal sort, in turn invokes the SORT product of your
installation. (DFSORT). In the run JCL, allocate at least three sort work files. (SORT-WKnn =>
nn can be 00-99).
FASTSRT compiler option makes the DFSORT to do all file I-O operation than your COBOL
program. It would significantly improve the performance. The result of the SORT can be checked
in SORT-RETURN register. If the sort is successful, the value will be 0 else 16.
Syntax:
Syntax:
Syntax:
Sometimes it would be more efficient to process data before it is sorted, whereas other times it is
more efficient to process after it is sorted. If we intend to eliminate more records, then it would be
better preprocess them before feeding to SORT. If we want to eliminate all the records having
spaces in the key field then it would be efficient if we eliminate them after sorting. Because the
records with blank key comes first after sorting.
MERGE
It is same as sort. USING is mandatory. There should be minimum two files in USING.
MERGE Sort-work-file ON ASCENDING KEY dataname1 dataname2
USING file1 file2
26
GIVING file3 / OUTPUT PROCEDURE is section-1
END-MERGE
STRING MANIPULATION
It is used to tally the occurrence of a single character or groups of characters in a data field.
INSPECT identifier-1 TALLYING identifier-2 FOR ALL/LEADING literal-1|identifier-3
[BEFORE|AFTER INITIAL identifier-4|literal-2] - Optional.
INSPECT identifier-1 TALLYING identifier-2 FOR CHARACTERS [BEFORE|AFTER
INITIAL identifier-4|literal-2] - Optional.
Main String is identifier-1 and count is stored in identifier-2. Literal-1 or Identifier-3 is a
character or group-of-characters you are looking in the main-string. INSPECT further qualifies
the search with BEFORE and AFTER of the initial occurrence of identifier-4 or literal-2.
Example:
WS-NAME - 'MUTHU SARAVANA SURYA CHANDRA DEVI'
INSPECT WS-NAME TALLYING WS-COUNT ALL 'S'
BEFORE INITIAL 'SARAVANA' AFTER INITIAL 'CHANDRA'
END-INSPECT
Result:
WS-COUNT contains - 1
It is used to replace the occurrence of a single character or groups of characters in a data field.
INSPECT identifier-1 REPLACING ALL|LEADING literal-1|identifier-2 BY identifier-3|literal-2
[BEFORE|AFTER INITIAL identifier-4|literal-2] - Optional.
INSPECT identifier-1 REPLCING CHARACTERS BY identifier-2 BEFORE|AFTER INITIAL
identifier-3|literal-1
INSPECT-FOR COUNTING AND REPLACING It is a combination of the above two methods.
INSPECT identifier-1 TALLYING (tallying part ) REPLACING (replacing part)
27
STRING
Syntax:
Syntax:
String (Starting-Position:Length)
MOVE '18' TO AGE-OUT(1:2) does the same as what we did with STRING command.
When it is used in array elements, the syntax is Array-element (occurrence) (Starting-
Position:Length)
UNSTRING
Syntax:
28
WS-FLD3 DELIMITER IN WS-D3 COUNT IN WS-C3
END-UNSTRING.
Result:
COPY Statement
A COPY statement is used to bring a series of prewritten COBOL entries that have been stored in
library, into a program.
1.Common routines like error routine, date validation routine are coded in a library and bring into
the program by COPY.
2. Master files are used in multiple programs. Their layout can be placed in one copybook and be
placed wherever the files are used. It promotes program standardization since all the programs
share the same layout and the same data names.
This reduces coding and debugging time. Change in layout needs change in copybook only. It is
enough if we just recompile the program for making the new copy effective.
Syntax:
Example:
When a specific functionality need to be performed in more than one program, it is best to write
them separately and call them into each program. Sub Programs can be written in any
29
programming language. They are typically written in a language best suited to the specific task
required and thus provide greater flexibility.
CALL statement is used for executing the sub-program from the main program. A sample of
CALL statement is given below:
CALL 'PGM2' USING BY REFERENCE WS-VAR1, BY CONTENT WS-VAR2.
PGM2 is called here. WS-VAR1 and WS-VAR2 are working storage items.
WS-VAR1 is passed by reference. WS-VAR2 is passed by Content. BY REFERENCE is default
in COBOL and need not be coded. BY CONTENT LENGTH phrase permits the length of data
item to be passed to a called program.
Sub-Program Changes:
01 LINKAGE SECTION.
05 LK-VAR1 PIC 9(04).
05 LK-VAR2 PIC 9(04).
In addition to define them in linkage section, the procedure division should be coded with these
data items for address-ability.
30
Difference between Pass-by-reference and Pass-by-content
Sl
Passl By Reference Pass By Content
#
CALL 'sub1' USING BY REFERENCE CALL 'sub1' USING BY CONTENT WS-VAR1 (BY
1
WS-VAR1 CONTENT keyword is needed)
It is default in COBOL. BY BY CONTENT key word is mandatory to pass an
2
REFERENCE is not needed. element by value.
3 Address of WS-VAR1 is passed Value of WS-VAR1 is passed
The sub-program modifications on the The sub-program modifications on the passed
4 passed elements are visible in the main elements are local to that sub-program and not
program. visible in the main program.
Sl
STATIC Call DYNAMIC Call
#
Identified by Call variable and the variable should be
Identified by Call literal. Ex: CALL
1 populated at run time. 01 WS-PGM PIC X(08).
'PGM1'.
Move 'PGM1' to WS-PGM CALL WS-PGM
If you want convert the literal calls into DYNAMIC,
Default Compiler option is NODYNAM
the program should be compiled with DYNAM
2 and so all the literal calls are considered
option. By default, call variables and any un-resolved
as static calls.
calls are considered as dynamic.
If the subprogram undergoes change, sub
If the subprogram undergoes change, recompilation
3 program and main program need to be
of subprogram is enough.
recompiled.
Sub modules are link edited with main Sub modules are picked up during run time from the
4
module. load library.
5 Size of load module will be large Size of load module will be less.
6 Fast Slow compared to Static call.
7 Less flexible. More flexible.
Sub-program will not be in initial stage
the next time it is called unless you
8 Program will be in initial state every time it is called.
explicitly use INITIAL or you do a
CANCEL after each call.
INTRINSIC FUNCTIONS:
Returns the length of the PIC clause. Used for finding length of group item
LENGTH :-
that spanned across multiple levels.
MAX :- Returns the content of the argument that contains the maximum value
MIN :- Returns the content of the argument that contains the minimum value
Returns the numeric value represented by an alphanumeric character string
NUMVAL :-
specified in the argument.
Same as NUMVAL but currency and decimal points are ignored during
NUMVAL-C :-
conversion.
31
CURRENT
:- Returns 21 Chars alphanumeric value – YYYYMMDDHHMMSSnnnnnn
DATE
INTEGER OF
:- Returns INTEGER equivalent of Gregorian date passed.
DATE
INTEGER OF
:- Returns INTEGER equivalent of Julian date passed.
DAY
DATE OF
:- Returns Gregorian date for the integer passed.
INTEGER
DAY OF
:- Returns Julian date for the integer passed.
INTEGER
FILE HANDLING
A data file is collection of relevant records and a record is collection of relevant fields. The file
handling in COBOL program involves five steps.
Steps in file-handing
1.Allocation: The files used in the program should be declared in FILE-CONTROL paragraph of
environment division. The mapping with JCL DDNAME is done here. The file is allocated to
your program by this statement.
2.Definition. The layout of the file and its attributes are defined in the FILE SECTION of DATA
DIVISION.
3.Open: Dataset is connected/readied to your program using OPEN statement. The mode of
OPEN decides the operation allowed and the initial pointer in the dataset. For example, EXTEND
mode allows only write access and the pointer is kept on the end of file to append.
4.Process: Process the file as per requirement, using the I-O statements provided by COBOL.
(READ, WRITE, REWRITE and DELETE)
5. Close: After the processing, close the file to disconnect it from the program.
32
SELECT Statement- OPTIONAL Clause
This can be coded only for input files. If OPTIONAL is not coded, then the input file is expected
to present in JCL. If not, an execution error will occur. If OPTIONAL is coded, then if the file is
not mapped in JCL, it is considered as empty file and the first read results end of file. The file can
also be dynamically allocated instead of static allocation in JCL.
FILENAME is the logical name used inside the program and DDNAME is the logical name in the
JCL, mapped with physical dataset. DDNAME can be prefixed with 'S-' to indicate QSAM file,
'-AS' to indicate ESDS file and with no prefix to indicate KSDS/RRDS file.
JCL Step executing the program should have a dataset with DDNAME as label
//DDNAME DD DSN=BPMAIN.EMPLOYEE.DATA, DISP=SHR
SELECT Statement-ORGANIZATION
It can be SEQUENTIAL (PS or VSAM ESDS), INDEXED (VSAM KSDS), RELATIVE (VSAM
RRDS). Default is Sequential.
SEQUENTIAL.
It is default access mode and it is used to access the records ONLY in sequential order. To read
100th record, first 99 records need to be read and skipped.
RANDOM.
Records can be randomly accessed in the program using the primary/alternate key of indexed file
organization or relative record number of relative organization.100th record can directly be read
after getting the address of the record from the INDEX part for INDEXED files.100th record can
directly be read for RELATIVE files even without any index.
DYNAMIC.
It is mixed access mode where the file can be accessed in random as well as sequential mode in
the program. Example: Reading the details of all the employees between 1000-2000. First
randomly access 1000th employee record, then read sequentially till 2000th employee record.
START and READ NEXT commands are used for this purpose in the procedure division.
It is primary key of VSAM KSDS file. It should be unique and part of indexed record structure.
33
SELECT Statement-ALTERNATE RECORD KEY IS
This phrase is used for KSDS files defined with AIX. Add the clause WITH DUPLICATES if the
AIX is defined with duplicates. Referring to VSAM basics, every alternate index record has an
associated PATH and the path should be allocated in the JCL that invokes this program. The
DDNAME of the path should be DDNAME of the base cluster suffixed with 1 for the first
alternate record clause, suffixed with n for nth ALTERNATE RECORD KEY clause in SELECT
clause.
WS-FILE-STAT1 should be defined as PIC X(02) in working storage section. After every file
operation, the file status should be checked for allowable values. WS-FILE-STAT2 can be coded
for VSAM files to get the VSAM return code (2 bytes), VSAM function-code (1 byte) and
VSAM feedback code (3 bytes). This is a 6- byte field in working storage.
RESERVE Clause.
RESERVE clause [RESERVE integer AREA ] can be coded in the SELECT statement. The
number of buffers to be allocated for the file is coded here. By default two buffers will be
allocated if the clause is not coded. Since similar option is available in JCL, this is not coded in
program.
RESERVE 1 AREA allocates one buffer, for the file in the SELECT statement.
FD FILENAME
RECORDING MODE IS V/VB/F/FB
RECORD CONTAINS M CHARACTERS (TO N CHARACTERS)
BLOCK CONTAINS X CHARACTERS/RECORDS (TO Y CHARACTERS/RECORDS)
LABEL RECORDS ARE OMITTED/STANDARD
DATA RECORD IS FILE-RECORD.
01 FILE-RECORD PIC X(nnn).
FD-RECORD CONTAINS
It specifies the length of the record in terms of bytes. (It will be RECORD contains m to n
CHARACTERS for variable format files)
FD-BLOCK CONTAINS
It specifies the physical record size. It can be mentioned as number of logical records OR number
of characters, that is multiple of logical record length. It is suggested to code BLOCK
CONTAINS 0 RECORDS so that system will decide the optimum size for the file based on the
device used for storing the file. BLOCK CONTAINS clause is treated as comments for VSAM
files.
34
Advantage of Blocking:
1.I-O time is reduced as n numbers of records are read into main memory buffer during an I-O.
2.Inter record gap is removed and the gap exist only between blocks. So memory wastage due to
IRG is avoided.
FD-RECORDING MODE IS
If there is no recording mode/record contains clause, it is still possible to identify variable length
records. If there is an OCCURS depending on clause or there are multiple 01 levels and every 01
level is of different size, then the file would be of variable length. Multiple 01 level in File section
is an example for implicit redefinition.
As a general rule, LABEL RECORDS are STANDARD is coded for Disk and Tape files, LABEL
RECORDS ARE OMITTED is coded for printer files. In COBOL74, this clause is a mandatory
clause whereas COBOL85 made this as optional.
It is used to name the data record(s) of the file. More than one record can be coded here.
OPEN STATEMENT
Syntax:
CLOSE statement.
The used files are closed using CLOSE statement. If you don't close the files, the completion of
the program closes all the files used in the program.
Syntax:
35
CLOSE FILENAME
If more than one file is stored in a reel of tape, it is called as multi-file volume. When one file is
stored in more than one reel of tape, it is called as multi-volume label. One reel is known as one
volume. When the end of one volume is reached, automatically the next volume opens. So there
is no special control is needed for multi volume files.
After opening a TAPE file, the file is positioned at its beginning. When opening the file if the
clause REVERSED is coded, then the file can be read in the REVERESE direction. (Provided
hardware supports this feature)
When you close the file, the tape is normally rewound. The NO REWIND clause specifies that
the TAPE should be left in its current position.
CLOSE statement with REEL option closes the current reel alone. So the next READ will get the
first record of next REEL. This will be useful when you want skip all the records in the first reel
after n number of records processing.
Since TAPE is sequential device, if you create multiple files in the same TAPE, then before
opening the second file, first file should be closed. At any point of time, you can have only one
file is active in the program. In addition to this, you have to code MULTIPLE FILE clause in the
I-O control paragraph of environment division.
MULTIPLE FILE TAPE CONTAINS OUT-FILE1 POSITION 1
OUT-FILE3 POSITION 3.
The files OUT-FILE1 and OUT-FILE3 used in the program are part of a same TAPE and they
exist in first and third position in the tape. Alternatively, this information can be passed from JCL
using LABEL parameter.
READ statement
Syntax:
READ FILENAME [INTO ws-record] [KEY IS FILE-KEY1]
[AT END/INVALID KEY imperative statement1]
[NOT AT END/NOT INVALID KEY imperative statement2]
END-READ
If INTO clause is coded, then the file is directly read into working storage section record. It is
preferred as it avoids another move of file-section-record to working-storage-record followed by
simple READ. READ-INTO is not preferred for variable size records where the length of the
36
record being read is not known.
KEY IS clause is used while accessing a record randomly using primary/alternate record key.
AT END and NOT AT END are used during sequential READ of the file.
INVALID KEY and NOT INVALID KEY are used during random read of the file. Before
accessing the file randomly, the key field should have a value before READ.
WRITE Statement
Write statement is used to write a new record in the file. If the file is opened in EXTEND mode,
the record will be appended. If the file is opened in OUTPUT mode, the record will be added at
the current position.
Syntax:
WRITE FILE-RECORD [FROM ws-record]
[INVALID KEY imperative statement1]
END-WRITE
FROM clause avoids the explicit move of working storage record to file section record before
WRITE.
REWRITE Statement
REWRITE is used to update an already read record. To update a record in a file, the file should be
opened in I-O mode.
Syntax:
REWRITE FILE-RECORD [FROM ws-record]
[INVALID KEY imperative statement1]
END-REWRITE
START Statement
START is used with dynamic access mode of indexed files. It establishes the current location in
the cluster for READ NEXT statement. START itself does not retrieve any record.
Syntax:
START FILENAME KEY is EQUAL TO/NOT LESS THAN/GREATER THAN key-name
[INVALID KEY imperative statement1]
END-START.
37
DELETE Statement
DELETE is used to delete the most recently read record in the file. To delete a record, the file
should be opened in I-O mode.
Syntax:
DELETE FILENAME RECORD
[INVALID KEY imperative statement1]
END-DELETE.
There are chances for failure of any file I-O processing. The failure of an I-O operation can be
accepted or cannot be tolerated. The severity of failure has to be defined in the program design
stage.
Let us assume that we don't have any error handling in our program. In this case, for example, if
you don't have a specific record in the file, the random read of that record would immediately
terminate the program with error 'record not found'.
The sudden termination can be avoided by handling this error, with INVALID KEY clause of
READ. Based on the importance of the record and business rule, we can continue our program
with next record or terminate the program properly.
AT END is another error handling clause provided by COBOL. But there is no way to handle all
such errors in this way.
The second method is, assigning file-status to the file in the SELECT clause and checks the file
status after each and every I-O and ensures that the value of status code is one of the allowable
values. If it is not an allowable return code, then abnormally end the program with error
statements that would be easier to debug.
But we have to do this checking after each and every I-O operation.
This is MOST PREFERRED ERROR HANDLING METHOD in structured programming.
COBOL provides an option to group all the possible errors of specific operation(s) in a place and
that will be automatically invoked during the respective operation(s) of any file. This avoids
redundant code.
This is done in DECLARATIVE section of the procedure division. DECLARATIVE should be
the first section in the procedure division if coded.
PROCEDURE DIVISION.
DECLARATIVES.
USE-PROCEDURE SECTION.
USE AFTER EXCEPTION PROCEDURE ON INPUT.
38
ERROR-PROCEDURE.
Check the file-status code for validity.
END-DECLARATIVES.
Whenever there is an error in the processing of ANY FILE opened in INPUT mode, then the
control comes to ERROR-PROCEDURE. The validity of error should be checked in this
paragraph and allow or restrict the process down, based on severity of error code.
Syntax:
RESERVE clause of SELECT statement specifies the number of buffers to be allocated for a file.
SAME AREA allows more than one file to use the same buffer area. This will be very useful
when the program must work with a limited memory space. But the problem is only one file
should be open at a time if SAME AREA is coded.
Syntax:
Syntax:
Syntax:
SAME SORT|SORT-MERGE AREA for file-1 file-2. File-1 or file-2 should be a SD file.
39
I-O CONTROL- RERUN Clause
ENTRY statement
ENTRY statement establishes an alternate ENTRY point in a COBOL called sub-program. When
a CALL statement naming the alternate entry point is executed in a calling program, control is
transferred to the next executable statement following the entry statement. Except when a CALL
statement refers to an entry name, the ENTRY statements are ignored at run-time.
Matching Logic
If you have been given two files of similar type, say master and transaction file and you are
requested to update the master file with transaction file information for existing records and
prepare a report of new transactions and deleted transactions, then you should go for what is
called Matching logic. This is also known as co-sequential processing.
Sort both the files on key and compare the keys. If the keys are matching then update the file. If
you find any record that is found in transaction but not in master file, then that is new addition
and the reverse is deletion. If the master key is greater than transaction key, then that corresponds
to the first case and reverse is the second case.
This can be easily done in JCL using ICETOOL.
40
FILE STATUS CODES
File
Result Explanation
Status
VALID DUPLICATE ALTERNATE
2 N/A
KEY DETECTED.
ATTEMPT TO OPEN A FILE THAT
5 N/A
IS NOT AVAILABLE.
INCONSISTENCY IN STORAGE
7 N/A
DEVICE.
A sequential READ statement was attempted and no
next logical record existed in the file because the end
10 END OF FILE REACHED of the file had been reached, or the first READ was
attempted on an optional input file that was not
present.
INVALID READ ATTEMPT ON A sequential READ statement was attempted for a
RELATIVE FILE. THE GIVEN RRN relative file and the number of significant digits in
14
NUMBER IS LARGER THAN THE the relative record number was larger than the size of
RELATIVE KEY. the relative key data item described for the file.
A READ WAS ATTEMPTED WHEN
16 AT THE END CONDITION IS N/A
TRUE.
20 INVALID KEY. N/A
A sequence error exists for a sequentially accessed
indexed file. The prime record key value has been
changed by the program between the successful
21 RECORD OUT OF SEQUENCE execution of a READ statement and the execution of
the next REWRITE statement for that file, or the
ascending requirements for successive record key
values were violated.
An attempt was made to write a record that would
create a duplicate key in a relative file; or an attempt
was made to write or rewrite a record that would
create a duplicate prime record key or a duplicate
22 DUPLICATE KEY
alternate record key without the DUPLICATES
phrase in an indexed file. This key value applies to an
indexed file in which the alternate key has been
declared 'UNIQUE'.
An attempt was made to randomly access a record
that does not exist in the file, or a START or random
23 RECORD NOT FOUND
READ statement was attempted on an optional input
file that was not present.
An attempt was made to write beyond the externally
defined boundaries of a relative or indexed file. Or, a
NO MORE SPACE ALLOCATED TO
sequential WRITE statement was attempted for a
24 FILE. WRITING BEYOND THE
relative file and the number of significant digits in
ALLOCATION OF THE FILE.
the relative record number was larger than the size of
41
42
Cobol Coding
All level numbers increment by an odd number in order to allow for the insertion of extra levels
during modifications; this reduces the need for wholesale renumbering of the levels with all the
problems that this entails.
4.
01 LEVEL-1.
05 LEVEL-2.
10 LEVEL-3 PIC 9(02) COMP-3 VALUE ZEROES.
PARAGRAPHs or SECTIONs should be used; they should not be mixed except when the
5. PARAGRAPH names are used to subdivide the SECTION. If this is used then only the SECTIONs
should be performed.
It corresponds to the sequence/logical position in the structure of the code. This enables the location
6. to be easily ascertained in a listing and also allows the user to see where the program has
progressed to in the event of any problems.
The SORT and MERGE statements should be avoided if at all possible, it is more efficient to use an
external sort, e.g. SYNCSORT/DFSORT, rather than calling the internal sort which also uses one of
these sorts. This is because with an internal sort, control is passed back to the program after each
7. record reducing the speed of the sort. It is also easier to debug a COBOL program than it is to
debug the dump from an internal sort abend. If SORT routines are used then the maximum key
length is 4092 bytes with no maximum number of keys. To increase the efficiency of the sort, keep
the key fields at the start of the record and as contiguous as possible.
GOTO should never be used; a structured program should not need to use this command. If
however because of coding or processing constraints, then the only possible use is to transfer
8.
control to the end of the SECTION or PARAGRAPH being processed. It MUST NOT be used in
any other case.
Nested IF statements should be avoided and consideration should be given to the use of
EVALUATE as an alternative. The other option is to restructure the logic of the program so that the
if statement is either eliminated or simplified. The WHEN OTHER must always be coded; if this is
9.
not present then if none of the prior conditions are satisfied then the program will fall through with
no processing occurring. The WHEN OTHER statement should always be the last option; if it is not
then all conditions following are irrelevant as they will not be tested.
Care should be taken when using STRING and UNSTRING as this may hide data structures. When
using these operations then the ON OVERFLOW clause should always be used; if this is not used
10.
then you are not notified of the incomplete operation and control passes to the next sequential
statement.
11. All structures are terminating with END-XXX.
43
JCL(Job Control Language)
1. WHAT IS JCL?
JCL is not used to write computer programs. Instead it is most concerned with input/output---
telling the operating system everything it needs to know about the input/output requirements. It
provides the means of communicating between an application program and the operating system
and computer hardware.
44
1.2 IS JCL DIFFICULT? ... NOT NECESSARILY!
The role of JCL sounds complex and it is---JCL can be downright difficult.
JCL can be difficult because of the way it is used. A normal programming language, however
difficult, soon becomes familiar through constant usage. This contrasts with JCL in which
language features are used so infrequently that many never become familiar.
• consists of individual parameters, each of which has an effect that may take pages to
describe
• has few defaults--must be told exactly what to do
• requires specific placement of commas and blanks
• is very unforgiving--one error may prevent execution
JCL is not necessarily difficult because most users only use a small set of similar JCL that never
changes from job to job.
Interactive Processing means that you give the computer a command and the computer responds
to your command request. It is more like a conversation.
Batch Processing means that you give the computer a whole group of commands, usually in the
form of some sort of program you have written, and have the computer process this group of
commands. It is more like writing a letter.
| | | |
name operation operand field comment field
field field
name field - identifies the statement so that other statements or the system can refer to it. The
name field must begin immediately after the second slash. It can range from 1 to 8 characters in
length, and can contain any alphanumeric (A to Z) or national (@ $ #) characters.
operation field - specifies the type of statement: JOB, EXEC, DD, or an operand command.
operand field - contains parameters separated by commas. Parameters are composites of
prescribed words (keywords) and variables for which information must be substituted.
comments field - optional. Comments can be extended through column 80, and can only be coded
if there is an operand field.
45
General JCL Rules:
When the total length of the fields on a control statement exceeds 71 columns, continue the fields
onto one or more following statements.
• Interrupt the field after a complete operand (including the comma that follows it) at or
before column 71
• Code // in columns 1 and 2 of the following line
• Continue the interrupted statement beginning anywhere in columns 4 to 16.
JCL should be commented as you would any programming language. The comments statement
contains //* in columns 1 to 3, with the remaining columns containing any desired comments.
They can be placed before or after any JCL statements following the JOB statement to help
document the JCL. Comments can also be coded on any JCL statement by leaving a blank field
after the operand field.
DD Data Definition, i.e., Identifies what resources are needed and where to find them
46
The JOB statement informs the operating system of the start of a job, gives the necessary
accounting information, and supplies run parameters. Each job must begin with a single JOB
statement.//jobname JOB USER=userid
jobname - a descriptive name assigned to the job by the user which is the banner on your printout
- any name from 1 to 8 alphanumeric (A-Z,0-9) or national ($,@,#) characters
- first character must be alphabetic or national
4.1.1 MSGCLASS
The MSGCLASS parameter allows you to specify the output class to which the operating system
MVS is to write the job log or job entry subsystem (JES) messages. If you do not code the
MSGCLASS parameter, MSGCLASS=J is the default and will be used. MSGCLASS=J indicates
the output will be printed on 8 1/2" by 11" hole paper.
• A greenbar paper
• 5-9 TSO held output
• C-Z IBM page printer output classes. See chart in section "Sys-out Classes for IBM
Print" on page 28.
47
5. THE EXEC STATEMENT
Use the EXEC (execute) statement to identify the application program or cataloged or in-stream
procedure that this job is to execute and to tell the system how to process the job.
// EXEC PGM=pgmname
A program referred to on the EXEC PGM= statement is a compiled and linked version of a set of
source language statements that are ready to be executed to perform a designed task. It is also
known as an executable load module. It must reside in a partitioned dataset.
// EXEC cataloged-procedure-name
Because the same set of JCL statements are often used repeatedly with little or no change they
can be stored in cataloged procedures. JCL provides programmers with the option of coding these
statements only once, recording and cataloging the statements under an appropriate name in a
procedure library, and then invoking these statements through an EXEC statement. Such a
previously established set of JCL statements is known as a "cataloged procedure." The effect of
using a cataloged procedure is the same as if the JCL statements in the procedure appeared
directly in the input stream in place of the EXEC statement calling the procedure. This saves the
user from writing lengthy error-prone JCL statements. In short, this is JCL that does not have to
be included in batch jobs.
Additional statements may be added to the JCL comprising a cataloged procedure at the time of
invocation. Also, operand values on existing JCL statements may be altered or parameters defined
in the procedure may be substituted at invocation time.
48
The value in the override statement replaces the value for the same parameter in the cataloged
procedure. Cataloged procedure statements must be overridden in the same order as they appear
in the procedure.
//procstepname.ddname DD parameter=value
To modify an existing DD statement, only those operands to be changed need be coded on the
modifying DD statement. The remaining operands of the DD statement within the procedure will
be unchanged. If more than one DD statement in a procedure is to be modified, the modifying DD
statements must be placed in the same order as the original DD statements occur in the procedure.
To add a DD statement to an existing procedure, place the DD statement after the procdure
invocation EXEC statement and any modified DD statements within the job step.
// EXEC SAS
//NEWDD DD DSN=user.file,DISP=SHR
When looking at your output, the following symbols will determine what kind of statement is
indicated when your job runs:
A DD (Data Definition) statement must be included after the EXEC statement for each data set
used in the step. The DD statement gives the data set name, I/O unit, perhaps a specific volume to
use, and the data set disposition. The system ensures that requested I/O devices can be allocated
to the job before execution is allowed to begin.
The DD statement may also give the system various information about the data set: its
organization, record length, blocking, and so on.
49
//ddname DD operand,operand,etc.
DD - DD statement identifier
The DD Statement
Instream data is perhaps the most common form of input. To include data in the input stream,
code:
//ddname DD *
.
.
.
/* (to specify end of data)
SYSIN is often used as a ddname for instream data. The /* marks the end of the data.
In this example, the userid UGUSER is executing a Fortran procedure with the Fortran program
inserted after the FORT.SYSIN line and the data inserted after the GO.SYSIN line.
50
In this example, the userid UGIBM is executing a SAS procedure with the SAS program inserted
after the SYSIN line.
//ddname DD UNIT=unittype,
// DSN=userid.name,
// DISP=(beginning,normal-end,abnormal-end),
// SPACE=(TRK,(primary,secondary,directory)),
// RECFM=xx,LRECL=yy,MGMTCLAS=retainx
ddname - data definition name; a 1-8 character word of your choice, must begin with a letter or
$, @, #
DD - DD statement identifier
UNIT = unittype - an I/O unit is a particular type of I/O device: a disk, tape, etc. UNIT=SYSDA
refers to the next available disk storage device.
DSN=userid.name DSN parameter names the data set. Data sets can be temporary or
nontemporary. A temporary data set is created and deleted within the job, whereas nontemporary
data sets can be retained after the job completes. A data set name can contain up to 44 characters
including periods.
Ex. UGIBM.DATA
mgmtclas - MGMTCLAS specifies the name of the Management Class which is a set of
specifications for the way the storage occupied by the data set should be treated by SMS.
Generally, this deals with how long you want to keep this data set around. UCNS has set up the
following management classes:
51
RETAIN3 3 RETAIN14 14
RETAIN4 4 RETAIN28 28
RETAIN5 5 RETAIN56 56
RETAIN6 6 RETAIN95 95
RETAIN7 7 STANDARD (18 months past last use)
//ddname DD UNIT=unittype,VOL=SER=unitname,
// DSN=filename,
// DISP=(beginning,normal-end,abnormal-end),
// DCB=(RECFM=xx,LRECL=yy,BLKSIZE=zz,DEN=density),
// LABEL=(file#,labeltype,,mode)
ddname - data definition name; a 1-8 character word of your choice, must begin with a letter or
$, @, #
DD - DD statement identifier
UNIT=unittype - an I/O unit is a particular type of I/O device: disk, tape, etc.
TAPE16 refers to a 1600 bpi tape drive
TAPE62 refers to a 6250 bpi tape drive
TAPECA refers to a 38K or XF catridge tape drive
DSN=filename - DSN parameter names the file on the tape. The filename can be from 1 to 17
characters in length.
Ex. COWDATA
The DISP parameter describes the current status of the data set (old, new, or to be modified) and
directs the system on the disposition of the dataset (pass, keep, catalog, uncatalog, or delete)
either at the end of the step or if the step abnormally terminates. DISP is always required unless
the data set is created and deleted in the same step.
52
SHR PASS CATLG
MOD DELETE UNCATLG
UNCATLG
This is the status of the data set at the beginning of the step. If the data set is new, the system
creates a data set label; if it is old, the system locates it and reads its label
OLD designates an existing data set; it can be an input data set or an output data set to rewrite
SHR identical to OLD except that several jobs may read from the data set at the same time.
MOD modifies a sequential data set - positions the pointer at the end of the data set in order to
add new data to the data set.
Normal disposition, the second term in the DISP parameter, indicates the disposition of the data
set when the data set is closed or when the job terminates normally. The abnormal dispositions,
effective only if the step abnormally terminates, are the same as normal dispositions except that
PASS is not allowed.
PASS passes the data set on to subsequent job steps, and each step can use the data set once.
CATLG catalogs a nontemporary data set. CATLG is similar to KEEP except that the unit and
volume of the data set are recorded in the catalog along with the data set name.
UNCATLG uncatalogs a data set. UNCATLG is the same as KEEP except that the data set name
is removed from the catalog.
53
6.4.2 SPACE Parameter
All new data sets on disk volumes must be allocated space. Storage on disk volumes can be
allocated in units of blocks, cylinders, tracks, kilobytes and bytes.
The space may be requested as a primary and a secondary amount. The primary amount is
allocated when the data set is opened with a disposition of NEW. The secondary amount is
allocated if the primary amount is exceeded.
The primary amount can be conservative, with the secondary amount providing a reserve. The
secondary amount provides for data set growth over time.
secondary receive this amount of space each time more is needed (up to 15 times)
directory reserve this amount of blocks to keep the directory of a partitioned dataset (NOT
USED for a sequential dataset)
1 directory block allows for 5 members in a partitioned dataset
Any named collection of data is called a data set. A partitioned dataset consists of multiple files
within one data structure. A sequential dataset consists of one file within a data structure.
Partitioned Dataset
Sequential Dataset
54
|-----------------| | |
| MEMBER1 | | |
|-----------------| | DATASET |
| MEMBER2 | | |
|-----------------| | |
| ....... | | |
|-----------------| | |
| MEMBERn | | |
|--------------------------| |_______________|
|_______________|
A partitioned dataset differs from a sequential dataset in that it has a directory of its members.
Whenever you refer to a member of a partitioned dataset, you include the member name in
parentheses.
On the TSO service, data sets are typically created and reside on disk volumes. A volume is a
standard unit of storage. These disk volumes are referred to as DASD, which stands for Direct
Access Storage Device. Each block of data on a DASD volume has a distinct location and a
unique address, making it possible to find any record without extensive searching. One DASD
volume can be used for many different data sets, and space on it can be reallocated and reused.
At the University of Georgia, you are now required to utilize the Data Facilities Storage
Management Subsystem (DFSMS) to establish permanent data sets. The Storage Management
Subsystem (SMS) is an operating environment that automates the management of storage. With
SMS, users can allocate data sets more easily. The data sets allocated through the Storage
Management Subsystem are called system-managed. System-managed means that the system
determines data placement and automatically manages data availability, performance, space,
reclamation, and security. One of the most beneficial goals of System-managed storage is to
relieve users of performance, availability, space, and device management details.
DFSMS stores data in a device-independent format so that it can easily move the data to any of
the following devices:
• Management Class
• Data set Usage
• Minimum percent free space on a DASD Volume
• Request by storage administrator or user
55
DFSMS records the location of each dataset it moves in a control data set. The actual migration is
handled by DFHSM (Data Facilities Hierarchical Storage Manager). DFHSM is a DASD
management product tool for managing low-activity and inactive data.
Data sets that have reached the end of their retention period (expired) will be deleted. Data sets
with a management class of STANDARD will be deleted if the data set has not been referenced
for a period of eighteen months. A notification will be sent to the user after a STANDARD data
set has not been referenced for six months informing the user of the STANDARD deletion policy.
At this time the data set will be moved to tape.
All data sets that have a management class of RETAIN95 or STANDARD will be automatically
backed up by DFHSM. Two copies of each will be kept. The change indicator will trigger the
backup after the first backup is made. A user can use the HBACK command to add non-
STANDARD and non-RETAIN95 data sets to this.
// SPACE=(TRK,(primary,secondary,directory))
This SPACE example allows a total of 40 tracks for the dataset with 1 block of space reserved for
the directory.
// SPACE=(TRK,(10,2,1))
This SPACE example allows a total of 100 tracks for the dataset with 8 blocks reserved for the
directory.
// SPACE=(TRK,(25,5,8))
// SPACE=(TRK,(primary,secondary))
// SPACE=(TRK,(8,3))
56
This SPACE example allows a total of 520000 bytes for the dataset.
// SPACE=(80,(5000,100))
With SMS, you do not need to use the DCB parameter to specify data set attributes. ALL of the
DCB keyword subparameters (record length, record format, and blocksize) can be specified
without the need to code DCB=.
// DCB=(RECFM=FB,LRECL=80,BLKSIZE=8000)
// RECFM=FB,LRECL=80
The blocksize parameter can be omitted because SMS will select the optimum blocksize.
RECFM=xx specifies the record format. The format can be one or more of the following
characters:
F fixed-length records
V variable-length records
U undefined-length records
FB fixed and blocked
FBA fixed, blocked, with ANSI carriage control characters
VB variable and blocked
VBA variable, blocked, with ANSI carriage control characters
equal to the size of the largest record plus the 4 bytes describing the record's size
for
variable-length records
57
BLKSIZE=zz specifies the blocksize if you wish to block records
// RECFM=FB,LRECL=80,BLKSIZE=9040
This dataset will have fixed length records with a length of 80. There will be 113 records of data
per block.
// RECFM=VB,LRECL=255, BLKSIZE=3120
This dataset will have variable length records with a maximum of 255 characters. The blocksize
of the dataset will be 3120.
RECFM=xx specifies the record format. The format can be one or more of the following
characters:
F fixed-length records
V variable-length records
U undefined-length records
FB fixed and blocked
FBA fixed, blocked, with ANSI carriage control characters
VB variable and blocked
VBA variable, blocked, with ANSI carriage control characters
58
BLKSIZE=zz specifies the blocksize if you wish to block records
must be a multiple of LRECL for fixed-length records
must be equal to or greater than LRECL for variable-length records
must be as large as the longest block for undefined-length records
BLKSIZE can range from 1 to 32760 bytes
DEN=density measures the number of bits that are stored in a unit of measurement on the tape.
This measurement is commonly referred to as BPI (bits per inch).
when adding files to an existing tape all new files will be written at the same density
as the first file no matter if you specify differently.
The LABEL parameter tells the type of label, the relative file number on the tape, and whether the
data set is to be protected for input or output.
// LABEL=(file#,labeltype,,mode)
In this example, the userid UGIBM is executing a Fortran procedure with the Fortran program
inserted after the FORT.SYSIN line, and the data is being read by UNIT 3 from the data set
UGIBM.FOOD.
59
//FORTRUN JOB USER=UGIBM
// EXEC FORTVCLG, REGION=2000K
//FORT.SYSIN DD *
read(3,10) x,y
10 format(1x,f4.1,1x,f4.1)
/*
//GO.FT03F001 DD DSN=UGIBM.FOOD,UNIT=SYSDA,DISP=SHR
/*
//
In this example, the userid UGIBM is executing a SAS procedure with the SAS program inserted
after the SYSIN line and the data is being read from the data set UGIBM.DATA.
/*
//
In this example, the userid UGABC is executing a Fortran procedure with the Fortran program
inserted after the FORT.SYSIN line, and the results are written by UNIT 8 to the data set
UGABC.NEWFILE. This dataset will only be retained for 7 days. If the user decides to keep the
dataset for a longer period of time, the ALTER command can be issued. For example, ALTER
'UGABC.NEWFILE' MGMTCLAS(RETAIN14), will keep the dataset around for another week.
Since the BLKSIZE is not specified, SMS will determine the most efficient blocksize.
write(8,10) x,y
10 format(1x,f4.1,1x,f4.1)
/*
//GO.FT08F001 DD DSN=UGABC.NEWFILE,UNIT=SYSDA,
// DISP=(NEW,CATLG,DELETE),
60
// SPACE=(TRK,(40,10),RLSE),
// RECFM=FB,LRECL=80,MGMTCLAS=RETAIN7
/*
//
In this example, the userid UGXYZ is executing a SAS procedure with the SAS program
inserted after the SYSIN line and the results are written to the data set UGXYZ.SAS.DATA. This
dataset, based on the management class of standard, will be retained on the system as long as the
user utilizes it.
data example;
input x y z;
cards;
123
456
;
data _null_; set example; file newdata;
put x y z;
return;
/*
//
The SYSOUT parameter provides a convenient means of routing output to printers or other
devices.
//ddname DD SYSOUT=class
DD - DD statement identifier
SYSOUT=class - defines this data set as a system output data set, usually called a sysout data set
and assigns this sysout data set to an output class. Here is a list of available output classes:
61
• A greenbar paper
• 5-9 TSO held output
• C-Z IBM page printer output classes. See chart in section "Sysout Classes for IBM Print"
on page 28.
* Note that if a sysout data set has the same class as the MSGCLASS parameter, the job log
appears on the same output listing as this sysout data set.
SYSOUT*
PAPER ORIENTATION SIDES IMAGES CHAR/LINE LINES/IMAGE
CLASS
C hole landscape 1 1 132 62
D hole portrait 1 1 80 62
F bond landscape 2 1 132 62
G bond portrait 2 1 80 62
H bond landscape 2 2 90 80
I bond portrait 2 1 80 70
J hole landscape 2 1 132 62
K hole portrait 2 1 80 62
Q bond landscape 1 1 132 62
S bond portrait 1 1 80 62
W hole portrait 2 2 132 62
X bond portrait 2 2 132 62
Y bond landscape 2 1 132 62
Z hole landscape 2 1 132 62
Graybar Overlay: The paper used for classes C,F,H,J, and Q is shaded to mimic standard greenbar
paper.
Service Site Page Printers: To route your output to one of the page printers in the Journalism or
Aderhold sites, you must use a SYSOUT class or message class (MSGCLASS) with a paper type
of "hole" (C, D, J, K, W, or Z).
Line Printer SYSOUT Class: To route your output to a line printer, use a SYSOUT class or
message class (MSGCLASS) of A. Your output will be printed on greenbar paper.
Special Hold Classes: To route your output to a hold queue, use a SYSOUT class or message
class (MSGCLASS) of 5, 6, 7, 8, or 9.
------------------------
62
* SYSOUT class values may be used for message class (MSGCLASS).
The OUTPUT statement is used to specify processing options for a system output data set. These
options are used only when the OUTPUT statement is explicitly or implicitly referenced by a
sysout DD statement.
PAGEDEF=pdef - specifies the logical page length and width, fonts, lines within a page, and
multiple logical pages on a physical page
POR1 portrait, 62 lines at 6 lines per inch
POR2 portrait, 70 lines at 6 lines per inch
POR3 portrait, 2 up format, 62 lines per frame
LAN1 landscape, 62 lines at 8 lines per inch
LAN2 landscape, 2 up format, 80 lines per frame
COPIES=n - specifies how many copies of the sysout data set are to be printed
63
SSS03 Aderhold Building
NCT19 Brooks Hall
DEFAULT=dd - specifies that this OUTPUT statement can or cannot be referenced by a sysout
DD statement
YES specifies that this is the default OUTPUT statement for for all print files within a job
NO specifies that this is not the default OUTPUT statement
* Note if you are going to HOLD a print dataset with an OUTPUT statement associated with it,
you will have to fully specify all of the parameters on the OUTPUT statement. Contact the UCNS
Helpdesk for more details.
To request that the "gray bar" overlay not print on a landscape sysout class for all print files,
code:
To request simplex (one sided) printing for a duplex sysout class for all print files, code:
- with -
//ddname DD SYSOUT=F,OUTPUT=*.OUT1
The //*MAIN statement is used to define the processor requirements for the current job. It
specifies what time the job will be executed, how many lines in the job, and where the job is to be
printed.
//*MAIN CLASS=x,LINES=y,ORG=UGAIBM1.org
64
CLASS=x specifies the job class for this job
B Batch (default) Anytime daily
NITE 6:00 PM until 7:00 AM daily
WEEKEND 6:00 PM Friday until 7:00 AM Monday
Z 1:30 AM until 7:00 AM daily, weekends, holidays
BL 6:00 PM until 7:00 AM daily, more than 8 MEG region
ZL 1:30 AM until 7:00 AM daily, more than 8 MEG region
LINES specifies the maximum number of lines of data to be printed from this job in multiples of
a thousand (default = 5000)
Since TSO is a time sharing operating system, it allows many people to use the computer at the
same time in such a way that each is unaware that the computer is being used by others. Time
sharing attempts to to maximize an individuals use of the computer, not the efficiency of the
computer itself. In order to do this, job scheduling is used to assign jobs to a certain class in order
to maximize the resources available to each user.
Priority
-------
___________
BATCH| 4
|
| __________ 3
____
NITE | ____ 2
//*MAIN CLASS=NITE
or
//*MAIN CLASS=WEEKEND
65
6 0-30 0-2048 0-5000 0
The //*OPERATOR statement is primarily used to issue a message to the operator requesting that
the tape with the specific VRN, VSN and KEYWORD is to be mounted for the job.
VRN will be assigned when the tape is checked in. This identifies the tape in the tape library.
Cartridge Tapes must have #C in the first two column positions on the vrn parameter.
VSN the volume serial number on the the internal label of a standard labeled tape. This must be
the actual internal label. For non-labeled tapes, this can be any arbitrary name. In both cases, the
VSN must match the VOL=SER parameter on the DD card.
KEY is a password that you will assign to the tape for security purposes. The operator will check
the keyword in your JCL against the keyword on the tape before mounting the tape.
The //*Operator statement in the JCL stream is placed after the JOB or //*MAIN statement and
before the EXEC statement. Each //*Operator statement should be referenced by a DD statement
to read or write a file to the tape.
The following example illustrates the operator card with the referencing DD statement. Note that
the VSN and the VOL=SER must be the same. In this example, the user is going to read the first
file on a standard labeled (SL) tape with the name COWDATA. The tape is going to be read on a
6250 BPI tape drive.
66
10. EXAMPLE FORTRAN AND SAS PROGRAMS
In this example, the userid UGA001 is executing a Fortran procedure with the Fortran program
inserted after the FORT.SYSIN line and the data inserted after the GO.SYSIN line. This job will
not begin executing until after 6:00PM, and the output will be held to the terminal by the
MSGCLASS=6.
read(5,10) cent
10 format(f6.2)
fahr=(cent*9/5)+32
write(6,20) cent,fahr
20 format(f6.2,' cent = ',f6,2,'fahr')
/*
//GO.SYSIN DD *
100.00
/*
//
In this example, the userid RESRCH is executing a SAS procedure with the SAS program
inserted after the SYSIN line and the data is being read from the first file of a standard labeled
cartridge tape with the file name of DATAFIL. The output will go directly to the printer with the
sysout class of S.
67
// DSN=DATAFIL,
// DISP=(OLD,PASS)
//SYSIN DD *
data one;
infile sampdata;
input a b c d;
proc print;
/*
//
The UCNS Helpdesk, located in the Computer Services Annex on the corner of East Campus
Road and Cedar Street and on the first floor of the Boyd Graduate Studies Research Center,
function as the initial contact point for all computer related needs associated with the University
of Georgia computer systems. The primary purpose of the Helpdesk is to aid faculty, staff, and
students with the use of our computer systems through general consulting and information
requests. Assistance is provided through telephone contacts, walkins, and electronic mail.
• IBM MVS JCL Publication No. GC28-1300 - This manual is the basic reference
document on the syntax and usage of IBM JCL. This manual is available for reference at
the Client Services Help Desk.
• System/370 Job Control Language by Gary Deward Brown - This reference is a standard
and popular textbook for introducing IBM JCL to persons familiar with computers but
not necessarily IBM 370 systems.
68
JCL Utilities:-
JCL or Job Control Language is used to communicate with the computer’s operating system. A
JOB is a unit of work the computer is to perform. A JOB STREAM consists of JCL statements,
programs that are to be executed, and data that are to be processed. The data included in the job
stream are called INPUT STREAM DATA
JCL statements :-
JOB statement :- The first statement in a job stream must be a job statement whose function is to
identify the job to the system.
EXEC statement :- The job statement is usually followed by an exec statement. The exec
statement names the program or the procedure that is to be executed.
DD statement :- Following the exec statement are the DD statements (data definition)
statements. The DD statements describe the data used by the program.
The other JCL statements are delimiter, null, comment, proc & pend.
Job executes procedures, procedures have various steps to execute various programs, which use
parameters and parameter files.
Naming conventions :-
69
Parameters used will be held in datasets with .parm or parmlib extensions
e.g ORSLIVE.REL#1.PARMS
Parameters :-
There are two kinds of parameters in the operand field :- positional and keyword
parameters. The operating system recognizes positional parameters by their position in the
operand field. Keyword parameters can be coded in any order. Positional parameters must be
coded in a specific order before any keyword parameter.
Consider the job statement :-
Symbolic parameters
Symbolic parameters offer a convenient way of changing a procedure to fit your requirement.
Consider the example procedure-proglod, sysctl, sym, etc. are all symbolic parameters. Symbolic
parameter names may consist of from one to seven alphanumeric or national characters preceded
by an ampersand. The first character however must be alphabetic / national. Exec statement
keyword parameters may not be used as names of symbolic parameters. For e.g., & REGION.
This restriction does not extend to DD statement keyword parameters. For e.g. &DSN can be
used as symbolic parameter.
Linkage parameter
Linkage parameters are used in COBOL programs. Linkage parameters are passed on to the
COBOL programs through JCL by coding ‘parm=‘ parameter in the exec statement. Whenever
70
linkage parameters have to be used, Linkage section has to be coded in the COBOL program after
the data division and the procedure division should specify the use of linkage section.
//DD400S01 EXEC PGM=DD400900,PARM='&PROCTYPE&DBNME&DICTNME'
A generation data group is a collection, or group, of cataloged data sets having the same name
and related to one another chronologically. Each of these datasets is called a generation data set
or, simply, a generation.
Each generation data set is distinguished by others by the generation number.
The main advantage of using a GDG is that the same JCL can be reused without change.
Generation group index contains information on how many generations are to be retained and
what to do when the index gets full.
71
If you want to create a new generation,
you code DSN= DDSNUS.DEVTDV.DD460302(+1).
The absolute no. used by the system is in the form GXXXXVYY,where xxxx is a generation no.
from 0000 to 9999 and yy is a version no. from 00 to 99.
Thus the generation specified as DSN= DDSNUS.DEVTDV.DD460302(0) might appear to the
system, for e.g.. ,as
DDSNUS.DEVTDV.DD460302.G0006V00.
Then the data set with a relative no. of (-1) would be
DDSNUS.DEVTDV.DD460302.G0005V00,
(+1) would be DSNUS.DEVTDV.DD460302.G0007V00.
Libraries
IEFBR14
Strictly speaking it is not a utility program because it does nothing. It clears register 15 and
BR(branch) 14.
It is used to create or delete a library based on the DD statement parameters.
IEBGENER
IEBGENER uses four data sets described by SYSPRINT, SYSIN, SYSUT1 & SYSUT2.
SYSPRINT is the DDNAME of the data set that IEBGENER uses to write messages.
SYSIN is the DDNAME of the data set that contains the control statements to tell IEBGENER
how the input data set should be modified while it is being copied.
SYSUT1 is the DDNAME of the input data set that IEBGENER is to copy.
SYSUT2 is the DDNAME of the output data set that is to be created.
IEBCOPY
IEBCOPY is a utility program that may be used to copy one or more members from an existing
PDS to a new or existing PDS, to make a backup copy of a PDS, and to reorganize a PDS in order
to reclaim the unused space.
DFSORT
72
datasets into one data set that is in the same order.
The sort program requires three pieces of information: where to find the input data, which fields
in the records to do the sorting on, and where to put the sorted output data set.
The most commonly used sort control statements are SORT and MERGE.
A typical control statement would look like : SORT FIELDS=(1,10,CH,A).
The syntax for the fields parameter is FIELDS=(position,length,format,sequence...) or
FIELDS=(position,length,sequence...), FORMAT=format.
Position is the starting byte of the control field in the record.
Length is the length in bytes of the control field.
Format is the format of the data in the control field.
Commonly used values for format are ZD for zoned decimal, PD for packed decimal, BI for
binary, AC for ASCII character, CH for EBCDIC character, AQ for EBCDIC character using
alternative collating sequence.
Sequence is either A for ascending or D for descending.
The include & omit statements The include & omit statements are used to select the records to
be included in the sort. By selecting records for the sort, you can decrease the amount of time the
sort requires.
Only one include or omit statement is permitted in a sort. The syntax is include cond=(test) &
omit cond=(test)
The only difference between include & omit is in the result. If test coded with include is true for a
particular record, that record is included in the sort; whereas if test coded with omit is true, that
record is omitted from the sort.
In either case test is coded as follows test=(position,length,format,operator,value) The
position,length & format sub parameters specify a field in the record,just as in sort fields
parameter.
The operator sub parameter may be GT, GE, EQ, NE, LT & LE.
The last sub parameter, value, may be either a field in the record-specified by its own position,
length & format, or a constant.
Numeric constants are coded as simple values, such as 15 or -20. Character constants are
enclosed in apostrophes and preceded by a c,as in c’dec’. Hexadecimal constants are enclosed in
apostrophes and preceded by an x,as in x’f1f2c3’.
If more than one test is coded, the tests are joined by the boolean operator AND or OR..
73
alignment on a half-word, full-word, and double-word boundary respectively.
Merging
When you merge, you start with two or more sorted data sets and create a new data set that is in
the same sorted order.
While merging you must specify more than one input data set. These data sets have the DD
names SORTINnn, where nn may range from 01 to 16.
SKIPREC & EQUALS / NOEQUALS options are not used on the merge statement.
The sort control statements are normally coded in a parameter file.
There are three types of VSAM data sets : key sequence data sets,entry sequence data sets, and
relative record data sets. For VSAM data sets, unlike non-vsam data sets, a utility program,
IDCAMS is used to perform functions like :
DEFINE CLUSTER
is the command using which all the descriptive information about the VSAM data set is supplied.
REPRO
FILE-AID
utility from ISPF primary menu(v.1) can be used to allocate / manage VSAM data sets.
74
JCL Error Codes
An I/O error ocurred. Check reason code for exact cause. Examples are
S001 trying to read beyond End of File, trying to write to an input file or a file
length error.
Invalid I/O record, eg attempting to write a record that is longer than the
S002
maximum record length.
S004 Error occured during OPEN. Eg Invalid DCB.
Error OPENing a dataset, eg PDS member does not exist, record length
S013
in program doesn’t match dataset’s record length.
Operation Exception. Check for subscript errors, missing DD card, file
S0C1
not opened.
Protection Exception/Storage Violation. Trying to access storage not
S0C4 available to the program. Can be caused by a subscripting error or
reading/writing a file that isn’t open.
Program Check Exception - Data. Check for spaces in a packed decimal
S0C7 or numeric field. Check to see if record layouts or file layouts have been
changed.
Job has been cancelled. The value of x will vary depending on the way
the job was cancelled. S222 means job was cancelled by a user or
Sx22
operator without a dump. If a TSO session times out you will probably
get an S522 abend code.
Unable Link or Load. The job was unable to find the specified load
S806 module. Check that the job is looking at the correct Load Libraries,
specify a STEPLIB if required.
Not enough Virtual Sorage to satisfy a GETMAIN or FREEMAIN
S80A
request.
Unable to obtain to obtain enough space to satisfy a REGION= request
S822
May need to change REGION statement in the JCL..
Not enough storage available to satisfy a GETMAIN or FREEMAIN
S878 request.. Job was anable to allocate an area of memory of the correct
size. Try Specifying or amending the ‘REGION=’ JCL statement.
S913 You are trying to access a dataset which you are not authorized to use.
Unable to allocate enough storage for a dataset. You might need to
increase the amount of primary and secondary space to be allocated for a
Sx37 dataset in the ‘SPACE=’ parameter, or you may have to move the dataset
to a different DASD devive which has enought space to store the
dataset. ‘x’ will vary, likely Abends are SB37, SD37 or SE37.
U1020 I/O Logic error. Typical reasons are; trying to write to a file opened as
input; Rewrite without a previous read. See the message IGZ020I for
75
details of the exact reason.
Inavlid OPEN/CLOSE. Check there is a DD statement for the file. See
U1035
the message IGZ035I for more detailed information.
These codes indicate VSAM errors. They appear on the JOB log.
76
Retrieval, the key requested is lower than the previous key requested.
For Shared Resources, buffer pool is full.
016(10) Record not found.
020(14) Record already held in exclusive control by another requester.
024(18) Record resides on a volume that cannot be mounted.
Data set cannot be extended because VSAM can't allocate additional
Direct-Access Storage Space. Either there is not enough space left to
028(1C)
make the secondary allocation or you attempted to increase the size of
a data set while processing SHROPT=4 and DISP=SHR.
Key Ranges were specified for the data set when it was defined but no
036(24)
range was specified that includes the record to be inserted.
Insufficient Virtual Storage to complete the request. 044(2A) Work
040(28)
area too small. 064(40) All available strings are in use.
You attempted to use a type of processing (Output or Control-Interval
068(44)
Processing) that was not specified when the data set was opened.
074(4A) Trying to use keys on ESDS or RRDS.
You issued an Addressed or Control-Interval PUT to add to a Key-
076(4C) Sequenced data set, or issued a Control-Interval put to a Relative
Record data set.
080(50) Trying to delete from ESDS.
084(54) Using OPTCODE=LOC for a PUT.
You issued a Sequential GET request without having caused VSAM
to be positioned for it, or you changed from Addressed Access to
Keyed Access without causing VSAM to be positioned for Keyed-
088(58)
Sequential Retrieval; there was no Sequential PUT insert for a
Relative Record data set, or you attempted an illegal switch between
forward and backward processing.
A PUT for update or an ERASE was issued without a previous GET
92(5C)
for update, or a PUTIX was issued without a previous GETIX.
Changing the Prime Key or Key of Reference when making an
96(60)
update. 100(64 Trying to change record length.
he RPL options are either invalid or conflicting. 108(6C) RECLEN
specified was larger than the maximum allowed, equal to 0, or smaller
104(68) than the sum of the length and the displacement of the key field;
RECLEN was not equal to record (SLOT) size specified for a
Relative Record data set.
112(70) Invalid key length.
116(74) Trying to update an empty dataset.
Request was submitted by the wrong task. 132(84) An attempt was
120(78)
made in Locate Mode to retrieve a Spanned Record.
You attempted an Addressed GET of a Spanned record in a Key-
136(88)
Sequenced data set.
140(8C) Inconsistent Spanned record.
144(90) Invalid pointer (no associated base record) in an Alternate Index.
148(94) Maximum number of Alternate Index pointers exceeded.
152(98) Not enough buffers available.
156(9C) Invalid control interval.
192(C0) Invalid Relative Record number in a RRDS dataset.
77
196(C4) Addressed access to a Relative Record (RRDS) dataset is not allowed.
Addressed Access or Generic Backward processing by Key thru a
200(C8)
path is not allowed.
204(CC) Attempting a PUT in backward mode.
252(FC) Record mode processing is not allowed for a Linear data set.
78
and verified for output processing.
JCL FAQ's :-
Question: What is the parameter to be passed in the job card for the unlimited time, irrespective
of the job class?
Answer: TIME=1440
Answer: Use a file //dd1 DD sysout=(*,intrdr) write your JCL to this file.
Question: Definition of COND p-r in JCL and a correction to a previously posted question
2nd - condition. If COND is true, the step on which COND is coded will be BYPASSED.
Answer: A) S0C7 - Data exception error - you will get it whenever you are trying to move the
low values or spaces into the numeric field, or compare the numeric fields with low values, or try
79
to do some arithmetic operations on the low values. To avoid this you have to always initialize the
numeric fields otherwise they will contain the low values.
B)S0C 30 - I have never heard of it, let you know if I come accross it.
Question: How to pass the temp dataset form one JOB step to another?
Answer: COND means condition parameter. It is compared with system return code of previous
step. //step1 exec pgm=abcd//step2 exec pgm=xyz, cond=(4,lt) step2 will be executed when
system return code of step1 is less than 4.
Answer: 15.
80
Answer: Jell which changes during run time i.e. the values for the jell such as pigmy name, did
name will change .i.e. same jell can be used for various job, equivalent to dynamic sql...
Answer: Edit the JCL in Extra partition TDQ and submit the same using some system command
(not sure) under CICS subsystem. This is what i think, please clarify....
Answer: It is interface between operating system (mvs) & application program. when 2 related
programs are combined together on control statements is called job control language
2.EXEC: Identifies a job step by indicating the name of the program to be executed.
Question: What does the statements: type run=scan and type run=hold doing a JCL statement
81
Answer: Typrun=scan checks the JCL for errors,
Question: Which of the following is online transaction? CICS, DB2 and JCl
Answer: CICS
Answer: 5
Question: which is the most widely used batch performance monitor for DB2?
Answer: DB2PM
Answer: It is used as an alternative for steplib.When we specify the dataset name in include, it
will search in all the datasets specified in the include dataset.
Answer: This error is faced when we execute the cobol program.the main reason for this error is
that a variable is defined with less characters and we are trying to move data which is larger than
the actual storage space.
Answer: JCL is Job Control Language and is used for Batch processing. The startup procedures
of OS and standard products like CICS etc are written in JCL.
Answer: RCT
82
Question: GDG?
Answer: GDG - group of dataset that are logically or chronologically related, referred by name
and a relative generation number - an integer which identifies the generation of a dataset and is
coded in parentheses after dataset name. Absolute GDG name - GxxxxVyy, where xxxx-absolute
gen.number, yy-version number. Can be sequential, direct, partitioned. (VSAM - no). Must
always be cataloged. Advantage - all datasets have the same name and system keeps track of
adding new and retaining previous generations and deleting oldest successive generation. To
create a GDG we create a GDG index in the system catalog with IDCAMS utility and then a
model (prototype, DSCB) on the same volume to supply DCB information. Empty - when limit is
reached all members are removed from the index, otherwise-only oldest. Scratch-removed
members are uncataloged & deleted, otherwise - removed & uncataloged, but remain in the
system (not members of GDG any more). GDG number is updated at the end of the job. If
number is not specified all generations will be processed from the beginning.
Answer: This is managed by JES.This is used for Queuing the Outputs that are intended for
Printing and are first stored in SPOOLDASD. This can be managed Using
Answer: SIX
83
Answer: 3273
Answer: 56 KB
Answer: SIX
Answer: 255
Question: How much is memory space involved, when we code BLOCKSIZE, TRK & CYL
Answer: One block constitutes 32KB of formatted memory/ 42KB of Unformatted memory, 6
blocks makes one Track & 15 Tracks makes one cylinder.
Answer: Documentation.
Answer: IEFBR14 is a Dummy utility and it is used for the take of EXEC PGM= .... Statement in
JCL[when used it wouldn't perform any task]. e.g. While Allocating a dataset you don't have to
run any utility [this could be done by giving disp=new in DD statement]. But for a PGM name
must be given in EXEC statement, it is used.
84
Answer: 1. Datasets must be of the same type (disk or tape)
3. The dataset with the largest block size must be listed first.
Question: On the DD statement, what is the main difference between creating a new sequential
flat file and a partitioned dataset?
Answer: SPACE=(n,m) for a sequential file, SPACE=(n,m,p) for a PDS where n, m, and p are
numbers. The p designates how many directory blocks to allocate.
Question: What is the difference between IEBGENER, IEBCOPY and REPRO in IDCAMS
utility?
Answer: IEBGENER -- This is a dataset utility for copying sequential datasets which produces a
PDS or a member from a sequential dataset.
IEBCOPY -- This is a dataset utility for copying one PDS to another or to merge PDSs.
Answer: Use a file //dd1 DD sysout=(*,intrdr) write your JCL to this file. Pl some on try this out.
Question: What is the difference between static call & Dynamic call
Answer: In the case of Static call, the called program is a stand along program, it is an executable
program . During run time we can call it in our called program. As about Dynamic call, the called
program is not an executable program it can executed thru the called program
Question: What is the difference between catalouge procedure and In-Stream procedure?
Answer: In Stream procedures are set of JCL statements written between JOB and EXEC
statements, start with PROC and end with PEND statement. Mainly used to test catalog
procedures. Cataloged procedure is cataloged on the procedure library and is called by specifying
the procedure name on the EXEC statement.
85
Question: What do you feel makes a good program?
Answer: A program that follows a top down approach. It is also one that other programmers or
users can follow logically and is easy to read and understand.
Answer: No
Question: What are the maximum and minimum sizes of any CONTROL AREA (VSAM
datasets) ?
Question: How many parameters are there to a DISP statement and what are their uses.
Parameter 2: normal close action for data set (catlg, keep, delete)
Answer: A set of precoded JCL that can be modified through the use of parameters or override
cards. Note: Procedures can be catalogued or instream.
Question: What is the difference between specifying DISP=OLD and DISP=SHR for a dataset?
86
Answer: OLD specifies exclusive use of a dataset, SHR allows multiple jobs to concurrently
access the dataset Note: When updating a dataset, you would normally use OLD.
Question: What are the three basic types of statements in a job stream?
Answer: JOB(one per job stream) EXEC(one or more per job) DD(one or more per jobstep)
Answer: Instream data follows this card and is terminated when followed by a card containing //
or /* in columns 1 and 2.
Question: What are three major types of JCL statements? What are their functions?
Answer: JOB, EXEC, DD. JOB - indicates start of jobstream to the operating system and through
parms coded on it, certain details about the job (time, region, message level, job accounting data).
EXEC - indicates the start of execution of a particular job step, be that step a program or a
proc.DD - is a data definition, which is used to describe the attributes of a data set (name, unit,
type, space, disposition).
Question: What is STEPLIB, JOBLIB? What is it used for? What is order of searching of the
libraries in a JCL?
Answer: Specifies that the private library (or libraries) specified should be searched before the
default system libraries in order to locate a program to be executed.
STEPLIB applies only to the particular step, JOBLIB to all steps in the job. First any private
libraries as specified in the STEPLIB or JOBLIB, then the system libraries such as
SYS1.LINKLIB. The system libraries are specified in the linklist.
Answer: The space is allocated when the data set is first created.
Question: What is the difference between primary and secondary allocations for a data set?
87
Answer:Secondary allocation is done when more space is required than what has already been
allocated.
Question: How many extents are possible for a sequential file ? For a VSAM file ?
Answer:16 extents on a volume for a sequential file and 123 for a VSAM file.
Answer: That this is a new dataset and needs to be allocated, to CATLG the Data set if the step is
successful and to delete the data set if the step abends
CICS Tutorial :-
CICS
INTRODUCTION
ONLINE SYSTEM
DEFINITION : ONLINE processing allows a user to interact with a computer and access its
resources via a terminal.
Example : Railway Reservation system.
88
Operator (or operating system) initiates the Once CICS is initialized, entering
Start of A job job. Other jobs in the same region must transaction id triggers the transaction
wait. to start.
Processing Single task single thread. Priority in job Multi task multi thread. Priority
Mode scheduling processing.
Each transaction. Once CICS is
End of job Each job terminated, no transactions can be
entered.
printed reports, output files. User must wait
Message terminals updated files,
Output for batch jobs to produce reports (day,
system Instant feed back
week, month)
Resource Usage Less More
Example of
Monthly sales report Airline reservation system
application
WHAT IS CICS?
Note : Role of CICS is to interface between application programs and the DB/DC control system.
89
• FCT (FILE CONTROL TABLE)
• JCT (JOURNAL CONTROL TABLE)
• PCT (PROGRAM CONTROL TABLE)
• PPT (PROCESSING PROGRAM TABLE)
• TCT (TERMINAL CONTROL TABLE)
• DCT (DESTINATION CONTROL TABLE)
• TST (TEMPORARY STORAGE TABLE)
CICS START UP
CICS SHUTDOWN
ROLE OF CICS
• MULTI TASKING
o More than one task can be executed concurrently.
• MULTI THREADING
o Tasks share the same program under the multi tasking environment.
• RE-ENTRANT PROGRAM
o Program when does not modify itself in any way during execution.
• QUASI RE-ENTRANT
o Is a reentrant program under the CICS environment.
INTRODUCTION TO BMS
• To make the application program device independent and format independent CICS
provides Basic Mapping Support (BMS)
• BMS is a standard facility, to deal with the formatted screen operations
• Screen defined through BMS is called a "MAP"
Physical Map
90
• Ensures device independence in the application program
• For input operations, it defines the maximal data length and starting position of each field
to be read and allows BMS to interpret an input data stream
• For output operations it defines starting position, length, field characteristics
• (Attribute Bytes) and default data for each field, and allows BMS to construct an output
data stream.
• Physical map is a program in the form of Load module
• Physical map is coded using BMS macros
• BMS macros are assembled separately and link edited into the CICS load library
SYMBOLIC MAP
Halfward binary
L
Contain the length of data entered by the terminal operator
F One byte flag field
I Contains the data entered by the operator
A One byte field that contains Attribute byte
O Contains data to be sent to terminal
91
OUTPUT MAPPING
“MAP ONLY”
EXEC CICS SEND
MAP (“mapname1’)
MAPSET (‘mapset1’)
MAPONLY
END-EXEC
“DATA ONLY”
EXEC CICS SEND
MAP (‘mapname1’)
MAPSET (‘mapset1’)
DATA ONLY.
END-EXEC.
o The physical map and the data from symbolic map is sent to the terminal.
• ERASE: Current screen is erased before the map specified appears on the screen
• ERASEAUP: erase all the unprotected fields.
• FREEKB: to free the keyboard
• ALARM: to make an alarms sound.
• FRSET: to reset MDT to zero
• CURSOR: to place the cursor in a specified field
CURSOR POSITIONING
• Static positioning
o If IC option is specified in the ATTRB field of DFHMDF macro the cursor will
be placed at this field.
• Dynamic / symbolic positioning.
92
o Place (-1) into the field length field (“L” suffix). Cursor will be placed in the
field.
• Dynamic / Relative positioning.
o Cursor (data-value) option is used.
o Data-Value will have the value at which the cursor has to be positioned.
o E.g.. EXEC CICS SEND
MAP (…..)
MAPSET (…..)
CURSOR (100)
ERASE
END-EXEC.
• MAPFAIL condition will caused in RECEIVE MAP command.
o If the data to be mapped has a length of zero.
o If the operator presses any key (clear, PA, PF, ENTER, Keys) without entering
any data.
• LINKAGE SECTION
o Copying a symbolic description map structure here does NOT mean the storage
will be available. Some methods for providing storage are passing a
COMMAREA, acquiring temporary storage with the SET option, or using a GET
MAIN command.
SEND / RECEIVE
93
Using constants in the name field for MAP and MAPSET(FROM is not
required)
Using variables in the name field for MAP and MAPSET (This makes
FROM a required parameter)
Using only the MAP parameter. In this case the name in the MAP option
must be the MAPSET name.
• RECEIVING into the symbolic description map
RECEIVE MAP(`MAP1')
MAPSET(`SET1') ... MAP1 I
Move `MAP1' to MAPVAR
Move `SET1' to SETVAR ..... MAP1 I
RECEIVE MAP (MAPVAR)
MAPSET(SETVAR)
INTO (MAP1 I)
Receive MAP (`SET1') ... SET1 I
o RECEIVE MAP coding alternatives You can code the RECEIVE MAP
command to locate the symbolic description map in several ways:
Using constants in the name field for map and mapset (INTO/SET is not
required) This is the most commonly used format.
Using variables in the name field for MAP and MAPSET. This makes
INTO (database) or SET a required parameter.
Using only the MAP parameter. In this case the name in the MAP option
must be the MAPSET name.
Linkage Section.
01 DFHCOMMAREA
01 LST
02 PTR-2-LIST PIC S 9(8) COMP.
02 PTR-2-BMS PIC S 9(8) COMP.
RECEIVE MAP (`MAP1') MAPSET (`SET1')
SET (PTR-2-BMS) ..... MAP1 I
Using the SET option requests CICS to get the storage and return a
pointer to it. The symbolic description map must be in the LINKAGE
SECTION.
OUTBOUND FUNCTIONS
SEND MAP (`MAPA') MAPSET (`SETA')
[ERASE/ ERASEAUP]
[FREEKB]
[ALARM]
[FRSET]
[PRINT]
ERASE Erase Buffer, place cursor in upper left corner then write
ERASEAUP Erase all the unprotected fields before the Write
FREEKB Unlock Keyboard after the write
ALARM Active alarm with the write
FRSET Set all MDT currently on to off
PRINT Start the 3270 print operation.
94
Control Functions:
• Typically the first type of command in the program is a SEND MAP. Certain control
functions may be included in that command.
• ERASEAUP will clear out each field whose attribute is unprotected. It will NOT alter
any attribute settings.
• If you do not free the keyboard using FREEKB, the operator will have to press the
RESET key before entering data.
• If you code FRSET, all attribute bytes currently having Modified Data Tags (MDT) set on
will be set off. Selective resetting of the MDT's must be done another way.
• When sending data to a 3270 screen the actual printing from the buffer will occur when
the PRINT function is requested.
Attributes :
• The `A' suffixed field is an attribute field which controls the following:
PROTECTED/UNPROTECTED
ASKIP
NUM
MDT
Non Display (dark)DISPLAY (normal/bright)
• If the color or highlighting of a field has to be changed, additional symbolic fields are
needed which are called the EXTENDED ATTRIBUTES.
EXTENDED ATTRIBUTES
• DSATTS (for symbolic map) and MAPATTS (for physical map) support the extended
attribute characteristics
• The MAPATTS allows you to set up the physical map with any of the characteristic(s)
coded.
• The DSATTS will create appropriate suffixed labels for the attribute characteristic(s)
coded.
EIBAID/CURSOR
• WORKING-STORAGE SECTION.
COPY DFHAID.
......
PROCEDURE DIVISION.
95
IF EIBAID = DFHPF12 THEN
......
IF EIBAID = DFHENTER THEN
......
IF EIBCPOSN LESS THAN 80 THEN
......
• When you first enter your program as a result of a transaction id, you can test EIBAID
and/or EIBCPOSN. This may be done prior to issuing a RECEIVE command, if so
chosen.
• If the operator uses any PA key or presses the CLEAR key, no data is transmitted
• EIBAID is useful when function keys are defined for the user.
• for eg. PF12 may be the exit function
PF3 may be an update function etc.
Thus testing for the type of AID will alter the logic flow.
• EIBCPOSN can be used to determine where the cursor was positioned on the screen. This
information is especially useful with screens containing an action bar.
CURSLOC
Sample Map
• CURSLOC= YES allows you to determine after a RECEIVE MAP command, which map
field had the cursor in it.
CURSLOC=NO is the default.
• CURSLOC=(NO/YES) may be coded on the DFHMSD or the DFHMDI macro. If coded
on the DFHMSD macro, it will provide a default for all the maps in that mapset.
96
• When CURSLOC=YES, BMS will set the `F' suffix field to X'02' indicating that field
contained the cursor. If the cursor is in a field for which there is no symbolic label i.e. a
DFHMDF with no label the program will not be notified.
• Note : The `F' suffix field continues.
• To be used to indicate the operator pressed the erase to end of fixed (EOF) key by being
set to X'80'.
• Therefore, if CURSLOC=YES it is possible to have both these conditions occur for the
same field, in which case the `F' suffix field will contain a X'82'.
EDITING
• If PICIN/PICOUT is not coded in the macro, the pic generated is always PIC X (length of
field)
• By using PICIN/PICOUT BMS can be forced to generate the appropriate PIC.
• PICIN tells BMS how to move data into the `I' suffix field.
• PICOUT tells COBOL how to edit your data move to the `O' suffix field.
• BIF DEEDIT is used to remove the special characters from the input field.
• The Amount field displayed has a dollar sign and a decimal point
• By using BIF DEEDIT dollar sign and decimal point is removed. Thus the number can be
used for arithmetic operations.
• COBOL compiler requires LENGTH specification:
• VS COBOL-II uses the implied length of the data-area used in the field parameter.
97
CICS PROGRAM COMPONENTS
OBJECTIVES
Identification Division
Program - ID required
Environment Division
Other requirements:
TERMINATION STATEMENTS
Notes :This is not the way to terminate a CICS program. CICS has a command for that purpose.
Nevertheless, COBOL and VS COBOL II have three statements to conclude programs.
• Control must not be allowed to pass beyond the last statement of a CICS Program.
• STOP RUN in COBOL uses operating system facilities, and therefore, is discouraged.
• EXIT program is ignored if the program has not been called.
98
• CICS RETURN COMMAND and/or GOBACK statement is recommended.
• Transactions
• Task
• Program
Transactions
An exchange between a terminal and a data base representing an application process. For
example, an inquiry or a deposit and balance update
Task
Program
CONVERSATIONAL TRANSACTION
• The task is terminated after a message is sent with a linkage for the next task. CICS
provides a facility (COMMAREA) to made it easier to accomplish this.
• When the user completes response (by pressing enter) reset task is automatically initiated
by CICS.
• The task receives the message from the terminal & processes it.
• This is a multitask operation from system's point of view.
PROGRAM PREPARATION
• Running the DB2 precompiler first is the preferred method. DB2 precompiler precedes
another process, binding, not mentioned here.
• Output of the DB2 precompiler can serve as input to the translator.
• Output of the translator will be input to the compiler.
• Messages or warnings are provided on all the listings.
• TRANSLATOR recognizes EXEC CICS and EXEC DLI statements. They are
commented out and replaced with statements in the appropriate language. Here, COBOL
MOVE instructions and a CALL are inserted and passed on to the COBOL compiler.
99
• DB2 Precompiler is supplied by the relational data base managers, DB2 and SQL/DS. It
recognizes EXEC SQL statements which it will comment out and replace with in our
case. COBOL PERFORM and CALL statements.
• Output of the transaction is i/p to the compiler
• The o/p of the linkage editor is executable. The load module is placed in the CICS online
program library.
• Messages or warnings are provided on all the listings. The compiler listing is or limited
use if the translator listing would not process all commands.
TESTING
CEMT set program (prg1) New comp
Or
CEMT S PR (prg1) N
• After making changes to a program the new version replaces old version, but CICS which
is currently executing has no way of knowing this automatically. The CICS processing
program table PPT still points to the old-version.
• To avoid testing with the old version, you must use the CICS-provided CEMT transaction
to update the pointer to the program.
COMMON FORMAT
• A CICS command consists of a keyword phrase, delimiter, function, options and their
argument values.
• Be careful about periods. Avoid them after END-EXEC. Where you don't really want
them.
For eg. within an If .... then ... else statement
• The translator will place a period into the generated code if a period follows end-exec.
ARGUMENT VALUES
PIC S9(4) comp Halfword binary
data - value PIC S9(8) comp Fullword binary
PIC X(15) character string constants permitted
COBOL data name
(Not a constant)
eg :-
data - area 01 Record-area.
05 Fld 1
05 Fld 2
name COBOL data name Character string
label Paragraph name
PIC S9(7) comp 3
hhmmss
Packed decimal
BLL cell
pointer-ref
Usage pointer
100
RECEIVE COMMAND
• RECEIVE command is used to receive incoming data from the terminal to which this
CICS transaction is associated.
• A receiving area must be defined in working storage section and has to be specified in the
INTO parameter.
• Length field must be defined in working storage section as a S9(4) comp. It has to be
specified in length option.
SEND COMMAND
• The data to be sent must be stored in working storage section, and this field name has to
be specified in the FROM parameter.
• Length must be specified the same as that of the Receive command.
EXCEPTIONAL CONDITIONS
• RESP option
o Define a full word binary field S9(8) comp in the working storage section as the
response field.
o Place RESP option with the response field in any CICS command.
o After command execution, check the response code in the response field with
DFHRESP (xxxx)where xxxx is
NORMAL for normal completion or Any exceptional condition
HANDLE CONDITION
• Handle condition command is used to transfer control to the procedure label specified if
the exceptional condition, specified occurs.
• Remains active until the end of program or another handle condition request overrides it.
IGNORE CONDITION
• Ignore condition command causes no action to be taken if the condition specified occurs
in the programs.
• Request by the IGNORE CONDITION command is valid until the subsequent HANDLE
CONDITION command for the same condition.
101
NO HANDLE OPTION
• If NOHANDLE option is specified in any CICS command, no action will be taken for
any exceptional condition occurring during execution of this command.
o Eg : EXEC CICS SEND
From (...)
Length (...)
NOHANDLE
END-EXEC
• ASKTIME Command
o used to request the current date and time
o EIBDATE and EIBTIME fields have the values at the task initiation time.
• FORMAT EXEC CICS ASKTIME END-EXEC
DELAY COMMAND
• used to delay the processing of a task for the specified time interval or until the specified
time.
FORMAT
EXEC CICS DELAY
INTERVAL (002000)
TIME (152000)
102
End - EXEC
COMMAREA
PSEUDO CONVERSATIONAL
Pseudo conversational technique is uses the multiple transaction identifiers (pct entries) and
multiple program (pct entries). It performs the terminal conversation in the following way:
A conversational program is logically and physically divided into separte programs after sending
a message and before receving the message. For each separate program, a unique cics trasction
identifier is assigned. before terminating the program, each program issues the RETURN
command with the next transaction identifier which is associated with the next program, unless it
is the least return to CICS itself. in this way, a series of terminal conversations can be carried out
continuously.
• Notes :
o The first time commarea is passed, it must begin as an area of storage in the
working storage section of the program passing it.
o A commarea parameter in the RETURN will pass the area to the program
associated with the subsequent transaction. In this case, itself.
o The subsequent program (in this case the same program) must define access to all
the commarea that was passed to it.
• PAYROLL as both the sender and the receiver of the COMMAREA needs the working
storage definition to send and the linkage section DFHCOMMAREA to receive.
• PAYROLL must therefore be able to distinguish between FIRST TIME into the program.
When there is no COMMAREA and subsequent times in. Where one exists in the
Linkage section. The EIB field, EIBCALEN indicates the length of the commarea.
EIBCALEN
103
PASSING DATA USING LINK
• To pass control from one program to another and then return to the original like executing
a subroutine.
• The link command passes control to another program defined in CICS PPT expecting that
the program will return to the linking program instruction following the LINK command.
This happens when the linked program issues a RETURN command.
• Data may be passed using the commarea.
• The commarea is shared between the two program regains control may changes made to
the commarea by the linked program are accessible.
• The two programs executive under the same task.
• The working storage section for the linking program is retained. Working storage for the
linked program is automatically released after its RETURN command is executed.
• To pass control from one program to another and then return to the original like executing
a subroutine.
• The link command passes control to another program defined in CICS PPT expecting that
the program will return to the linking program instruction following the LINK command.
This happens when the linked program issues a RETURN command.
Functional overview
• DIRECT RETRIEVAL
o VSAM DATA STRUCTURES
• DIRECT RETRIEVAL
o RELATIONAL TABLE ROW
• BROWSE
o VSAM DATA STRUCTURE
• BROWSE
o RELATIONAL TABLE ROWS
• Entry for VSAM file has to be there in FCT (File Control Table)
• Each entry contains all descriptive information for the file it represents. So, programmer
need not define the physical organization and other attributes of the files.
o The File parameter coded in the program must be the same as the file name in the
FCT.
o Interface between CICS and Relational Database is called CICS attachment
Facility. Statement are coded in SQL language in the application program to
Communicate data requests to the database.
TOPICS
• DIRECT RETRIEVAL
o VSAM FILE RECORD
o RELATIONAL TABLE ROW
104
• BROWSE
o VSAM FILE RECORDS
o SET OF RELATIONAL TABLE WORKS
PROGRAM ORGANIZATION
RECORD IDENTIFICATION
• RECORD KEY
• RELATIVE BYTE ADDRESS
• RELATIVE RECORD NUMBER
• PARTIAL KEY
o key of the record to be read is specified in the RIDFLD. for KSDS
o Key specified can be a full key or partial key
o If partial key, key length has to be provided
o RBA (Relative Byte Address)
o Can also be used instead of actual key value
• For ESDS
o RIDFLD contain a 4 byte RBA
• For RRDS
o RIDFLD contains 4 Byte binary relative record number.
• RIDFLD must be set to the value of the key of the record to be retrieved.
• RIDFLD must be large enough to hold a full record key even when a partial key is used.
105
READ COMMAND
EXCEPTIONAL CONDITIONS
The exceptional condition can be trapped using RESP option in the READ command.
ADDRESSABILITY TECHNIQUES
• a module given control through the use of a CICS XCTL command will not return to the
program that issued the XCTL.
• The required. program name is character string constant (max 8 characters)
• The PGMIDERR exception condition occurs when the name is not in the PPT.
106
LOGICAL LEVELS
• The linked to program runs at a new logical level and returns to a logical level back to the
linking program.
• The linking program and its storage area remain available.
Notes :
• To quit the repeated execution simply RETURN without the TRANSID option.
• Any linked program could use the same COMMAREA of the parameters so indicated.
• The transid & commarea option easy enough to use to make this method practical.
• CICS LINK
• CICS XCTL
• COBOL CALL
• Alternative to XCTL or LINK ? COBOL CALL·
• COBOL CALL passes control to other programs.
• INPUT MSG & INPUT LEN PARAMETERS USED WITH XCTL OR LINK.
• Receiver uses EXEC CICS RECEIVE command
ADDRESSABILITY
107
CICS QUEUEING FACILITIES
All Intra partition TDQ are stored in only 1 physical file (VSAM)
• Interface among CICS transaction. Application program 1 TDQ Appl . Pgm 2 report
• Automatic task Initiation (ATI)
• Message routing
• Message Broad cast.
Extra partition TDQ is a separate physical file & may be a disk, tape or reporter.
• DCT determines the initial open / close status of a file while the file can be opened or
closed through the master terminal transaction during CICS session.
• TDQ can be defined as an Input or output but not both.
• Records are fixed, variable, blocked or unblocked.
108
TRANSIENT DATA OUTPUT
EXCEPTIONAL CONDITIONS
TEMPORARY STORAGE
WRITEQ TS
READQ TS
109
QUEUE (NAME)
INTO (DATA - AREA)
LENGTH (DATA-VALUE)
[ITEM (DATA-VALUE) | NEXT]
[NUMREC (DATA-AREA)]
END-EXEC.
• NEXT - to retrieve the next - logical record in the TSQ. mutually exclusive to the item
option
• NUMREC - the data area is defined as PIC 9(4) comp. to find the Total no. of records in
the TSQ.
• Item - for direct access specify the item no of the record.
DELETEQ TS of TSQ
• EXEC CICS
DELETEQ TS
QUEUE (NAME)
END-EXEC.
• All records is TSQ are deleted.
• All associated storage is released.
EXCEPTIONAL CONDITIONS
110
• HANDLE AID
• HANDLE ABEND
For invoking CECI, type CECI with the CICS command to be interpreted.
• CEBR can be invoked while you are already in the CEDF mode.
• Press the PF5 key to display the working storage section.
• Then, press PF12 key to invoke CEBR.
CEBR allows to browse information in Temporary Storage (TS) queues.
• Help (PF1) give you a list of CEBR commands on the screen.
• TS queues are retained until purged.
EXCEPTION HANDLING
CICS to respond to exceptional conditions in one of three ways:
• RESP option: - The RESP option can be specified in any CICS command. Its function is
similar to the return code in the batch program.
o Define a fullword binary field (S9(8)COMP) in the working storage section as a
response field.
Place the RESP option with the response filed in a command.
After command execution, check the response code in the response field
with DFHRESP (xxxx), where xxxx is the - NORMAL
- Any exceptional condition
• HANDLE CONDITION This command is used to transfer control to the procedure label
specified if the exceptional condition specified occurs.
• IGNORE CONDITION This command causes no action to be taken if the condition
specified occurs in the program.
EXEC CICS HANDLE CONDITION
Condition (Label)
[Condition (Label)]
[Error (Label)]
END-EXEC.
or
EXEC CICS IGNORE CONDITION
Condition
111
[Condition]
END-EXEC.
• ABEND CODE
112
CICS Adend Codes :- Execute Interface Block and cics abend codes
Some of the more common CICS abends are briefly described below. These are only brief
descriptions and do not cover all possible reasons.
ASRA
This is the most common abend in CICS. It indicates a Program Check Exception, roughly
equivalent to having an S0C7 in a batch program. Check for spaces in a packed decimal
numeric field and changes to the file and record layouts.
There are numerous abends that start with AEI or AEY. They indicate that an exception has
occured, and RESP (or NOHANDLE) is not is use. The last character indicates the exact error
AEI0
indicates a PGMIDERR.
AEI9
is a MAPFAIL condition,
AEIO
AEIN
AEID
AEIS
AEIP
AEY7
113
CICS FAQ’s:-
CICS FAQS
Question: Which of the following statements correctly describe the syntax of CICS command
language?
Answer:
1. If an EXEC CICS command must be continued onto a second line a hyphen (-) must be
coded in column 7 of the continued line.
2. If an EXEC CICS command must be continued onto a second line an 'X' must be coded
in column 72 of each line to be continued.
3. An EXEC CICS command CANNOT be coded within a COBOL IF statement, between
the IF command and the period (.) ending it.
4. The END-EXEC delimiter is optional and never needs to be placed at the end of a CICS
command.
5. The options specified within an EXEC CICS command can be in any order. For example
'EXEC CICS SEND FROM(MSG1) LENGTH(30) END-EXEC' can also be coded
'EXEC CICS SEND LENGTH(30) FROM(MSG1) END-EXEC'
Question: .A CICS program ABENDS with an ASRA ABEND code. What is its meaning?
Answer:
1. A link was issued to a program whose name does not exist in the PPT (Program
Processing Table).
2. A program attempted to use a map that is not defined in the PCT (Program Control
Table).
3. A security violation has occurred. The operator is not defined with the proper authority in
the SNT (Sign-on Table) to use a particular file.
4. A program interrupt (0C0 or 0C1 or 0C2 or ...) has occurred in a CICS program.
5. An I/O error has occurred when attempting to use a VSAM file from a CICS program
114
Question: Which of the following commands, when issued by 2 different programs running at the
same time, will prevent simultaneous use of resource 'SINGLE'?
Answer:
Question: how many ways are there for initiating a transaction? what are they?
Answer: There are six ways in initiating a transaction. they are as follows.
1. embedding four character transid on the top left most corner of the screen.
2. making use of EXEC CICS START TRANSID ( )
3. making use of EXEC CICS RETURN TRANSID ( )
4. By defining the transid in DCT ( destination control table) to enable ATI (AUTOMATIC
TASK INITIATION)
5. Making use of PLT ( program list table)
6. By associating four character transid in PCT (program control table)
115
files. and the DB2 changes are committed. Usually CICS signals Db2 to complete the next phase
and release all the locks.
Question: In SYMBOLIC Cursor Positioning after moving -1 to the length field also the cursor is
not positioned in that particular field. Give reasons?
Answer: You have to explicitly specify the word CURSOR between your EXEC CICS and END-
EXEC in the program.
Question: What command do you issue to delete a record in a transient data queue ?
Answer: READQ TD, the read is destructive. Yes it is correct but there is a restriction. U can
deletethe records sequentially.. For example if one want to delete 10 th record directly it is not
possible with this..
Question: What command do you issue to delete a record in a transient data queue?
Answer: READQ TD, the read is destructive.
1. BY GIVING TRANSACTION ID
2. BY GIVING CICS START COMMAND
3. AUTOMATIC TASK INITIATION.
116
executed. While in LINK command, program control resumes its instruction following the LINK
parameter. The disadvantage of LINK is that it requires that both the calling program and the
called program remain in main memory even though both are no longer needed.
Question: What is the difference between CICS Program Control Table (PCT) and CICS
Processing Program Table (PPT) ?
Answer: PCT contains a list of valid transaction ID. Each transaction ID is paired with the name
of the program ,CICS will load and execute when the transaction is invoked. On the other hand,
PPT indicates each program's location which pertains to a storage address if the program has
already been loaded or a disk location if the program hasn't been loaded. PPT will also be used to
determine whether it will load a new copy of the program when the transaction is invoked.
Question: What is the difference between a physical BMS mapset and a logical BMS mapset?
Answer: The physical mapset is a load module used to map the data to the screen at execution
time. The symbolic map is the actual copybook member used in the program to reference the
input and output fields on the screen.
Question: How would you release control of the record in a READ for UPDATE?
Answer: By issuing a REWRITE,DELETE, or UNLOCK command or by ending the task.
Question: How would you release control of the record in a READ for UPDATE?
Answer: By issuing a REWRITE,DELETE, or UNLOCK command or by ending the task.
Question: What is the difference between a RETURN with TRANSID and XCTL ?For example
prog. A is issuing REUTRN with TRANSID to prog B. Prog A. is issuing XCTL to prog B.
Answer: In RETURN with TRANSID the control goes to the CICS region and the user have to
transfer the control to prog. B by pressing any of the AID KEYS.In XCTL the control is directly
transfer to prog. B.
117
Question: What is the maximum number of exceptions that can be specified with a single
HANDLE CONDITION command in CICS ?
Answer: SIXTEEN (16)
Question: WHAT WILL BE THE LENGTH OF THE EIBCALEN ,IF THE TRANSACTION IS
USED TO CICS FIRST TIME?
Answer: THE LENGTH WILL BE 0(ZERO)
.
Question: WHAT IS DFHEIBLK?
Answer: DFHEIBLK is Execute Interface Block. It is placed in the linkage section automatically
by CICS translator program. It must be the first entry in linkage section. CICS places values prior
to giving control to the program and we can find almost any information about our transaction.
Question: What is the difference between the XCTL and LINK commands?
Answer: The LINK command anticipates return of control to the calling program, theXCTL
command does not. Return to the calling program will be the result of the CICS RETURN
command, specifying TRANSID(name of the calling program).
Question: What CICS command would you use to read a VSAM KSDS sequentially in ascending
order?
Answer: First issue a STARTBR(start browse), which will position the browse at the desired
record. Retrieve records by using subsequent READNEXT commands. Indicate the end of
sequential processing with the ENDBR command. If the generic key is specified in the
STARTBR command positioning in the file will be before the first record satisfying the generic
key.For reading in descending order use the READPREV instead of READNEXT.
118
DB2 Tutorial :-
Introduction to Databases
What is data?
What is a database?
An integrated and shared repository for stored data or collection of stored operational data
used by application systems of some particular enterprise.
Data redundancy
Multiple Views
Shared data
Data dictionary
Search versatility
Cost effective
119
Concurrency
Hierarchical Model
Network Model
Relational Model
Object-Oriented Model
HIERARCHICAL MODEL
Examples: IMS
NETWORK MODEL
Does not distinguish between parent and child. Any record type can be associated with any
number of arbitrary record types Enhanced to overcome limitations of other models but
in reality there is minimal difference due to frequent enhancement
Example: IDMS
RELATIONAL MODEL
Data stored in the form of table consists of multiple rows and columns.
120
OBJECT-ORIENTED MODEL
Data attributes and methods that operate on those attributes are encapsulated instructions
called objects.
Types of Integrity
Entity Integrity
Referential Integrity
Domain Integrity
Entity Integrity
Is a state where no column that is part of a primary key can have a null values.
Referential Integrity
Is a state where every foreign key in the first table must either match a primary key value in
the second table or must be wholly null.
Domain Integrity
Represented as entities relationship between entities and attributes of both relationships and
entities.
121
An entities may transform into tables.
The unique identity for information stored in an entity is called a primary key
DB2
OBJECTS
Stogroup(Storage group)
Database
Table Space
Table
View
Index
When a given space needs to be extended, storage is acquired from the appropriate stogroup.
Database
A collection of logically related objects – like table spaces, index spaces, tables etc.
Not a physical kind of object, may occupy more than one disk space.
In a given database, all the spaces need not have the same STOGROUP.
TABLE SPACES
122
Simple
Partitioned
Segmented
Depending on application, storing more than one tables might enable faster retrieval for joins
using these tables.
Usually only one table is preferred. This is because a single page can contain rows from all
tables defined in the database.
Can contain more than one stored tables, but in a segmented space.
Lock Table on table locks only the table, not the entire table space.
If a table is dropped, the space for that table can be reclaimed within minimum
reorganization.
Different partitions can be stored on different storage groups for efficient access.
TABLES
123
Each COLUMN contains some specific information about suppliers and each ROW contains
all the information about a particular supplier.
VIEWS
Views can be very practical ways of simplifying queries by reducing the number of different
tables.
Views can also hide sensitive data from users who don’t need access to it.
SYNONYMS
Synonym is like a nick name to a table name and when no longer needed it can be dropped.
Synonym access is specific to the user who has created it.
A powerful database management language that performs the function of data manipulation,
data definition and data control.
A non-procedural language.
The capability to act on a set of data and the lack of need to know how to retrieve it.
It allows to specify WHAT the result should be, NOT HOW the result obtained.
124
SQL TYPES(Others)
As an end-user you will be using SQL on-line to access data and produce formatted reports.
As an application programmer, you will use SQL to extract data from one or more tables and
pass these data to another program for additional processing.
SQL task is center about four basic functions & these functions correspond to the four basic
SQL command (SELECT, UPDATE, INSERT, DELETE)
If the table belongs to another user, you may have to prefix the table name with the other
user’s ID.
125
How do you specify which COLUMNS you want to display?
Using the ‘*’ to indicate all columns should be displayed is inefficient if you don’t need to
see all the columns.
You can put the columns in the order you want them.
SELECT SNAME
FROM SUPPLIER
WHERE STATUS=30
SQL automatically orders data in ascending order if you have any ORDER BY statement in
your query.
If you want your data in descending order, use the DESC keyword.
SELECT STATUS FROM SUPPLIERS ORDER BY STATUS DESC
Simple add the columns you want to sort to the ORDER BY clause, separated by comma.
Example:
SELECT SNAME ,STATUS, CITY FROM SUPPLIERS ORDER BY STATUS,SNAME
126
Sometimes a single search condition is not precise enough to select only the rows you need.
So you need to use the logical operator AND and OR.
You can link as many search expression as you want using AND and OR.
Using both operator together, searched expression linked by AND are paired up first.
Parentheses can be used to force expression to be paired together.
By adding the keyword DISTINCT immediately following SELECT , you suppress any
duplicates. SELECT DISTINCT STATUS FROM SUPPLIERS
SYMBOL CONDITION
= equal to
> greater than
< less than
>= greater than or equal to
<= lesser than or equal to
<> less than or greater than
LIKE containing certain characters
BETWEEN within a range of values
IN one of a set of values
Each condition also has a negative version.
IN
Lets you retrieve data from each row whose columns has a value equal to one of the several
listed values.
BETWEEN
• Lets you retrieve data from each row whose columns has a value with two limits.
• Example: WHERE STATUS BETWEEN 10 AND 30
• Any row with STATUS column value of 10 thru 30 is selected.
127
• It can be used for both numeric and character values.
• The two values must be separated by AND, the lower value must be the first value.
LIKE
• Lets you retrieve data from each row whose columns has a value similar to the value
specified in the WHERE CLAUSE.
• Example: WHERE SNAME LIKE ‘B%C’
• Any row with name column beginning with ‘B’ followed by ANY VALUE of ANY
LENGTH, and ending with ‘C’ is selected.
• A ‘%’ represents any value of any length, where as an underscore ‘_’ represents any
single character LIKE can’t use for any numeric column.
What is NULL?
• To select all rows with a NULL value in the COMM column, you must use WHERE
COMM IS NULL as your search condition
• To select all rows that do NOT have a NULL value, you must use WHERE COMM IS
NOT NULL as your search condition
• Note:
ARITHMETRIC EXPRESSIONS
• An arithmetic expression is a calculation using numeric values and one or more of the
arithmetic operators :addition (+), subtraction (-), multiplication (*), and division (/).
• Example: SELECT SALARY + COMM,NAME,DEPT
• Arithmetic expressions can also be used in a WHERE clause: WHERE SALARY +
COMM >5000.00
128
RULES FOR CODING ARITHMETIC EXPRESSIONS
• SQL works from left to right, evaluating multiplication and division before addition and
subtraction (*, / , +, -).
• However any expressions in parentheses are evaluated first.
BUILT IN FUNCTION
• SUM
• MAX
• MIN
• AVG
• COUNT(*)
• COUNT(DISTINCT col name)
SUM
• Display either the highest or lowest value found in the rows selected by the query.
SELECT MAX(SALARY),MIN(SALARY) FROM EMP
AVG
COUNT(*)
129
COUNT(DISTINCT col name)
• It counts only those rows that have a unique value in the specified column
SELECT COUNT(DISTINCT STATUS) FROM SUPPLIERS
• COUNT (*) counts all the rows selected
• COUNT(DISTINCT col name) does not count rows with a duplicate value in the
specified column.
• COUNT(DISTINCT col_name) does not count rows that have NULLS in the specified
column.
• When you request a built-in summary functions, SQL goes through several steps to reach
a result.
• First, all the rows and columns are selected. This intermediate result is kept in a
temporary table.
• Next, the system process your GROUP BY request, creating a temporary table for each
GROUP and putting the appropriate rows in each table.
• Then the built-in functions are calculated.
• If, for example you requested an AVG, then the average for each temporary sub group is
calculated.
GROUP BY
HAVING
JOINING
• Joining tables involves matching the rows of one table with related rows of another table
to produce a table consisting of rows with columns from both the original tables.
• It will combine related information from two tables into a single row.
130
• If a value appears once in the “joining column” of one table, but several times in the
other, the higher number of occurrences will appear in the output table.
• If a value exists in the “joining column” of one table, but not in the other, no row appears
in the output table with that value.
JOINING COLUMN
• It is a column that is common to all the tables being joined and contains the row values
that tie one table to next.
MERGING
• Merging tables also involves combining data from two tables, but the rows are not joined
together.
• Example:SELECT *FROM EMP UNION SELECT * FROM SUPPLIER
• UNION sorts the result tables, UNION ALL does not. In other words, UNION mixes
rows together in the output. UNION ALL outputs all the rows from the first table that
meet the search condition. UNION removes duplicate rows, UNION ALL does not.
• Each column selected from first table must be compatible with the corresponding
columns from the second table.
• A numeric column are compatible with numeric column, a character column to a
character column, and so on.
• Numeric data types need not be the same column length You must select the same
number of columns from each tables.
131
CREATING AND UPDATING TABLES
• To create a new table you must use the SQL statement CREATE TABLE. You must
specify the table name and the names and attributes of each column.
• Maximum 18 characters
• Permissible characters
o letters of the alphabet
o @, #, and $
o numbers
o underscore (_)
• The first character must be alphabetic or @,#, or $
DATA TYPES
Data type depends on the nature of the data itself and will always be one of two types –
NUMERIC or CHARACTER
CHAR – Allows any values to be entered in the column. All entries are the
same length
VARCHAR – Allows any values to be entered in the column. All entries are
the varying length
DECIMAL - For numbers with a fixed number of decimal places after the decimal point. The
number can have a total of 15 digits
FLOAT -For very large numbers with an undetermined number of decimal places after the
decimal point
132
TIMESTAMP – TIMESTAMP columns contain both date and time information, with the time
value accurate to the millisecond.
PRIVILEGES
• The only change you can make to a table or view after it has been created is to add an
additional column.
• This is done with the SQL command ALTER
o ALTER TABLE EMP ADD COMM DECIMAL (7 ,2)
DROP
• When you no longer need a TABLE, VIEW, or SYNONYM you can DROP them.
o DROP TABLE SUPPLIER
o DROP VIEW EMP_VIEW
o DROP SYNONYM S
INSERTING A TABLE
UPDATE
• SQL provides two commands for updating row values – UPDATE and SET.
133
• UPDATE tells SQL which table you want to update and SET provides the name of the
column to update and the new value for the column.
• You tell SQL which row to update with a WHERE clause can be very specific, so that a
single row gets changed, or it can be very general, so that many rows get updated.
o <B>UPDATE SUPPLIER SET STATUS = 40 WHERE S# = ‘S1’
o UPDATE EMP SET SALARY = SALARY + SALARY *.01
DELETE
• Using the DELETE command you can delete rows and using WHERE clause you can
specify which rows you want to delete.
o DELETE FROM SUPPLIER WHERE S# = ‘S1’
Complex SQL’s
• One terms a SQL to be complex when data that is to be retrieved comes from more than
one table.
• SQL provides two ways of coding a complex SQL
o Subqueries and Join
SUB QUERIES
JOINS
• OUTER JOIN
• INNER JOIN
OUTER JOIN
• For one or more tables being joined both matching and the non-matching rows are
returned.
• Duplicate columns may be eliminated.
• Non-matching columns will have nulls.
INNER JOIN
• Here there is a possibility one or more of the rows from either or both tables being joined
will not be included in the table that results from the join operation
134
QMF- Query Management Facility
Program Preparation
• Precompile
• Compile & Link
• Bind
o Package
o Plan
Precompile
• Searches all the SQL statements and DB2 related INCLUDE members and comments out
every SQL statement in the program.
• The SQL statements are replaced by a CALL to the DB2 runtime interface module along
with parameter.
• All SQL statements are extracted and put in a DBRM.
• Places a time stamp in the modified source and the DBRM so that these are tied.
• All DB2 related INCLUDE statements must be placed between EXEC SQL & END-
EXEC key words for the precompiler to recognize them.
Bind
135
Package
Advantages of Package
Plan
DB2 Optimizer
• Analyzes the SQL statements and determines the most efficient way to access data, gives
physical data independence.
• It evaluates the following factors: CPU cost, I/O cost, DB2 catalogue statistics & the SQL
statements.
• It estimate CPU time, cost involved in applying predicates traversing pages & sorting.
• It estimates the cost of physically retrieving and writing data.
136
FROM employee WHERE eno=1001
END-EXEC.
Host Variables
• These are variables defined in the host language to use the predicates of a DB2 table.
These are referenced in the SQL statement.
• A means of moving data from and to DB2 tables.
• DCLGEN produces host variables the same as the columns of the tables.
DCLGEN
SQLCA
CURSOR
DECLARE:
EXEC SQL
DECLARE empcur CURSOR FOR
SELECT empno, ename, dept, job
FROM emp WHERE dept=‘D11’
FOR UPDATE OF job
END-EXEC.
137
OPEN empcur
END-EXEC.
END-EXEC.
DB2 LOCKING
138
o ACQUIRE USE / ALLOCATE
o RELESE COMMIT / DEALLOCATE
Catalogue Tables
DB2 Utilities:-
UTILITIES
• CHECK
• COPY
• MERGECOPY
• RECOVER
• LOAD
• REORG
• RUNSTATS
• EXPLAIN
CHECK
COPY
• Used to create an image copy for the complete table space or a portion of the table space-
full image copy or incremental image copy.
• Every successful exception of COPY utility places in the table, SYSIBM.SYSCOPY, at
least one row that indicates the status of the image copy.
MERGECOPY
• The MERGECOPY utility combines multiple incremented image copy data sets into a
new full or incremental image copy dataset.
RECOVER
139
• Standard unit of recovery is table space.
LOAD
REORG
• To reorganize DB2 tables and indexes and there by improving their efficiency of access
re-clusters data, resets free space to the amount specified in the ‘create DDL’ ,statement
and deletes and redefines underlying VSAM datasets for stogroup defined objects.
EXPLAIN
• Explain can be used to obtain the details about the access paths chosen by the DB2
optimizer for SQL statements.
• Used specifically for performance monitoring.
• When EXPLAIN is requested the access paths that the DB2 chooses are put in coded
format into the table PLAN_TABLE, which is created in the default database by the user.
• The other method is specifying EXPLAIN YES with BIND command
• The PLAN_TABLE is to be queried to get the required information
• Since the EXPLAIN results are dependent on the DB2 catalogue, it is better to run
RUNSTAT before running EXPLAIN.
DB2 FAQS
1. How would you find out the total number of rows in a table?
o Use SELECT COUNT(*) ...
2. How do you eliminate duplicate values in SELECT?
o Use SELECT DISTINCT ...
3. How do you select a row using indexes?
o Specify the indexed columns in the WHERE clause.
4. What are aggregate functions?
o Built-in mathematical functions for use in SELECT clause.
5. How do you find the maximum value in a column?
o Use SELECT MAX(...)
6. Can you use MAX on a CHAR column?
o Yes.
7. My SQL statement SELECT AVG(SALARY) FROM EMP yields inaccurate results.
Why?
o Because SALARY is not declared to have NULLs and the employees for whom
the salary is not known are also counted.
140
8. How do you retrieve the first 5 characters of FIRSTNAME column of EMP table?
o SELECT SUBSTR(FIRSTNAME,1,5) FROM EMP;
9. How do you concatenate the FIRSTNAME and LASTNAME from EMP table to give a
complete name?
o SELECT FIRSTNAME ¦¦ ' ' ¦¦ LASTNAME FROM EMP;
10. What is the use of VALUE function?
o Avoid -ve SQLCODEs by handling nulls and zeroes in computations
o Substitute a numeric value for any nulls used in computation
11. What is UNION,UNION ALL?
o UNION : eliminates duplicates
UNION ALL: retains duplicates
Both these are used to combine the results of different SELECT statements.
12. Suppose I have five SQL SELECT statements connected by UNION/UNION ALL, how
many times should I specify UNION to eliminate the duplicate rows?
o Once.
13. What is the restriction on using UNION in embedded SQL?
o It has to be in a CURSOR.
14. In the WHERE clause what is BETWEEN and IN?
o BETWEEN supplies a range of values while IN supplies a list of values.
15. Is BETWEEN inclusive of the range values specified?
o Yes.
16. What is 'LIKE' used for in WHERE clause? What are the wildcard characters?
o LIKE is used for partial string matches. '%' ( for a string of any character ) and '_'
(for any single character ) are the two wild card characters.
17. When do you use a LIKE statement?
o To do partial search e.g. to search employee by name, you need not specify the
complete name; using LIKE, you can search for partial string matches.
18. What is the meaning of underscore ( '_' ) in the LIKE statement?
o Match for any single character.
19. What do you accomplish by GROUP BY ... HAVING clause?
o GROUP BY partitions the selected rows on the distinct values of the column on
which you group by.
o HAVING selects GROUPs which match the criteria specified
20. Consider the employee table with column PROJECT nullable. How can you get a list of
employees who are not assigned to any project?
o SELECT EMPNO
FROM EMP
WHERE PROJECT IS NULL;
21. What is the result of this query if no rows are selected:
o SELECT SUM(SALARY)
FROM EMP
WHERE QUAL='MSC';
NULL
22. Why SELECT * is not preferred in embedded SQL programs?
o For three reasons:
1. If the table structure is changed ( a field is added ), the program will have
to be modified.
141
2. Program might retrieve the columns which it might not use, leading on
I/O over head.
3. The chance of an index only scan is lost.
23. What are correlated sub queries?
o A sub query in which the inner ( nested ) query refers back to the table in the
outer query. Correlated sub queries must be evaluated for each qualified row of
the outer query that is referred to.
24. What is a cursor? why should it be used?
o Cursor is a programming device that allows the SELECT to find a set of rows but
return them one at a time.
o Cursor should be used because the host language can deal with only one row at a
time.
25. How would you retrieve rows from a DB2 table in embedded SQL?
o Either by using the single row SELECT statements, or by using the CURSOR.
26. Apart from cursor, what other ways are available to you to retrieve a row from a table in
embedded SQL?
o Single row SELECTs.
27. How do you specify and use a cursor in a COBOL program?
o Use DECLARE CURSOR statement either in working storage or in procedure
division (before open cursor), to specify the SELECT statement. Then use
OPEN, FETCH rows in a loop and finally CLOSE.
28. What happens when you say OPEN CURSOR?
o If there is an ORDER BY clause, rows are fetched, sorted and made available for
the FETCH statement. Other wise simply the cursor is placed on the first row.
29. Is DECLARE CURSOR executable?
o No.
30. Can you have more than one cursor open at any one time in a program?
o Yes.
31. When you COMMIT, is the cursor closed?
o Yes.
32. How do you leave the cursor open after issuing a COMMIT? (for DB2 2.3 or above
only )
o Use WITH HOLD option in DECLARE CURSOR statement. But, it has not
effect in psuedo-conversational CICS programs.
33. Give the COBOL definition of a VARCHAR field.
o A VARCHAR column REMARKS would be defined as follows:
10 REMARKS.
34. What is the physical storage length of each of the following DB2 data types: DATE,
TIME, TIMESTAMP?
DATE: 4bytes
TIME: 3bytes
142
TIMESTAMP: 10bytes
35. What is the COBOL picture clause of the following DB2 data types: DATE, TIME,
TIMESTAMP?
DATE: PIC X(10)
TIME : PIC X(08)
TIMESTAMP: PIC X(26)
36. What is the COBOL picture clause for a DB2 column defined as DECIMAL(11,2)?
o PIC S9(9)V99 COMP-3.
Note: In DECIMAL(11,2), 11 indicates the size of the data type and 2 indicates
the precision.
37. What is DCLGEN?
o DeCLarations GENerator: used to create the host language copybooks for the
table definitions. Also creates the DECLARE table.
38. What is JOIN and different types of JOIN.
o The ability to join rows and combine data from two or more tables is one of the
most powerful features of relational system. Three types of joins:
1. Equi-join
2. Non-equijoin
3. self-join
39. Can I alter a table (e.g. adding a column) when other user is selecting some Columns or
updating some columns from the same table?
o yes possible. until the updation or selection is committed db2 table will not be
restructured. new column definition will be there but it will not be included until
all the tasks on the table are committed.
40. What are the different methods of accessing db2 from tso?
o There are three ways in establishing tso/db2 connection
1. SPUFI
2. QMF
3. CATALOG VISIBILITY
41. How is the connection established between TSO & DB2?
o A thread between TSO & DB2 is established while attempting to make
Connection between tso & db2.
42. What is sqlcode -922?
o Authorization failure
43. How do you do the EXPLAIN of a dynamic SQL statement?
o Use SPUFI or QMF to EXPLAIN the dynamic SQL statement
o Include EXPLAIN command in the embedded dynamic SQL statements
44. How is a typical DB2 batch pgm executed?
o Use DSN utility to run a DB2 batch program from native TSO. An example is
shown:
DSN SYSTEM(DSP3)
RUN PROGRAM(EDD470BD) PLAN(EDD470BD)
LIB ('EDGS01T.OBJ.LOADLIB')
END
o Use IKJEFT01 utility program to run the above DSN command in a JCL.
45. Is it mandatory to use DCLGEN? If not, why would you use it at all?
143
o It is not mandatory to use DCLGEN.
Using DCLGEN, helps detect wrongly spelt column names etc. during the
pre-compile stage itself (because of the DECLARE TABLE ).
DCLGEN being a tool, would generate accurate host variable definitions for the
table reducing chances of error.
46. Name some fields from SQLCA.
o SQLCODE, SQLERRM, SQLERRD
47. How does DB2 determine what lock-size to use?
o Based on the lock-size given while creating the table space
o Programmer can direct the DB2 what lock-size to use
o If lock-size ANY is specified, DB2 usually choses a lock-size of PAGE
48. What is the difference between CS and RR isolation levels?
o CS: Releases the lock on a page after use
o RR: Retains all locks acquired till end of transaction
49. Where do you specify them?
o ISOLATION LEVEL is a parameter for the bind process.
50. How do you simulate the EXPLAIN of an embedded SQL statement in SPUFI/QMF?
Give an example with a host variable in WHERE clause.
o Use question mark in place of a host variable (or an unknown value). e.g.
SELECT EMP_NAME
FROM EMP
WHERE EMP_SALARY > ?
51. What is ACQUIRE/RELEASE in BIND?
o Determine the point at which DB2 acquires or releases locks against table and
Table spaces, including intent locks.
52. In SPUFI suppose you want to select max. of 1000 rows, but the select returns only 200
rows. What are the 2 sqlcodes that are returned?
o 100 (for successful completion of the query), 0 (for successful COMMIT if
AUTOCOMMIT is set to Yes).
53. How would you print the output of an SQL statement from SPUFI?
o Print the output data set.
54. What does it mean if the null indicator has -1, 0, -2?
o -1 : the field is null
o 0 : the field is not null
o -2 : the field value is truncated
55. How do you retrieve the data from a nullable column?
o Use null indicators. Syntax ... INTO :HOSTVAR:NULLIND
56. What else is there in the PLAN apart from the access path?
o PLAN has the executable code for the SQL statements in the host program
57. What is lock escalation?
o Promoting a PAGE lock-size to table or table space lock-size when a transaction
has aquired more locks than specified in NUMLKTS. Locks should be taken on
objects in single table space for escalation to occur.
58. When is the access path determined for dynamic SQL?
o At run time, when the PREPARE statement is issued.
59. What are the various locks available?
o SHARE, EXCLUSIVE, UPDATE
144
60. What is sqlcode -811?
o SELECT statement has resulted in retrieval of more than one row.
61. What are the advantages of using a PACKAGE?
o Avoid having to bind a large number of DBRM members into a plan
o Avoid cost of a large bind
o Avoid the entire transaction being unavailable during bind and automatic rebind
of a plan
o Minmize fallback complexities if changes result in an error.
62. What is REORG? When is it used?
o REORG reorganizes data on physical storage to re-cluster rows, positioning
oveflowed rows in their proper sequence, to reclaim space, to restore free space.
It is used after huge updates, inserts and delete activity and after segments of a
segmented table space have become fragmented.
63. How does DB2 store NULL physically?
o as an extra-byte prefix to the column value. physically, the nul prefix is Hex '00'
if the value is present and Hex 'FF' if it is not
64. What is CHECK PENDING?
o When a table is LOADed with ENFORCE NO option, then the table is left in
CHECKPENDING status. It means that the LOAD utility did not perform
constraint checking.
65. When do you specify the isolation level? How?
o During the BIND process. ISOLATION (CS/RR)...
66. What is a DBRM, PLAN?
o DBRM: DataBase Request Module, has the SQL statements extracted from the
host language program by the pre-compiler.
o PLAN: A result of the BIND process. It has the executable code for the SQL
statements in the DBRM.
67. Is DECLARE TABLE in DCLGEN necessary? Why it used?
o It not necessary to have DECLARE TABLE statement in DCLGEN. This is used
by the pre-compiler to validate the table-name, view-name, column name etc.,
during pre-compile.
68. What do you need to do before you do EXPLAIN?
o Make sure that the PLAN_TABLE is created under the AUTHID.
69. What is a collection?
o a user defined name that is the anchor for packages. It has not physical existence.
Main usage is to group packages.
70. How can you quickly find out the # of rows updated after an update statement?
o Check the value stored in SQLERRD(3).
71. What is EXPLAIN?
o EXPLAIN is used to display the access path as determined by the optimizer for a
SQL statement. It can be used in SPUFI (for single SQL statement ) or in BIND
step (for embedded SQL ).
72. Where is the output of EXPLAIN stored?
o In userid.PLAN_TABLE
73. Suppose I have a program which uses a dynamic SQL and it has been performing well till
now. Off late, I find that the performance has deteriorated. What happened?
145
o Probably RUN STATS is not done and the program is using a wrong index due to
incorrect stats. Probably RUNSTATS is done and optimizer has chosen a wrong
access path based on the latest statistics.
74. What are the contents of a DCLGEN? - GS
o EXEC SQL DECLARE TABLE statement which gives the layout of the
table/view in terms of DB2 data types.
o A host language copy book that gives the host variable definitions for the column
names.
75. Will pre-compile of an DB2-COBOL program bomb, if DB2 is down?
o No. Because the pre-compiler does not refer to the DB2 catalogue tables.
76. What are the isolation (also called isolation parameters) levels possible?
o CS: Cursor Stability
o RR: Repeatable Read
77. What is the picture clause of the null indicator variable?
o S9(4) COMP.
78. EXPLAIN has output with MATCHCOLS = 0. What does it mean?
o A non-matching index scan if ACCESSTYPE = I.
79. I use CS and update a page. Will the lock be released after I've done with that page?
o No.
80. What are the various locking levels available?
o PAGE, TABLE, TABLESPACE
81. What is ALTER?
o SQL command used to change the definition of DB2 objects.
82. Can I use LOCK TABLE on a view?
o No. To lock a view, take lock on the underlying tables.
83. What are the disadvantages of PAGE level lock?
o High resource utilization if large updates are to be done
84. What are PACKAGES ?
o They contain executable code for SQL statements for one DBRM.
85. Lot of updates have been done on a table due to which indexes have gone haywire. What
do you do?
o Looks like index page split has occured. DO a REORG of the indexes.
86. What is dynamic SQL?
o Dynamic SQL is a SQL statement created at program execution time.
87. What is IMAGECOPY ?
o It is full backup of a DB2 table which can be used in recovery.
88. What is QUIESCE?
o A QUIESCE flushes all DB2 buffers on to the disk. This gives a correct snapshot
of the database and should be used before and after any IMAGECOPY to
maintain consistency.
89. What does the sqlcode of -818 pertain to? - GS
o This is generated when the consistency tokens in the DBRM and the load module
are different.
90. What happens to the PLAN if index used by it is dropped?
o Plan is marked as invalid. The next time the plan is accessed, it is rebound.
91.
o
92. What is FREEPAGE and PCTFREE in TABLESPACE creation?
146
o PCTFREE: percentage of each page to be left free
o FREEPAGE: Number of pages to be loaded with data between each free page
93. Are views updatable?
o Not all of them. Some views are updatable e.g. single table view with all the
fields or mandatory fields. Examples of non-updatable views are views which are
joins, views that contain aggregate functions (such as MIN), and views that have
GROUP BY clause.
94. What is COPY PENDING status?
o A state in which, an image copy on a table needs to be taken, in this state, the
table is available only for queries. You cannot update this table. To remove the
COPY PENDING status, you take an image copy or use REPAIR utility.
95. What is an inner join, and an outer join?
o Inner Join: combine information from two or more tables by comparing all values
that meet the search criteria in the designated column or columns of one table
with all the values in corresponding columns of the other table or tables. This
kind of join which involve a match in both columns are called inner joins.
o Outer join is one in which you want both matching and non matching rows to be
returned. DB2 has no specific operator for outer joins, it can be simulated by
combining a join and a correlated sub query with a UNION.
96.
o
97. What is the difference between primary key & unique index?
o Primary: a relational database constraint. Primary key consists of one or more
columns that uniquely identify a row in the table. For a normalized relation, there
is one designated primary key.
o Unique index: a physical object that stores only unique values. There can be one
or more unique indexes on a table.
98. When do you use the IMAGECOPY?
o To take routine backup of tables.
o After a LOAD with LOG NO. After REORG with LOG ON.
99. What is RUNSTATS?
o A DB2 utility used to collect statistics about the data values in tables which can
be used by the optimizer to decide the access path. It also collects statistics used
for space management. These statistics are stored in DB2 catalog tables.
100.How do you insert a record with a nullable column?
o To insert a NULL, move -1 to the null indicator
o To insert a valid value, move 0 to the null indicator
Fileaid :-
FILE AID
GENERAL INFORMATION
147
KEY FEATURES
File-AID's functions enable you to significantly reduce the time required to perform day-to-day
data file manipulation tasks such as creating and modifying test data, resolving production data
problems, and performing ad-hoc file conversions and comparisons.
KEY FEATURES:
- provides on-line editing of sequential, BDAM, PDS, ISAM, IAM, and VSAM files
using
eliminates file size restriction by using selection criteria to limit the number of records to
be edited
- provides optional audit trail of all records updated, inserted, and deleted while editing a
data file
- the record layout is the sole definition of files thus eliminating the need to redefine the
file/data in another language
- superimposing the record layout over raw data brings meaning to that
data
- records may be selected for copying using selection criteria based on record counts and/or
specific values in individual fields .
- selection criteria can be used in the Browse, Edit, Copy, Print, or Compare functions .
148
o Runs as a single dialog under ISPF
- executes in storage available above the 16 megabyte line on systems running MVS/XA or
MVS/ESA
File-AID executes as a dialog under IBM's ISPF dialog manager facility. You can invoke it by
selecting the File-AID option from a customized version of the ISPF primary option menu, or
from a sub-menu panel your installation has set up.
If the File-AID execution CLISTS have been installed, you may invoke File-AID from any ISPF
screen. For example, the command TSO FASTART suspends your current screen and displays
the File-AID primary option menu. Upon exit from File-AID your suspended screen is
restored.
This option consists of the ISPF-provided parameter option screens and several screens to specify
File-AID default parameters.
This option is used to display but not change the contents of files using any of three display
modes - formatted, vertical, and character.
149
This option is used to create, display and change the contents of files using the formatted,
vertical, and character display modes.
OPTION 3 - UTILITIES/E
3.3 Copy (Selective record copying for all file types including PDS members),
3.5 VSAM (Define VSAM clusters, indexes, and paths online or in batch),
3.7 VTOC (Search volumes for datasets using pattern characters, analyze space),
This option is used to print data file contents, the selection criteria and rcd/layout XREFs
created in options 6 and 7 of File-AID, formatted record layouts, and audit trail datasets created
while editing a data file in option 2 (Edit) or 3.6 (Update) of File-AID.
This option is used to create and maintain selection criteria for use in the Browse, Edit, Copy,
Print, and Compare functions.
This option is used to create and maintain rcd/layout XREFs for use in other File-AID
functions.
This option is used to display the contents of COBOL or PL/I layouts as interpreted by File-
AID.
150
This option allows the records of an input file to be reformatted and written to an output file
based on record layouts defining the input and output files.
OPTION 10 - COMPARE
This option is used to compare two files and report the differences between
them.
File-AID uses the full screen for display and entry of data.
The first three lines of each display, called the heading lines, have a common format for all File-
AID displays. The remainder of the screen may contain a list of options, input fields and prompts,
or scrollable data.
|----------------------------------------|------------------------ --|
|-----------------------------------------------------------------------|
The TITLE area (line 1) identifies the function being performed and, where appropriate, library
or dataset information.
151
The COMMAND/OPTION area (line 2) is used to enter a command. On an option selection
menu, it may be used to enter either a command or an option.
The SCROLL area (line 2) contains the current scroll amount whenever scrolling is applicable.
You may change it by overtyping.
The LONG MESSAGE area (line 3) is used to display an explanation of error conditions upon
request (see HELP command). This line will normally be blank or will contain heading (non data
entry) information. Dataset specification screens allow you to enter information such as dataset
names, member names, and other parameters. The fields in which you may enter information are
labeled and preceded with an arrow. If you fail to enter a required value or if you enter
inconsistent values, you are prompted with a message.
|************************************************
specification screen. |
Several fields on dataset specification screens are pre-entered with values that you entered the last
time on that screen or on a similar screen. If the values are correct, simply press ENTER. If the
values are not correct, overtype the fields that need to be changed before pressing ENTER.
The pre-entered information comes from your user profile, which File-AID automatically builds
and maintains across sessions. Information that is maintained in your user profile
includes:
152
- Dataset names and member names
- PF-Key defaults
In most functions it is possible to obtain multiple member lists prior to entering the function.
|************************************************
Scrollable data display screens show file contents or record layouts and allow up/down
scrolling, and in some cases left/right scrolling. On many scrollable data display screens, you can
also update file contents by typing over fields on the screen.
The example below shows the edit formatted screen. You can scroll using the UP and DOWN
commands, and can update file contents by typing over the FIELD VALUE column.
153
COMMAND ===> SCROLL ===> PAGE
RCD SEQ NO 1
01 ORDER-LINE
05 QTY-ORDERED 11 100
05 LIST-PRICE 14 2400.00
Unscrollable data display screens show "nonrepeating" information which fits on a single
screen. The Selection Criteria Options screen shown below is an example of this type of
screen.
******************************************************************************
**
COMMAND ===>
154
File-AID provides commands for commonly used functions. You may enter commands in one of
two ways:
1) By typing the command in the command/option field (line 2 of the screen) and then pressing
the ENTER key, or
2) By pressing a program function (PF) key to which you have assigned the desired command.
You can assign commands to PF keys using option 0.0.3 or the KEYS command. When you press
the PF key, the processing is the same as if you typed the command in the command field and
pressed ENTER.
Before you press a PF key, you can enter information in the command field. The PF key
definition is concatenated ahead of the contents of the command field. For example, suppose you
assign the DOWN command to the PF8 key. If you type "6" in the command field and press PF8,
the results are the same as if you had typed "DOWN 6" in the command field and pressed
ENTER.
You can stack multiple commands for execution in one interaction by entering a special delimiter
between the commands. The default delimiter is a semicolon (;). You can change the delimiter
using option 0.0.1. For example:
In this example the DOWN and LEFT commands have been stacked.
File-AID primary commands are divided into four categories listed below. Commands
designated with an asterisk (*) have the same syntax and function as in ISPF.
In many File-AID functions, the information to be displayed exceeds the screen size. Scroll
commands allow you to move the screen "window" in as many as three dimensions across the
information: up/down, left/right, and forward/back. For a more detailed description of scrolling,
see the SCROLLING section within GENERAL INFORMATION.
UP * Causes scrolling toward the top of a record, file, record layout, or member list.
DOWN * Causes scrolling toward the end of a record, file, record layout, or member list.
LEFT * Causes scrolling toward the left margin of the data or causes backward scrolling
towards the beginning of a file.
RIGHT * Causes scrolling toward the right margin of the data or causes forward scrolling
towards the end of a file.
155
FORWARD Causes record scrolling toward the bottom of the file.
LOCATE Causes up or down scrolling to the specified line number, label, or member
name.
LOCATE Causes up or down scrolling to the record with a label (dataname) or exclude
classification. Also causes scrolling to a data-name that contains, in part or full, the data
name(occ) string.
LR Causes forward or backward scrolling to a specified record number, label, or any record
with a label classification.
Record manipulation commands allow you to update file contents and to find and change
occurrences of a string in a file.
INSERT Causes "n" records to be inserted after the current record (not supported for BDAM
files)
DELETE Causes "n" records to be deleted beginning with current record (not supported for
BDAM files)
REPEAT Causes a record to be repeated "n" times (not supported for BDAM
files)
SAVE * Causes the data to be stored back into the edit dataset
When using an XREF to work with "segmented" records the following are valid:
156
REMOVE Remove a segment at a point in the record.
Session control commands have to do with terminating the current function or switching from
one function to another.
END * Terminates the current operation and returns to the next higher level screen (also used
to indicate end of table input)
Recursive commands: File-AID has special commands like F1 (Browse), F2 (Edit), F33 (Copy)
that let you suspend your current display and start another function. Upon end from the new
function, the suspended display is resumed.
1 - Recursive Commands
MISCELLANEOUS COMMANDS
Miscellaneous commands cover a variety of functions. They are listed and briefly described
below.
KEY Causes a specified key to be retrieved or the key specification screen to be displayed
(applies to BDAM, ISAM, VSAM-KSDS, VSAM-RRDS, and IAM files only)
CAPS * Causes alphabetic data entered from the terminal to be either translated to upper case
or left as- is
RESET * Causes a general resetting of intensified messages and incomplete line commands
157
CHAR Causes a switch from Formatted or Vertical editing modes to Character editing
mode
FORMAT Causes a switch from Vertical or Character editing modes to Formatted editing mode
(Aliases: FMT, MAP)
VFMT Causes a switch from Formatted or Character editing modes to Vertical editing
mode
SPLIT * Causes split screen mode to be entered or changes the location of the split
line
SWAP * Moves the cursor to wherever it was previously positioned on the other logical screen
of a split screen pair
KEYS * Causes an immediate display of a screen on which current PF key definitions are
displayed and modifiable
PANELID * Causes all subsequent screens to be displayed/not displayed with the panel identifier
shown in the upper left corner of the screen
PRINT * Causes a snapshot of the current screen to be recorded in the ISPF list file for
subsequent printing
PRINT-HI* Same as PRINT except that high-intensity characters on the screen are printed with
overstrikes to simulate the high-intensity display
The two program access (PA) keys have special meaning in ISPF and File-AID. They are not
equated to ISPF or File-AID commands, and they may not be reassigned.
Normally, you should not use PA1 while operating in File-AID full screen mode. However, there
are two exceptions.
158
If you press PA1 after the keyboard has been unlocked by File-AID, it is treated like PA2
(RESHOW). It does not cause exit from File-AID. However, if you press PA1 a second time
without any intervening interaction, it causes the current processing to be terminated and the ISPF
PRIMARY OPTION MENU is redisplayed.
If you press PA1 after the keyboard has been manually unlocked (by pressing the RESET key), it
usually causes the current processing to be terminated. The ISPF PRIMARY OPTION MENU is
redisplayed.
You can use PA2 to reshow the last full screen image displayed by File-
AID.
You may need to reshow the screen if you accidentally press the ERASE INPUT or CLEAR key,
or if you have typed data on the screen that you want ignored and have not yet pressed ENTER or
a PF key.
DEFAULT ASSIGNMENT
| | | |
| | | |
|---------------|------------|------------------|
| UP | DOWN | SWAP |
| | | |
|---------------|-------------|-----------------|
159
| PF10/22 | PF11/23 | PF12/24 |
| | | |
|----------------|------------|-----------------|
In many File-AID functions, the information to be displayed exceeds the screen size. Scrolling
allows you to move the screen "window" in as many as three dimensions across the information:
up/down, left/right, and forward/back.
PAGE SCROLLING
These commands function exactly as they do in ISPF/PDF. On all screens involving scrolling, a
scroll amount is displayed on line 2 of the screen. This value indicates the number of lines or
columns to scroll when you enter one of the four page scrolling commands. You can change the
scroll amount by simply typing over the scroll amount field.
- MAX - specifies scrolling to the top, bottom, left margin, or right margin, depending on which
scrolling command is used.
160
- CSR - specifies scrolling based on the current position of the cursor. The line or column where
the cursor is positioned is moved to the top, bottom, left, or right of the screen depending on
which scrolling command is used. If the cursor is not in the body of the data, or if it is already
positioned at the top, bottom, left, or right, a full page scroll occurs.
For scrolling purposes a "page" is defined as the amount of information currently visible on the
logical screen. In split screen mode, for example, the edit character display might have 12 lines
by 80 columns of scrollable data. In this case, a scroll amount of HALF would move the window
up or down by 6 lines, or right or left by 40 columns.
The current scroll amount is saved in the user profile. When you type over the scroll amount, the
new value remains in effect until you change it again.
You can override the current scroll amount on a given interaction by entering a scroll amount in
the command field and using a scroll command or PF key.
To reduce keystrokes, you can change the scroll amount field by typing over the first character(s)
only:
- To change the scroll amount to PAGE, DATA, HALF, MAX, or CSR, type over the first
character with P, D, H, M, or C respectively.
- To change the scroll amount to a number of lines or columns, type over the first character(s)
with the desired number.
RECORD SCROLLING
The LEFT (PF10/PF22) and RIGHT (PF11/PF23) commands can be used in place of BACK and
FORWARD, respectively.
161
These commands apply to the screens where one "record" per screen is displayed formatted with
a record layout (edit/browse Formatted, edit formatted field selection criteria, define formatted
XREF) and are used to move forward or backward "n" records (or criteria sets) in a file.
You enter the scroll amount for record scrolling in the COMMAND input area (unless you have
assigned both the command and the scroll amount to a PF key). Valid scroll amounts
are:
- MAX or M - specifies scrolling to the last record (FORWARD) or the first record (BACK) in
the file
There may be times when you want to perform another File-AID function or ISPF/PDF function
without ending the current function. File-AID provides the ability to 'split' the physical screen
image into two logical screens that operate independently of one another, as though you had two
terminals.
In split screen mode, only one of the logical screens is considered active at a time. Any
interactions, such as pressing ENTER or a PF key, are interpreted as having meaning for the
active screen. The current location of the cursor identifies which of the two screens is active. To
switch from one screen to the other, simply move the cursor to the desired screen or enter the
SWAP command.
When you invoke File-AID from the ISPF primary option menu, eventually terminate ISPF/PDF
using the END command, and used either the log or list files, a termination screen is displayed.
General information about the use of datasets by File-AID follows. Each topic is presented in
sequence, or may be selected by number:
162
2 - Data File Dataset
All datasets processed on-line must reside on a direct access storage device or on a mass storage
device. Uncataloged disk data file datasets are allowed in all functions and can be accessed by
specifying a VOLSER.
Temporary data files and tape datasets are allowed as input to independent File-AID/Batch jobs
for which you develop the JCL. File-AID/Batch JCL can be optionally generated with Copy
(3.3), Search/Update (3.6), Print (5.x), Reformat (9), and Compare (10)
When a Dataset Name is required in File-AID, you may enter a fully qualified (quoted),
unqualified (no quotes, userid prefix implied), or pattern (catalog search request).
File-AID saves the name of the most recently referenced dataset of each type (Data file, Record
Layout, XREF, Selection Criteria) in your session profile and redisplays these names on all
appropriate screens.
You may enter any fully qualified data set name by enclosing the name in apostrophes (').
Trailing quotes are never required.
UNQUALIFIED NAMES
If you omit the apostrophe(s), your TSO prefix is left-appended to the entered data set name
(unless the TSO profile option "NOPREFIX" has been specified).
163
If you specify a default VSAM INTERMEDIATE NAME with the 0.1 System Parameters
function, and/or your installation uses the optional File-AID VSAM high level index, and no
dataset can be
The constructed "VSAM prefix" is then left-appended to the entered dataset name (VSAM
prefix.dataset) and the catalog is again searched for the dataset. If allocating a VSAM cluster,
with the 3.5 VSAM utility, the VSAM prefix is always constructed when an unqualified name is
specified.
UNCATALOGED DATASETS
If the dataset is not cataloged, you must specify a Volume serial number.
You can use pattern characters in the dataset field to dynamically invoke File-AID's catalog
search (3.4) to look for matching dataset names. Valid pattern characters are: ? and % (single
character) * (multiple characters in one node), + (0 or more nodes). Pattern characters are used to
represent any or all characters which are not part of the high-level node of a dataset name. The
high-level node must be fully specified. Following are some examples of using the
or
or
After specifying the pattern, press ENTER. The File-AID 3.4 Catalog Utility is invoked, and a
list of datasets corresponding to the pattern that you specified is displayed. Type S in the
COMMAND column to the left of the name of the dataset you want to select and press ENTER.
The selected dataset will be used and will replace the pattern you specified on the panel for
the function you are performing.
164
If you are not licensed for File-AID/SPF, you will receive an error if you use a pattern character
in the dataset field.
For further information on pattern characters, explore the tutorial for the 3.4 Catalog utility or see
the File-AID Online Reference Manual, CATALOG UTILITY.
PDS DATASET(MEMBER)
A member name enclosed in parentheses may follow the data set name (within the apostrophes,
if they are present) for partitioned data sets. For selection purposes, specifying a member name
for a partitioned dataset will cause the member to be processed as a sequential dataset.
In most instances a Member Name prompt is provided under the Dataset Name prompt. If a
member name is specified in parentheses along with the dataset name, the member information is
considered as if it had been entered in the Member Name field.
When referencing a PDS dataset, you may specify a Member Name of blank, or use a pattern to
generate a list of members for selection.
You can use a question mark (?) or percent (%) to represent a single character of the member
name or an asterisk (*) to represent multiple
characters in a member name. However, you must enter at least the first character of the member
name before you can use the asterisk. (Exception: in 3.3 Copy or 3.6 Search Update, a member
name of asterisk (*) means to process all members and to bypass all PDS
Using blank or a member name pattern will either cause a File-AID member list to be displayed
or a PDS Processing Option screen to appear to provide additional member selection options.
Once a list of members is presented, you can select a member from this list by using the S line
command.
You can also enter the full member name, in parentheses, on the same line as the dataset name. If
you do so, you can ignore the Member Name field.
GENERATION DATASETS
165
This example references the most recently allocated data set in
CATALOG DATASET
On some panels a catalog dataset name may be entered. In this case whether the catalog dataset
name is enclosed in quotes or not, the name is always considered to be a fully qualified name and
no prefix is appended to it.
In the above example, both entries are correct and treated equally.
The data file dataset contains the data to be browsed, edited, reformatted from/into, copied
from/into, searched, updated, printed or compared. It can also be a dataset you are defining or
managing with the extended utilities.
File-AID supports user written I/O exit programs for data file datasets. I/O exits can handle
compression/decompression, encryption/decryption, or can perform all physical I/O to your data
file. See the File-AID Installation Guide for details and samples.
The next two tutorial pages display tables showing the combinations of dataset organizations and
record formats allowed for data files. For sequential (PS), partitioned (PO), BDAM (DA), and
ISAM (IS) files, the LRECL and BLKSIZE can range from 1 to 32,760 for each RECFM. For
VSAM files, the LRECL can range from 1 to 32,767.
The table below shows the combinations of dataset organizations and record formats allowed for
data files.
RECFM
DSORG F FB V VB U SPANNED
PS
X X X X X X
(Sequential)
PO
X X X X X X
(Partitioned)
IS (Indexed X X X X n/a n/a
166
Sequential)
DA (BDAM) X X
The table below shows the combinations of dataset organizations and record formats allowed for
VSAM data files.
RECFM
DSORG F FB V VB U SPANNED
AM (VSAM-
n/a n/a X n/a n/a X
KSDS,ESDS)
AM (VSAM-
X n/a n/a n/a n/a n/a
RRDS)
AM (IAM) X n/a X n/a n/a X
AM (VSAM-
(allocate, delete, info only)
LDS)
1) VSAM-KSDS and ESDS files are treated as variable length files. Also, the concept of
blocking, as applied to PS, PO, and IS files, does not apply to VSAM.
2) File-AID does not support ISAM files with OPTCD=L in the DCB information when the key
starts in the first position (RKP=0 for fixed length files, RKP=4 for variable length files)
3) File-AID does not support fixed length unblocked ISAM files with a relative key position of 0
(RKP=0), or variable length unblocked ISAM files with a relative key position of 4
(RKP=4).
4) File-AID supports reading a VSAM-KSDS in an alternate key sequence via a VSAM PATH.
A PATH name may be specified for the input data file name in the browse, edit, copy, print, and
compare options.
5) File-AID treats RECFM=FB BDAM files as RECFM=F (i.e., records are not de-blocked.)
Keyed BDAM files are processed by File-AID as if the key were concatenated in front of
each data block.
6) IAM files exist as fixed or variable length files. Due to a constraint in the information
available to File-AID from the IAM access method, all files are currently handled as variable
length files. If the length is changed on an IAM file which is truly fixed, File-AID will display an
error message. IAM files are processed as VSAM-KSDS files in all functions.
File-AID allows you to access data file datasets with OS password protection. Any dataset may
be protected to permit read-only or read/write access. More than one password may be assigned
to the same dataset. A dataset that is read/write protected, for example, might allow several
authorized users to read it, but only one user to write.
167
If you attempt to access a dataset protected by an OS password, File-AID will present the OS-
Password-Protected screen containing a field where you can specify a dataset password as
follows:
A nondisplay input field is used so that the password does not appear on the screen while you are
typing it.
Note that the File-AID 3.5 VSAM utility supports specification and modification of passwords
for VSAM clusters.
This dataset contains the record layouts which are used in many File-AID functions. The record
layout dataset can be one of four types:
A record layout may be a separate COPYLIB member or may be hard-coded within the source
statements of a program. If the layout is in a program or if a COPYLIB member contains
multiple record layouts, you can isolate the specific layout, or portion of a layout, that File-AID
should use by specifying a starting data-name.
If you do not specify a starting data-name, File-AID uses every layout found in the program, or
COPYLIB member, to format the data, treating the second through last layouts as additional
layouts that may be manually selected and overlaid at any offset via the USE command.
Note: File-AID Release 6 "MAP" libraries containing compiled record layouts are acceptable as a
record layout library.
LANGUAGE SUPPORT
Layouts may be used when browsing, editing, printing, reformatting and comparing data
files.
168
Layouts can also be used to define selection criteria and to specify tests for multiple record type
layout usage.
File-AID supports Format 1 of the COBOL data definition statement and ignores Formats 2 and
3. When a 66 or 88 level item is encountered File-AID skips to the end of the sentence and
performs no syntax checking.
FORMAT 1 FORMAT 2
REDEFINES clause
OCCURS clause
SIGN clause
SYNCHRONIZED clause
USAGE clause
VALUE clause.
1) The first data description entry in the COBOL layout need not have level number 01.
2) If multiple data description entries have level number 01, the second through "n" 01 level
entries are treated as though they redefine the first 01 level entry. Each 01 level entry need not be
successively longer than the previous 01 level entry.
4) The PICTURE clause must be specified for every elementary item with the exception of
INDEX, COMP-1, and COMP-2 data items.
169
5) Each data description entry must be terminated by a period.
7) The EJECT, SKIP1, SKIP2, and SKIP3 reserved words may be imbedded between data
definition statements within a COBOL layout. File-AID skips over these words.
8) File-AID also skips over the TITLE statement, which is valid in VS COBOL II.
9) Sort file description entry statements (SD) and file description entry statements (FD) may be
imbedded within the COBOL layout. File-AID skips these statements and performs no syntax
checking.
10) File-AID also skips debugging lines ("D" in column 7) and sentences which do not begin
with a valid level number.
11) File-AID ignores the REDEFINES clause if it is on the first data description entry in the
COBOL layout.
The level number and data-name are required in the COBOL data description entry. The format
is:
The level number may be any number from 1 through 49. You may not use level number 77.
Data-names must be 30 characters or less but are not otherwise validated. For example, you are
not restricted to using characters A through Z, 0 through 9, and hyphen to form data-names, and
you need not make data-names unique. The keyword FILLER is treated the same as other data-
names.
The level numbers of data-name-1 and data-name-2 must be identical and can be any level
number from 1 to 49. Between the data descriptions of data-name-2 and data-name-1, there may
be no entries having numerically lower level numbers than the level number of data-name-2 and
data-name-1.
The data description entry for data-name-2 may not contain an OCCURS clause. However, data-
name-2 may be subordinate to an item containing an OCCURS clause with or without the
DEPENDING ON option. Items subordinate to data-name-2 may contain an OCCURS clause
without the DEPENDING ON option.
170
Data-name-1 and any items subordinate to data-name-1 may contain an OCCURS clause with or
without the DEPENDING ON option. If data-name-1 contains an OCCURS clause, its length is
computed to be the length of one occurrence multiplied by the number of occurrences.
The size of the redefining area must be less than or equal to the size of the redefined area.
Multiple redefinitions of the same redefined area may reference the data-name of the redefined
area or the data-name of any of the preceding redefining areas.
REDEFINES clauses may also be specified for items subordinate to items containing
REDEFINES clauses.
File-AID ignores the REDEFINES clause if it is on the first data description entry in the COBOL
layout.
The word "WHEN" is optional. This clause is checked for valid syntax but it does not affect
processing in any way.
JUSTIFIED (RIGHT)
JUST
The JUSTIFIED clause is used to override normal positioning of data within a receiving
alphanumeric data item. This clause affects processing in the reformatting function (option 9)
only.
Normally data is left justified in the receiving field and either truncation or blank padding occurs
on the right. When the JUSTIFIED clause is specified, data is right justified in the receiving field
and either truncation or blank padding occurs on the left.
FORMAT 1
DESCENDING
171
FORMAT 2
DESCENDING
The words "TIMES", "KEY IS", and "BY" are optional in both formats.
In FORMAT 2, integer-1 represents the minimum number of occurrences and integer-2 represents
the maximum number of occurrences. Integer-1 must be greater than or equal to 0, and integer-2
must be greater than integer-1 and less than 32,768.
Three nested levels of OCCURS clauses are allowed. The OCCURS clause may not be specified
on 01 level items.
The ASCENDING KEY, DESCENDING KEY, and INDEXED BY options are checked for valid
syntax, but do not affect processing in any way.
PIC
File-AID interprets all options of the PICTURE clause. The alphabetic, alphanumeric,
alphanumeric edited, and numeric edited categories of data are all treated as alphanumeric data
(i.e. treated as if the character string contained all X's). Picture characters
A X B 0 Z , . * - CR DB $ E
172
are all treated as the picture character X (XX for CR and DB). For alphanumeric edited and
numeric edited data items, File-AID does not validate the character string according to the
"precedence of symbols" as COBOL does.
External floating point items are fully syntax checked and treated as picture X items. Also, the
scaling position character, P, is supported
TRAILING
The word "CHARACTER" is optional in the SEPARATE option. File-AID treats the SIGN
clause exactly as COBOL treats it.
SYNCHRONIZED (LEFT)
SYNC (RIGHT)
The SYNCHRONIZED clause may be specified at the 01 or elementary item level. When
specified at the 01 level, every elementary item within the 01 level is synchronized.
File-AID treats all other aspects of the SYNCHRONIZED clause exactly as COBOL treats them,
including computation of slack bytes for groups, defined with the OCCURS clause, containing
synchronized items.
DISPLAY
DISPLAY-1
COMPUTATIONAL
COMP
COMPUTATIONAL-1
COMPUTATIONAL-2
COMP-2
173
COMPUTATIONAL-3
COMP-3
COMPUTATIONAL-4
COMP-4
INDEX
The USAGE clause can be specified at any level of data description. However, if the USAGE
clause is written at a group level, it applies to each elementary item in the group. The usage of an
elementary item may not contradict the usage of a group to which an elementary item belongs.
If the USAGE clause is not specified for an elementary item, or for any group to which the item
belongs, usage DISPLAY is assumed.
The VALUE clause is checked for valid syntax but does not affect processing in any way.
When File-AID encounters an error during its on-line processing of a COBOL layout, an error
messages is written to your ISPF log file. These messages contain an image of the last line File-
AID read from the COBOL layout, plus the internal layout representation File-AID built before
the error occurred. By using these messages in conjunction with the error message File-AID
displays at your terminal, you will be able to resolve most COBOL layout errors.
Whenever you leave the layout member name blank or use a pattern, File-AID presents a member
list. A partitioned processing options (PPO) screen usually appears first to let you filter the
member list to improve performance. A pattern consisting only of an asterisk (*) tells File-AID to
list all members and to bypass the PPO screen.
174
NOTE: Using a single asterisk (*) pattern to list all members of a large layout library (such as a
Panvalet or Librarian library) may be time consuming.
Member list presentation occurs automatically in the XREF function when you use line
commands, or enter a pattern in the member name field (with or without using the S or SU line
command).
SOURCE OPTIONS
When File-AID cannot compile your record layout with the default source options, the Source
Statement Selection panel is displayed. This panel contains a Source Statement selection area
and a compiler option section. Record layout extraction can be done by "Character string" or
"Statement number".
The Source Options panel is also used to enter compiler options. The compiler options are
Language, Starting level number, Literal delineator (COBOL only) and Use 48 character set (PL/I
only).
COBOL compiler that either the quote (") or the apostrophe (') is the character used to delineate
literals.
Use 48 character set indicates to the PL/I compiler that the source is written in the 48-character
set.
175
If File-AID cannot determine the language, or if compilation fails, it will display this panel to
allow you to change source or compile options.
XREF DATASET
record layout. The XREF dataset must have the following attributes:
You create XREF members to communicate information about the record layout dataset to File-
AID in the following situations:
1) the data file you want to work with contains records with differing formats, requiring different
record layouts to define the various formats
2) the record layout that defines the data file is hard-coded in a program
3) the record layout that defines the data file is stored in a COPYLIB member that contains
multiple record layouts
4) each record in the data file requires two or more record layouts, presented in sequence, to
define it
For the first situation, the XREF contains two pieces of information:
1) the name or the length and starting position of the field(s) within each data record that File-
AID should use to identify the data record's type (referred to as the "record type field(s)")
2) a list of all the possible record type values and the corresponding layout library member which
defines the data records with those values
For the second and third situations, the XREF contains the data-name that starts the data structure
you want (referred to as the "starting data-name"). File-AID reads the layout from the source
library member (containing either multiple layouts or a program) starting with the data-name you
specify. File-AID stops reading when it finds a new data structure (equal or lower level number)
or when the end of the record layout, library member, or program is reached.
For the fourth situation, the XREF contains the names of the layout library members for each
segment of a data record. It also contains the rules for identifying each segment of the record
176
by locating the "segment type field" and field values to use for selecting a segment layout (via
NEXT command of Formatted Browse/Edit).
In any of the File-AID primary options which use layouts to define the data, the record layout
dataset and XREF dataset information are specified as shown in the example below.
RECORD LAYOUT USAGE indicates whether you will use a single record layout (usage "S"), a
layout XREF (usage "X"), or no source layouts (usage "N") to define the file.
The table below shows the valid dataset and member entries for the record layout and layout
XREF datasets, for each layout usage.
This dataset contains existing "selection criteria information" created using option 6 of File-AID.
You can use saved selection criteria in the browse, edit, copy, search/update, print, and compare
functions.
This dataset contains saved Reformat Definitions created using option 9 of File-AID. You can
use a saved Reformat Definition online or in batch (REFORMAT function).
177
TYPE DSORG RECFM LRECL
Partitioned Dataset PO V, VB 1570
When partitioned datasets are specified on the dataset specification screens, you may display a
member list by:
A pattern is a partial member name containing one or more of the single character "wild cards" *
(asterisk) ? (question) or % (pct). If any pattern character is present, the name becomes a mask
matching any member name starting with the pattern entered (as if the pattern contained all "wild
cards" at the end). Therefore, one trailing pattern character is used only if it is the only
"wild card" in the mask, otherwise it is assumed. (Ex. PR?G is the same as PR?G???? and
PR?G*. However PRO and PRO* are different because PRO is a member name not a pattern like
PRO* is.)
For example, the patterns: ?RO*, ?RO, P*, PR?G%, P?O?G, PROGRAM* all match and produce
the following list:
PROGRAM1
PROGRAM2
PROGRAM3
Use the S (Select) line command to select the member you want. You may also scroll through the
member list using the UP and DOWN commands. In addition, you can enter a LOCATE primary
command and scroll directly to (or near) a specified member name.
On certain dataset specification screens, you can specify multiple partitioned datasets. Therefore,
it is possible for you to receive multiple member list screens (one for each partitioned dataset
specified without a member or with a pattern) before proceeding to the next screen in the
function. The member lists are displayed in the sequence that the datasets appear on the dataset
specification screen.
178
If the main dataset in Browse (1), Edit (2), Copy (3.3), Search/Update (3.6), and Print data (5.1),
is a PDS and an explicit member is not specified, File-AID provides a PDS Processing Options
(PPO) screen. The PPO screen lets you specify additional member qualification filters such as:
member name range, last modified userid range, create date range, and modified date range.
If you wish to bypass the PPO screen and process all members, use a member name of * on the
main entry screen (Ex. Edit DSN=MY.PDS(*) ).
Note that when multiple PDSs are specified on the entry screen the list of members matching
your PPO options may not appear until AFTER all other PDS member lists have been presented
and a member selected.
ABNORMAL TERMINATION
In both situations, File-AID intercepts the abend and displays an error screen. In the first case, a
message is displayed describing the unrecoverable error encountered. In the second case, the
system and user abend codes are displayed.
The first keyboard interaction on the error display screen causes the ISPF abnormal termination
screen to be displayed.
File-AID attempts to close all open files prior to returning control to ISPF.
DATASET SECURITY
File-AID is completely compatible with any data security software your installation may have
(Ex. RACF, CA-ACF2/TOP Secret, etc). File-AID processing does not circumvent your security
software in any way.
File-AID provides your installation with the capability of creating its own security exit routine
that File-AID will call during its processing. This enables your installation to limit access to
certain datasets. Following are some examples of the optional security exit routine uses:
- To allow only authorized users to browse and/or edit selected data files
If you require information on your installation's security exit routine, contact the person
responsible for File-AID at your installation.
In addition to the security exit, an audit exit is provided that can be customized for various uses
including:
179
- To force the creation of an audit trail when option 2 of File-AID is used to edit selected data
files, and/or to force the printing of an audit trail report upon completion of the data file updates
When you use option 2 of File-AID to edit a data file, you may specify that File-AID capture all
of your update activity in an audit trail dataset. Every insert, repeat, delete, copy, typeover, and
CHANGE command you perform causes a before and/or after image of the record(s) affected to
be written to the audit trail dataset. When you complete your edit session, a screen is displayed
giving you the option to print, delete, or keep the audit trail. If you specify that the audit trail be
printed, a batch job is submitted which produces a formatted audit trail report.
File-AID also provides your installation with the ability to force the creation of an audit trail
during any user's edit session through an audit exit routine. This is especially useful, for example,
if your installation wants to ensure that an audit trail is created whenever File-AID is used to edit
certain sensitive data files. When the edit session is complete, the audit exit routine can also be
used to force the automatic submittal of a batch job to produce the audit trail report, thereby
ensuring that a record of the edit session is printed.
In addition to the audit trail facility, File-AID provides the option to log all dataset updates to the
system SMF datasets.
If you require information on how your installation may be using any of these audit trail facilities,
contact the person responsible for File-AID at your installation.
COMPRESSION/ENCRYPTION EXIT
File-AID provides your installation with the capability of creating its own
compression/encryption exit routine that will act as an interface between File-AID and any
compression/encryption software you may have (e.g., SHRINK or DATA PACKER). This allows
you to work with data files that are stored on disk or tape in a compressed or encrypted format in
all File-AID options. File-AID invokes the compression/encryption exit for data files only, not
for record layout datasets, record/layout cross references, or selection criteria.
If you require information on your installation's compression/ encryption exit, contact the person
responsible for File-AID at your installation.
File-AID will automatically detect and present DBCS data characters if your terminal type is set
to 3277KN or 3278KN from option 0.0.1 of File-AID, or option 0.1 of ISPF (ISPF terminal
characteristics).
180
There are two ways File-AID presents data.
File-AID assumes that all character fields contain a mixture of EBCDIC data and Double-Byte
Character Set (DBCS) data. The DBCS characters are enclosed with shift-out (X'0E') and shift-in
(X'0F') characters.
For PIC G(nn) fields in COBOL or GRAPHIC(nn) fields in PL/I File-AID assumes that the field
contains only Double-Byte Character Set (DBCS) data. DBCS data does not include shift-out
(X'0E') and shift-in (X'0F') characters and should be an even number of bytes in length.
Note: X'0E' and X'0F' are for IBM sites. Other platforms such as FSP and Hitachi may use other
representations for shift-in and shift-out.
When data is presented without COBOL or PL/I record layouts (three-line hexadecimal or
character format), each character line displayed is considered a character field.
File-AID assumes that all character fields contain a mixture of EBCDIC data and Double-Byte
Character Set (DBCS) data. The DBCS characters are enclosed with shift-out (X'0E') and shift-
in (X'0F') characters.
Use caution when entering DBCS characters to ensure that the shift-out and shift-in characters
are accounted for and will not overlay other data values unexpectectly.
The command HEX ON is useful to view the location of the shift bytes.
File-AID will automatically detect and present DBCS data characters if your terminal type is set
to 3277KN or 3278KN from option 0.0.1 of File-AID, or option 0.1 of ISPF (ISPF terminal
characteristics).
181
FORMATTED DATA PRESENTATION
File-AID assumes that all character fields contain a mixture of EBCDIC data and Double-Byte
Character Set (DBCS) data. The DBCS characters are enclosed with shift-out (X'0E') and shift-in
(X'0F') characters.
For PIC G(nn) fields in COBOL or GRAPHIC(nn) fields in PL/I File-AID assumes that the field
contains only Double-Byte Character Set (DBCS) data. DBCS data does not include shift-out
(X'0E') and shift-in (X'0F') characters and should be an even number of bytes in length.
Note: X'0E' and X'0F' are for IBM sites. Other platforms such as FSP and Hitachi may use other
representations for shift-in and shift-out.
When data is presented without COBOL or PL/I record layouts (three-line hexadecimal or
character format), each character line displayed is considered a character field.
File-AID assumes that all character fields contain a mixture of EBCDIC data and Double-Byte
Character Set (DBCS) data. The DBCS characters are enclosed with shift-out (X'0E') and shift-in
(X'0F') characters. Use caution when entering DBCS characters to ensure that the shift-out and
shift-in characters are accounted for and will not overlay other data values unexpectectly.
The command HEX ON is useful to view the location of the shift bytes
The record has 100 characters and block has 500 characters, hence there are 5 records per block.
Environment attribute describes the physical properties of a data set. consecutive means that
records are stored sequentially.
LOCATE mode
In this mode the logical records are directly processed in buffer. here a based variable or a pointer
variable is needed (a structure with the length of a logical record) is like a mask which is laid over
the buffer.
record input in locate mode :- Files to be processed using locate mode must, like other files be
182
declared and opened. the first physical record has already been read into the buffer and opened.
The address of the first record logical pointer is put in the variable pointer.
POINTER Variable
A pointer variable is a variable (full word, 4 bytes) which contains a storage address. this address
can be assigned to pointer variable in various ways.
A pointer is used to point to the position of the next record in a buffer or to another variable.
BASED Variable
In the e.g. given below, read places the address of next logical record in the pointer ptr.
The based variable efile is overlaid on the logical record, as it has the attribute based and contains
address as the pointer.
On 6th read, the 2nd physical record is retrieved from the data set and put in buffer.
you recognize MOVE mode by the option FROM and LOCATE mode by the option SET.
183
form :- LOCATE based_variable FILE(filename);
note :- There is 4 byte record length field (RL)before every variable record.
There is a 4 byte block length field before every block.
e.g. :- suppose the biggest logical record can be 1000 bytes long and that the records are to
be blocked in such a way that a block is likewise to have the maximum length of 1000
bytes, then environment attribute of file declaration would look like
env(vb recsize(1004) blksize(1008));
Size statements are calculated as :-
184
recsize = 1000 bytes + 4 bytes record length
blksize = recsize + 4 bytes block length
In fixed format, the record length and the block length are fixed but in variable format, the
record length and the block length vary
Note :- Sequential is the default file organization, hence vsam should be specified in the ENV
option.
Vsam files are always record files. Records on a vsam file are not held in blocks, hence the
blksize option even if specified is ignored. A recsize option will be checked against the details
stored with the file.
The utility IDCAMS (access method services) is used to set up a vsam file initially.
185
Vsam files are all direct access files. associated with every record is a key, which helps in
accessing the record in any order.
If you want to start at the beginning and process every record, just as with a consecutive file,
specify the file as sequential.
The first read of the program specifies the key of the record you want to start at subsequent
sequential read statements are issued without a key.
When a file is originally set, it can be given one or more passwords. if attribute record is given, it
means that it must be a file, hence the attribute file is implied and therefore optional.
KSDS is used to hold master file data. identification is by means of key so the attribute DIRECT
implies KEYED.
e.g.:- dcl amast file record direct input env(vsam);
Sequential access is possible with ksds.
A ksds has a key which is part of a data record, this is known as an embedded key.
Keys are also stored in another part of data set called as prime index.
The keys are unique since duplication is not allowed.
KSDS Features Reading a ksds directly :- Records are accessed by specifying a value using the
key option.
Updating a ksds directly :- The file should be opened as update. you cannot amend the key.
186
2 kskey char(5) init('00081'),
2 ksname char(15);
read file(kmast) into(area) key(kskey);
/* amend */
rewrite file(kmast) from(area) key(kskey);
GENKEY option
e.g. :- dcl vsam file record sequential keyed
env(vsam genkey);
read file(vmast) into(area) key('123');
read file(vmast) into(area);
If genkey option is not specified in the environment statement, vsam searches for a record with a
key of ‘123‘.
If genkey option is specified the first read reads the first record of data set beginning with 123.
It is the most likely consecutive non-vsam file. i.e. data is not in a particular order, hence the file
is sequential.
An esds file which already has data on it, may only be opened with either input or update
attributes.
e.g. :- dcl esds file record sequential update env(vsam);
187
It is possible to change records once they have been written to esds file.
Write can also be used and the new records added are always added at the end.
You have to get hold of rba by using KEYTO option on read and write.
Rba must be a 4 byte character string. this will add a new record to the end of the file and place
the relative byte address of the record in the field rba. this is then used as a key on a read or
rewrite. file should be declared as keyed.
188
rewrite file(esds) from(area) key(rba);
Records are read and can be accessed sequentially or directly with or without keys.
The data set may be thought of as a set of numbered slots each of which may hold record. the
numbering starts at 1 and goes to the maximum specified.
Record number is the relative record number. this is the key to the file.
The key must be declared as a character string of length 8.
WRITE in an RRDS
relrecno = '00000005';
189
read file(rrds) into(area) key(relrecno);
......
delete file(rrds) key(relrecno);
......
write file(rrds) from(area)
keyfrom(relrecno);
Index function is used to look for a certain character or a string of chars in a given string.
190
VERIFY (Built-in Function)
VERIFY function :- Verify will see that a string will have only certain characters present.
form :- verify(x, y);
3 would be returned, because the third character is not in the second parameter of verify.
form :- translate(x, y, z)
This determines the length of the string. value returned is binary fixed point number (15,0).
form :- length(x);
191
ilength receives the value 11.
Pseudovariables
/* soln is 'ABCDEABCDE' */
Program Organization
Types of Blocks
PL/1 knows two types of blocks :-
1. Procedures
2. Begin-blocks
1. External Procedures
2. Internal Procedures
An INTERNAL procedure is invoked by a call from a surrounding block and control returns to
statement after the call.
Within an external procedure you can have upto 50 internal procedures.
192
: ^ inner:proc; <-------
: : statement3
: : statement4
V ------- end inner;
----------> statement5
statement6
end outer;
BEGIN-block :- They always lie within a procedure and are executed where they are. They
finish with an end statement.
form :- A:proc;
......
begin;
......
......
end;
......
end A;
Scope of Declaration
1. Internal
2. External
If a variable has an INTERNAL scope, then it is known in the block in which it was declared and
in all the blocks which physically lie in that block until it is not declared in one of these
subordinate blocks.
193
within their blocks.
If a variable is to be same in two external procedures, then it must be declared with same
attributes EXTERNAL.
Structure rec which is declared in both external procedures, occupies the same data area.
Using storage class attributes, the programmer defines, when storage space is to be allocated to a
variable and when this storage space is freed.
1. Automatic (default)
2. Static
3. Based
4. Controlled
194
program. This storage class cannot be influenced by the programmer during program execution.
Based storage class is used in connection with record i/o. Based variable should always have
attribute internal. In locate mode, it was necessary to declare the storage class based for record to
be read in / written out.
With controlled variable the programmer has complete control over storage space. Using
ALLOCATE space is assigned and with FREE the storage space is freed again. they can have the
attributes internal or external.
Subroutines
It is always an internal or external procedure. A subroutine is not replaced by a result value after
its execution. A subroutine is always invoked with a call statement. Subroutines are often added
as external procedures.
195
dcl ......;
call srou1;
......
call srou2;
end mrou;
srou1:proc; srou2:proc
dcl ......; dcl ......;
...… ......
end srou1; end srou2;
Arguments
When a procedure is invoked using a call, it is possible to pass variables which are called as
arguments.
Parameters
A program to which arguments are passed when it is invoked, are called as parameters.
e.g.:- srou:proc(a,b);
dcl a char(100);
dcl 1 b,
2 b1 char(10),
2 b2 fixed dec(7,2);
196
e.g. :- prog1:proc options(main);
call prog5(a,b);
call ent2(a,b,c);
call ent1(c);
end prog1;
proc5:proc(x,y);
......
ent1:entry(m);
......
ent2:entry(x,y,m);
......
end prog5;
e.g. :- srou:proc(x,y);
......
ent2:entry(m,n,o);
......
if x = 0 then return;
......
end srou;
Functions
Functions are always a part of an expression. A function is replaced by its result after execution.
197
(ON-UNIT)
On ENDPAGE and on ENDFILE are some important conditions which can be forseen.
This writes the current page number when the preceding page is full.
SIGNAL option :-With signal statement, a condition can be caused artifically. The program
continues with the statement which comes immediately after signal statement.
form :- SIGNAL condition;
Signal is used to raise conditions deliberately.
198