COBOL Mainframe Tips

ISPF

TIP # 001
ISPF
Lets start with a generic and simpler one.
Consider that you are editing a file/program and you want to know the changes you have done
since the last SAVE command.
How to find that?
Answer:
Give COMPARE SESSION on the command line
Further use of COMPARE commands…
- Can be used like 3.13 option
TIP # 002
ISPF
Usually the PDS or PS bears the ID of the creator or the ID of the person who modified it
recently.But is it possible to change these ID values without leaving trace of one’s own ID?
Answer:
Yes its possible! In the command area against the member name or PS name, by giving ‘G’.
Dialog box will pop up allowing you to change the ID values.
TIP # 003
ISPF
Suppose you are in a ISPF Screen and want to know in which TSO Region ( Development,
Production, or other TSO regions) you are now .
Answer:
Issue on the command line : SAREA
ISPF STATISTICS Pop-up window will show you the region( and other info too)

ISPFTIP # 001ISPFLets start with a generic and simpler one.Consider that you are editing a file/program and you want to know the changes you have donesince the last SAVE command.How to find that?Answer:Give COMPARE SESSION on the command lineFurther use of COMPARE commands…- Can be used like 3.13 optionTIP # 002ISPFUsually the PDS or PS bears the ID of the creator or the ID of the person who modified itrecently.But is it possible to change these ID values without leaving trace of one’s own ID?Answer:Yes its possible! In the command area against the member name or PS name, by giving ‘G’.Dialog box will pop up allowing you to change the ID values.TIP # 003ISPFSuppose you are in a ISPF Screen and want to know in which TSO Region ( Development,Production, or other TSO regions) you are now .Answer:Issue on the command line : SAREAISPF STATISTICS Pop-up window will show you the region( and other info too)

TIP # 004

ISPF

Any command entered in the COMMAND LINE disappears after the successful execution of its

intended function.

If you want to repeat the same command , you got to re-type it or use some PF key to retrieve the

last command entered.

But here is a cool method the make the command entered not to disappear and stay on the screen.

Precede commands with ‘& ‘

For Example:

COMMAND ===> &C ‘110-PARA’ ‘220-PARA’ SCROLL ===> CSR

****** ************************ TOP OF DATA **************

000001 IDENTIFICATION DIVISION.

000002 PROGRAM-ID. COBOLSAMY.

000003 DATE-WRITTEN. APRIL 2004.

After the execution of the command, the below command stays on the screen.

This way you can entering the same command or modifying the command a little and using it

multiple times.

TIP # 005

ISPF

While trying to open any member in a PDS, we sometimes come across

“member in use” message. In that situation, if you want to know who is using the member

currently, press F1 twice.

TIP # 006

ISPF

We usual search for members in a PDS by the first string of the members.

Consider this situation .

I have a PDS and I want to search it for member only by middle string of the members.

e.g. there are some members like BESTJCL1,RESTJCL2,PESTCBL1, BESTCBL2,

WESTCBL3,TESTASM1,BESTASM2…etc

I want to find members which have CBL in them.

How can I search and find these members?

Answer:

Use ISPF 4.12 option.

Specify the dataset to be searched and the pattern of the string.

Specify the LANG type as COB

And select the browse option.

TIP # 007

ISPF

How can I find the last 10 datasets that I have accessed ?

Answer:

1.GO TO ISPF 3.4 option.

2. On the top, there is a MENUBAR. Select REFLIST

3. Select Option 1 in it.

Using this option you can find out the last 30 datasets that you have accessed….

TIP # 008

ISPF

Alternate to SuperCE Option(3.13) is to use the macro COMPARE .

Use this when you there is less difference between the two files.

1.Open a DSN in EDIT or VIEW Mode

2. On the Command line , issue COMP ‘YOUR.SECOND.COMPARISON.DSN’

3. If you want only the changes to be listed, issue COMP

‘YOUR.SECOND.COMPARISON.DSN’ EXC

TIP # 009

ISPF

While Browsing Internet, we have some cool option called address autocomplete…we enter

some letters in the address bar and the browser auto completes it with the closest guess.

Does MAINFRAME has the same feature??

Answer:

Yes! It has “Autocomplete” feature!!!

How to use it?

1.go to ISPF 3.4 ,

2. enter KEYS in the command line,KEYS window will popup

3. set any key to AUTOTYPE, save and exit

2. now type any Dataset partially and press the assigned PFkey!!

Note: It will not retrieve GDGs and VSAM files.

TIP # 010

ISPF

I want to find a member but I don’t know the PDS to which it belongs. I only know the high

level qualifier of the PDS.

Answer:

For example, lets consider high level Qualifier as MYID.MYAPPLN.* and member as MYMEM

1. Go to 3.4 and list all PDS with MYID.MYAPPLN.*

2. Now issue, MEMBER MYMEM on the command line

TIP # 011

ISPF

I want to know what are the last 25 COMMAND LINE commands that I have issued from ISPF

panel.

Answer:

To get that, I have to issue, RETP on the Command line.

TIP # 012

ISPF

I want to edit a member, which has CBL as middle string in the PDS MY.PDS.MEMBERS.

One shortcut way is to in the ISPF 3.4 listing of the PDS,

issue S *CBL* E in the command line. If we don’t use E at the end, it will open in browse mode.

TIP # 013

ISPF

Here is another tip on ISPF 3.4 Option

Usually to find the last edited member, we issue SORT CHA or SORT CHANGED on

the command line.

One can save few keystrokes by placing the cursor on any of the column

header in the ISPF 3.4, and press ENTER.

In our case, if we place the cursor on the CHANGED header, we will get the

members sorted on that column.

TIP # 014

ISPF

Here is a tip by which you can avoid ISPF 3.4 Option!!!

To Open a PS or PDS member, we usually use ISPF 3.4 to open in EDIT or BROWSE

MODE.

Here is one way where one can open PS or PDS member in EDIT/VIEW/BROWSE

mode from any command line.

Thus, we can avoid using 3.4 option.

Issue : EPDF ‘MYID.MYPS’ . The Dataset will be opened in EDIT MODE

If you want to open in VIEW mode:

Issue : EPDF ‘MYID.MYPS’ VIEW

Similarly, for opening in BROWSE mode, type BROWSE at the end.

TIP # 015

ISPF

Here is a situation. I have received a maintenance change

request on one of the program.

While I am making changes to the program, one of my friend pops

in and I leave with him for a cup of coffee without SAVING the

changes I made.

After few minutes , when I am back, I am not sure what changes I

made previously on the program?

How can I find the changes I have made (without getting out of

this screen)?

Well, here is one simple command line command to achieve this…

Issue : COMP * X

TIP # 016

ISPF

When I issue CUT , I know that the CUT content are placed in a

clipboard. And when I issue PASTE, the clipboard content are

pasted.

But is it possible for me to view/edit the clipboard ?

One can view the clipboard after any valid CUT command was issued.

To view the clipboard, issue : CUT DISPLAY.

Clipboard manager will pop up and gives us options to edit or browse the

content.

TIP # 017

ISPF

Here is another tip on ISPF CUT. I have a dataset with 10,000

lines.I want to cut the first 10 lines and last 10 lines and

paste into another dataset.When I cut the first 10 lines and

then again the last 10 lines ,only the last 10 lines are pasted

into the new dataset.

Is there anyway out (other than doing a 2 cut & paste)?

The answer for the above question is to:

1.first cut 10 lines, then issue CUT APPEND

2.then cut last 10 lines, then issue CUT APPEND

3.When you PASTE it, you got both.

All about Mainframe VSAM

MAINFRAME COBOL TIPS

Techideas.info

ISPF

TIP # 001

ISPF

Lets start
with a generic and simpler one.

Consider that you are editing a file/program and you want to know
the changes you have done

since the last
SAVE command.

How to find that?

Answer:

Give COMPARE SESSION on the command line

Further use of COMPARE commands…

- Can be used like 3.13 option

TIP # 002

ISPF

Usually the PDS or PS bears the ID of the creator or the ID of the
person who modified it

recently.But is it possible to change these ID values without leaving trace of
one’s own ID?

Answer:

