how array can be declare in cobol?

Answers were Sorted based on User's Feedback



how array can be declare in cobol?..

Answer / sivakumar s

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).

Is This Answer Correct ?    77 Yes 14 No

how array can be declare in cobol?..

Answer / ahmed

01 ARRAYNAME
05 ARRAY-RECDFORMAT OCCURS 20 TIMES
10 ARRAYNAME-FIELDNAME1 PIC X(20)
10 ARRAYNAME-FIELDNAME2 PIC X(30)

AND WE CAN ACCESS THIS ARRAY BY USING SUBSCRIPT...
LIKE DISPLAY ARRAY-NAME(I)
AND ALSO INDIVIDUAL FIELD: DISPLAY ARRAYNAME-FIELD1(I)

Is This Answer Correct ?    32 Yes 12 No

how array can be declare in cobol?..

Answer / vinay gautam

working-storage section.
77 index1 pic 9 value 1.
01 week value 'montuewedthufrisatsun'.
03 days pic x(3) occurs 7 times indexed by idx.
procedure division.
perform varying index1 from 1 by 1 until index1 >= 8
display days(Index1)
compute index1 = index1 + 1
end-perform.
stop run.

Is This Answer Correct ?    7 Yes 1 No

how array can be declare in cobol?..

Answer / ashish

we declare table as
01 SALES-OF-YEAR-2010 OCCURS 12 TIMES indexed by YY.
02 MONTH PIC A(10).
02 NUM-OF-UNITS PIC 9(7).
02 PRICE-OF-UNIT PIC 9(5).

and we can call table elemnts as follows

procedure division.
.......
.......
MOVE 1 TO YY.
DISPLAY MONTH(YY).

Is This Answer Correct ?    9 Yes 5 No

how array can be declare in cobol?..

Answer / vinay gautam

This is a working example of 1D arrey...
in last ex. o posted there was a comment line......


Working-storage section.
77 index1 pic 9 value 1.
01 week value 'montuewedthufrisatsun'.
03 days pic x(3) occurs 7 times indexed by idx.

Procedure division.
perform varying index1 from 1 by 1 until index1 >= 8
display days(Index1)
End-Perform.
stop run.


Regards Vinay Gautam

Is This Answer Correct ?    4 Yes 1 No

how array can be declare in cobol?..

Answer / rajesh

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).

Is This Answer Correct ?    7 Yes 5 No

Post New Answer

More COBOL400 Interview Questions

What is comp?

0 Answers  


Explain the difference between comp & comp-3?

0 Answers  


Explain what all the conditiones required for using open opcode on a file?

0 Answers  


It's possible use %TRIM statement like rpgile?

2 Answers  


Define perform?

0 Answers  






Explain the input procedure and output procedure?

0 Answers  


Explain how to convert 2010/02/11 to m/dd/yyy.. With string and without string if any other method... Code?

0 Answers  


How to update data area in cobol 400 program?

0 Answers  


What is perform?

0 Answers  


How u detect record is locked in Cobol/400 ? Wat is the solution for that ?

2 Answers   CGI,


How can i change the below code in SQL to cobol/400? EXEC SQL SELECT COUNT(*) INTO : WS-COUNT FROM Db file WHERE Field 1 = : WS-VAR AND Field 2 = : WS-USERID END-EXEC * EVALUATE TRUE WHEN SQLCODE = +000 MOVE WS-COUNT TO Copybook field WHEN SQLCODE = +100 MOVE ZEROES TO Copybook field

2 Answers  


What is sort?

0 Answers  


Categories