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

What are the different rules of SORT operation?

0 Answers  


how do you define single dimensional array and multidimensional array in your cobol?

0 Answers  


what is sort? whis is internal & external sort ?when do u go for inter sort & external sort? tell about some sort utilites?

2 Answers   BirlaSoft,


Why we should use cursor ?

3 Answers  


Hi pls anybody tell me about " ANALYSIS DOCUMENT PREPARATION AND ESTIMATION OF TASK " (in real time project)."I want to update a sequential file in my project" for that purpose i need both structures i mean analysis document and estimation of task.

0 Answers  






We know that size of redefine and redefining need not to be same..Then does the below case true 01 ws-date pic 9(6). 01 ws-redf-date REDEFINES ws-date 05 ws-year pic 9(4) 05 ws-mon pic 9(2) 05 ws-day pic 9(2)

1 Answers   Cap Gemini,


how do u link sub pgm to main pgm ?

2 Answers   TCS,


What is cobol?

0 Answers  


01 a pic s9(5) occupies how many bytes ?

9 Answers   Wipro,


How many times the loop runs here 01 a pic 9(2) value 1. perform para1 until a=10 move 1 to a. stop run. para1: move 10 to a.

5 Answers  


I want to remove a duplicates form a given input field using cobol program. please Any one help me out to solve this ... Thanks in Advance.

3 Answers   IBM,


Difference between file status codes 02 and 22.... since both are for duplicate key detection.

1 Answers  


Categories