IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Need description about array and index


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
HARIBHARAT

New User


Joined: 05 Jul 2006
Posts: 65
Location: pune

PostPosted: Wed Sep 06, 2006 8:35 pm
Reply with quote

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
View user's profile Send private message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1208
Location: Bangalore,India

PostPosted: Wed Sep 06, 2006 9:25 pm
Reply with quote

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
View user's profile Send private message
krishna_sureka

New User


Joined: 05 Sep 2006
Posts: 7
Location: Pune

PostPosted: Wed Sep 06, 2006 11:40 pm
Reply with quote

Any inputs on which one should be used in which case and what difference it makes.

Thanks
Krishna.
Back to top
View user's profile Send private message
HARIBHARAT

New User


Joined: 05 Jul 2006
Posts: 65
Location: pune

PostPosted: Thu Sep 07, 2006 11:41 am
Reply with quote

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
View user's profile Send private message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1208
Location: Bangalore,India

PostPosted: Thu Sep 07, 2006 2:39 pm
Reply with quote

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 icon_smile.gif
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Cobol file using index COBOL Programming 2
No new posts COBOL Ascending and descending sort n... COBOL Programming 5
No new posts DL/I status code AK for GU call using... IMS DB/DC 1
No new posts To find an array of words (sys-symbol... JCL & VSAM 9
No new posts How to move values from single dimens... COBOL Programming 1
Search our Forums:

Back to Top