You are on page 1of 47

What is LPAR?

Ans: OS/400 Version 4, introduced a feature LPAR (Logical PARtitioning) which facilitates running
multiple operating systems simultaneously on one IBM System i unit ensuring that one OS doesnt
interfere others system resources/memory.
What is library is AS400? What are the types of library?
Ans: When we execute a command or call a program, the AS/400 must know where to find the command
or program and the answer is library. A Library is a collection of objects. QSYS is the only library that
contains other library. QSYS is the root library where the entire user defined/ system defined library is
created. System supplied libraries begin with the letter "Q" or "#".
Library list types:
System library: All IBM supplied library e.g. QSYS, QHLPSYS, QUSRSYS
Product Library: Whenever Ibm product is used it is added to the library automatically and is removed
itself when the job completes.
Current Library: Current library is the working library i.e. all the work done by you is stored in current
library.
User Library: Non-IBM supplied i.e. created by the user.
Which library gets first loaded into the system when we login?
Ans: QSYS
Is QGPL a user library or system library?
Ans: Its a user library.
How can we see all the objects and its sizes in a library?
Ans: By using the command DSPLIB.
7.

What is source physical file?

Ans: Source physical file is a file which contains the sources of different types of objects. There can be up
to 32768 members. Source physical file is an object. But the source member is not an object. When we
compile the member, the object is created for that source. Command used is CRTSRCPF.
CRTSRCPF FILE(IROBO1/QRPGSRC) RCDLEN(112) TEXT('SOURCE PHYSICAL FILE)
8.

How to see all members of a file?

Ans: By using the command shown below:


DSPFD FILE(IROBO1/QRPGLESRC) TYPE(*MBRLIST)

9.

How to see all record formats used in a file?

Ans: By using the command shown below:


DSPFD FILE(IROBO1/QRPGLESRC) TYPE(*RCDFMT)
10. How to change the record size of a physical file?
Ans: By using the command below:
CHGPF FILE(AMITNEM/OBJ) SRCFILE(AMINEM/QDDSSRC) SRCMBR(OBJ_SRC)
12. How to refer another file to define a new field in a physical file?
Ans: below is an example, we are going to use the file REFER to get the field definition for new file.
USE OF REFERENCE
13. Can LEVEL CHECK ERROR occur if we do CHGPF?
Ans: It depends on the value that we have set for LVLCHK (Record format level check) attribute. If its
value is *YES then the record format level identifier is checked when the file is opened and if it doesnt
match it throws the error. If its value is *NO, then the record format level identifier is not checked, hence
no error.
1.
What is the use of RGZPFM? Give example of RGZPFM.
Reorganize physical file member(RGZPFM)
We generally use RGZPFM to reuse the deleted records of a file for future insert operation. The data in
a file in inserted sequentially. If we delete some in between records, then those freed spaces wont be used
for inserting new record. Like this, the toll of space accumulated by deleted records goes on and we
cannot use them until and unless we run RGZPFM command to reorganize the space.
Once we delete the records the relative record number of the records gets changed due to reorganization
of file.
Suppose a file is used in most of the programs based on its key value. If we want to change the access
path of this file from sequential to keyed or from one key value to another key value, then we can go for
RGZPFM
How to create a multi-member physical file?
TO ADD A NEW MEMBER TO THE FILE USING ADDPFM
ADDPFM FILE(AMINEM/ACCOUNT) MBR(MBR2)
Member MBR2 added to file ACCOUNT in AMINEM.
STRDFU => SELECT member as MBR2 to add record in the new member.
TO ADD A NEW MEMBER TO THE FILE USING CPYF
CPYF FROMFILE(AMINEM/ACCOUNT) TOFILE(AMINEM/ACCOUNT) FROMMBR(ACCOUNT)
TOMBR
(MBR3) MBROPT(*ADD) CRTFILE(*NO) FROMRCD(1) NBRRCDS(3)

Member MBR3 added to file ACCOUNT in AMINEM.


3 records copied from member ACCOUNT.
1. What is logical file in AS400? What are the types of logical file?
Logical file

Logical file does not occupy any memory.

One or more logical file can be derived from a single physical file.

It simply contains the record selection definition and when accessed retrieves the records from
the physical file to which it refers.

A logical file can contain up to 32 record formats.

It selects records dynamically. It cannot exist without a physical file.

We can filter the data with criteria by using select and omit command.

A logical file does not contain any data but provides the VIEWS of the data to satisfy endusers needs.

There are two types of Logical file


1)
2)

Non-join logical file


Join logical file

1) Non-join logical file


Non-join logical files can either be a simple logical file, which contains only one record format or a
multiple record format logical file, which contains more than one Record format.
Logical files can be derived from 1 to 32 physical files and so a logical file can have a maximum of 32
record formats.
Single record format Non-join logical file:
If a logical file is derived from single physical file it is called simple logical file.
Multiple record format Non-join logical file:

Multiple record non-join logical files will select records from 2 or more physical files by
referring to only one logical file.

2.

Each record format is always associated with one or more physical file

The same PF can be used in more than one record format


What is DYNSLT?

DYNSLT: Use this file-level keyword to indicate that the selection and omission tests specified in the
file (using select/omit specifications) are done at processing time. This keyword specifies dynamic
select/omit rather than access path select/omit.
Only a Physical file contains data. Logical files just contain pointers for processing the data in a specific
sequence and/or subset of data.When a record is added/changed/deleted in a physical file, the system has
to put a lock on it and then go out to check and update any logical files before it can release the lock.
While the amount of time to do this is hardly measurable, it can be significant if massive batch updates
are done to a file.If you are using the Select/Omit option in your DDS and using DYNSLT, the above
process does not need to be done at record update time. Where this is beneficial is when your selection
process includes almost all the records in the file. Now when you process using DYNSLT, it will read all
the records in the file, but do the selection of which records to process at that time rather than having
done all the maintenance ahead of time.
3.

What is the Difference between access path and Dynamic select?

Ans: Dynamic select occurs whenever the program reads file. But access path occurs before the file is
read (but not necessarily).
4.

What is the use of JDUPSEQ in AS400?


JDUPSEQ
This joinlevel keyword is used to specify the order in which records with duplicate join fields are
presented when the JLF is read.
The format for this keyword is:
JDUPSEQ (Sequencing field-name [*DESCEND])
This keyword has no effect on the ordering of records with unique keys.
If *DESCEND is not specified then the default is sequencing in ascending order.

5.

What is the use of JDFTVAL in AS400?


JDFTVAL

When this file-level keyword is used the system provides default values for all for fields when
a join to a secondary file does not produce any records.

If this keyword is not specified a record in the primary file for which there is no corresponding
record in the secondary file is skipped.

1. What is the difference between non-join logical files and join logical files?
Non join logical file
We can insert or delete or update records

Join logical file


Insertion, updating or deletion of records is not

using non-logical file.


DFU can be used to display non-join logical
file.
1-32 record format is specified
Commitment control is used
2.

possible in join logical files.


DFU is not available
Only one record format can be specified
Commitment control cannot be used.

What is the difference between physical file and logical file?


Physical file
1. Occupies the portion of memory. Its containing
data.
2. A physical file contains one record format
3.Can be exist even without LF
4. If you delete a LF, the PF cant be deleted
5.CRTPF command is used to create such object

4.

Logical file
Does not occupy any memory space. Does not
contain any data.
A logical file can contain up to 32 record formats.
Cant exist without PF
If you delete a LF, the PF cant be deleted
CRTLF command is used to create such type object

What are the record format field mapping options in CPYF?

Record format field mapping (FMT)


*MAP Fields with the same name in the from-file and to-file record formats are copied, and any fields in
the to-file that do not exist in the from-file format are set to the default value specified on the DFT
keyword for the data description specification (DDS) of the to-file or zero for numeric fields, blanks for
character fields, current date/time for date/time fields, or null value for null-capable fields.
If *MAP is specified, *DROP can also be specified.
*DROP This value must be specified for field-level mapping if any of the field names in the from-file
record format do not exist in the to-file format. If *DROP is specified, *MAP can also be specified. When
*DROP is specified, all the field names that exist in both record formats must have the same attributes
and relative positions in the from-file and to-file record formats, or *MAP must also be specified. Null
values are copied.
*NOCHK If the record formats of the database files are different, the copy operation continues despite
the differences. Record data is copied directly (left to right) from one file to the other. FMTOPT
(*NOCHK) is required when copying all record formats from a logical file with multiple formats (when
RCDFMT (*ALL) is specified) to a physical file that is of the same type (source or data) as the from-file.
*CVTSRC This value is used to copy between database files, from a source file to a data file, or from a
data file to a source file. It is valid only when the from-file and to-file are different types (source and
data).
5.

