1⟩ What is the difference between section,paragraph and sentences?
Section is group of Praragraphs.
Paragraph is group of executable statements.
Sentence is statement(executable statements).
“IBM COBOL400 frequently Asked Questions in various IBM COBOL400 job Interviews by interviewer. Get preparation of IBM COBOL400 job interview”
Section is group of Praragraphs.
Paragraph is group of executable statements.
Sentence is statement(executable statements).
to execute set of statement elsewhere in the prgram.
types :
perform para-name.
perform para1 until condition.
perform para1 n times.
perform para1 thru para4 until condition.
inline perform.
perform varying i from 1 by 1 until condition.
perform para1 with test before/after until condition.
"COMP" in Cobol = Binary storage format(if -ve bit is ON,
if +ve bit is OFF)
COMP-1 = Single precision floating point. Uses 4 bytes.
COMP-2 = Double precision floating point. Uses 8 bytes.
COMP-3 = packed decimal format. Uses 4 bytes.
Example 01 WS-VAR USAGE COMP-1.
Comp : Store the data in Binary formate, it will take less
space compare to Comp-3.
Comp-3 : Store the data in Pack decimal,it will take more
space compare to Comp.
Example :
S9(18)
Comp : takes 4 bytes
Comp-3: takes 10 bytes
Array can be declared in cobol using the OCCURS clause.
Syntax is,
For one dimensional array,
01 Arrays.
05 Var1 PIC X(10) Occurs 10 times.
For two dimensional array,
01 Arrays.
03 AAA Occurs 10 times
05 BBB Occurs 10 times
07 Value PIC 9(3).
Check the file status, if the file status is 9D then it indicates that the record is locked. Solution should be READ the file with NO LOCK.
When a programmer is not intended to use any fields in a record structure, it can be defined as Filler.
This can’t be initialized or used in any operation of the procedure division.
Eg: if a record contains the following fields
05 EMP-REC.
10 EMP-KEY PIC XXX.
10 EMP-NAME PIC X(32).
10 EMP-SEX PIC X.
10 EMP-DEPT PIC X(10)
10 EMP-DESIG PIC X(5).
10 EMP-SAL PIC 9(7).
If the programmer is not intended to use , name ,dept and sal in the program the u can define the structure as follows
05 EMP-REC.
10 EMP-KEY PIC XXX.
10 FILLER PIC X(32).
10 EMP-SEX PIC X.
10 FILLER PIC X(10)
10 EMP-DESIG PIC X(5).
10 FILLER PIC 9(7).
The cobol compiler is IGYCRCTL
yes, we can open closed file in COBOL any no. of time but
the condition is the file is not closed with "WITH LOCK"
clause otherwise you can't open.
There are some conditions,
1. File should be decare in FILE-CONTROL, FILE SECTION.
2. file should be closed before opening it other wise ut
will gives error.
Search verb searches an item in a sequential manner. But
Search All searches an item by using Binary search, so it
is more efficient and faster than its counter part. One
thing required in Search All verb is the array must be
sorted.
Declare below three variables in working storage section.
77 WS-COUNT PIC 99. VALUE ZEROS.
77 WS-VAR PIC X(10) VALUE "WELCOME".
77 WS-USERID PIC x(5) VALUE "AAAAA".
Decalre one indicator for end of file.
04 EOF-DB-FILE PIC X VALUE "N".
88 EOF-DB-FILE VALUE "Y".
Read each record from input file(Db file) and increase
count if the conditions are satisfied.
PROCEDURE DIVISION.
OPEN INPUT DB-FILE.
READ Db-file
AT END MOVE "Y" TO EOF-DB-FILE
GO TO 1000-EXIT.
IF FIELD1 = WS-VAR AND FIELD2 = WS-USERID
ADD 1 TO WS-COUNT
END-IF
GO TO 1000-EXIT.
DISPLAY WS-COUNT
CLOSE DB-FILE.
STOP RUN.
SEARCH ALL is a binary search. So, the data needs to be in
sorted order and the array used for search all operation
should have index by.
Either DISPLAY keywords in COBOL-400 we can update the data
area.
For example
MOVE 'bbbb' TO GP-FILLER.
DISPLAY GP-FILLER UPON OTHER-DATA-AREA
FOR "SKDTAARA" LIBRARY "QGPL".
In COBOL we can directly access the particular index of the
array using subscript.
Eg: Arrayname(5)
or
Move 5 to indx
Arrayname(indx).
The above issue can be resolved by using REDEFINES clause.
01 DATE-FIELD
05 DATE-YYYY PIC 9(04).
05 DATE-MM PIC 9(02).
05 DATE-DD PIC 9(02).
01 DATE-CONT REDEFINES DATE-FIELD
05 DATE-MM-CONT PIC 9(02).
05 DATE-DD-CONT PIC 9(02).
05 DATE-YYYY-CONT PIC 9(04).
I guess the above declaration will resolve it. I have not
tested it.
Here the sort is considered as an internal sort that is we
want to manipulate the data before feeding it to sort.Else
in rest of the cases we use external sort.
The syntax is :
SORT SORTFILE ON ASCENDING/DESCENDING KEY
USING FILE1,FILE2/ INPUT PROCEDURE PARA-1
GIVING FILE3/ OUTPUT PROCEDURE PARA-2
SORT WORKFILE ASCENDING KEY EMP-NO
INPUT PROCEDURE PARA-1
OUPUT PROCEDURE PARA-2.
SO INPUT PROCEDURE(RELASE THE RECORDS FOR SORTING)
OUTPUT PROCEDURE(RETURN THE SORTED RECORDS).
REDEFINE is a Cobol Verb.
It is similar to RENAME Verb.
It uses the same WORKING-STORAGE memory of a data name
With another data name programmer want instead.
Syntax.
WORKING-STORAGE SECTION.
01 WS-NAME PIC x(15).
01 WS-AGE PIC 99.
05 NAME REDIFINES WS-NAME.