How do you define a table/array in COBOL?

Answers were Sorted based on User's Feedback



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

Answer / dipak chowdhury

01 tab
02 OC-TAB.
05 FILLER PIC 9(10) VALUE 0102001002.
05 FILLER PIC 9(10) VALUE 0202001002.
05 FILLER PIC 9(10) VALUE 0302001073.
05 FILLER PIC 9(10) VALUE 0402001002.
05 FILLER PIC 9(10) VALUE 0502001002.
05 FILLER PIC 9(10) VALUE 0602001002.
05 FILLER PIC 9(10) VALUE 0702001002.
05 FILLER PIC 9(10) VALUE 1004301024.
05 FILLER PIC 9(10) VALUE 1102001002.
05 FILLER PIC 9(10) VALUE 1202001002.
05 FILLER PIC 9(10) VALUE 1302001002.
05 FILLER PIC 9(10) VALUE 1602001002.
05 FILLER PIC 9(10) VALUE 3101899012.
05 FILLER PIC 9(10) VALUE 4102001002.
05 FILLER PIC 9(10) VALUE 4402001002.
05 FILLER PIC 9(10) VALUE 5002001002.
05 FILLER PIC 9(10) VALUE 5102001002.
05 FILLER PIC 9(10) VALUE 5302101020.
05 FILLER PIC 9(10) VALUE 5502101003.
05 FILLER PIC 9(10) VALUE 5402101001.
05 FILLER PIC 9(10) VALUE 5602001029.
05 FILLER PIC 9(10) VALUE 5702001017.
05 FILLER PIC 9(10) VALUE 5902001021.
05 FILLER PIC 9(10) VALUE 6302001029.
05 FILLER PIC 9(10) VALUE 6502101001.
05 FILLER PIC 9(10) VALUE 6902001029.
05 FILLER PIC 9(10) VALUE 7402001002.
05 FILLER PIC 9(10) VALUE 9902001002.
02 OC-TABR REDEFINES OC-TAB OCCURS 28 TIMES
indexed by t.
05 OC-CDT PIC 99.
05 OC-FCD-AAA PIC 9(5).
05 OC-FCD-BB PIC 999.

Is This Answer Correct ?    34 Yes 8 No

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

Answer / anil prajapati

Table/array can be defined in cobol by using occurs with
times clause

like
working-=storage section.
01 tab1 value 'anilkumarprajapati'.
03 tab2 pic x(3) occurs 6 times indexed by i.
procedure division.

display tab2(i).
stop run.

output will be dsiplayed like

ani
lku
....

Is This Answer Correct ?    23 Yes 9 No

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

Answer / thaya

To define a table use occur clause ..

01 WT-TABLE-DATA.
03 WT-TAB-PARM OCCURS 99 TIMES
INDEXED BY WT-TAB-IDX.
05 WT-TAB-PARMREC.
10 TBL-PARM-UPDT-CD PIC X(02).
10 FILLER PIC X(01).
10 TBL-STATUS-FLAG PIC X(01).
10 FILLER PIC X(76).

we can use "depending on" keyword with occure clause to
limit our occurences in output.

Is This Answer Correct ?    17 Yes 3 No

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

Answer / sudheer

To define a table use occur clause ..

01 WT-TABLE-DATA.
03 WT-TAB-PARM OCCURS 99 TIMES
INDEXED BY WT-TAB-IDX.
05 WT-TAB-PARMREC.
10 TBL-PARM-UPDT-CD PIC X(02).
10 FILLER PIC X(01).
10 TBL-STATUS-FLAG PIC X(01).
10 FILLER PIC X(76).

Is This Answer Correct ?    10 Yes 2 No

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

Answer / mojib khan

To define a table using occurs clause..
working -storage section.
01 table.
*for one dimensional array
02 table-name pic size() occurs n times.
03 field1-name pic size.
03 field2-name pic size.
.......
........
........
03 fieldn-name pic size.

Is This Answer Correct ?    7 Yes 2 No

Post New Answer

More COBOL Interview Questions

comp-3 field occupy?

5 Answers  


What is the local-storage section?

0 Answers  


What are differences between Static Call and Dynamic Call?

10 Answers   IBM, KBC, Keane India Ltd, Verizon,


Suppose, file A has 100 records and file B has 500 records. We want to write records common to both A and B into file C and records which are present only in either A or B into another file D. What should be the logic of Cobol program to achieve this?

7 Answers   Bank Of America, Mind Tree,


How to delete leading spaces/blank in COBOL ? Example:- 01 data-name-1 pic x(220) " English is a language". I would like to delete leading spaces.

7 Answers   Financial Services,






how you will define variables length in cobol.

3 Answers   Temenos,


How do you get the data to code the BMS macro?

0 Answers   IBM,


What are the different data types in cobol?

0 Answers  


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?

0 Answers  


What are different data types in cobol?

0 Answers  


can you declare redefine in level 01?

8 Answers   Patni,


What is the default value(s) for an initialize? What keyword will allow for an override of the default?

0 Answers  


Categories