What is the Difference between CRTDUPOBJ and COPYF?

Ans: In CRTDUPOBJ for a logical file the created duplicate file will be also logical file and for a physical
file the created file will also be a physical file. Even the record format identifier will also be the same.
While in case of COPYF, if we are copying a logical file then the created file be a physical file not a
logical file.
6.

What is access path in AS400?

Access path
Access path describes the order in which records are to be read.
Access paths can be kept on the system permanently (such as physical or logical file) or temporarily.
OPNQRYF command may create a temporary access path for use one time, and then discard the
7.

access path.
What are the types of access path? How to change the access path of a file?
Types of Access Path
Arrival sequence access path
Keyed sequence access path

Arrival sequence access path


Sequentially, where each record is taken from the next sequential physical position in the file.
Directly by relative records number, where the record number is identified by its position from the
start of the file.
Keyed sequence access path
It is based on the contents of the key fields as defined in DDS. This type of access path is updated in
the contents of a key field is changed.
There are three ways of bounding the access path:
o Immediate
o Rebuild
o Delayed
Change access path of a file: We use CHGPF to change the access path maintenance parameter as
shown below.
***Note: RGZPFM can also be used to change the access path of a file.
The three ways of maintaining access paths of closed files are:
*IMMED: Immediate maintenance of an access path means that the access path is maintained as
changes are made to its associated data, regardless if the file is open.
*REBLD: Rebuild maintenance of an access path means that the access path is only maintained while
the file is open, not when the file is closed; the access path is rebuilt when the file is opened the next

time. When a file with rebuild maintenance is closed, the system stops maintaining the access path.
When the file is opened again, the access path is totally rebuilt.
*DLY: Delayed maintenance of an access path means that any maintenance for the access path is
done after the file member is opened the next time and while it remains open. However, the access
path is not rebuilt as it is with rebuild maintenance. Updates to the access path are collected from
the time the member is closed until it is opened again. When it is opened, only the collected
changes are merged into the access path.
8.

What is the default access path of a file? If you do not specify the type of maintenance for a
file, the default is immediate maintenance.

1.

What is the maximum number of fields that can be in a file? Maximum no of fields included
in a PF is 8000.

2.

Maximum no of parameter passed in a RPG? Maximum no of parameter passed in RPG is


255.

3.

Maximum no of parameter passed in a CL? Maximum no of parameter passed in CL is 40.

What is the maximum number of record format in a physical file? -- 1


What is the maximum number of record format in a join logical file? Ans: 1
What is the maximum number of record format in non-join logical file? Ans: 32
7.

What is the maximum number of record format in a display file? 1024

8.

What is the maximum number of record format in a subfile? 512


What is the maximum no of key fields in file? Ans: 120
How to reset dates in SEU?
Changing Session Defaults (F13)

Before you start entering the source code make sure the session environment for SEU is set-up as you
wanted.
In Session environment you can edit the session attributes highlighted below.
We can change the session default that will be used during source entry/editing process.
How to search records based on date as searching criteria in SEU?

FIND/CHANGE Command
Shift-F2
We can search a string or search for date in source (included/excluded/all).
It has been discussed previously also in X line command section.
An alternative way is to directly give the SEU command entry as F E A 8. This command will find(F)
records with character E at position 8 in all(A) source.
12. How to see another member source in the same SEU?
Specifying the Browse/Copy Option SHIFT+F3
1.
What is array in AS400? What are the types of array?
Array is collection of elements of same data type. Types of Array
1)
Compile time array
2)
Pre-runtime array
3)
Run time array
2.
What is compile time array in AS400? Give example of compile time array.
Compile time array

The compile time array means the elements of the array will be loaded before the execution of
the programs i.e. at compile time.

The value will be static.

We must declare in keyword command DIM (), CTDATA (), and PERRCD ().
DIM() represents the size of the array.
CTDATA() represents that it is compile time array.
PERRCD() represents the number of entries in one array record.
Dim = row i* col j
e.g. PERRCD=2, NO. OF ROWS=3, THEN DIM = PERRCD*NO. OF ROWS=6

3.

We mention the array element just after the last statement of the program.
What is Pre run time array in AS400? Give example of Pre run time array.

Pre-runtime array

There are some limitations of compile time array. E.g. If we want to change the value of an
array element, we need to make changes in the program source code where the arrays element is
defined and then recompile the program.

In pre-runtime array, we maintain the array element in separate file. Hence, if we are making
any change in array element we can just change this file containing the array element; we dont
need to compile the source program again and again as in compile time array.

The file that stores the array element must be defined in the F specs with T as File
Designation entry.

Record length is also a mandatory entry in F spec.


length of record = Perrcd *size of 1 element

The file is opened at program initialization. At that time the array loads from this external file.

To define the array in our program, we use keyword FROMFILE() instead of CTDATA().
Example- I
Flat-File USED: Flat01
4.
What is run time array in AS400? Give example of run time array.
Run time array

The run time array means the value will be loaded during the runtime only.

The value will be dynamic.


What is indicator data structure in AS400? Give example indicator data structure.
The indicator data structure is used to rename the indicators used in our program with the name that is
more meaningful and understanding.
If we want to use indicator data structure in our program then INDARA is a mandatory keyword in the
display file used.
How can we create subsystem in AS400?
Steps of creating the subsystem
Create Subsystem description (CRTSBSD)
First of all we create subsystem description as below:
CRTSBSD
SBSD (AMINEM/MYSBSD) POOLS ((2 *BASE)) MAXJOBS(2)
subsystem description')

