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

how to check whether the open command of a sequential file is successful? or not?

2 Answers   CSC, IBM,


Which of the following paragraphs is compulsory in every COBOL program? (a) SPECIAL-NAMES (b) PROGRAM-ID (c) FILE-CONTROL (d) OBJECT-COMPUTER

4 Answers  


Hi Guys, I have faced one interview question if I have requirement to add 5 new columns to existing table what are prerequisite do i need to take.

1 Answers  


diffrence between renames and redifnes with examples

3 Answers   IBM,


I have sequential file recl 1000 i want to add another 15 bytes to it. The record length should not change..How?

1 Answers   CTS, HCL,






What is the LINKAGE SECTION used in COBOL?

0 Answers   UGC Corporation,


How to recover a deleted source physical file from library?

1 Answers   HCL,


What is redefines clause in COBOL?

0 Answers   B-Ways TecnoSoft,


What are declaratives and what are their uses in cobol?

0 Answers  


How is sign stored in Packed Decimal fields and Zoned Decimal fields?

6 Answers   ABC, HCL, TCS,


Mention the guidelines to write a structured cobol program?

0 Answers  


What does EXIT do ?

3 Answers   Deloitte,


Categories