Interview Questions & Answers
Interview Questions & Answers
In 3 modes we can access our COBOL files i.e. Sequential(PS file), Random/
Dynamic(VSAM – KSDS)
In COBOL, you can open a file in four main modes: INPUT, OUTPUT, I-O, and EXTEND.
INPUT- Used to read records from an existing file. READ - The file pointer is set to the
beginning of the file, and you can only read records sequentially.
OUTPUT- Used to create a new file or write new records to an empty one. WRITE-
If a file with the same name already exists, all existing records are deleted before any new
records are written. A new file is created if it does not exist.
I-O- Used for both input and output operations, allowing records to be read and rewritten.
READ, REWRITE, DELETE-
Allows you to update records in place. The file must already exist to be opened in I-O mode.
EXTEND- Used to add new records to the end of an existing sequential file. WRITE-
This mode opens the file and positions the pointer at the end of the last existing record, so
new data is appended without deleting old records. This mode is only for sequential files.
What is the mode in which you will OPEN a file for writing?
In COBOL, the MOVE statement is used to copy data from one storage area to another.
2. Group move
A group move transfers data between group-level items as if they were a single alphanumeric
string.
EX: - MOVE WS-GRP1 TO WS-GRP2
EX: - If both WS-DATE-MDY and WS-DATE-DMY have elementary items named WS-
DATE-MM, WS-DATE-DD, and WS-DATE-YYYY, the statement MOVE CORR WS-
DATE-MDY TO WS-DATE-DMY will move data only between those matching pairs,
regardless of their order in the group.
4. Reference Modification move
Reference modification allows you to move a specific portion of a data item, acting like a
substring. This is useful for manipulating specific parts of a string.
EX: - MOVE WS-PHONE-NBR(5:8) TO WS-FULL-PHN-NBR(5:8). This example copies 8
characters from WS-PHONE-NBR starting at position 5 into WS-FULL-PHN-NBR at the
same relative position.
By using repro command, we can load the data from PS file to VSAM file but before loading
we need to sort the key field inASC order and check no duplicates in it.
In DB2, both CHAR and VARCHAR are used to store character strings, but they differ
significantly in how they handle storage and length:
Char is the fixed length field where as varchar is variable length field. Both are used
for alphanumeric.
What is pre-compilation?
In our source program we have both DB2 and COBOL stuff. If we go for normal compilation
process, then our compiling utility program cannot understand DB2 stuff it will through
compilation errors because DB2 is not native to COBOL. So before going to compilation
process we need to go for pre-compilation
When a COBOL-DB2 program is precompiled, all the embedded SQL statements are
extracted and stored in a separate file called a DBRM (Database Request Module).
The DBRM is not executable. It simply contains the SQL statements in a format DB2 can
understand.
To make these SQL statements usable by DB2 at runtime, a bind process is required.
The bind process is typically performed using a utility like IKJEFT01, which runs under TSO
(Time Sharing Option).
During the bind, DB2 reads the SQL statements from the DBRM and:
Generates access paths for the SQL queries (i.e., how to access data efficiently based on
indexes, statistics, etc.).
Verifies that the tables and columns referenced in the SQL exist in the catalog.
Checks user authorization to ensure the user has permission to access or modify the
referenced tables or views.
To count the number of records in a file using COBOL, you typically read the file
sequentially and increment a counter variable for each record read until the end of the file is
reached.
1. Explain difference between positional & keyword parameters or what is JOB card
in JCL?
TYPRUN=SCAN is specified keyword parameter which is used at JOB card level which
is used to scan the entire JCL before I actually submit a JOB.
If there are any syntax errors so that syntax errors will be rooted to the JESYSMSG. So,
based on the messages that has been displayed in JESYSMSGS I’ll go back to correct it
and rescan it and recheck it. So, if I don’t see any JESYSMSGS in the spool that means
submitted JOB queue so that means my JCL is ready to submit JCL.
SB37- Abend occurs when the specified primary & secondary space is not enough.
SD37- When secondary space is not specified.
SE37- Same like SB37, primary & secondary is not enough, but occurs in case of PDS.
Mod in Disp parameter is used to allocate dynamic ds if they don't exist, they just append
data at the end
11. HOW CAN U SAVE THE LOG DETAILS OF A JOB, AFTER THE EXECUTION
OF A JOB.
Type the command XDC before the name in the spool and hit enter, then it will give
the dataset where the output is saved for future verification by the client.
Step1:Use the command XDC before the job name is enter
Step1:Give the dataset name (LRECL=133,RECFM=VB)
NOTE: Whenever we go for XDC, the dataset has to be created with LRECL=133,
RECFM=VB.
12. HOW CAN U RESTART A PROC FROM JCL.
14. HOW CAN U PASS THE DATA FROM JCL TO COBOL PROGRAMME.
There are two ways,
1. PARM:
Used to pass data from JCL to COBOL. Maximum length is 100 CHAR.
2. SYSIN DD *:
Used to pass the data more than 100 bytes.
JCL
//JOBCARD
//S1 EXEC PGM=IEFBR14,PARM="4-1-2012"
COBOL
LINKAGE SECTION
01 LS-PARM
49 LS-PARM-LEN PIC S9(4) COMP.
49 LS-PARM-TEXT PIC X(100).
PROCEDURE DIVISION UISING LS-PARM
DISPLAY LS-PARM-TEXT.
15. WHAT IS THE LENGTH OF PARM PARAMETER.
100 bytes
16. STEP1
STEP2
; HOW U WILL EXECUTE STEP3 ONLY.
;
STEP5
In the job card, RESTART=STEP3, COND=(0,LE). Then the 3rd step will be
executed, and the remaining steps will be checked with condition. When the condition is true,
the remaining steps will be bypassed.
17. I WANT TO RUN STEP3 EVEN THE JOB IS GIVING ABEND CODE.
COND=EVEN on STEP3. This will execute the 3rd step. Even the previous step
executed successfully or unsuccessfully.
18. WHAT IS [Link] U WILL CREATE GDG.
Generation data group(GDG) is a group of datasets where all the datasets are related
to each other functionally or chronologically. The datasets in the GDG are called generations.
CREATION OF GDG:
//JOB001AB JOB NOTIFY=&SYSUID
//STEP1 EXEC PGM=IDCAMS
//SYSIN DD *
DEFINE GDG(NAME([Link])-
LIMIT(5)-
NOEMPTY/EMPTY-
NOSCRATCH/SCRATCH)
/*
//SYSOUT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//
19. HOW DO U CREATE GDG BASE.
//JOB001AB JOB NOTIFY=&SYSUID
//STEP1 EXEC PGM=IDCAMS
//SYSIN DD *
DEFINE GDG(NAME([Link])-
LIMIT(5)-
NOEMPTY-
SCRATCH)
/*
//SYSOUT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//
20. WHAT ARE THE DISP PARAMETERS.
DISP=(STATUS,NORMAL,ABNORMAL)
1. STATUS:
A. NEW: Dataset does not exist. It will be created in this step.
B. SHR: Dataset already exist and can be shared.
C. OLD: Dataset already exist but can’t be shared.
D. MOD: If the dataset does not exist, it is to be created. If already exist, records are to
be added to the end of the dataset.
2. NORMAL TERMINATION:
A. CATLG: The dataset has to be catalogued.
B. DELETE: Dataset is no longer required.
C. PASS: Dataset is passed to subsequent steps in the same job and each step can use the
dataset only once.
D. KEEP: Dataset is to be kept on volume.
E. UNCATLG: System is to delete the catalog entry.
3. ABNORMAL TERMINATION.
A. CATLG: The dataset has to be catalogued.
B. DELETE: Dataset is no longer required.
C. KEEP: Dataset is to be kept on volume.
D. UNCATLG: System is to delete the catalog entry.
PASS is not allowed here.
21. CAN WE OVERRIDE THE CONDITION IN JCL.
Using EXEC, we can. COND value of an EXEC statement in the procedure can be
added/modified/nullified in the invoking JCL in the following way.
//STEP1 EXEC PROC, [Link]-IN-PROC=NEW-VALUE
22. DCB=(LRECL=80,RECFM=FB,BLKSIZE=0) HERE WE CAN SEE THE
OUTPUT WHEN UR TRYING TO COPY THE DATA FROM INPUT FILE TO
OUTPUT FILE.
The dataset can be created with BLKSIZE=0, and we can use it as a output dataset.
But the dataset cannot be readed(i.e. we can’t use it as a input).
23. IN DISP=(____,_____,____) AFTER SUCCESSFUL COMPILATION IF THE JOB
ABENDS ALSO,I HAVE TO SEE THE OUTPUT IN THE OUTPUT FILE,FOR
THAT WHAT WE HAVE TO CODE IN DISP.
DISP=(NEW,CATLG,CATLG)
3. KEYWORD PARAMETERS :
Keyword parameters are those, which can appear in any order. They are identified by
writing the keyword. The following keyword parameters are important for the JOB
statement.
CLASS, PRTY, MSGCLASS, MSGLEVEL, TYPRUN, NOTIFY, RESTART.
CLASS: A CLASS parameter categorizes the JOB based on the factors like CPU
consumption time and CPU resource utilization etc.
CLASS parameter has a range of values A-Z, 0-9.
JOBS submitted with in the same class parameter will be queued and jobs executed
one after the other. JOBS submitted with the different class parameter will be in a
separate queue and are executed simultaneously with the other class jobs.
PRTY: It specifies the priority to a job execution. ‘PRTY’ has a range of values ‘0-15’
Highest priority value ,the first preference it given for execution, if priority low then
execution is also low.
1. When two jobs are submitted, the job which is submitted first will be executed first.
2. If the jobs are submitted at the same time then based on the CLASS parameter the
jobs will be executed.
3. If the jobs are submitted with same CLASS parameter and at the same time then the
job is executed based on the ‘PRTY’ parameter.
4. If jobs are submitted with same CLASS parameter with same priority and at the same
time then they are kept under wait and after the wait time the operator cancels the job.
MSGCLASS:
It specifies the output device to which messages are sent. It has the range of values
A-Z, 0-9.
MSGCLASS = A printer
= X spool
= 0 tool1
= 1 tool2
MSGLEVEL:
It specifies the ‘type’ of messages to send and ‘when’ those messages have to be
send.
MESLEVEL = (Statements, Messages)
Statements: -- Type of messages
0 only job related messages
1 all JCL related messages includes PROCS and system messages
2 all JCL related messages excluding PROCS and system messages
Messages: -- when messages have to be sent.
0 upon successful execution of JOB
1 upon successful or unsuccessful execution of JOB
Default: -- MSGLEVEL = (1,1)
NOTIFY:
It specifies the user id to which the notification about the successful or unsuccessful
execution of the JOB is sent. Because of the “NOTIFY=&SYSUID” we are getting the
‘MAXCC=?’ value for that particular ‘SYSUID’.
NOTIFY = &SYSUID will substitute the user-id with which the user has been logged
in and so the notifications has send to same user-id.
If we specify a different user-id (NOTIFY=USER ID) then notifications will be sent
to this user-id, but the spool remains with the user-id.
REGION:
It specifies the amount of work space required for a job or step execution.
REGION must be specified in ODB quantities in Kilo or Mega bytes
The mega region space can be allocating by specifying REGION= 0K or 0M.
Note: -- If the specified Region space is enough then job will abend with S106.
TIME:
It specifies the maximum time allocated for a job or step execution.
Syntax:-- TIME = (Minutes ,Seconds)
=(10,10)
Note:-- Maximum time can be allocated by using
TIME = 1440 Hrs.
= 248 days
= NOLIMIT (or) MAX
TYPERUN:
It tells the system what needs to be done to the JOB.
1. “TYPERUN=SCAN”
It checks JCL syntax errors or compile JCL.
2. “TYPERUN=HOLD”
It checks JCL syntax errors but keeps the JOB on HOLD without
executing it. To release the JOB on hold specify the line command ‘a’ beside
the job name.
3. “TYPERUN=COPY”
It copies the JOB to particular location.
RESTART:
It is used to start the execution of the JOB from a particular step
// JOB1 JOB…………RESTART=STEP3.
// STEP1 EXEC PGM=PGM1
------------
-------------
// STEP2 EXEC PGM=PGM2
// STEP3 EXEC PGM=PGM3
28. HOW CAN PASS THE DATA FROM JCL TO COBOL,WHERE WE CAN
DECLARE IN COBOL.
There are two ways,
1. PARM:
Used to pass data from JCL to COBOL. Maximum length is 100 CHAR.
2. SYSIN DD *:
Used to pass the data more than 100 bytes.
29. INSTREAM PROCEDURES & CATALOGUE PROCEDURE.
PROCEDURE: Set of reusable executable JCL statements. There are two procedures.
1. INSTREAM PROCEDURE:
- Present inside the same job stream.
- The statements between PROC and PEND will be considered as a instream
procedure.
- This procedure can be executed maximum of 15 times within a JOB.
2. CATALOG PROCEDURE:
- will be present in another PDS.
- this procedure can be called by JCLLIB ORDER
- can be executed ‘n’ no of time.
30. DIFFERENCE BETWEEN STEPLIB & JOBLIB.
In Mainframe, there are three types of libraries.
1. system library([Link]): we don’t need any JOBLIB/STEPLIB to
call/execute the program like IEFBR14, IEBGENER,..(UTILITIES)
designed by IBM.
2. private/user library: we have to generate a load library where the program
can be called and executed.
3. temporary library: dataset will get deleted once it reaches the expiry date.
To execute the programs presented in Private or User library, temporary library, we
should use JOBLIB/STEPLIB.
JOBLIB: valid for all the steps in the job.
STEPLIB: valid only for the particular step where it is coded.
If both are coded, then steplib will override the joblib.
ANS:
In mainftame there are three lib
(i) SYSLIB([Link])
(ii) USER/PRIVATE LIB
(iii) TEMPARARY LIB
SYSLIB:The programs which are presented in system library have the load modules these are
generate by an IBM
--> To execute the program present in SYSLIB no need to specify the STEPLIB AND
JOBLIB
USER/PRIVATELIB: THE PROGRAMS CODED BY A PROGRAMERS ARE CALLED
AS USER OR PRIVATE PROGRAMS
--> TO EXECUTE THIS PROGRAMS THE LOAD LIBRARY PRESENTED IN A
PRIVATE LIBRARIES
->tO EXECUTE THIS PROGRAM WE WILL USE STEPLIB AND JOBLIB
// STEP1 EXEC PROC,UNIT=TEMPDA will set &UNIT as TEMPDA for this run of
procedure.
We can use symbolic overrides in EXEC and DD statements.
40. WHAT IS [Link] IS THE PURPOSE OF GDG.
Generation data group(GDG) is a group of datasets where all the datasets are related
to each other functionally or chronologically. The datasets in the GDG are called generations.
GDG dataset are reffered in JCL using GDG base and relative number. So the same
JCL can be used again and again without changing the dataset name and this is biggest
advantage of GDG. A GDG base has pointer to all its generations. When you want to read all
the transactions done till today, you can easily do it by reading the GDG base if is available.
Otherwise you have to concatenate all the transaction files before reading.
GDG-(Generation Data Group)
1) It is used for taking backups of data
2) For generating reports
2 1
4 3
5 7
6 8
Use the SORT
//FSS045AS JOB NOTIFY=&SYSUID
//* MERGING OF TWO DATA SETS ****/
//S1 EXEC PGM=SORT
//SYSPRINT DD SYSOUT=*
//SORTIN1 DD DSN=[Link].PS300,DISP=SHR
//SORTIN2 DD DSN=[Link].PS400,DISP=SHR
//SORTOUT DD DSN=[Link].PS500,DISP=SHR
//SYSOUT DD SYSOUT=*
//SYSIN DD *
MERGE FIELDS=(1,4,CH,A,1,4,CH,A)
/*
46. IF UR JCL CONSISTS BOTH JOBCAT & STEPCAT THEN WHICH ONE IS
MORE EFFICIENT/WHICH ONE HAS HIGHER PREFERENCE.
The datasets used in step are first checked in the STEPCAT (ICF or VSAM Catalog)
before checking in the system catalog. If there is no STEPCAT in the step and there is a
JOBCAT, then the datasets are first searched in JOBCAT before checking in the system
catalog.
ANS: STEPCAT OR STEPLIB
47. WHAT IS CONDITIONAL PARAMETER.
It is used to control the execution of the steps.
SYNTAX:
COND=(COMPARISION CODE, RELATIONAL OPERATOR, RC)
If the ‘COND’ specified in the step is false, then the step executes. And if it is true
then the step is bypassed.
TRUE Bypassed
FALSE Executes
COND=EVEN” it executes the step even if the previous steps executed successfully
or unsuccessfully.
COND=ONLY” it executes the step only if the previous step executes unsuccessful.
COND=(00,LE) is always ‘TRUE’ condition it bypass the step all the time.
COND=(00,GT) is always ‘FALSE’ condition it executes the step all the time.
48. HOW WE CAN RENAME THE DS'[Link] IT POSSIBLE TO RENAME THE DS'S.
By specifying R, infront of the dataset, the dataset can be renamed.
ANS: By giving R before the ds name
R [Link].PS1(ENTER)
NEW name : PS5 (enter)
then it will be automatically renamed.
JOBLIB: It specifies the load library in which all the steps, program load modules are
searched.
STEPLIB: It specifies the load library in which a particular steps load module is
searched. It has the highest priority.
54. WHAT IS [Link] ARE PARAMETERS IN [Link] I DELARE LIKE
THIS
//SYSIN DD *
DEFINE GDG(NAME( )
LIMIT(5)
NOEMPTY
SCRATCH)
Generation Data Groups or GDGs are a group of data sets which are related to each
other chronologically and functionally. These related Data Sets share a unique Data Set
Name.
Every GDG data set has a Generation number and Version number assigned to each data set.
PURPOSE:
1. Used to take back-up of data.
2. It automates the process of creating and deleting datasets.
3. We need not change the JCL when we need to create a new file.
EG.
//MYJOB JOB NOTIFY=&SYSUID
//STEP1 EXEC PGM=IDCAMS
//SYSIN DD *
DEFINE GDG(NAME([Link]) -
LIMIT(10) -
NOEMPTY -
SCRATCH)
/*
//
PARAMETERS:
NAME - This parameter is used to specify the name of the data set that is to be
created.
LIMIT - This parameter is used to specify the total number of generations that the
GDG may
Contain
EMPTY/NOEMPTY - These two parameters are mutually exclusive. EMPTY
specifies that all existing generations of the GDG are to be uncataloged whenever the
generations of GDG
Reached the maximum limit NOEMPTY specifies that only the oldest generation of the GDG
is to be uncataloged if the limit is reached
SCRATCH/NOSCRATCH - These two parameters are mutually exclusive. SCRATCH
parameter specifies that whenever entry of the GDG is removed from the index, it should be
deleted physically and uncataloged. NOSCRATCH parameter specifies that whenever
entry of the GDG is removed from the index, it should be uncataloged, not physically deleted.
1. Using FILE-AID.
2. Perform varying WS-I from 50 by -1 until WS-CNT=1
WHEN statement is used to specify the condition. We can use maximum of 255 WHEN
conditions
WHEN OTHER is always a true condition and hence must be specified as last when
condition.
THRU or THROUGH is used to specify a range of values.
END-EVALUATE is the mandatory scope terminator.
Note:
1). Redefines is possible for elementary item to elementary item.
2).Redefines is possible for Group item to Group item.
3). Redefines is not possible for Sub-elementary item to Sub-elementary item.
23. IN WHAT SITUTATIONS WE ARE USING REDEFINES IN COBOL.
While validating one information with other, redefines needed.
24. CAN WE REDEFINE COPYBOOK.
No. its not possible.
25. WHAT IS COMPUTATIONAL FIELD.
There are below types of Computational clauses in COBOL .
1).Comp
2).Comp-1
3).Comp-2
4).Comp-3
5).Comp-4
6).Comp-5
1. Comp:
Binary representation of data item.
PIC clause can contain S and 9 only.
S9(01) – S9(04) Half word.
S9(05) – S9(09) Full word.
S9(10) - S9(18) Double word.
Most significant bit is ON if the number is negative.
Syntax: 01 WS-A PIC S9(8) USAGE COMP.
2. Comp-1:
Single word floating point item. PIC Clause should not be specified. The sign is contained
in the first bit of the of the leftmost byte and the exponent is contained in the remaining 7 bits
of the first byte. The last 3 bytes contain the mantissa.
Syntax: 01 WS-A USAGE COMP-1.
3. Comp-2:
Double word floating-point item. PIC Clause should not be specified. 7 bytes are used
for mantissa and hence used for high precision calculation.
Syntax:01 WS-AUSAGE COMP-2
4. Comp-3:
Packed Decimal representation. One digit takes half byte. PIC 9 (N) comp-3 data item
would require (N + 1)/2 bytes. The sign is stored separately in the rightmost half-byte
regardless of whether S is specified in the PICTURE or not.
C – Signed Positive D – Signed Negative F-Unsigned Positive.
Syntax:01 WS-A PIC 9(2)V9(4) USAGE COMP 3.
1. Comp:
Binary representation of data item.
PIC clause can contain S and 9 only.
S9(01) – S9(04) Half word.
S9(05) – S9(09) Full word.
S9(10) - S9(18) Double word.
Most significant bit is ON if the number is negative.
Syntax: 01 WS-A PIC S9(8) USAGE COMP.
2. Comp-3:
Packed Decimal representation. One digit takes half byte. PIC 9 (N) comp-3 data item
would require (N + 1)/2 bytes. The sign is stored separately in the rightmost half-byte
regardless of whether S is specified in the PICTURE or not.
C – Signed Positive D – Signed Negative F-Unsigned Positive.
Syntax:01 WS-A PIC 9(2)V9(4) USAGE COMP 3.
4. Access is fast.
SSRANGE-Subscript Range.
NOSSRANGE- No Subscript Range
PARM=SSRANGE for dynamic array.
PARM=NOSSRANGE for static array. It is default.
41. HOW DID U FIND WHETHER IT IS AN STATIC OR DYNAMIC CALL BY
SEEING THE PGM.
SYNTAX: CALL ‘PGM-NAME’ for static.
CALL VARIABLE-NAME for dynamic.
42. WHAT IS DIFFERENCE BETWEEN INDEX&SUBSCRIPT.
SUBSCRIPT INDEX
1. It is an occurrence number of an array 1. It is the displacement value of an array
element is defined as subscript. element
2. Must be declared a separate variable in
working-storage section. 2. It is declared by using INDEXED BY
3. It is decremented/incremented using CLAUSE.
arithmetic operation.
4. Access is slow. 3. Incremented/decremented using SET
clause.
4. Access is fast.
43. COMP-1 & COMP-2 WHICH ONE IS MOST EFFICIENT FOR STORING THE
FLOATING POINT VALUE
1. Comp-1: It is Single precision floating point value. Maximum 4 byte
Single word floating point item. PIC Clause should not be specified. The sign is contained
in the first bit of the of the leftmost byte and the exponent is contained in the remaining 7 bits
of the first byte. The last 3 bytes contain the mantissa.
Syntax: 01 WS-A USAGE COMP-1.
2. Comp-2: It is double precision floating point value. Maximum 8 byte
Double word floating-point item. PIC Clause should not be specified. 7 bytes are used
for mantissa and hence used for high precision calculation.
Syntax:01 WS-AUSAGE COMP-2
SEQUENTIAL ->ESDS
ACCESS MODE IS INDEXED ->KSDS
RELATIVE ->RRDS
RECORD KEY IS DATANAME1.
47. WHAT IS REFERENCE MODIFICATION.
It is used to move only a part of a field to a part of another field.
IDENTIFICATION DIVISION.
PROGRAM-ID. ELEM.
DATA DIVISION.
WORKING-STORAGE SECTION.
02 A PIC X(13) VALUE 'PRAVEEN KUMAR'.
02 B PIC X(7).
02 C PIC X(5).
PROCEDURE DIVISION.
MOVE A(1:7) TO B.
MOVE A(9:5) TO C.
DISPLAY B
DISPLAY C
STOP RUN.
WHEN statement is used to specify the condition. We can use maximum of 255 WHEN
conditions
WHEN OTHER is always a true condition and hence must be specified as last when
condition.
THRU or THROUGH is used to specify a range of values.
END-EVALUATE is the mandatory scope terminator.
WORKCOPY:
WORKING-STORAGE SECTION.
01 A PIC X(5) VALUE ‘ARTHI’.
01 B PIC X(13) VALUE ‘IBM-MAINFRAME’
59. HOW CAN U RESOLVE SOC-7.
Invalid data in numeric field (datatype mismatch).
There are two possibilities of getting this abend.
1. while passing, non-numeric value to numeric field using MOVE statement.
2. There are some non-numeric values are presented in file. Those files are declared as
numeric.
SOLUTIONS:
Go to SPOOL, select CESDUMP, get the line no. and offset address. If we are unable
to get the exact location, then copy the offset address from the CESDUMP, goto SYSPRINT,
type [Link] ADDRESS. Then it will give the particular line no. Now GOTO the Main
program, type L line no in Command Line, the cursor will be positioned at particular line.
Then edit the values.
60. WHAT IS SOC-4.
Storage violation error.
REASONS:
- Missing select statement, during compilation time.
- Bad subscript or index.
- Read/write attempt to unopened file.
- Move data to/from unopened file.
- Missing parameters is called sub-programs.
61. WHAT R THE ERROR CODES U KNOW IN COBOL.
SOC7, SOC4, U4O38, SOCB, SOC1
62. WHAT IS NESTED-IF STATEMENT.
However, use nested IF statements sparingly. The logic can be difficult to follow,
although explicit scope terminators and indentation help. When a program has to test a
variable for more than two values, EVALUATE is probably a better choice.
IF CONDITION1
IF CONDITION2
STATEMENT1
ELSE
STATEMENT-2
END-IF
STATEMENT-3
ELSE
STATEMENT-4
END-IF
Example:
IDENTIFICATION DIVISION.
PROGRAM-ID. COPY1
ENVIRONMENT DIVISION.
COPY WORKCOPY
PROCEDURE DIVISION.
DISPLAY A.
DISPLAY B.
STOP RUN.
Copybook contains below information.
WORKCOPY:
WORKING-STORAGE SECTION.
01 A PIC X(5) VALUE ‘ARTHI’.
01 B PIC X(13) VALUE ‘IBM-MAINFRAME’.
GOBACK is coded in the mainly in the subroutines or called programs. The control
will be returned to the calling program. If STOP RUN is coded in the calling program the
program will go to an infinite execution. GOBACK can be coded in the programs which is
not called by any programs instead of STOP RUN.
66. 01 A X(5).
01 B X(3).
PROCEDURE DIVISION.
MOVE 'ABCDE' TO B.
DISPLAY B.
WHAT IS VALUE OF B.
B=ABC
67. 01 A 9(5).
01 B 9(3).
PROCEDURE DIVISION.
MOVE 12345 TO B.
DISPLAY B.
WHAT IS VALUE OF B.
B=345
68. S9(5) COMP--HOW MANY BYTES IT WILL OCCUPY.
S9(5) COMP-3----HOW MANY BYTES IT WILL OCCUPY.
S9(5) COMP = 4BYTE
S9(5) COMP-3 = 3BYTE
3. IF WE WANT TO PASS THE DATA FROM JCL TO COBOL,WE USE PARM=' ',
IN EXEC STATEMENTS,IF WE NEED TO PASS THE DATA TO COBOL-DB2
PROGRAMME HOW & WHERE WE CAN SPECIFY PARM PARAMETER.
At RUN-TIME, in SYSTSIN card of IKJEFT01 using PARM parameter.
4. TIME STAMP MISMATCH,PRECOMPILATION PROCESS,NULL INDICATOR.
TIMESTAMP MISMATCH, -818, is a RUNTIME ERROR. Whenever there is a
mismatch of timestamp between DBRMLIB & LOADLIB. In that case, we have to REBIND
the program.
PRE-COMPILATION PROCESS: COBOL-DB2 Program is first feed to DB2 pre-
compiler that extracts the DB2 statements into DBRM and replace the source program DB2
statements with COBOL CALL statements. This modified source is passed to COBOL
compiler and then link editor to generate load module. During pre-compilation, time stamp
token is placed on modified source and DBRM.
NULL INDICATOR: NULL INDICATOR VARIABLE are used to know, if any
NULL values are retived from DB2 into COBOL variables.
- If indicator value is <0 then it indicates NULL value is retrived and since COBOL
default values based on the DATA TYPE.
- If indicator value is 0 then value is properly retrived.
- If value is >0 the the data retrived is truncated.
5. CURSORS,ISOLATION LEVELS(CS),AT WHAT TYPE OF SITUTATIONS WE
WILL GO FOR CS.
To retrieve more than one row randomly from DB2 table, we are going to use the
cursors.
STEPS TO USE CURSOR:
There are four steps to use cursor.
1. Declare cursor
2. Open cursor
3. Fetch cursor
4. Close cursor
NOTE:
-811 abend caused because the user trying to retrieve more than one row, without
declaring cursor.
If we want to retrieve more than one row without using cursor, then use FETCH in
SELECT statement as follows. In that case the rows will be retrieved sequentially.
Syntax: SELECT * FROM TABLE FETCH FIRST N ROWS ONLY
ISOLATION LEVEL:
There are 3 isolation levels in DB2.
1. Cursor stability (CS). –row level locking
2. Repeatable read (RR). –page level locking
3. Uncommitable read (UR) –it wont lock any record.
6. WHAT IS THE PICTURE CLAUSE FOR NULL INDICATOR.
01 EMP-LANDLINE-NO PIC S9(4) COMP.
Whenever we want to pass value to null, that should be declared in WS section. Then
only we can pass.
7. GIVE SOME ABENDS IN DB2.
-805: REASON: DBRM/PACKAGE is not found in the PLAN.
-911: REASON: DEADLOCK. The program is used by some other.
SOLUTION: submit after sometime.
-922: REASON: AUTHOURIZATION FAILURE.
SOLUTION: Send mail to DBA to get access for particular tables. Or client
will give the access to complet the JOB.
8. HOW CAN U DISPLAY FIRST ROW IN THE TABLE.
Syntax: SELECT * FROM TABLE FETCH FIRST 1 ROWS ONLY
9. TO SELECT THE NULL DATA.
Syntax: SELECT * FROM TABLE WHERE COLNAME=NULL
10. HOW CAN U SELECT SUBSTRING.
SELECT SUBSTRING (FIELDNAME, STARTING POSITION, LENGTH)
11. HOW CAN WE INSERT NULL VALUES TO A PARTICULAR COLOUMN OF A
TABLE.
INSERT INTO TABLENAME VALUES (‘A001’, ‘RAHUL’, ‘ ‘)
12. DIFFERENCE BETWEEN PRIMARY KEY & UNIQUE INDEX.
PRIMARY KEY UNIQUE INDEX
1. It is not null & unique. (it won’t allow 1. Will create the unique index. For the
duplicate). primary key field. It is useful to retrieve
the data from DB2 table. (without unique
index we cant create primary key).
ROW:- LOCK,UPDATE,RELEASE
2) REPEATABLE READ(RR):- It is page level locking , An X-Lock is acquired on an
entire page on which the row to be modified is present. The lock is released on the
page only when the control moves to the next updatable page.
3) UNCOMMITED READ(UR):-It allows users to access the data which is modified
but not yet committed. Here U-Lock is issued.
46. WHAT ARE THE ABENDS U WILL GET IN UR DAILY WORK IN DB2.
-805: REASON: DBRM/PACKAGE is not found in the PLAN.
-911: REASON: DEADLOCK. The program is used by some other.
SOLUTION: submit after sometime.
-922: REASON: AUTHOURIZATION FAILURE.
SOLUTION: Send mail to DBA to get access for particular tables. Or client
will give the access to complet the JOB.
-818: REASON: TIMESTAMP MISMATCH, is a RUNTIME ERROR. Whenever
there is a mismatch of timestamp between DBRMLIB & LOADLIB.
SOLUTION: In that case, we have to REBIND the program.
-811: REASON: the user trying to retrieve more than one row, without declaring
cursor.
SOLUTION: Cursor has to be declared.
47. CAN I INSERT MORE THAN ONE RECORD AT A TIME INTO TABLE.
By using dynamic SQL, we can insert more than one row into the DB2 table.
In SPUFI, put ; at the end of each query, to execute more than one query and put ‘-‘ in
front of the query, if you don’t want to execute.
48. CAN I SELECT MORE THAN ONE TABLE AT A TIME.
SELECT * FROM TABLE1, TABLE2
49. WHAT IS SPUFI.
SQL processing using file input
50. I DIDN'T GIVE CLOSE CURSOR IN THAT CASE WHAT IT WILL HAPPEN.
If I CLOSE CURSOR is not declared, in that case we can’t select the records from
DB2 table.
51. WHAT IS RDBMS.
RDBMS-Relational Database Management System.
There is a relationship between the columns of DB2 table.
52. U KNOW ANY OTHER RDBMS.
No
53. CAN I SELECT MORE THAN ONE TABLE BY USING SELECT QUERY.
SELECT * FROM TABLE1, TABLE2
54. CAN I USE MORE THAN ONE PRIMARY KEY FOR A TABLE.
No I can’t use more than one primary key.
55. WHAT IS THE TABLE SPACE WHAT IT CONTAINS.
Amount of space required to store the tables, views (simple objects). There are three
types.
1. SIMPLE: In a page of TS, more than one table of data is stored.
2. SEGMENTED: In a page, single table data is stored
3. PARTITIONED: If a particular group of data is stored in a set of pages is called
partitioned. Then it is called partitioned table space.
56. WHAT ARE THE ERROR CODES U KNOW IN DB2.
-805: REASON: DBRM/PACKAGE is not found in the PLAN.
-911: REASON: DEADLOCK. The program is used by some other.
SOLUTION: submit after sometime.
-922: REASON: AUTHOURIZATION FAILURE.
SOLUTION: Send mail to DBA to get access for particular tables. Or client
will give the access to complet the JOB.
-818: REASON: TIMESTAMP MISMATCH, is a RUNTIME ERROR. Whenever
there is a mismatch of timestamp between DBRMLIB & LOADLIB.
SOLUTION: In that case, we have to REBIND the program.
-811: REASON: the user trying to retrieve more than one row, without declaring
cursor.
SOLUTION: Cursor has to be declared.
57. IN WHAT SITUATION WE WILL USE NULL INDICATORS.
If suppose I want to move null value to a land-line no. then that variable has to be
declared in WORKING-STORAGE SECTION as follows.
01 variable-name PIC S9(4) COMP.
58. WHAT IS -805.
-805: REASON: DBRM/PACKAGE is not found in the PLAN.
59. IF I OPENED A CURSOR I DIDN'T CLOSE [Link] WILL HAPPEN I DIDN'T
GET ANY ERROR.
If we don’t CLOSE CURSOR, that also will give abend. Because, if a table is opened
in BATCH mode, then it can’t be opened in CICS region, (i.e., ONLINE mode), if we don’t
close the cursor.
60. WHAT IS THE UTILITY FOR RUNNING A COBOL-DB2 PROGRAMME.
For pre-compilation, the utility is “DSNHPC’. For BIND, the utility is “IKJEFT01”.
61. WHAT IS EXPLAIN IN DB2.
EXPLAIN OF YES: Will give the best path, by using RUNSTAT utility after binding.
PACKAGE: DBRM+best access path
EXPLAIN OF NO: Will not give the best path after binding.
62. WHAT IS THE SYNTAX OF DECLARE CURSOR.
Declaring the cursor :-
EXEC SQL
DECLARE CURSORNAME CURSOR FOR
SELECT * FROM TABLENAME
END-EXEC.
Declare cursor statement just creates the cursor declaration can be given ‘working
storage selection’ or ‘ procedure division ‘.
To keep the cursor open even after ‘commit’ is issued.
EXEC SQL
DECLARE CURSORNAME CURSOR WITH HOLD
FOR SELECT * FROM TABLENAME
END-EXEC.
NOTE:-
It I want to “commit” the updations ,(we are doing for the table) and again I want to
update next 10 records, at that time the cursor will automatically closed because of
“COMMIT”.If we want to hold the cursor until all the records are updated. Then
cursor should declare with “WITHHOLD” option.