TEXT('My

Here, the subsystem job will run in pool 2 and will use *BASE for main memory storage. There can
maximum of 2 jobs inside the subsystem at a time.
Create Job queue (CRTJOBQ)
Then we create a job queue as below:
CRTJOBQ JOBQ (AMINEM/MYJOBQ) TEXT('My job queue')
Add Job Queue Entry (ADDJOBQE)
Once the job queue is created, then we attach the (ADDJOBQE) command, as follows:
ADDJOBQE SBSD (AMINEM/MYSBSD) JOBQ (AMINEM/MYJOBQ) MAXACT (1)
MAXACT denotes the number of the jobs that can be process at the same time.
Create Class (CRTCLS)

Class defines the run time attribute e.g. Run priority, Time slice, Default wait time, Maximum
temporary storage etc.
CRTCLS CLS(AMINEM/MYCLS) RUNPTY(40)
Add Routing Entry (ADDRTGE)
ADDRTGE SBSD(AMINEM/MYSBSD) SEQNBR(9999) CMPVAL(*ANY) PGM(SYS/QCMD)
CLS(AMINEM/MYCLS)
Start Subsystem (STRSBS)
STRSBS SBSD(AMINEM/MYSBSD)
Once the subsystem is started it can be used to submit the job.
2. What is data queue in AS400? Give example of data queue.
Data Queue

It is used for making asynchronous communication between the two jobs. If we are sending
data from one job to another using data queue using QSNDDTAQ API, but at that time the receiver
job is not active, then the data will be there in the queue and whenever the receiver job becomes
active, it retrieves the data using the QRCVDTAQ API.

It facilitates fastest communication compared to when we use other things to communicate like
dataarea, message queue or database files.

It can yet be used for synchronous communication also or within the same job.

We use APIs to make communication e.g. QSNDDTAQ, QRCVDTAQ.

The content of the data queue is messages in free format.

The messages on the data queue is stored in *FIFO, *LIFO or *KEYED. *KEYED means the
messages can be retrieved using key value associated with the messages. In case of *KEYED we
need to mention key length also.

First create the data queue by using CRTDAQ command

Data query is nothing but a queue in which are program can send a data and other program or
the same program can receive the program. QSNDDTAQ is stored in QSYS.


We can create data queue on local system or on remote system by making the data queue type
as *DDM. By default it will be *STD. In case of DDM data queue, we need to mention Remote data
queue name(RMTDTAQ) and remote system name(RMTLOCNAME) also as parameter.

QSNDDTAQ

By using this command sent data same / another program.


QSNDDTAQ PARM (QUEUE-NAME LIB &LEN &DAT)

QRCVDTAQ

By using this command receive data same /another program


QRCVDTAQ PARM (QUEUE-NAME LIB &LEN &DAT &WAIT)
1. Create Stream File from PF and Create PF from Stream File
(1) CRTDIR DIR('''/HOME/DIR1''')
(2) COPY ANY DATABASE FILE IN QTEMP AND CREATE FILE AMINEM/MAST.
(3)
CPYTOIMPF
RCDDLM(*CR)

FROMFILE(AMINEM/MAST)

TOSTMF('/HOME/DIR1/XXX.TXT')

STRDLM(' ') FLDDLM('|')


All records copied from file MAST in AMINEM.
(4) WRKLNK '/HOME/DIR1/XXX.TXT'

1.

What is data structure in AS400? What is the use of data


structure?

Ans:
DATA STRUCTURE
Data structure in general means a structure of different data type.
Data structure is specified in the Input Specification of an RPG 3 Program whereas in RPG
1V we specify it in 'D' specification.
Data Structure is used-

1. To break fields into subfields


2. To Group fields
3. To change the format of the field
4. To Group non-contiguous data into contiguous format 5.To convert data.

2.

What are the types of data structure in AS400? Give


example of data structure?

Ans: Below are the types of data structures in as/400:


I.

PROGRAM DESCRIBED DATA STRUCTURE

II.

EXTERNALLY DESCRIBED DATASTRUCTURE

III.

MULTIPLE OCCURENCE DATASTRUCTURE

IV.

INDICATOR DATA STRUCTURE

V.

DATA AREA DATA STRUCTURE (SPECIFIED IN 'U')

VI.

PROGRAMME STATUS DATASTRUCTURE (SPECIFIED IN 'S')

VII.

3.

FILE INFORMATION DATASTRUCTURE

What is program status data structure(PSDS) in AS400?


Give example if PSDS.

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

4.

What is file information data structure(INFDS) in AS400?


Give example if INFDS.

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

5.

What is indicator data structure in AS400? Give example


indicator data structure.

The indicator data structure is used to rename the indicators used in our program
with the name that is more meaningful and understanding.
If we want to use indicator data structure in our program then INDARA is a
mandatory keyword in the display file used.

2.

What is journaling? Give example of journaling?

Journaling

Journaling, generally speaking, is a process of recording activity.

On the iSeries, journaling refers to the process of recording object activity.

Journaling on the iSeries typically involves the recording of the activity related to files, namely,
physical files. When a file is being journaled, activity such as file-opens, file-closes and data updates
are recorded.

Set up journaling
1.
Use the Create Journal Receiver (CRTJRNRCV) command to create a journal receiver.
The journal receiver is where the journal entries are actually recorded. The journal "connects" the
receiver to the file.
It's a good habit to name the journal receiver the same as the journal, plus a numeric suffix such as 0
or 1.
Also, you should put journal receivers in the same library as the file.
2.

Create a journal. Use the Create Journal (CRTJRN) command to create a journal and specify the
receiver created in step 1. Although you can journal multiple files to the same journal (and, in some
cases, that is actually preferable), you will generally want to have a journal "serving" a single file.

3.

Start journaling the file. This is done by using the Start Journal Physical File (STRJRNPF)
command. This is how you associate a file to a journal. Once the association is made, the system will
record in the journal receiver a copy of any record added, updated or deleted from the file. Other

activity, such as when the file is opened and closed, can also be recorded in the journal receiver if you
choose by selecting the appropriate options on the STRJRNPF command.
Message subfile

Message subfile as the name signifies is a subfile of messages. It is a special subfile specially
designed to hold messages.

Message subfile loads itself automatically at runtime loads with the messages from program
message queue to display it on the screen.

To load the subfile we simply fill the message queue with the messages and link the subfile
with that message queue.

Similarly to clear the subfile, we clear the message queue.

Message subfile can be used in a case we want to display multiple error/information


messages at the same time on the screen or other way it can be used to display additional
information for a particular error message like what should be done in a case it appears. More
precisely we can say that by using this we can display 2 nd level messages by programming with
great ease.

6.

How many messages we want to display on the screen, it depends on SFLPAG value.
Give example of EDTCDE keyword in as400?

EDTCDE (Edit Code)

This keyword is used to edit output-capable numeric fields.

Edit code, depending upon the data type edits the contents.

e.g. By using it, the field can be punctuated with commas and periods. E.g. 1,000.50
Negative values can be printed with a minus sign or CR to the right. E.g. 100.50CR, 100.50 A currency symbol can be printed with the help of this keyword. E.g. 100.50$
The value can be padded with zeros at the left instead of blank padded. E.g. To print 000125.50
instead of XXX125.50 (where X=blank)
Date can be formatted with the keyword EDTCDE(Y). E.g. 1/12/99

Zero values can be printed as zeros or blanks as per the requirement.


Use EDTCDE(Z) to remove , separator in the field value.
66. Give example of EDTWRD keyword in AS400.
EDTWRD

Sometimes we are not able to get the desire editing result by EDTCDE. In that case it is better
to go for EDTWRD.

In the EDTWRD parameter we specify the format matching the required data.

This keyword is valid only for numeric field (Specified with Y data type).

Before EDTWRD, Value of C_FLD001= .12


After EDTWRD, Value of C_FLD001=0.12
Before EDTWRD, Value of STIME= 1:12:12
After EDTWRD, Value of STIME=01:12:12
A zero stops zero suppression.
We place it in the farthest right position where zero suppression is to stop. Thats why here the time is not
suppressed at the leftmost position.
67. Explain FLDCSRPRG with example.
FLDCSRPRG

This field-level keyword is used to define the field to which the cursor moves when

exiting this field.


INDARA

This keyword is used at file level.

It is used to put the field option indicators and function(response) key indicators in a separate
area of memory called indicator area.

By using this keyword, we can make indicator data structure in our program to give the
customized name to indicators defined in the display file. Hence, it makes the program more
readable and easy to understand.

OVERLAY

This display file keyword is used at record level to specify that the record is displayed on the
screen without completely erasing the previous displayed screen.

Suppose we have 3 records on the display screen: HEADER, DETAIL and FOOTER, Where
HEADER contains the content/data of the top part of the screen; DETAIL contains the content of
data part and FOOTER contains the content of FOOTER part. Now if we want to write all the
screens at the same time and want to display the content that it is containing then we go for
overlay keyword. We put overlay keyword on the DETAIL and FOOTER and do the operation

SFLCSRRRN

This keyword is used at record level to provide the relative record number (RRN) of the
record on which cursor is placed.

SFLDROP

This keyword is used at record level to display the subfile in truncated form i.e. the subfile
records are truncated to fit on one display line.

We assign a CA (command attention) or CF (command function) key to control the truncated


and folded behavior of subfile by pressing the function key.

By default the display mode be truncated one but when the user presses the function key it goes
to folded mode.

The operator presses the specified CF or CA key to switch from truncated form to folded form
or from folded form to truncated form. It is used along with the keyword SFLMODE and
SFLFOLD.

SFLFOLD

This keyword is used at record level to display the subfile in folded form by default.

We assign a CA (command attention) or CF (command function) key to control the truncated


and folded behavior of subfile by pressing the function key.

By default the display mode is folded one but when the user presses the function key it goes to
truncated mode.

The operator presses the specified CF or CA key to switch from folded form to truncated form
or from truncated form to folded form. It is used along with the keyword SFLMODE and
SFLDROP.

SFLMODE

This keyword is used at record level to set the mode of the subfile i.e. to control if the subfile is
to be displayed in folded or truncated form.

We use a hidden variable as a parameter of this keyword to control the behavior of the subfile
by setting the value of the hidden variable.

The operator presses the specified CF or CA key to switch from truncated form to folded form
or from folded form to truncated form. By default the display mode be truncated one.

It is used along with the keyword SFLDROP and SFLFOLD.

SFLINZ and SFLRNA

These two keyword is used to initialize a subfile which is done in case we want to make a data
entry screen.

After the entry is made to be the subfile then only it becomes active, before that it will be
inactive. This is done by SFLRNA.

By using SFLINZ, the fields in each subfile record are initialized like as below:

Session or device error


Below are the situations which can lead to session or device error:

Incorrect record number in subfile SFLRCDNBR or SFLSIZ field.

In program code, at display (EXFMT) subfile code, check the value of RRN. If is zero and you
are making on the SFLDSP indicator *ON or it is un-conditional and doing display subfile. Then it
will give you the same error.

Trying to show empty subfile.

Field and position in Display file DDS is not correct.

The keywords are not properly organized in Display file DDS.

Trying to write more than 9999 record on the Display file for Load All subfile

Subfile

A subfile is nothing but just displaying records in tabular format on a display device.

It can be an editable tabular format due to which it can be used in data entry screen,
inquiry(static) screen or combination of both i.e. editing the information for a particular inquiry.

The subfile first of all loads the data in subfile buffer. Maximum of 9999 can be loaded in
subfile buffer at a time. Trying to load more leads to session or device error.

To create a subfile we use SCREEN DSIGN AID tool (Command STRSDA)

A subfile has two record format:


1. Subfile control record format
2. Subfile record format

A subfiles process can be divided mainly into 3 parts:


1. Clearing the subfile control record format.
2. Loading the subfile buffer with the relevant data.
3. Displaying the data from subfile buffer to the display device.

CHAIN, READC, UPDATE, or WRITE operation codes can be used for subfile record format
to transfer data between the program and the subfile.

READ, WRITE, or EXFMT operation codes cane be used for subfile control-record format to
transfer data between the program.

EXFMT first of all write the keyboard input to the screen (to the screen field variable) and then
read it. Hence by write operation we can have the value in the screen field available.

Session or device error comes when there are no records in the database to fill the subfile. For
more information on session or device error refer the chapter on Session or device error.

Types of subfile
I.

Load-All Subfile

In Load-All subfile all the records are written to the subfile buffer at once and then the data in the
subfile loaded from the buffer.

In this case SFLSIZ should be at-least 1 greater than the SFLPAG.

If we are writing more records in the subfile buffer than the SFLSIZ declared and SFLSIZ<9999,
then the SFLSIZ is extended to accommodate all records till the size of 9999. 9999 is the buffer
limit.

In this case PAGEUP AND PAGEDOWN is taken care by system. SFLPAG should be less than
SFLSIZ.

In load-All subfile if we do PAGEDOWN and then press ENTER on the page, by-default
ENTER bring the display screen to the very first page irrespective of the current page number. To
avoid this situation, we use file information data structure to get the current page RRN number and
pass it to the SFLRCDNBR hidden field defined in the display file DDS.

II.

Single Page/non-elastic

In this case sub file size (SFLSIZ) must be equal to subfile page (SFLPAG).

Every time the record is written in the buffer, buffer is cleared before writing. After clearing the
subfile buffer, records equal to the size of SFLPAG is written. Hence every time we find
SFLSIZ=SFLPAG.

We call this subfile Non-elastic also which means, the buffer size will be equal to the page size
always.

In this case, PAGEUP and PAGEDOWN handling is required.

III.

Expandable/elastic/growing
In this case each time the subfile buffer is loaded with SFLPAG size. But unlike single page the
buffer is not cleared before writing the new data. Hence as a result the buffer size starts growing.

if first time we have loaded 10 records from the Physical file to subfile buffer then second time
the size of the buffer will be 10 +10, 3rd time the size of subfile buffer will be 10+10+10. and so
on. Due to the growing nature of this subfile, we also call is growing or elastic subfile.

In this case SFLSIZ should be at-least 1 greater than the SFLPAG.

If we are writing more records in the subfile buffer than the SFLSIZ declared and SFLSIZ<9999,
then the SFLSIZ is extended to accommodate all records till the size of 9999. 9999 is the buffer
limit.

In this PAGEUP handling is not required as it is taken care by the system itself. Only
PAGEDOWN handling is required.

In Expandable subfile after PAGE UP if we press ENTER, then the page that is displayed on the
screen is that we had at our last PAGEDOWN. i.e. suppose we are on page-3 after pressing 2
PAGEDOWN. From page-3 if we press 1 PAGEUP and then press ENTER, the page to be
displayed should be the 2nd page, but it is not the case. In this case, the page that is displayed after
pressing ENTER is 3rd page which is the page no. that we got after the latest PAGEDOWN activity.
To avoid this situation, we use file information data structure to get the current page RRN number
and pass it to the SFLRCDNBR hidden field defined in the display file DDS.

SFLNXTCHG

This keyword is very useful in case of editable subfile.

If before processing the subfile records, we are validating those records, then first of all we will
use REACDC to find the records that is to be validated and then again by using READC we will
process the same records.

But READC works the first time but not the second time on the same record.

The reason behind is, the first READC operation issued on the record, sets the MDT(modified
data tag) off, resulting into the situation in which that record wont be read again by 2 nd READC
operation.

READC identifies the records that have been changed by the processing option.2 nd time since
the MDT flag for those records will be off, the records wont be treated as the changed records.

Now if we want that the second time also the record should be read, so that it can be processed,
we need to use SFLNXTCHG keyword.

One more thing to note about is that the record of a subfile is treated to be changed if it is field
exited or it is keyed into or some wrong processing option is taken or some wrong entry/update is
made to the record.

1.

What is FTP in AS400? What are the FTP commands in


AS400?

Ans: We are using FTP in as400 to send and receive data from/to remote system.
Below are the basic FTP commands in the transfer:
LCD directory-name
This command is used to change the Local system directory to
directory-name.
CD directory-name
This command is used to change the Remote system directory to
directory-name.
GET library/source-physical-file. Member-name
This command is used to fetch a file from remote system.
MGET:
It is used to fetch multiple file from remote system, GENERIC
IS ALLOWED.
PUT:
To send a file to remote system

MPUT: To send multiple files to remote system It is used to


fetch multiple file from remote system, GENERIC IS ALLOWED.
NAMEFMT (name formatting)
Its value can be 0 or 1, it has been explained below.
QUOTE SITE NAMEFMT 0
For working with standard library objects
File identifiers have three components: Library, File and
member.
Library

and

file

components

are

separated

by

the

delimiter.
File and member components are separated by the . delimiter.
Syntax: Library/file.member
QUOTE SITE NAMEFMT 1
For working with IFS objects (ie. All objects)
Directory levels separated by the / delimiter.
Database

files

use

format:

/QSYS.lib/Libname.lib/Fname.file/Mname.mbr
Documents

(files)

stored

in

folders

use

format:

/QDLS/folder/document.ext
CD / (puts you in the root IFS folder)
QUIT
Ends the FTP session with the remote computer and exits ftp.
Bye
Ends the FTP session with the remote computer and exits ftp.
ASCII
It Sets the file transfer mode to ASCII (Note: this is the
default mode for most FTP programs)

ASCII
the

is a character-encoding scheme originally based on


English

alphabet.

ASCII

codes

represent

text

in

computers, communications equipment, and other devices that


use text. Most modern character-encoding schemes are based
on ASCII, though they support many additional characters.
Binary
It Sets the file transfer mode to Binary
the binary mode transfers all eight bits per byte and must
be used to transfer non-ASCII files or non-standard files
e.g. zip file, tar file, image file, .DAT file, save file,
executable files, sound files, graphic files etc.
Quote
It will send an argument to the remote FTP Server. This
statement is similar in purpose as the "LITERAL" statement.
Site
This parameter is used at the client system to transfer a
function (via the LITERAL or QUOTE statement) to the host
site.
Open
It opens a new FTP connection with another system.

Example- II : Transferring AS400 objects from one AS400system to another AS400-system using save file
To download source member from telnet system SYS5005 SYS4004 Local disk

In System SYS5005 from which the object QRPGLESRC is to be sent, we


do the below steps:
CRTLIB TRANSFER
CRTSRCPF FILE(TRANSFER/QRPGLESRC) RCDLEN(112) Put here all the members required.
CRTSAVF QGPL/SAV005
SAVOBJ OBJ(QRPGLESRC) LIB(TRANSFER) DEV(*SAVF) SAVF(QGPL/SAV005) TGTRLS(V5R4M0)

In System SYS4004 where the object QRPGLESRC is to be restored, we


do the below steps:

CRTSAVF QGPL/SAV005
CRTLIB GETLIB
FTP SYS5005
RSTOBJ OBJ(*ALL) SAVLIB(TRANSFER) DEV(*SAVF) SAVF(QGPL/SAV005) RSTLIB(GETLIB)
*** For save file BIN(binary) command is needed as the savefile cannot be dealt With
default ASCII.
In GETLIB the object QRPGLESRC has been restored. To see the members do,WRKMBRPDM
FILE(GETLIB/QRPGLESRC)

1.

What is compiler directive in AS400? Give example of


compiler directive.

Compiler directive

Compiler directive is an instruction (directive) given to the compiler, to


perform some specific task during compilation or to generate customize
compiler listing report after compilation.

Compiler directive serve many purposes like it is used to control the heading
information in compiler listing, to control the spacing of the compiler listing, to
include source statement from other source member, to do a free form
calculation in our rpgle program, to control the source records
selection/omission based on some condition etc.

Compiler directives are:


(1)

2.

/FREE... /END-FREE

(2)

/TITLE

(3)

/EJECT

(4)

/SPACE

(5)

/COPY or /INCLUDE

(6)

/IF/ELSEIF. /ELSE /ENDIF

(7)

/EOF

What is data queue in AS400? Give example of data queue.

Data Queue

It is used for making asynchronous communication between the two jobs. If


we are sending data from one job to another using data queue using
QSNDDTAQ API, but at that time the receiver job is not active, then the data
will be there in the queue and whenever the receiver job becomes active, it
retrieves the data using the QRCVDTAQ API.

It facilitates fastest communication compared to when we use other things


to communicate like dataarea, message queue or database files.

It can yet be used for synchronous communication also or within the same
job.

We use APIs to make communication e.g. QSNDDTAQ, QRCVDTAQ.

The content of the data queue is messages in free format.

The messages on the data queue is stored in *FIFO, *LIFO or *KEYED.


*KEYED means the messages can be retrieved using key value associated
with the messages. In case of *KEYED we need to mention key length also.

First create the data queue by using CRTDAQ command

Data query is nothing but a queue in which are program can send a data
and other program or the same program can receive the program.
QSNDDTAQ is stored in QSYS.

We can create data queue on local system or on remote system by making


the data queue type as *DDM. By default it will be *STD. In case of DDM data
queue, we need to mention Remote data queue name(RMTDTAQ) and remote
system name(RMTLOCNAME) also as parameter.

QSNDDTAQ
By using this command sent data same / another program.
QSNDDTAQ

PARM (QUEUE-NAME LIB

&LEN

&DAT)

QRCVDTAQ
By using this command receive data same /another program

QRCVDTAQ

PARM (QUEUE-NAME LIB &LEN &DAT &WAIT)

ASSUME/OVERLAY

If we want to specify that the OS/400 program is to assume that this record is already shown
on the display
when the file is opened.

Use this keyword to receive data that a previous program has left on the
display.

If we dont use this keyword then the display screen of the previous display
file goes blank when the new display screen is opened. To avoid this situation
we use ASSUME keyword along with overlay.

OVERLAY keyword allows the overlaying of fields on this record without


erasing the entire display.

ASSUME is placed on a format that a program is supposed to pretend is on


the screen.

It is mainly used for display files that present windows.

It is not placed on the window itself, but a dummy non window format

KEEP

If we want to Keep the display from being deleted when the display file is
closed.

It avoids the flicker that happens when we are returning to the previous
display file after closing the current one. E.g. We press F4 on the main screen
to display a window and then when we return from this window a flicker
happens. To avoid this we use this KEEP keyword.

6.

Give example of EDTCDE keyword in as400?


EDTCDE (Edit Code)

This keyword is used to edit output-capable numeric fields.

Edit code, depending upon the data type edits the contents.

e.g.
By using it, the field can be punctuated with commas and periods. E.g. 1,000.50

Negative values can be printed with a minus sign or CR to the right. E.g. 100.50CR,
100.50-

EDTWRD

Sometimes we are not able to get the desire editing result by EDTCDE. In that case it is
better to go for EDTWRD.

In the EDTWRD parameter we specify the format matching the required data.

This keyword is valid only for numeric field (Specified with Y data type).

Chain

The CHAIN command does a SETLL and a READE in order to find a match. CHAIN is
best used to locate a unique record (like a customer record) from a full procedural file.

In case of CHAIN, the file operation is used to randomly retrieve a record from a file.

We cannot move to another record, which meets the same criteria specified in the Chain
operation. So the conclusion is we cannot read more number of records with the Chain
operation, if there are more number of records exists with the same criteria in the file.

The CHAIN operation applies a record lock to files that are open in update mode. To
avoid lock we use operator extender N.

The search argument must be the key or key list or relative record number.

If the corresponding record for the search argument is not found then the HI level
indicator gets turned on and if found gets turned OFF. %FOUND built-in function also
does the same thing by returning '0' if no record is found and 1 if a record is found.

To handle CHAIN exceptions (file status codes greater than 1000), either the operation
code extender 'E' or an error indicator at LO level can be used.

If the data-structure is specified in result field then the result of the operation is filled in
the data structure.

EXCEPT (rpgle) / EXCPT (rpg)

The EXCEPT opcode is used to write the exception records.

Exceptional records are defined at O-spec with E as record type.

Whatever exceptional fields have been defined inside the exception records will be
processed during the c-spec calculation.

If there are multiple entries for the same record name then they will be processed one by
one.

EXCEPT can be used for printing a report and to partially update a physical file.

ITER (Iterate)

It can be used in DO, DOU, DOUxx, DOW, DOWxx, and FOR loops to transfer control
immediately to a loop's ENDDO or ENDFOR statement.

It causes the next iteration of the loop to be executed immediately.

ITER affects the innermost loop

PLIST (Identify a Parameter List)

It is used to define a list of parameter that will be used for calling a program.

Using the Open Query File (OPNQRYF) command


The Open Query File (OPNQRYF) command is a CL command that allows you to perform many
data processing functions on database files. Essentially, the OPNQRYF command acts as a filter
between the processing program and the database records. The database file can be a physical or
logical file. Unlike the Create Physical File (CRTPF) or Create Logical File (CRTLF)
commands, the OPNQRYF command creates only a temporary file for processing the data; it
does not create a permanent file.
The OPNQRYF command has functions similar to those in DDS, and the CRTPF and CRTLF
commands. DDS requires source statements and a separate step to create the file. OPNQRYF
allows a dynamic definition without using DDS. The OPNQRYF command does not support all
of the DDS functions, but it supports significant functions that go beyond the capabilities of
DDS. In addition, Query for iSeries can be used to perform some of the function the
OPNQRYF command performs. However, the OPNQRYF command is more useful as a
programmer's tool.
The OPNQRYF command parameters also have many functions similar to the SQL SELECT
statements. For example, the FILE parameter is similar to the SQL FROM statement, the

QRYSLT parameter is similar to the SQL WHERE statement, the GRPFLD parameter is similar
to the SQL GROUP BY statement, and the GRPSLT parameter is similar to the SQL HAVING
statement.
The following is a list of the major functions supplied by OPNQRYF.

Dynamic record selection

Dynamic keyed sequence access path

Dynamic keyed sequence access path over a join

Dynamic join

Handling missing records in secondary join files

Unique-key processing

Mapped field definitions

Group processing

Final total-only processing

Improving performance

Open Query Identifier (ID)

Sort sequence processing

CL program coding with the OPNQRYF command

The Open Query File (OPNQRYF) command has three basic rules that can prevent coding
errors.
1. Specify selection fields from a database file without an ampersand (&). Fields
declared in the CL program with DCL or DCLF require the ampersand.
2. Enclose fields defined in the CL program with DCL or DCLF within single
quotes ('&testfld', for example).
3. Enclose all parameter comparisons within double quotes when compared to
character fields, single quotes when compared to numeric fields.

In the following example, the fields INVCUS and INVPRD are defined as character data:

QRYSLT('INVCUS *EQ "' *CAT &K1CUST *CAT '" *AND +


INVPRD *GE "' *CAT &LPRD *CAT '" *AND +
INVPRD *LE "' *CAT &HPRD *CAT '"')

If the fields were defined numeric data, the QRYSLT parameter could look like the following:
QRYSLT('INVCUS *EQ ' *CAT &K1CUST *CAT ' *AND +
INVPRD *GE ' *CAT &LPRD *CAT ' *AND +
INVPRD *LE ' *CAT &HPRD *CAT ' ')
Example 1: Selecting records using the Open Query File (OPNQRYF) command

This example shows how to select records with a specific value using the Open Query File
(OPNQRYF) command.
Assume that you want to select all the records from FILEA where the value of the
Code field is D. Your processing program is PGMB. PGMB only sees the records that
meet the selection value (you do not have to test in your program).
Note: You can specify parameters easier by using the prompt function for the
OPNQRYF command. For example, you can specify an expression for the QRYSLT
parameter without the surrounding delimiters because the system will add the
single quotation marks.
Specify the following parameters:
OVRDBF
OPNQRYF
CALL
CLOF
DLTOVR

FILE(FILEA) SHARE(*YES)
FILE(FILEA) QRYSLT('CODE *EQ "D" ')
PGM(PGMB)
OPNID(FILEA)
FILE(FILEA)

Logical file Versus OPNQRYF

The main thing to understand is that a logical file is a persistent object and OPNQRYF is
not. Therefore a logical file almost always (depending on your AS400 setup) will have
usable access path to sort the records. i.e. access path will be permanent for a logical file.

An OPNQRYF will always need to determine what access path to use based on the sort
order and filtering set in the command call. If an access plan exists that it can use it will,
otherwise it will copy the data and do what is called a table scan to find the records.

Since a LF is a persistent object it will incur persistent storage needs which will also
affect overall system performance.

If you are always going the same sort order and sequence again and again, then a LF is
the best way to go, because it will be almost a readily available access path. Now if you
need a multiple sort order and random filtering, then maybe you should use OPNQRYF,
but performance will be an issue.

Another aspect to consider is interactive updating. Persistent Access paths need to


frequently update to be useful. Typically the best time for this to happen is when a record
gets added or updated. This of course affects performance, especially wit

The quick and simple file is that the logical file will already have the index built and therefore
has a speed advantage over OPNQRYF which has to build the index before it can be used. The
down side to the LF is that it takes up space on the disk.
The primary advantage of the OPNQRYF over logical files is the flexibility of being able to
create indexes on the fly as and when needed.
The decision of which to use usually depends on the number of records in the physical and the
frequency of use of the index.

Message Queues
When a message is sent to a procedure, a program, or a system user, it is placed
on a message queue associated with that procedure, program, or user. The
procedure, program, or user sees the message by receiving it from the queue.
OS/400 provides message queues for:
Each workstation on the system
Each user enrolled on the system
The system operator
The system history log
Additional message queues can be created to meet any special application requirements. Messages sent to
message queues are kept, so the receiver of the
message does not need to process the message immediately.

Q1) Name the divisions in a COBOL program ?.


A1) IDENTIFICATION DIVISION, ENVIRONMENT DIVISION, DATA DIVISION,
PROCEDURE DIVISION.
Q2) What are the different data types available in COBOL?
A2) Alpha-numeric (X), alphabetic (A) and numeric (9).
Q3) What does the INITIALIZE verb do? - GS

