MAINFRAME - TIP OF THE DAY :
When you specified V for RECFM parameter, LRECL value is largest record in the file plus 4 bytes. These four bytes contain the actual length of each variable length record in the file
Programmers Voted for below topics. Please Vote for good Posts.
Thank You! for your feedback. Connecting to the server. Please Wait...
To access 2nd month we sepcify WS-MONTH(2).
Value enclosed in brackets is called subscript ( in this case 2 ).
You can use INDEX for the same.
Ex. 01 WS-GROUP.
05 WS-MONTH PIC X(3) OCCURS 12 TIMES INDEXED BY WS-INDX.
In above example WS-INDX is a INDEX data item.
we can use this variable to access the elements in the array.
If you want to access 2nd element in the array. need to write the code as follows
SET WS-INDX TO 2.
DISPLAY " 2nd element in array " , WS-INDX.
An index is similar to a subscript, but internal value in the variables are different..
Normaly subscript refer the occurance number of the item in array. in our example that is 2. means to refer second occurance we use number 2.
In case of index, to refer second element of your array, it shoud contains value of displacement from the starting of the arrary. i.e, in our example we used SET command to set value in index field WS-INDX. after execution of this command
WS-INDX contain the value 3. To refer third element it should contains the value of
6, for fourth element it should contain the value of 9 ( in our example array element size is 3 ).
These are interview questions. please post them in interview questions forum.
I would suggest you to complete the cobol course.
Joined: 28 Apr 2009 Posts: 11 Location: Missouri USA
Posted: Fri Jan 22, 2016 9:37 pm Post subject:
In addition to the explanation above, the indexing method of table (or array) handling has some coding benefits.
First - The SEARCH verb can be used to lookup data in the table.
Second - A SEARCH verb by itself will sequentially lookup information in the table. This is good for when the key to the data is unstructured or not in sequence.
Third - A SEARCH ALL can be used to do a binary search when the key to the data is in ascending (or descending) order.
If you are using subscripting, and you want to do a binary search, you will have to code the routine to do that type of search. This is much more difficult than using a SEARCH ALL.
I'll leave it up to you to look into the manual for the setup of the table (or array) and the actual syntax.
Are you unfamiliar with a binary search? It is VERY FAST! A million entry table would only require looking at 20 entries, at most, to find what you're looking for. If you're doing a sequential search you'd have to look at an average of 500,000 entries - quite a difference. _________________ David Earhart
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
Cobol Tutorial This cobol tutorial covers most of the important topics like STRING, UNSTRING, COMP, COMP-3.....
DB2 Tutorial DB2 Tutorial focuses on DB2 COBOL Programming. Explains in simple language. Some Chapters are locked, Forum members have free access to these chapters
CICS Tutorial This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming...
JCL Tutorial This is most popular JCL tutorial from mainframegurukul. It does contain important jcl ....
SORT Tutorial This Tutorial covers all important aspects of DFSORT. Has more SORT examples