Yes its possible! In
the command area against the member name or PS name, by giving ‘G’.

Dialog box will pop up allowing you to change the ID values.

TIP # 003

ISPF

Suppose you are in a ISPF Screen and want to know in which TSO
Region ( Development,

Production, or other TSO regions) you are now .

Answer:

Issue on the command line : SAREA

ISPF STATISTICS Pop-up window will show you the region(
and other info too)

Techideas.info

TIP # 004

ISPF

Any command entered in the COMMAND LINE disappears after the successful
execution of its

intended
function.

If you want to repeat the same command ,
you got to re-type it or use some PF key to retrieve the

last command
entered.

But here is a cool method the make the command entered not to
disappear and stay on the screen.

Precede commands with & ‘

For Example:

COMMAND ===> &C ‘110-PARA’ ‘220-PARA’
SCROLL ===> CSR

****** ************************ TOP OF DATA **************

000001 IDENTIFICATION DIVISION.

000002 PROGRAM-ID. COBOLSAMY.

000003 DATE-WRITTEN. APRIL
2004.

After the execution of the command, the below command
stays on the screen.

This way you can entering the same
command or modifying the command a little and using it

multiple times.

TIP # 005

ISPF

While trying to open any member in a PDS, we sometimes come across

member in use” message. In
that situation, if you want to know who is using the member

currently, press F1 twice.

TIP # 006

ISPF

We usual search for members in a PDS by the first
string of the members.

Consider this situation .

I have a PDS and I want to search it for member only by middle
string of the members.

e.g. there
are some members like BESTJCL1,RESTJCL2,PEST
CBL1, BESTCBL2,

WESTCBL3,TESTASM1,BESTASM2…etc

I want to find members which have CBL in them.

How can I search and find these members?

Techideas.info

Answer:

Use ISPF 4.12 option.

Specify the dataset to be searched and the pattern of the string.

Specify the LANG type as COB

And select the browse option.

TIP # 007

ISPF

How can I find the last 10 datasets that I have accessed
?

Answer:

1.GO TO ISPF 3.4 option.

2. On the top, there is a MENUBAR. Select REFLIST

3. Select Option 1 in it.

Using this option you can find out the last 30 datasets that you
have accessed….

TIP # 008

ISPF

Alternate to SuperCE Option(3.13)
is to use the macro COMPARE .

Use this when you there is less difference between the two files.

1.Open a DSN in
EDIT or VIEW Mode

2. On the Command line , issue COMP ‘YOUR.SECOND.COMPARISON.DSN’

3. If you want only the changes to be listed, issue COMP

‘YOUR.SECOND.COMPARISON.DSN’ EXC

Techideas.info

TIP # 009

ISPF

While Browsing Internet, we have some cool option called address autocomplete…we enter

some letters
in the address bar and the browser auto completes it with the closest guess.

Does MAINFRAME has the same feature??

Answer:

Yes! It has “Autocomplete” feature!!!

How to use it?

1.go to ISPF
3.4 ,

2. enter KEYS in the command line,KEYS window will popup

3. set any key to AUTOTYPE, save and exit

2. now type any Dataset partially and
press the assigned PFkey!!

Note: It will not retrieve GDGs and
VSAM files.

TIP # 010

ISPF

I want to find a member but I don’t know the PDS to which it
belongs. I only know the high

level qualifier
of the PDS.

Answer:

For example, lets consider high level Qualifier as MYID.MYAPPLN.*
and member as MYMEM

1. Go to 3.4 and list all PDS with MYID.MYAPPLN.*

2. Now issue, MEMBER MYMEM on the command line

TIP # 011

ISPF

I want to know what are the last 25 COMMAND LINE
commands that I have issued from ISPF

panel.

Answer:

To get that, I have to issue, RETP
on the Command line.

Techideas.info

TIP # 012

ISPF

I want to edit a member, which has CBL as middle string in the PDS
MY.PDS.MEMBERS.

One shortcut way is to in the ISPF 3.4 listing of the PDS,

issue S *CBL* E in the command line. If we don’t
use
E at the end, it will open in browse mode.

TIP # 013

ISPF

Here is another tip on ISPF 3.4 Option

Usually to find the last edited member, we issue SORT CHA or SORT CHANGED on

the command line.

One can save few keystrokes by placing the cursor on any of the column

header in the ISPF 3.4, and press
ENTER.

In our case, if we place the cursor on the CHANGED header, we will
get the

members sorted on that column.

TIP # 014

ISPF

Here is a tip by which you can avoid ISPF 3.4 Option!!!

To Open a PS or PDS member, we usually use ISPF 3.4 to open in EDIT or BROWSE

MODE.

Here is one way where one can open PS or PDS member in
EDIT/VIEW/BROWSE

mode from any command line.

Thus, we can avoid using 3.4 option.

Issue : EPDF ‘MYID.MYPS’ . The Dataset will be opened in EDIT MODE

If you want to open in VIEW mode:

Issue : EPDF ‘MYID.MYPS’ VIEW

Similarly, for opening in BROWSE mode, type BROWSE at the end.

Techideas.info

TIP # 015

ISPF

Here is a situation. I have received a maintenance change

request on one of the
program.

While I am making changes to the program, one of my friend pops

in and I leave with him for a
cup of coffee without
SAVING the

changes I made.

After few minutes , when I am back, I am
not sure what changes I

made previously on the program?

How can I find the changes I have made (without getting out of

this screen)?

Well, here is one simple command line command to achieve this…

Issue : COMP * X

TIP # 016

ISPF

When I issue CUT , I know that the CUT
content are placed in a

clipboard. And when I issue
PASTE, the clipboard content are

pasted.

But is it possible for me to view/edit the clipboard
?

One can view the clipboard after any valid CUT command was issued.

To view the clipboard, issue : CUT DISPLAY.

Clipboard manager will pop up and gives us options to edit or
browse the

content.

TIP # 017

ISPF

Here is another tip on ISPF CUT. I have a dataset with 10,000

lines.I want to cut the first 10 lines and last 10 lines and

paste into another dataset.When I cut the first 10 lines and

then again the last 10 lines ,only
the last 10 lines are pasted

into the new dataset.

Is there anyway out (other than doing a 2 cut & paste)?

Techideas.info

The answer for the above question is to:

1.first cut 10 lines, then issue CUT
APPEND

2.then cut last 10 lines, then issue CUT
APPEND

3.When you PASTE it, you got both.

TIP # 017

ISPF

Tired of typing the often-used datasets repeated?!!!

We have seen AUTOTYPE previously. Here is another one that saves
lots of key-strokes.

Use NRETRIEV.

How to use it?

1 enter KEYS in the command line,KEYS
window will popup

2 set any key to NRETRIEV and exit

3 now when you are in 3.4 or whichever screen you have set the
KEYS option, press the

assigned PF keys.

4. Pressing them repeated will bring up one-by-one the last 30
accessed datasets from the reflist.

TIP # 018

ISPF

Here is one simple one…….

I want to search a string like abc‘ (including quote).

In my pgm there may be more abc strings.But i don’t want to retrieve all of them.

i need the abc enclosed with quotes.

How to search is in 3.14 option?.

In the ISPF 3.14 , search with ‘’’abc’’’ string.(i.e. with 3 quotes at both sides of the
string)

TIP # 019

ISPF

I have to compare one input file field with one output file field.
The input file field in is column

1 to 10 and the output file field is in column 40 to 50.

How can I do it?

Techideas.info

1. Use the standard 3.13 ISPF option. In the same screen itself,
in the command line issue, E

2. then type,

CMPCOLN 40:50

CMPCOLO 1:10

3. press PF3 and exit

4. In the New dataset , type in the output
dataset

5. In the Old dataset , type in the input
dataset

TIP # 020

ISPF

Is an easy way to search member in Multiple PDS?

Go to 3.4 (where all the datasets will be displayed) .

In the Command line give

Command line==>M memname

This command will not work for the migrated PDS. So ensure all the
PDS are in

Disk.

Now the message “MEMBER(S): memname
found” will apppear in the right side of

the panel.

TIP # 021

ISPF

I have data which is of length 160. For some reasons, I want to
wrap the data in each record to 80