A3) Alphabetic, Alphanumeric fields & alphanumeric edited items are set to SPACES.
Numeric, Numeric edited items set to ZERO. FILLER , OCCURS DEPENDING ON items
left untouched.
Q4) What is 77 level used for ?
A4) Elementary level item. Cannot be subdivisions of other items (cannot be qualified), nor
can they be subdivided themselves.
Q5) What is 88 level used for ?
A5) For condition names.
Q6) What is level 66 used for ?
A6) For RENAMES clause.
Q7) What does the IS NUMERIC clause establish ?
A7) IS NUMERIC can be used on alphanumeric items, signed numeric & packed decimal
items and unsigned 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 - .
Q8) How do you define a table/array in COBOL?
A8) ARRAYS.
05 ARRAY1
PIC X(9) OCCURS 10 TIMES.
05 ARRAY2
PIC X(6) OCCURS 20 TIMES INDEXED BY WS-INDEX.
Q9) Can the OCCURS clause be at the 01 level?
A9) No.
Q10) What is the difference between index and subscript? - GS
A10) 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.
Q11) What is the difference between SEARCH and SEARCH ALL? - GS
A11) 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.
Q12) What should be the sorting order for SEARCH ALL? - GS
A12) 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).

Q13) What is binary search?


A13) 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.
Q14) 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?
A14) Must use compiler option SSRANGE if you want array bounds checking. Default is
NOSSRANGE.
Q15) How do you sort in a COBOL program? Give sort file definition, sort statement
syntax and meaning. - GS
A15) 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 (work) file 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 out file 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.
Q16) How do you define a sort file in JCL that runs the COBOL program?
A16) 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.
Q17) What is the difference between performing a SECTION and a PARAGRAPH? - GS
A17) 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.
Q18) What is the use of EVALUATE statement? - GS

