View previous topic :: View next topic
|
Author |
Message |
HARIBHARAT
New User
Joined: 05 Jul 2006 Posts: 65 Location: pune
|
|
|
|
Give me brief description about array and index i need sample code with result, i face the problem this related.
Bye
suresh |
|
Back to top |
|
|
guptae
Moderator
Joined: 14 Oct 2005 Posts: 1208 Location: Bangalore,India
|
|
|
|
Hi Suresh,
05 ws-array occurs 10 times
ascending key is ws-empid
indexed by I.
10 ws-empid pic 9(12).
10 ws-empname pic x(15).
05 ws-array1 occurs 12 time.
10 ws-vara pic 9(2).
10 ws-varb pic x(2).
05 J pic S9(4) comp.
Procedure Division.
Init-para.
perform varying J from 1 by 1 until i>12
initialize ws-vara(J), ws-varb(J)
end-perform.
Search-para.
set I to 1.
SEARCH ws-array VARYING I
AT END DISPLAY 'Emp not found'
WHEN ws-empid(I) = 4211
DISPLAY "Emp Name ", ws-empname(I)
END-SEARCH.
Here I is indexed for this table its decvlaration is not require & J is a variable. which is used as subscript & weneed to declare this variable is working storage
An index is defined with it's associated table using the INDEXED BY phrase. It is a storage area generated by the compiler. It is 4 bytes in length. You can?t display an index. The SET statement sets up and down an index.
A subscript is a positive integer defined in working-storage. It's best to define it as S9(4) COMP. A subscript is changed using ADD, SUBTRACT, MOVE or PERFORM VARYING. |
|
Back to top |
|
|
krishna_sureka
New User
Joined: 05 Sep 2006 Posts: 7 Location: Pune
|
|
|
|
Any inputs on which one should be used in which case and what difference it makes.
Thanks
Krishna. |
|
Back to top |
|
|
HARIBHARAT
New User
Joined: 05 Jul 2006 Posts: 65 Location: pune
|
|
|
|
Thanks ektha.
iam very thankful ibmmainframes site, i learned lot here, i want to congratulate each and evryone, i did not have words describe.
Thanks
suresh |
|
Back to top |
|
|
guptae
Moderator
Joined: 14 Oct 2005 Posts: 1208 Location: Bangalore,India
|
|
|
|
Krishna,
If we want to search on the table & need to pass it to calling program then index is better option.
Suresh,
Its EKta not ektha |
|
Back to top |
|
|
|