characters and have
the next 80 characters in the next line. So basically what I am looking for is ,

“Is there command similar to Wordwrap (as in Notepad or MS WORD) in mainframe?”

Yes, with ISPF, one can wrap the data as required.

To do that,

1.Open the
dataset in ISPF EDIT mode.

2.In the
first line, issue the line command: TF
80 (as in this case I want to wrap to 80 chars per

line)

3.All the
subsequent lines will wrap to 80 chars per line.

Techideas.info

TIP # 022

ISPF

Here is another tip on ISPF 3.4 option

From the ISPF 3.4 option listing, I can directly Edit/Browse/view
the member without listing all

the members
and then select the particular member.

To do that,

In the Line command issue, E / (member)

use for Browse (B) and view
(V)

Command – Enter “/” to select action Message Volume

——————————————————————————-

E /(MEMBER1)MYID.WORK.SRC NV1E56

***************************** End of Data Set list
****************************

JCL

TIP # 023

JCL

Hero’s Method:

If you prefer a dataset to be not deleted accidentally, then

———————————————————————————————————————

USING IDCAMS USING JCL COMMENTS

———————————————————————————————————————

TO(04365)
LABEL=RETPD=04365 Will protect till end of 2004

FOR(30) LABEL=RETPD=10
Will protect for 30 days

———————————————————————————————————————

Villain’s Method:

If by chance of fate, you want to delete a dataset that is
protected by the above method…

Use IDCAMS DELETE command with PURGE option.

e.g.,

//STEP1 EXEC PGM=EXEC

//SYSPRINT DD SYSOUT=*

//SYSIN DD *

DELETE TOP.SECRET.DATA -

PURGE