A18) 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.
Q19) What are the different forms of EVALUATE statement?
A19)
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
WHEN 100 ALSO TRUE
imperative stmt
WHEN -305 ALSO FALSE
imperative stmt
END-EVALUATE

EVALUATE SQLCODE ALSO TRUE


WHEN 100 ALSO A=B
imperative stmt
WHEN -305 ALSO (A/C=4)
imperative stmt
END-EVALUATE

Q20) How do you come out of an EVALUATE statement? - GS


A20) 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.
Q21) In an EVALUATE statement, can I give a complex condition on a when clause?
A21) Yes.
Q22) What is a scope terminator? Give examples.
A22) Scope terminator is used to mark the end of a verb e.g. EVALUATE, ENDEVALUATE; IF, END-IF.
Q23) How do you do in-line PERFORM? - GS
A23) PERFORM ... <UNTIL> ...
<sentences>
END-PERFORM
Q24) When would you use in-line perform?
A24) 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 Para name rather than in-line perform.


Q25) What is the difference between CONTINUE & NEXT SENTENCE ?
A25) They appear to be similar, that is, the control goes to the next sentence in the
paragraph. But, Next Sentence would
take the control to the sentence after it finds a full stop (.). Check out by writing the
following code example, one if
sentence followed by 3 display statements (sorry they appear one line here because of
formatting restrictions) If 1 > 0
then next sentence end if display 'line 1' display 'line 2'. display 'line 3'. *** Note- there is a
dot (.) only at the end of
the last 2 statements, see the effect by replacing Next Sentence with Continue ***
Q26) What does EXIT do ?
A26) Does nothing ! If used, must be the only sentence within a paragraph.
Q27) Can I redefine an X(100) field with a field of X(200)?
A27) 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.
A28) Can I redefine an X(200) field with a field of X(100) ?
Q31)1 Yes.
Q31)2 What do you do to resolve SOC-7 error? - GS
Q31) 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 installation might have
batch program debugging
tools. Use them.
Q32) How is sign stored in Packed Decimal fields and Zoned Decimal fields?

Q32) 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.
Q33) How is sign stored in a comp-3 field? - GS
Q33) 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...
Q34) How is sign stored in a COMP field ? - GS
Q34) In the most significant bit. Bit is ON if -ve, OFF if +ve.
Q35) What is the difference between COMP & COMP-3 ?
Q35) COMP is a binary storage format while COMP-3 is packed decimal format.
Q36) What is COMP-1? COMP-2?
Q36) COMP-1 - Single precision floating point. Uses 4 bytes.
COMP-2 - Double precision floating point. Uses 8 bytes.
Q37) How do you define a variable of COMP-1? COMP-2?
Q37) No picture clause to be given. Example 01 WS-VAR USAGE COMP-1.
Q38) How many bytes does a S9(7) COMP-3 field occupy ?
Q38) 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.
Q39) How many bytes does a S9(7) SIGN TRAILING SEPARATE field occupy ?
Q39) Will occupy 8 bytes (one extra byte for sign).
Q40) How many bytes will a S9(8) COMP field occupy ?
Q40) 4 bytes.
Q41) What is the maximum value that can be stored in S9(8) COMP?
Q41) 99999999
Q42) What is COMP SYNC?
Q42) 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.
Q43) What is the maximum size of a 01 level item in COBOL I? in COBOL II?
Q43) In COBOL II: 16777215
Q44) How do you reference the following file formats from COBOL programs:
Q44)
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).
Q45) What are different file OPEN modes available in COBOL?
Q45) Open for INPUT, OUTPUT, I-O, EXTEND.
Q46) What is the mode in which you will OPEN a file for writing? - GS
Q46) OUTPUT, EXTEND
Q47) In the JCL, how do you define the files referred to in a subroutine ?
Q47) Supply the DD cards just as you would for files referred to in the main program.
Q48) Can you REWRITE a record in an ESDS file? Can you DELETE a record from it?

Q48) Can rewrite (record length must be same), but not delete.
Q49) What is file status 92? - GS
Q49) Logic error. e.g., a file is opened for input and an attempt is made to write to it.
Q50) What is file status 39 ?
Q50) 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.
Q51) What is Static and Dynamic linking ?
Q51) 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.
Q52) What is AMODE(24), AMODE(31), RMODE(24) and RMODE(ANY)? (applicable
to only MVS/ESA
Enterprise Server).
Q52) These are compile/link edit options. Basically AMODE stands for Addressing mode and
RMODE for 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.
Q53) What compiler option would you use for dynamic linking?
Q53) DYNAM.
Q54) What is SSRANGE, NOSSRANGE ?
Q54) These are compiler options with respect to 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.
Q55) How do you set a return code to the JCL from a COBOL program?
Q55) Move a value to RETURN-CODE register. RETURN-CODE should not be declared
in your program.

Q56) How can you submit a job from COBOL programs?