/*

Techideas.info

TIP # 024

JCL

Is it possible to execute a program from any library using the referback?

The Answer is Yes!

//STEP1 EXEC PGM=IEFBR14

//PROGRAM DD DSN=SYSTEM.PGM.LOADLIB(COBOLPGM),DISP=SHR

//STEP2 EXEC PGM=*.STEP1.PROGRAM

TIP # 025

JCL

How does the system differentiates between JCL comment statements
(i.e., //* statements) and

JES3 Statements (which also start with //* )
?

If the 4th column contains JES3
keyword
, the line is considered to be
JES3 statement, else it is

considered as
normal JCL statement.

TIP # 026

JCL

We know JES2 and JES3 , but is there any
JES1?

OS/VS1 (the forefather of MVS) supported only one job entry
subsystem
namely JES1

TIP # 027

JCL

Consider this situation.

I have a JCL with 10 steps.

For reasons known only to me, I want to execute step 5 only.

How can I do it?

Techideas.info

One way to do it is to use RESTART from STEP05, but it will try to
execute the

subsequent steps too.

We have to insert null statement after step05 to prevent the
execution of

subsequent steps.

But one decent way is there in which we don’t need to touch the
job steps

code, but alter only the Jobcard.

And that is….

In the JOBCARD, code COND parameter. Then, when the Job is executed , only

the Step mentioned in the RESTART parameter will get executed.

e.g., RESTART=STEP05,COND=(0,LE)

TIP # 028

JCL

We know that JOBLIB statement must be placed after the JOB
statement and before the first

EXEC statement in the job.

But, the STEPLIB statement can be placed anywhere in the
particular step’s JCL (not necessarily

the first DD
statement in the STEP).

TIP # 029

JCL

Here is a quick question. Can Catalog Procedure have PEND

statement?

Yes! Now it can have PEND Statement.

Do check it out….

TIP # 030

JCL

How much data can TAPE store??

A typical tape reel might contain 170 MB whereas tape
cartridges
can contain as much as

10GB.

(Source: System 390 JCL by Gary
DeWard Brown)

Techideas.info

TIP # 031

JCL

Do you know why null statement was introduced in JCL?

Back when punched cards were used, a null coded on distinctive colored cards was used to help

operators separate
card decks. ( Hence , it helped to identify the
end-of-job card, and the start of

next job for
the operators)

(Source: System 390 JCL by Gary
DeWard Brown)

TIP # 032

JCL

Do you know why JCL has ‘//’ in col
1& 2 in each Statement??

The Slashes date back from when PUNCHED
CARDS
were used to submit JCL code for

execution. If the
cards were mistakenly put back to front in the reader, the slashes wouldn’t be

read first
and so the card deck could be rejected. So ‘//’ ensures that the punched cards
are placed

properly!!

(Source: System 390 JCL by Gary
DeWard Brown)

TIP # 033

JCL

How can I specify dummy VSAM dataset in a JCL?

Code AMP=’AMORG’ . This parameter tells
the OS to treat the file as VSAM file.

//NOVSAMIO DD DUMMY,AMP=’AMORG’

TIP # 034

JCL

I can specify the max limit of TIME parameter as

TIME=NOLIMIT or

TIME=MAXIMUM.

Techideas.info

Now which specification gives maximum time for a JOB?

TIME=MAXIMUM will allow the job to run for 357912 minutes (248.55
days)

TIME=NOLIMIT will allow the job for unlimited amount of time

Another advantage of NOLIMIT option is that it can remain in wait
status for more than the installation

time limit.

TIP # 035

JCL

I want to delete a member in a PDS, but someone is using it. How
can I delete it?

One can use the following JCL

//DELMEMB EXEC PGM=IDCAMS

//SYSPRINT DD SYSOUT=*

//PDS DD DSN=libraryname,DISP=SHR

//SYSIN DD *

ALLOC DDN(INFILE) SHR REUSE DSN(‘libraryname ‘)

DELETE libraryname(membername) FILE(PDS)

TIP # 036

JCL

&SYSUID is a “system
symbol” for which the system substitutes your TSO ID.

It is the only system symbol that can be used in a batch job, and
can be useful when more than one

individual submits the
same JCL.

Techideas.info

TIP # 037

JCL

I am overriding 2 DD statements in a PROC from my JCL. The first
DD statement is in step 10 and

second DD
statement is in step 40.

Usually , I specify
as

//PS010.INPUT DD DSN=MYID.DATASET

//PS040.SYSIN DD DSN= MYID.NEW.DATASET

What will happen if I specify step 40 first and step 10 next?

zOS JCL will process it! It will override irrespective of the order
it is specified. Formerly out-of-order DD

overrides were
ignored.

Techideas.info

COBOL

TIP # 038

COBOL

If you are accessing ESDS VSAM file, then in COBOL do you know

that SELECT
clause has something different about it!!

For ESDS,

SELECT FILE ASSIGN TO AS-DDNAME

Yes, the DDNAMEs should be prefixed with
AS- .

If you are not doing that then an S213 ABEND might occur when

attempting to open
data set.

TIP # 039

COBOL

When writing a COBOL program that is to be used as a CICS
application program,do not
use the

compiler option
DYNAM.

TIP # 040

COBOL

MERGE statement can have OUTPUT PROCEDURE but not INPUT PROCEDURE !!

TIP # 041

COBOL

Do you know how COBOL Compiler finds a dataset as VSAM dataset?

When the ORGANIZATION clause is coded for a file, the COBOL compiler interprets it as a

VSAM dataset.
Hence, the ORGANIZATION clause should not be coded with a non-VSAM

dataset.

Techideas.info

TIP # 042

COBOL

Do you know using an odd number of digits for PACKED DECIMAL (COMP-3) is 5% to 20%

faster than
using an
even number of digits !!

TIP # 043

COBOL

Performance considerations for indexes
vs subscripts
:

using COMP to
address a table is 30% slower than using indexes!

using COMP-3
to address a table is 300% slower than using indexes !!

using DISPLAY
data items to address a table is 450% slower than using indexes !!!

(source: Cobol performance tuning manual)

TIP # 044

COBOL

Rule of the THUMB:

For a table with less than 50 entries ==> go for SEARCH ( Sequential Search)

greater than 50 entries ==> go for SEARCH ALL
( Binary Search)

TIP # 045

COBOL

In CO BO L, why we READ FILE but W RITE RECO RD?

You READ a FI LE becaus e you don’t know
in advance:

1.whether ther e actually is a RECORD to read or
not

2. For var iable
or undefined length files , how long the nex t RECORD will be,

if ther e is one.

You Wr ite a
RECORD becaus e you know in advance the answer s to
both of

the above ques tions
.

Techideas.info

TIP # 046

COBOL

Using OPEN OUTPUT to load a VSAM file will significantly improve the performance of
your

program. Using OPEN I-O or OPEN
EXTEND
will have a negative impact on your program’s

performance.

TIP # 047

COBOL

Avoid repetitive uses of the INITIALIZE
statement.

INITIALIZE once and move it to a second like
sized 01 level, then move the second 01 level to

the first to
initialize the fields.

TIP # 048

COBOL

Consider using an in-line PERFORM instead of a SEARCH when you
have
less than 20

elements in a
table.

TIP # 049

COBOL

One can generate a complete listing of compiler diagnostic
messages, with their explanations, by

compiling a
program with the program-id of ERRMSG specified in the PROGRAM-ID

paragraph.

EX:

IDENTIFICATION DIVISION

PROGRAM-ID.ERRMSG.

ENVIRONMENT DIVISION.

DATA DIVISION.

PROCEDURE DIVISION.

STOP RUN.

Techideas.info

TIP # 050

COBOL

For KSDS or RRDS , when DELETE statement
is used, the file must be

opened in I-O Mode.

TIP # 051

COBOL

Performance Tuning

Taking constant expressions out of a loop speeds up a program with
no ill effects.

Example

Move zero to total.

Perform varying I from 1 by 1 until I > 100

Compute total = total + item (i) *
discount

End-perform

Remove multiply from loop

Move zero to total

Perform varying I from 1 by 1 until I > 100

Compute total = total + item (i)

End-perform

Compute total = total * discount

TIP # 052

COBOL

Sometimes my initialization doesn’t work when I use INTIALIZE verb?
Is there anything that I should take

care of?

When we use INITIALIZE verb to initialize group verbs, group elements which are FILLERs will

not be
initialized!

Techideas.info

TIP # 053

COBOL

I am using internal sort in my COBOL Program. Is there anyway to
test the return code of sort

operation?

The return-code or completion code is stored in a SORT-RETURN
special register.

If SORT-RETURN = 0 (successful completion of SORT/MERGE)

If SORT-RETURN = 16 (Unsuccessful completion of SORT/MERGE)

TIP # 054

COBOL

In general, it is advantage to use COMP for numeric data and
COMP-3 for decimal data.

TIP # 055

COBOL

Here is one better way of INITIALIZATION of a record or group item.

INTIALIZE WS-RECORD

REPLACING ALPHANUMERIC DATA BY SPACES

NUMERIC DATA BY ZEROES.

TIP # 056

COBOL

SEARCH ALL condition only test an equal
condition.

Techideas.info

TIP # 057

COBOL

In COBOL SELECT clause, I see sometimes see ASSIGN coded like this…

SELECT INFILE ASSIGN TO UT-S-INFILE

OR

SELECT INFILE ASSIGN TO DA-S-INFILE

What they mean actually…

First part in DDNAME: – Device
Class

UT stands for Utility (Tape or Sequential Disk)

DA stands for Direct-Access (disk)

Second part in DDNAME: – Method
of Organization

S – Sequential (Printer, terminal, disk or tape)

I, R, D – Disk files to be accessed randomly

TIP # 058

COBOL

When using INPUT /OUTPUT PROCEDURE with SORT

We RELEASE record-name (for INPUT PROCEDURE)
and

We RETURN file-name (for OUTPUT
PROCEDURE)

Techideas.info

VSAM

TIP # 059

VSAM

Performance Tuning

One can speed up applications greatly by using memory to cut I/O when dealing with VSAM

datasets.

For this VSAM Buffers can be enlarged.

In the DD statement code AMP parameters = BUFNI(index),
BUFND(data), BUFSP ( amount of

virtual storage)

Increase number of Data buffers (BUFND)
for sequential access

Increase number of Index buffers (BUFNI)
for random access

TIP # 060

VSAM

IDCAMS Utility can’t be executed without 2 DD Statements
.

They are SYSPRINT and SYSIN.

TIP # 061

VSAM

We know that FREESPACE(100,100)
specification causes one record to be written for each

Control interval, and one Control Interval would be written for
each control area. But do you

know why?

VSAM will always load the first record before taking FREESPACE option into
consideration!!!

TIP # 062

VSAM

DEFINE PATH command creates an alias for the VSAM base
cluster

DEFINE ALIAS command creates an alias for non-VSAM datasets

Techideas.info

TIP # 063

VSAM

CICS, DB2, IMS can process records in existing VSAM datasets but can’t create the dataset.

Even you can process VSAM data sets in COBOL programs only

after you create them with access
method services.

TIP # 064

VSAM

How can I specify dummy VSAM dataset in a JCL?

Code AMP=’AMORG’ . This parameter tells
the OS to treat the file as VSAM file.

//NOVSAMIO DD DUMMY,AMP=’AMORG’

TIP # 065

VSAM

I want to process a KSDS thru an alternate key. Now what are the 5 IDCAMS commands that must be

executed before the
records in a KSDS can be processed thru an alternate key?

1. DEFINE CLUSTER

2. REPRO (the base cluster must be
non-empty KSDS)

3. DEFINE ALTERNATEINDEX

4. DEFINE PATH

5. BLDINDEX

The first 3 IDCAMS commands should be executed in the
above-mentioned order.

The last 2 IDCAMS can be done in any order.

Techideas.info

TIP # 066

VSAM

I want to make my VSAM dataset read-only. How can I do it?

By using INHIBIT along with ALTER command

e.g.,

//STEP1 EXEC PGM=IDCAMS

//SYSPRINT DD SYSOUT=*

//SYSIN DD *

ALTER -

SECRET.KSDS.DATA -

INHIBIT

ALTER -

SECRET.KSDS.INDEX -

INHIBIT

/*

//

Notice that the ALTER command is used with DATA and INDEX and
not with the cluster.

TIP # 067

VSAM

VSAM equivalent of temp dataset is to create VSAM file with REUSE
option. A dataset created with

REUSE can be treated as a new dataset at any subsequent time.

Techideas.info

TIP # 068

VSAM

How should be VSAM file defined in order that it can be accessed
both in CICS and in BATCH

environment?

Define as SHAREOPTION (2,3)

TIP # 069

VSAM

While designing VSAM files, what’s the best way to choose Control
Interval (CI) size for the data and the

index?

Well, it depends on whether the data will be accessed directly or
sequentially.

For Direct access use small CI

For Sequential access use Lager CI

Techideas.info

FILEAID

TIP # 070

FILEAID

The Easiest and Coolest way to
locate bad data
is thru File-Aid’sF IND command.

1.OPEN the file
in FILE-AID (in either browse or edit mode)

2.XREF with
COPYBOOK.

3.Use FMT mode

4.Then issue ,

F /field-name INVALID

or

F /field-number INVALID

The control will take you to the first invalid data record for the
given field.

e.g.,

The FILE has 3 fields namely NAME,AGE,COUNTRY.

If you want to find the invalid data in the age field, then issue

F /2 INVALID

TIP # 071

FILEAID

We always face a s ituation
such that when we have opened a File in FI LEAI

D Brows e mode but later wished it was EDI T Mode and vice ver sa.
S o in

this s ituation, what we do is come out of
the brows e mode and again open in

edit mode and vice ver sa.
But ther e is a cool command available in FI LE-AI D

to help us in this type of s ituation.

I f u r in Brows e Mode and want to change it into EDI T Mode , in the Line

Command is sue

COMMAND = = > GO EDI T

I f u r in EDI T Mode and want to change it into BROWS E Mode , in the Line

Command is sue

COMMAND = = > GO BROWS E

Techideas.info

TIP # 072

FILEAID

How to determine compile date of loadlib member ??

Use FILE-AID !!

1. Go to FILE-AID 3.1 option

2. In the Library Utility type in the loadlib
dataset name

3. Type ‘a’ next to the member nam e

4. TDATE is compile date

TIP # 073

FILEAID

Whats the best way to count the number of records in a VSAM
File?

1.Choose FILE-AID
Option 3.8

2. At the prompt of ….ENTER NEXT FUNCTION OR END
,
enter TALLY

3. U will get the record count

4. Type END to exit.

TIP # 074

FILEAID

While working in MS Excel we have the option of “freeze Panes”. By this
options
we can freeze

some columns
and have other columns scrolling. This feature is helpful in analysis when
there

are lots of
columns(fields) in a file.

In mainframe too, we have similar such facility thru File-Aid.

1.Open the file
in File-Aid

2. use VFMT format

3. If you want to freeze columns(fields)
1,2,3, and 6 and have the rest as scrollable

issue command HOLD 1-3,6

Techideas.info

TIP # 075

FILEAID

Can I issue FIND command to find values that are less than or
greater than ‘certain value’ at

column 25??

We can’t accomplish this task thru ISPF ,
but File -Aid provides us the facility to issue FIND

command with
relational operators like EQ,NE,LT,GT,LE and GE.

e.g.,

FIND LT ‘2004’ 25 ALL

So if one wants to use relational operator along with FIND
command, open the same dataset in

FILE-AID.

TIP # 076

FILEAID

Consider this situation. I am doing a
verification
on an output file. The output file has 200 fields.

I need to verify only 25th and 175th fields
only.

I am using FILE-AID’s VFMT mode and for
each record I am scrolling between 25
th and 175th

field. Is there
any efficient way to handle this situation?

Some people might use HOLD to freeze 25th and 175th field , but still other fields are displayed ,

which is an
annoyance.

Here is one better way:

In the VFMT mode, issue DISPLAY 25
175 ONLY

Only 25th and
175
th fields will be
displayed.

TIP # 077

FILEAID

ABEND SOLVING

At midnight I receive production call.

One job abended due to
classic
S0C7.
Thru analysis I located the particular field which is a

COMP-3 and junk data is sitting in that
field for some records.These bad records are not

contiguous but occuring randomly in the input file.

Now to save my head I have to delete all the records with bad data in that particular field and reexecute

the job
quickly. Assume that input file has some
10 million records. How can I eliminate

the bad
records in an efficient and a fast method?

Techideas.info

Here is the approach:

Using the following FILE-AID option in batch mode

$$DD01 DROP IF=(field-position,
field-length, NEP)

NEP means Not Equal to PACK

One can generalize and customize the below JCL to deal with
similar type of ABENDS.

For Example,

My input layout is:

01 TEST-RECORD.

05 NAME-FIELD PIC X(5).

05 AMOUNT-FIELD PIC 9(3) COMP-3.

My JCL to eliminate the bad records:

//STEP01 EXEC PGM=FILEAID

//*

//SYSUDUMP DD SYSOUT=*

//SYSPRINT DD SYSOUT=*

//SYSLIST DD SYSOUT=*

//SYSTOTAL DD SYSOUT=*

//DD01 DD DSN=MYID.CHECK.OUT,DISP=SHR

//DD01O DD DSN=MYID.CHECK.OUT,

// DISP=(NEW,CATLG,CATLG),

// DCB=(MYID.CHECK.OUT)

//SYSIN DD *

$$DD01 DROP IF=(6,2,NEP)

/*

This will drop the bad data records and retain only the good one.

TIP # 078

FILEAID

I want to do Fuzzy Comparison of files!!

My requirement is to compare 2 files of which for one certain
field I can have + or – 1 value which should

be acceptable
while comparing.

Thru FILE-AID COMPARE (OPTION 10), one can set percentage amount
for numeric

fields that
determines “close enough” matches. When the “Formatted
Criteria” table

appears after the 2
files are specified, use the “T” line command. This brings up a

Techideas.info

“Tolerance Value/Percentage Specification” panel where
you can set a plus or minus

value for a
numeric field.

SORT

TIP # 079

SORT

Do you know COBOL Internal SORT and MERGE is actually done by DFSORT
?
!!

If you SORT or MERGE with COBOL, the
compiler
automatically generates a SORT or

MERGE control statement for you with the correct DFSORT
descriptions for the COBOL fields

you specify.

TIP # 080

SORT

How can I replace all the low-values in a file to spaces??

Use ALTSEQ CODE .

Here’s an example of how you could change all low values (X’00′)
to spaces (X’40′), in an FB

data set with
an LRECL of 80:

ALTSEQ CODE=(0040)

OUTREC FIELDS=(1,80,TRAN=ALTSEQ)

(Source: IBM SORT website)

Techideas.info

TIP # 081

SORT

SYNCSORT

My Production job is such that, on one of the steps it has to

copy a VSAM dataset to flat file,
and then process that flat

file in the subsequent steps.
Sometimes the input VSAM may be

empty. When its empty, my job abends. How can
I prevent the job

from abending
when the VSAM is empty ?

Pass the parameter, VSAMEMT=YES for the SORT utility.

i.e,

//STEP3 EXEC PGM=SORT,PARM=’VSAMEMT=YES’

//*

//SYSOUT DD SYSOUT=*

//SORTIN DD DSN=VSAM.DSN

// DISP=SHR

//SORTOUT DD DSN=FLATFILE.DSN

// DISP=SHR

//SYSIN DD *

SORT FIELDS=COPY

/*

SDSF

TIP # 082

SDSF

If you want to rearrange the columns in SDSF -

1.Go TO SDSF.

2.In command
line type
arr
?”.

3.This will
bring the complete list of SDSF column names.

4.You can move
the columns using “/” and “//”.

One Column in the SDSF that we can bring to the front position is
the
MAX-RC (which
usual is

the last
column in SDSF ) which shows the completion code or the abend
code of the job.

Techideas.info

TIP # 083

SDSF

How to allow another user to browse my job?

Usually if we want other user to see our job, we supply them with jobname and jobid.

They use, OWNER urid and PRE urid* to browse your job.

One simple way to allow another user to browse is to change the
DEST column in either the H /I

or ST panel
of the particular job to the another user id(who wants to view it).

The Other user need not issue commands or change panels to view
your job. It will be available

in his
Hold/Output panel itself.

TIP # 084

SDSF

I have some 50 jobs in my SPOOL. I want to list only the jobs that
are ABENDED.

For such a kind of listing, use the primary command FILTER on the command line as given in

the examples
below

FIL MAX AB* – shows jobs that has ABENDS

Other Examples are:

FIL MAX ‘JCL ERROR’ – shows jobs that has JCL errors

FIL MAX NE ‘RC 0000’ – shows jobs with “exceptional conditions”

FIL MAX EQ ‘RC 0000’ – shows successfully completed jobs

If you want to switch off the filter, then issue FIL OFF

TIP # 085

SDSF

For selecting jobs in the SDSF queue , I
either use “?” or “S”.

When I use “?” , I get the
break-up output groups for example like

JESMSGLG,JESJCL,JESYSMSG,SYSPRINT,SYSUT2
etc.

When I use “S” , the entire job
is selected without this break-up.

Is there any command to navigate to view each output group when I
use “S” to select the job?

After opening the job using “S”, use “N”
(next) or “P”(Previous) to navigate between different

output groups.

Techideas.info

CICS

TIP # 086

CICS

Use CALLs instead of LINKs
in CICS

EXEC CICS LINK

- establishes a new run unit

- sets up environment

- Does CICS table-search

- For all this activities, it executes 1400 machine code
instructions

CALL

- It executes around 12 machine code instructions

Just replacing EXEC CICS LINK with CALL statement on a case study, it was found
that

Internal Transaction Response time improved 23 – 78 %

Total CPU Time improved 15 – 23 %

Dynamic storage use improved 11 – 30 %

* CALL used in the study is STATIC CALL . COBOL refered here is VS
COBOL II

TIP # 087

CICS

You can use a COBOL CALL statement to call only
a VS COBOL II or an Assembler
language

program in the same load module as the calling
program.

For calls to programs written in languages other than VS COBOL II,
including other versions of

COBOL, you need to use the commands EXEC CICS LINK or EXEC CICS
XCTL.

Techideas.info

TIP # 088

CICS

Do you know how CICS was called initially ??

PUCICS!!!

PUCICS stands for Public Utilities Customer Information Control System.

After couple of years, it took the name CICS.

TIP # 089

CICS

What is the difference between getting the system time with EIBTIME
and ASKTIME

command?

ASKTIME = requests the current date and time

EIBTIME = field have the value at the task initiation time

TIP # 090

CICS

To access the system values like date, time, Userid
etc and store in a variable, one can use

EXEC CICS ASSIGN

TIP # 091

CICS

While doing a mass delete using a generic key, how can you
determine the number of records

deleted?

By using the NUMREC(data-area) option with the
generic key. Upon completion of the delete

the
data-area will contain the number of records that are deleted.

Techideas.info

TIP # 092

CICS

When generating Mapset, specify TIOAPX=YES for COBOL programs.
YES generates a 12-

byte FILLER
item at the beginning of each symbolic map. It should always be specified for

COBOL programs.

DB2

TIP # 093

DB2

Use the OS/390 – MVS solution ‘Move current-date to ……’ to obtain
a date or

to do a date calculation instead of DB2’s ‘SET CURRENT TIMESTAMP’.

TIP # 094

DB2

Avoid joins that involve more than two TABLES. Break it up into
multiple SQL statements.

In a case study, a 5-table join used 4190 CPU hours in a month for
a weekly process.

Breaking it up dropped the usage to 9 CPU hours per month!!

TIP # 095

DB2

If using CURSOR SQL for read only, use FOR FETCH ONLY in the SQL.

Techideas.info

TIP # 096

DB2

How To Match Contoken
Across Loadlib & Dbrmlib

Step 1.

Go to SYSIBM.SYSPACKAGE for that program – look at the latest bind
-

you can

look at the
time stamp column to find the latest. There will be a

column

called
CONTOKEN. This will have a value.

Ex -

-+———+———+———+———+———+———+———+—-

COLLID NAME CONTOKEN OWNER CREATOR TIMESTAMP

-+———+———+———+———+———+———+———+—-

CBPR39WO PGMNAME .îÒ#.¹”. DFDBS ABC

2004-04-21-06.42.00.

Step 2 .

Covert the CONTOKEN to zoned decimal format. From the above
example it

is
X’1756ed7b02da7f32′. You can use HEX on to find the ZD forma t.

Step 3.

Go to the DBRMLIB – Search for this String like – F
x’1756ed7b02ad7f32′

. If it is the correct DBRM lib using which it is bound then you
will find a

match.

Also you can get the DBRMLIB used for binding from the above Query
o/p

also if you
scroll towards the end. There is a Column for that also.

Now How to match it to load lib .

Step 4.

Go to your load lib in browse mode. Search for the First 8 bytes
in the

above ZD
format of the CONTOKEN

Like =– F ‘1756ed7b’. If you find a match then it is your matchin g

load !!!

The twist here is – on the SYSIBM.SYSPACKAGE and The DBRMLIB the

contoken is stored in the Same format, But in the Loadlib
the date & time part of

the CONTOKEN
is swapped and stored. This is why you need to search for the

8 bytes separately. Otherwise you need to swap the 16 bytes of the

CONTOKEN and search.

Techideas.info

TIP # 097

DB2

To get only the first n rows

select *

from table
name

fetch first n
rows only

with ur;

TIP # 098

DB2

Performance Tuning

Use JOIN instead of Sub-Queries

SELECT EMPNO, LASTNAME FROM EMP, DEPT

WHERE WORKDEPT =DEPTNO

AND DEPTNAME = ‘PLANNING’

SELECT EMPNO, LASTNAME FROM EMP

WHERE WORKDEPT IN

( SELECT DEPTNO
FROM DEPT

WHERE DEPTNAME = ‘PLANNING’ )

TIP # 099

DB2

How to select the duplicate rows from a table?

SELECT columns

FROM table

GROUP BY columns

HAVING COUNT(*) > 1

Techideas.info

TIP # 100

DB2

For SQL declaration of DECIMAL(n,m),

the COBOL equivalent generated is PIC S9(n-m)v9(m) COMP-3

How to order in Gifts2DOOR.com?

Gifts2DOOR.com order steps

JCL Interview questions

1) What is the function of DD DISP parameter? – JCL
(1) Tells the system what to do with the dataset following normal termination of the step
(2) Describes the status of the dataset
(3) Tells the system what to do with the dataset following abnormal termination of the step
(4) All of the above

2) How is the record format of an output dataset specified?
(1) RECORG parameter
(2) STORCLAS parameter
(3) RECFM parameter
(4) None of the above

3) What is the purpose of DD * statement in JCL?
(1) Begins an input data prompt at the system console
(2) Begins an in-stream dataset
(3) Marks the end of a command stream
(4) Includes all datasets within a naming pattern

4) A DD statement has 2 types of parameters. Name them ?
(1) Positional, Keyword
(2) Keyword, Control
(3) Dynamic, Static
(4) Named, Dynamic

5) What is the function of JOB statement in JCL ?
(1) Marks the end of a job
(2) Marks the beginning of an instream procedure
(3) Marks the beginning of a job & assigns a name to the job
(4) Assigns an execution priority to a job

6) How can a job send a status message to a TSO user at the completion of a job ?
(1) STATUS
(2) NOTIFY
(3) ENDMSG
(4) USER

7) What is the function of a DD statement ?
(1) Identifies & describes a dataset
(2) Delimits a DO loop
(3) Marks the start of a declarative section
(4) Delimits the start of an inline include section

8) When output dataset space is required, what quantity categories are used ?
(1) Primary, Secondary, Directory
(2) Address, Units, CONTIG or ALS
(3) Displacement and length
(4) Megabytes, Kilobytes and Bytes

9) What statement marks the beginning of a job step; assigns a name to the step; identifies the program or catalogued or in-stream procedure to be executed in the step ?
(1) START
(2) RUN
(3) EXEC
4. GO

10) How can unused space allocation be returned to the system when a dataset is closed ?
(1) RETURN
(2) RLSE
(3) CONTIG
(4) CLOSE

11) Can an individual step be restricted from using all the job’s allowed CPU time ?
(1) Yes
(2) No
(3) Only in Catalogued Procedure
(4) Through the STEPTIME parameter

12) Where can program checkpoints be stored for use in a restart ?
(1) CHCKPOINT DD statement
(2) SYSCHK DD statement
(3) CHKOUT DD statement
(4) CHECK or DD statement

13) How can the disposition of sysout datasets be set for an entire jobstream ?
(1) SYSOUT parameter
(2) OUTPUT parameter
(3) DEFAULT parameter
(4) DEST keyword

14) What statement marks the end of an in-stream or Catalogued procedure ?
(1) STREAM
(2) SET
(3) PROC
(4) PEND

15) What is the function of DD name parameter with a 2 part structure; Audit.Report ?
(1) Override the Audit DD statement in the report
(2) Override the Report DD statement in the Audit procedure
(3) Concatenate a dataset onto a DD statement in a called module
(4) Delete the Audit DD statement in the Report

16) Which DD parameters are required ?
(1) All parameters & Keywords are optional
(2) Dsname, SPACE, RECFM
(3) Dsname, SPACE, UNIT
(4) Dsname, DISP, SPACE

17) How can an in-stream dataset be terminated?
(1) //
(2) //*
(3) /*
(4) None of the above

18) What is the function of the DD DCB keyword?
(1) Begins the subparameters of the DCB
(2) Begins the DASD control block
(3) Marks the close of the DCB
(4) Modifies the record type parameters

19) What is the maximum length of a single line of JCL ?
(1) 71 bytes
(2) 60 bytes
(3) 55 bytes
(4 ) 80 bytes

20) What is the purpose of DD DUMMY statement ?
(1) Marks a deleted DD statement
(2) Begins an interpreted command stream
(3) Specifies no space allocation & no disposition processing
(4) Suppress command processing

21) Many JCL statements contain specific values designed to direct & control the execution of the statement. What are these fields called ?
(1) Linkage Variables
(2) Parameters
(3) Control Libraries
(4) Includes

22) When space is allocated for an output dataset, what units can be used?
(1) Disks
(2) Megabytes
(3) Cylinders, Tracks, Blocks
(4) Bytes

23) What is the format of comment statement ?
(1) //
(2) //*
(3) /*
(4 ) None of the above

24) A DD statement consists of 4 fields. Name them :-
(1) Name, DD, Space, Device
(2) Format, Name, DD, Space
(3) DD, parameter, device, format
(4) Name, DD, parameter, comments

25) What DD statement is used to supply the name of a dataset ?
(1) Name
(2) Dsname
(3) Label
(4) File

26. What is the purpose of the ‘DD KEYLEN’ parameter?
(1) Specify the length of a data set key in bytes
(2) Override the key length of an SMS defined VSAM dataset
(3) Override the key length specified in the dataset label
All of the above

27. What is the function of the STEPLIB DD statement?
(1) Identify a library to be searched for programs named in the EXEC statement
(2) Identify a library containing executable job steps
(3) Override the system step library within a job stream
(4) All of the above

28. How can return codes be tested before execution of a job step?
(1) Through the RC keyword
(2) Through the CODE keyword
(3) Through the COND keyword
(4) Through the RETURNCD keyword

29. What is concatenating?
(1) Overriding or adding procedures
(2) Logically connecting input datasets
(3) Overriding a called PROC dsname
(4) All of the above

COBOL interview questions

  1. Name the divisions in a COBOL program.

IDENTIFICATION DIVISION, ENVIRONMENT DIVISION, DATA DIVISION, PROCEDURE
DIVISION.

  1. 2. What are the different data types available in COBOL?

Alpha-numeric (X), alphabetic (A) and numeric (9).

  1. 3. What does the INITIALIZE verb do? �

Alphabetic, Alphanumeric fields & alphanumeric edited items are set to
SPACES.

Numeric, Numeric edited items set to ZERO.

FILLER , OCCURS DEPENDING ON items left untouched.

  1. 4. What is 77 level used for ?

Elementary level item. Cannot be subdivisions of other items (cannot be
qualified), nor can they be subdivided themselves.

  1. 5. What is 88 level used for ?

For condition names.

  1. 6. What is level 66 used for ?

For RENAMES clause.

  1. 7. What does the IS NUMERIC clause establish ?

IS NUMERIC can be used on alphanumeric items, signed numeric & packed
decimal items and usigned numeric & packed decimal items. IS NUMERIC
returns TRUE if the item only consists of 0-9. However, if the item being
tested is a signed item, then it may contain 0-9, + and – .

  1. 8. How do you define a table/array in COBOL?

01 ARRAYS.

05 ARRAY1 PIC X(9) OCCURS 10 TIMES.

05 ARRAY2 PIC X(6) OCCURS 20 TIMES INDEXED BY WS-INDEX.

  1. 9. Can the OCCURS clause be at the 01 level?

No.

10. What is the difference between index and subscript?

Subscript refers to the array occurrence while index is the displacement
(in no of bytes) from the beginning of the array. An index can only be
modified using PERFORM, SEARCH & SET.

Need to have index for a table in order to use SEARCH, SEARCH ALL.

11. What is the difference between SEARCH and SEARCH ALL?

SEARCH – is a serial search.

SEARCH ALL – is a binary search & the table must be sorted (
ASCENDING/DESCENDING KEY clause to be used & data loaded in this order)
before using SEARCH ALL.

12. What should be the sorting order for SEARCH ALL?

It can be either ASCENDING or DESCENDING. ASCENDING is default. If you want
the search to be done on an array sorted in descending order, then while
defining the array, you should give DESCENDING KEY clause. (You must load the
table in the specified order).

13. What is binary search?

Search on a sorted array. Compare the item to be searched with the item at
the center. If it matches, fine else repeat the process with the left half or
the right half depending on where the item lies.

14. My program has an array defined to have 10 items. Due to a bug, I find
that even if the program access the 11th item in this array, the program does
not abend. What is wrong with it?

Must use compiler option SSRANGE if you want array bounds checking. Default
is NOSSRANGE.

15. How do you sort in a COBOL program? Give sort file definition, sort
statement syntax and meaning.

Syntax:

SORT file-1 ON ASCENDING/DESCENDING KEY key….

USING file-2

GIVING file-3.

USING can be substituted by INPUT PROCEDURE IS para-1 THRU para-2

GIVING can be substituted by OUTPUT PROCEDURE IS para-1 THRU para-2.

file-1 is the sort workfile and must be described using SD entry in FILE
SECTION.

file-2 is the input file for the SORT and must be described using an FD
entry in FILE SECTION and SELECT clause in FILE CONTROL.

file-3 is the outfile from the SORT and must be described using an FD entry
in FILE SECTION and SELECT clause in FILE CONTROL.

file-1, file-2 & file-3 should not be opened explicitly.

INPUT PROCEDURE is executed before the sort and records must be RELEASEd to
the sort work file from the input procedure.

OUTPUT PROCEDURE is executed after all records have been sorted. Records
from the sort work file must be RETURNed one at a time to the output
procedure.

16. How do you define a sort file in JCL that runs the COBOL program?

Use the SORTWK01, SORTWK02,….. dd names in the step. Number of sort
datasets depends on the volume of data being sorted, but a minimum of 3 is
required.

17. What are the two ways of doing sorting in a COBOL program? Give the
formats.

See question 16.

18. Give the format of USING and GIVING in SORT statement. What are the
restrictions with it?

See question 16. Restrictions – Cannot massage records, canot select
records to be sorted.

19. What is the difference between performing a SECTION and a PARAGRAPH?

Performing a SECTION will cause all the paragraphs that are part of the
section, to be performed.

Performing a PARAGRAPH will cause only that paragraph to be
performed.

20. What is the use of EVALUATE statement?

Evaluate is like a case statement and can be used to replace nested Ifs.
The difference between EVALUATE and case is that no ‘break’ is required for
EVALUATE i.e. control comes out of the EVALUATE as soon as one match is
made.

21. What are the different forms of EVALUATE statement?

EVALUATE EVALUATE SQLCODE ALSO FILE-STATUS

WHEN A=B AND C=D WHEN 100 ALSO ‘00′

imperative stmt imperative stmt

WHEN (D+X)/Y = 4 WHEN -305 ALSO ‘32′

imperative stmt imperative stmt

WHEN OTHER WHEN OTHER

imperative stmt imperative stmt

END-EVALUATE END-EVALUATE

EVALUATE SQLCODE ALSO A=B EVALUATE SQLCODE ALSO TRUE

WHEN 100 ALSO TRUE WHEN 100 ALSO A=B

imperative stmt imperative stmt

WHEN -305 ALSO FALSE WHEN -305 ALSO (A/C=4)

imperative stmt imperative stmt

END-EVALUATE END-EVALUATE

22. How do you come out of an EVALUATE statement?

After the execution of one of the when clauses, the control is
automatically passed on to the next sentence after the EVALUATE statement.
There is no need of any extra code.

23. In an EVALUATE statement, can I give a complex condition on a when clause?

Yes.

24. What is a scope terminator? Give examples.

Scope terminator is used to mark the end of a verb e.g. EVALUATE,
END-EVALUATE; IF, END-IF.

25. How do you do in-line PERFORM?

PERFORM … …

END PERFORM

26. When would you use in-line perform?

When the body of the perform will not be used in other paragraphs. If the
body of the perform is a generic type of code (used from various other places in
the program), it would be better to put the code in a separate para and use
PERFORM paraname rather than in-line perform.

27. What is the difference between CONTINUE & NEXT SENTENCE ?

CONTINUE is like a null statement (do nothing) , while NEXT SENTENCE
transfers control to the next sentence (!!) (A sentence is terminated by a
period)

28. What does EXIT do ?

Does nothing ! If used, must be the only sentence within a
paragraph.

29. Can I redefine an X(100) field with a field of X(200)?

Yes. Redefines just causes both fields to start at the same location. For
example:

01 WS-TOP PIC X(1)

01 WS-TOP-RED REDEFINES WS-TOP PIC X(2).

If you MOVE ‘12′ to WS-TOP-RED,

DISPLAY WS-TOP will show 1 while

DISPLAY WS-TOP-RED will show 12.

30. Can I redefine an X(200) field with a field of X(100) ?

Yes.

31. What do you do to resolve SOC-7 error?

Basically you need to correcting the offending data.

Many times the reason for SOC7 is an un-initialized numeric item. Examine
that possibility first.

Many installations provide you a dump for run time abends ( it can be
generated also by calling some subroutines or OS services thru assembly
language). These dumps provide the offset of the last instruction at which the
abend occurred. Examine the compilation output XREF listing to get the verb
and the line number of the source code at this offset. Then you can look at
the source code to find the bug. To get capture the runtime dumps, you will
have to define some datasets (SYSABOUT etc ) in the JCL.

If none of these are helpful, use judgement and DISPLAY to localize the
source of error.

Some installtion might have batch program debugging tools. Use them.

32. How is sign stored in Packed Decimal fields and Zoned Decimal fields?

Packed Decimal fields: Sign is stored as a hex value in the last nibble (4
bits ) of the storage.

Zoned Decimal fields: As a default, sign is over punched with the numeric
value stored in the last bite.

33. How is sign stored in a comp-3 field?

It is stored in the last nibble. For example if your number is +100, it
stores hex 0C in the last byte, hex 1C if your number is 101, hex 2C if your
number is 102, hex 1D if the number is -101, hex 2D if the number is -102
etc…

34. How is sign stored in a COMP field ?

In the most significant bit. Bit is on if -ve, off if +ve.

35. What is the difference between COMP & COMP-3 ?

COMP is a binary storage format while COMP-3 is packed decimal
format.

36. What is COMP-1? COMP-2?

COMP-1 – Single precision floating point. Uses 4 bytes.

COMP-2 – Double precision floating point. Uses 8 bytes.

37. How do you define a variable of COMP-1? COMP-2?

No picture clause to be given. Example 01 WS-VAR USAGE COMP-1.

38. How many bytes does a S9(7) COMP-3 field occupy ?

Will take 4 bytes. Sign is stored as hex value in the last nibble.

General formula is INT((n/2) + 1)), where n=7 in this example.

39. How many bytes does a S9(7) SIGN TRAILING SEPARATE field occupy ?

Will occupy 8 bytes (one extra byte for sign).

40. How many bytes will a S9(8) COMP field occupy ?

4 bytes.

41. What is the maximum value that can be stored in S9(8) COMP?

99999999

42. What is COMP SYNC?

Causes the item to be aligned on natural boundaries. Can be SYNCHRONIZED
LEFT or RIGHT.

For binary data items, the address resolution is faster if they are located
at word boundaries in the memory. For example, on main frame the memory word
size is 4 bytes. This means that each word will start from an address
divisible by 4. If my first variable is x(3) and next

one is s9(4) comp, then if you do not specify the SYNC clause, S9(4) COMP
will start from byte 3 ( assuming that it starts from 0 ). If you specify
SYNC, then the binary data item will start from address 4. You might see some
wastage of memory, but the access to this

computational field is faster.

43. What is the maximum size of a 01 level item in COBOL I? in COBOL II?

In COBOL II: 16777215

44. How do you reference the following file formats from COBOL programs:

Fixed Block File – Use ORGANISATION IS SEQUENTIAL. Use RECORDING MODE IS F,
BLOCK CONTAINS 0 .

Fixed Unblocked – Use ORGANISATION IS SEQUENTIAL. Use RECORDING MODE IS F,
do not use BLOCK CONTAINS

Variable Block File – Use ORGANISATION IS SEQUENTIAL. Use RECORDING MODE IS
V, BLOCK CONTAINS 0. Do not code the 4 bytes for record length in FD ie JCL
rec length will be max rec length in pgm + 4

Variable Unblocked – Use ORGANISATION IS SEQUENTIAL. Use RECORDING MODE IS
V, do not use BLOCK CONTAINS. Do not code 4 bytes for record length in FD ie
JCL rec length will be max rec length in pgm + 4.

ESDS VSAM file – Use ORGANISATION IS SEQUENTIAL.

KSDS VSAM file – Use ORGANISATION IS INDEXED, RECORD KEY IS, ALTERNATE
RECORD KEY IS

RRDS File – Use ORGANISATION IS RELATIVE, RELATIVE KEY IS

Printer File – Use ORGANISATION IS SEQUENTIAL. Use RECORDING MODE IS F,
BLOCK CONTAINS 0. (Use RECFM=FBA in JCL DCB).

45. What are different file OPEN modes available in COBOL?

Open for INPUT, OUTPUT, I-O, EXTEND.

46. What is the mode in which you will OPEN a file for writing?

OUTPUT, EXTEND

47. In the JCL, how do you define the files referred to in a subroutine ?

Supply the DD cards just as you would for files referred to in the main
program.

48. Can you REWRITE a record in an ESDS file? Can you DELETE a record from it?

Can rewrite(record length must be same), but not delete.

49. What is file status 92?

Logic error. e.g., a file is opened for input and an attempt is made to
write to it.

50. What is file status 39 ?

Mismatch in LRECL or BLOCKSIZE or RECFM between your COBOL pgm & the
JCL (or the dataset label). You will get file status 39 on an OPEN.

51. What is Static,Dynamic linking ?

In static linking, the called subroutine is link-edited into the calling
program , while in dynamic linking, the subroutine & the main program will
exist as separate load modules. You choose static/dynamic linking by choosing
either the DYNAM or NODYNAM link edit option. (Even if you choose NODYNAM, a
CALL identifier (as opposed to a CALL literal), will translate to a DYNAMIC
call).

A statically called subroutine will not be in its initial state the next
time it is called unless you explicitly use INITIAL or you do a CANCEL. A
dynamically called routine will always be in its initial state.

52. What is AMODE(24), AMODE(31), RMODE(24) and RMODE(ANY)? ( applicable to
only

MVS/ESA Enterprise Server).

These are compile/link edit options.

AMODE – Addressing mode. RMODE – Residency mode.

AMODE(24) – 24 bit addressing. AMODE(31) – 31 bit addressing. AMODE(ANY) -
Either 24 bit or 31 bit addressing depending on RMODE.

RMODE(24) – Resides in virtual storage below 16 Meg line. Use this for 31 bit
programs that call 24 bit programs. (OS/VS Cobol pgms use 24 bit addresses
only).

RMODE(ANY) – Can reside above or below 16 Meg line.

53. What compiler option would you use for dynamic linking?

DYNAM.

54. What is SSRANGE, NOSSRANGE ?

These are compiler options w.r.t subscript out of range checking. NOSSRANGE
is the default and if chosen, no run time error will be flagged if your index
or subscript goes out of the permissible range.

55. How do you set a return code to the JCL from a COBOL program?

Move a value to RETURN-CODE register. RETURN-CODE should not be declared in
your program.

56. How can you submit a job from COBOL programs?

Write JCL cards to a dataset with

//xxxxxxx SYSOUT=(A,INTRDR) where ‘A’ is output class, and dataset should
be opened for output in the program. Define a 80 byte record layout for the
file.

57. What are the differences between OS VS COBOL and VS COBOL II?

OS/VS Cobol pgms can only run in 24 bit addressing mode, VS Cobol II pgms
can run either in 24 bit or 31 bit addressing modes.

Report writer is supported only in OS/VS Cobol.

USAGE IS POINTER is supported only in VS COBOL II.

Reference modification eg: WS-VAR(1:2) is supported only in VS COBOL
II.

EVALUATE is supported only in VS COBOL II.

Scope terminators are supported only in VS COBOL II.

OS/VS Cobol follows ANSI 74 stds while VS COBOL II follows ANSI 85
stds.

Under CICS Calls between VS COBOL II programs are supported.

Gifts2DOOR.com’s blog

58. What are the steps you go through while creating a COBOL program
executable?

DB2 precompiler (if embedded sql used), CICS translator (if CICS pgm),
Cobol compiler, Link editor.

If DB2 program, create plan by binding the DBRMs.

  • 59.Can you call an OS VS COBOL pgm from a VS COBOL II pgm ?
  • In non-CICS environment, it is possible. In CICS, this is not possible.