Q56) 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.
Q57) What are the differences between OS VS COBOL and VS COBOL II?
Q57) 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.
I. Report writer is supported only in OS/VS Cobol.
II. USAGE IS POINTER is supported only in VS COBOL II.
III. Reference modification e.g.: WS-VAR(1:2) is supported only in VS COBOL II.
IV. EVALUATE is supported only in VS COBOL II.
V. Scope terminators are supported only in VS COBOL II.
VI. OS/VS Cobol follows ANSI 74 stds while VS COBOL II follows ANSI 85
stds.
VII. Under CICS Calls between VS COBOL II programs are supported.
Q58) What are the steps you go through while creating a COBOL program executable?
Q58) DB2 precompiler (if embedded SQL used), CICS translator (if CICS pgm), Cobol
compiler, Link editor. If DB2
program, create plan by binding the DBRMs.
Q59) Can you call an OS VS COBOL pgm from a VS COBOL II pgm ?
Q59) In non-CICS environment, it is possible. In CICS, this is not possible.
Q60) What are the differences between COBOL and COBOL II?
A60) There are at least five differences:
COBOL II supports structured programming by using in line Performs and explicit scope
terminators, It introduces
new features (EVALUATE, SET. TO TRUE, CALL. BY CONTEXT, etc) It permits
programs to be loaded and
addressed above the 16-megabyte line It does not support many old features (READY
TRACE, REPORT-WRITER,
ISAM, Etc.), and It offers enhanced CICS support.
Q61) What is an explicit scope terminator?
A61) A scope terminator brackets its preceding verb, e.g. IF .. END-IF, so that all
statements between the verb and its scope terminator are grouped together. Other common
COBOL II verbs are READ, PERFORM, EVALUATE, SEARCH and STRING.
Q62) What is an in line PERFORM? When would you use it? Anything else to say about
it?

A62) The PERFORM and END-PERFORM statements bracket all COBOL II statements
between them. The COBOL equivalent is to PERFORM or PERFORM THRU a
paragraph. In line PERFORMs work as long as there are no internal GO TOs, not even to
an exit. The in line PERFORM for readability should not exceed a page length - often it
will reference other PERFORM paragraphs.
Q63) What is the difference between NEXT SENTENCE and CONTINUE?
A63) NEXT SENTENCE gives control to the verb following the next period.
CONTINUE gives control to the next verb after the explicit scope terminator. (This is not
one of COBOL II's finer implementations). It's safest to use CONTINUE rather than
NEXT SENTENCE in COBOL II.
Q64) What COBOL construct is the COBOL II EVALUATE meant to replace?
A64) EVALUATE can be used in place of the nested IF THEN ELSE statements.
Q65) What is the significance of 'above the line' and 'below the line'?
A65) Before IBM introduced MVS/XA architecture in the 1980's a program's virtual
storage was limited to 16 megs. Programs compiled with a 24 bit mode can only address 16
Mb of space, as though they were kept under an imaginary storage line. With COBOL II a
program compiled with a 31 bit mode can be 'above the 16 Mb line. (This 'below the line',
'above the line' imagery confuses most mainframe programmers, who tend to be a literal
minded group.)
Q66) What was removed from COBOL in the COBOL II implementation?
A66) Partial list: REMARKS, NOMINAL KEY, PAGE-COUNTER, CURRENT-DAY,
TIME-OF-DAY, STATE, FLOW, COUNT, EXAMINE, EXHIBIT, READY TRACE and
RESET TRACE.
Q67) Explain call by context by comparing it to other calls.
A67) The parameters passed in a call by context are protected from modification by the
called program. In a normal call they are able to be modified.
Q68) What is the linkage section?
A68) The linkage section is part of a called program that 'links' or maps to data items in
the calling program's working storage. It is the part of the called program where these
share items are defined.
Q69) What is the difference between a subscript and an index in a table definition?
A69) A subscript is a working storage data definition item, typically a PIC (999) where a
value must be moved to the subscript and then incremented or decrements by ADD TO and
SUBTRACT FROM statements. An index is a register item that exists outside the
program's working storage. You SET an index to a value and SET it UP BY value and
DOWN BY value.
Q70) If you were passing a table via linkage, which is preferable - a subscript or an index?

A70) Wake up - you haven't been paying attention! It's not possible to pass an index via
linkage. The index is not part of the calling programs working storage. Those of us who've
made this mistake, appreciate the lesson more than others.
Q71) Explain the difference between an internal and an external sort, the pros and cons,
internal sort syntax etc.
A71) An external sort is not COBOL; it is performed through JCL and PGM=SORT. It is
understandable without any code reference. An internal sort can use two different syntaxs:
1.) USING, GIVING sorts are comparable to external sorts with no extra file processing;
2) INPUT PROCEDURE, OUTPUT PROCEDURE sorts allow for data manipulation
before and/or after the sort.
Q72) What is the difference between comp and comp-3 usage? Explain other COBOL
usages.
A72) Comp is a binary usage, while comp-3 indicates packed decimal. The other
common usages are binary and display. Display is the default.
Q73) When is a scope terminator mandatory?
A73) Scope terminators are mandatory for in-line PERFORMS and EVALUATE
statements. For readability, it's recommended coding practice to always make scope
terminators explicit.
Q74) In a COBOL II PERFORM statement, when is the conditional tested, before or after
the perform execution?
A74) In COBOL II the optional clause WITH TEST BEFORE or WITH TEST AFTER
can be added to all perform statements. By default the test is performed before the
perform.
Q75) In an EVALUTE statement is the order of the WHEN clauses significant?
A75) Absolutely. Evaluation of the WHEN clauses proceeds from top to bottom and their
sequence can determine results.
Q76) What is the default value(s) for an INITIALIZE and what keyword allows for an
override of the default.
A76) INITIALIZE moves spaces to alphabetic fields and zeros to alphanumeric fields.
The REPLACING option can be used to override these defaults.
Q77) What is SET TO TRUE all about, anyway?
A77) In COBOL II the 88 levels can be set rather than moving their associated values to
the related data item. (Web note: This change is not one of COBOL II's better
specifications.)
Q78) What is LENGTH in COBOL II?
A78) LENGTH acts like a special register to tell the length of a group or elementary item.

Q79) What is the difference between a binary search and a sequential search? What are the
pertinent COBOL
commands?
A79) In a binary search the table element key values must be in ascending or descending
sequence. The table is 'halved' to search for equal to, greater than or less than conditions
until the element is found. In a sequential search the table is searched from top to bottom,
so (ironically) the elements do not have to be in a specific sequence. The binary search is
much faster for larger tables, while sequential works well with smaller ones. SEARCH
ALL is used for binary searches; SEARCH for sequential.
Q80) What is the point of the REPLACING option of a copy statement?
A80) REPLACING allows for the same copy to be used more than once in the same code
by changing the replace value.
Q81) What will happen if you code GO BACK instead of STOP RUN in a stand alone
COBOL program i.e. a
program which is not calling any other program.
A81) The program will go in an infinite loop.
Q82) How can I tell if a module is being called DYNAMICALLY or STATICALLY?
A82) The ONLY way is to look at the output of the linkage editor (IEWL)or the load
module itself. If the module is being called DYNAMICALLY then it will not exist in the
main module, if it is being called STATICALLY then it will be seen in the load module.
Calling a working storage variable, containing a program name, does not make a
DYNAMIC call. This type of calling is known as IMPLICITE calling as the name of the
module is implied by the contents of the working storage variable. Calling a program name
literal (CALL
Q83) What is the difference between a DYNAMIC and STATIC call in COBOL.
A83) To correct an earlier answer: All called modules cannot run standalone if they
require program variables passed to them via the LINKAGE section. DYNAMICally
called modules are those that are not bound with the calling program at link edit time
(IEWL for IBM) and so are loaded from the program library (joblib or steplib) associated
with the job. For DYNAMIC calling of a module the DYNAM compiler option must be
chosen, else the linkage editor will not generate an executable as it will expect u address
resolution of all called modules. A STATICally called module is one that is bound with the
calling module at link edit, and therefore becomes part of the executable load module.
Q84) How may divisions are there in JCL-COBOL?
A84) SIX
Q85) What is the purpose of Identification Division?
A85) Documentation.
Q86) What is the difference between PIC 9.99 and 9v99?

A86) PIC 9.99 is a FOUR-POSITION field that actually contains a decimal point where
as PIC 9v99 is THREE- POSITION numeric field with implied or assumed decimal
position.
Q87) what is Pic 9v99 Indicates?
A87) PICTURE 9v99 is a three position Numeric field with an implied or assumed
decimal point after the first position; the v means an implied decimal point.
Q88)
A88)
1)
2)
3)
4)

What guidelines should be followed to write a structured Cobol prg'm?


use 'evaluate' stmt for constructing cases.
use scope terminators for nesting.
use in line perform stmt for writing 'do ' constructions.
use test before and test after in the perform stmt for writing do-while constructions.

Q89) Read the following code. 01 ws-n pic 9(2) value zero. a-para move 5 to ws-n. perform
b-para ws-n times. b-para.
move 10 to ws-n. how many times will b-para be executed ?
A89) 5 times only. it will not take the value 10 that is initialized in the loop.
Q90) What is the difference between SEARCH and SEARCH ALL? What is more efficient?
A90) SEARCH is a sequential search from the beginning of the table. SEARCH ALL is a
binary search, continually dividing the table in two halves until a match is found. SEARCH
ALL is more efficient for tables larger than 70 items.
Q91) What are some examples of command terminators?
A91) END-IF, END-EVALUATE
Q92) What care has to be taken to force program to execute above 16 Meg line?
A92) Make sure that link option is AMODE=31 and RMODE=ANY. Compile option
should never have SIZE(MAX). BUFSIZE can be 2K, efficient enough.
Q93) How do you submit JCL via a Cobol program?
A93) Use a file //dd1 DD sysout=(*, intrdr)write your JCL to this file. Pl some on try this
out.
Q94) How to execute a set of JCL statements from a COBOL program
A94) Using EXEC CICS SPOOL WRITE(var-name) END-EXEC command. var-name is
a COBOL host structure containing JCL statements.
Q95) Give some advantages of REDEFINES clause.
A95)
1. You can REDEFINE a Variable from one PICTURE class to another PICTURE
class by using the same memory
location.
2. By REDEFINES we can INITIALISE the variable in WORKING-STORAGE
Section itself.

3. We can REDEFINE a Single Variable into so many sub variables. (This facility is
very useful in solving Y2000
Problem.)
Q96) What is the difference between static call & Dynamic call
A96) In the case of Static call, the called program is a stand-alone 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 through the
called program
Q97) What do you feel makes a good program?
A97) 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.
Q98) How do you code Cobol to access a parameter that has been defined in JCL? And do
you code the PARM
parameter on the EXEC line in JCL?
A98)
1) using JCL with sysin. //sysin dd *here u code the parameters(value) to pass in to
cobol program /* and in program
you use accept variable name(one accept will read one row)/.another way.
2) in jcl using parm statement ex: in exec statement parm='john','david' in cobol pgm
u have to code linkage section in that for first value you code length variable and
variable name say, abc pic x(4).it will take john inside to read next value u have to code
another variable in the same way above mentioned.
Q99) Why do we code S9(4) comp. Inspite of knowing comp-3 will occupy less space.
A99) Here s9(4)comp is small integer ,so two words equal to 1 byte so totally it will
occupy 2 bytes(4 words).here in s9(4) comp-3 as one word is equal to 1/2 byte.4 words
equal to 2 bytes and sign will occupy 1/2 byte so totally it will occupy 3 bytes.
Q100) The maximum number of dimensions that an array can have in COBOL-85 is
----------- ?
A100) SEVEN in COBOL - 85 and THREE in COBOL - 84
Q101) How do you declare a host variable (in COBOL) for an attribute named Emp-Name
of type VARCHAR(25) ?
A101)
01 EMP-GRP.
49 E-LEN PIC S9(4) COMP.
49 E-NAME PIC X(25).
Q102)
A102)

What is Comm?
COMM - HALF WORD BINARY

Q103) Differentiate COBOL and COBOL-II. (Most of our programs are written in
COBOLII, so, it is good to know,
how, this is different from COBOL)
A103) The following features are available with VS COBOL II:
1. MVS/XA and MVS/ESA support The compiler and the object programs it produces
can be run in either
24- or 31-bit addressing mode.
2. VM/XA and VM/ESA support The compiler and the object programs it produces can
be run in either
24- or 31-bit addressing mode.
3. VSE/ESA support The compiler and the object programs it produces can be run
under VSE/ESA.
Q104)

What is PERFORM ? What is VARYING ? (More details about these clauses)


A104)
The PERFORM statement is a PROCEDURE DIVISION statement which
transfers control to one or more specified procedures and controls as specified the
number of times the procedures are executed. After execution of the specified procedures
is completed (i.e., for the appropriate number of times or until some specified
condition is met), control is transferred to the next executable statement following
the PERFORM statement. There are 5 types of PERFORM statements:
a)

Basic PERFORM

b)
c)
d)
e)

PERFORM TIMES
PERFORM UNTIL
PERFORM VARYING
IN-LINE PERFORM

Q105) How many sections are there in data division?.


A105) SIX SECTIONS 1.FILE SECTION 2.WORKING-STORAGE SECTION 3.
LOCAL-STORAGE SECTION 4.SCREEN SECTION 5.REPORT SECTION 6.
LINKAGE SECTION
Q106) What is Redefines clause?
A106) Redefines clause is used to allow the same storage allocation to be referenced by
different data names .
Q107)
A107)

How many bytes does a s9(4)comp-3 field occupy?


3Bytes (formula : n/2 + 1))

Q108) What is the different between index and subscript?


A108) Subscript refers to the array of occurrence , where as Index represents an
occurrence of a table element. An index can only modified using perform, search & set.
Need to have an index for a table in order to use SEARCH and SEARCH All.

Q109) What is the difference between Structured COBOL Programming and Object Oriented
COBOL
programming?
A109) Structured programming is a Logical way of programming, you divide the
functionalities into modules and code logically. OOP is a Natural way of programming;
you identify the objects first, and then write functions, procedures around the objects.
Sorry, this may not be an adequate answer, but they are two different programming
paradigms, which is difficult to put in a sentence or two.
Q110) What divisions, sections and paragraphs are mandatory for a COBOL program?
A110) IDENTIFICATION DIVISION and PROGRAM-ID paragraph are mandatory for a
compilation error free COBOL
program.
Q111)
A111)

Can JUSTIFIED be used for all the data types?


No, it can be used only with alphabetic and alphanumeric data types.

Q112) What happens when we move a comp-3 field to an edited (say z (9). ZZ-)
A112) the editing characters r to be used with data items with usage clause as display
which is the default. When u tries displaying a data item with usage as computational it
does not give the desired display format because the data item is stored as packed
decimal. So if u want this particular data item to be edited u have to move it into a data
item whose usage is display and then have that particular data item edited in the format
desired.
Q113) What will happen if you code GO BACK instead of STOP RUN in a standalone COBOL program i.e. a program which is not calling any other program ?
A113) Both give the same results when a program is not calling any other program.
GO BACK will give the control to the system even though it is a single program.
Q114) what is the difference between external and global variables?
A114) Global variables are accessible only to the batch program whereas external
variables can be referenced from any batch program residing in the same system library.
Q115) You are writing report program with 4 levels of totals: city, state, region and
country. The codes being used can be the same over the different levels, meaning a city
code of 01 can be in any number of states, and the same applies to state and region code
so how do you do your checking for breaks and how do you do add to each level?
A115) Always compare on the highest-level first, because if you have a break at a
highest level, each level beneath it must also break. Add to the lowest level for each
record but add to the higher level only on a break.
Q116)

What is difference between COBOL and VS COBOL II?.

A116) In using COBOL on PC we have only flat files and the programs can access
only limited storage, whereas in VS COBOL II on M/F the programs can access up to
16MB or 2GB depending on the addressing and can use VSAM
files to make I/O operations faster.
Q117) Why occurs can not be used in 01 level ?
A117) Because, Occurs clause is there to repeat fields with same format, not the
records.
Q118)
A118)

What is report-item?
A Report-Item Is A Field To Be Printed That Contains Edit Symbols

Q119) Difference between next and continue clause


A119) The difference between the next and continue verb is that in the continue verb it
is used for a situation where there in no EOF condition that is the records are to be
accessed again and again in an file, whereas in the next verb the indexed file is accessed
sequentially, read next record command is used.
Q120) What is the Importance of GLOBAL clause According to new standards of
COBOL
A120) When any data name, file-name, Record-name, condition name or Index defined
in an Including Program can be referenced by a directly or indirectly in an included
program, Provided the said name has been declared to be a global name by GLOBAL
Format of Global Clause is01 data-1 pic 9(5) IS GLOBAL.
Q121) What is the Purpose of POINTER Phrase in STRING command
A121) The Purpose of POINTER phrase is to specify the leftmost position within
receiving field where the first transferred character will be stored
Q122)
A122)

How do we get current date from system with century?


By using Intrinsic function, FUNCTION CURRENT-DATE

Q123)
A123)

What is the maximum length of a field you can define using COMP-3?
10 Bytes (S9(18) COMP-3).

Q124) Why do we code s9 (4) comp? In spite of knowing comp-3 will occupy less
space?
A124) Here s9(4)comp is small integer, so two words equal to 1 byte so totally it will
occupy 2 bytes(4 words).here in s9(4) comp-3 as one word is equal to 1/2 byte.4 words
equal to 2 bytes and sign will occupy 1/2
byte so totally it will occupy 3 bytes.
Q125) What is the LINKAGE SECTION used for?
A125) The linkage section is used to pass data from one program to another program
or to pass data from a PROC to a program.
Q126)

Describe the difference between subscripting and indexing ?

A126)

Indexing uses binary displacement. Subscripts use the value of the occurrence.