Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Declare array with 3 fields. Pass 1 field & get back res

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
siddhartha biswas
Currently Banned

New User


Joined: 04 May 2008
Posts: 15
Location: india

PostPosted: Fri May 30, 2008 2:41 pm    Post subject: Declare array with 3 fields. Pass 1 field & get back res
Reply with quote

hi all,
I need to define an array in such a way that it should contain three fields..for example 'name', 'roll no', 'class' . This array has to be there in a sub program. When i pass any one field to the sub program, it should return the corresponding other two fields. For example if i pass 'name' i should get back ' roll no' and 'class'. Please suggest me a solution for this.
Back to top
View user's profile Send private message

the_gautam

Active User


Joined: 05 Jun 2005
Posts: 165
Location: Bangalore

PostPosted: Fri May 30, 2008 3:26 pm    Post subject:
Reply with quote

Code:
01 STUDENT-DETAIL.
     05 STUDENT-REC OCCURS 10 TIMES.
          10 STUD-NAME  PIC X(20).
          10 STUD-CLASS PIC X(02).
          10 STUD-ROLL  PIC 9(02).
Back to top
View user's profile Send private message
ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Fri May 30, 2008 3:32 pm    Post subject:
Reply with quote

How is this array being populated ???...

As per my understanding local variables to the subprogram are static ..meaning their value persists from one invocation to another ...

so define your array in the subprogram as

01 ws-array.
05 ws-arr occurs 100 times indexed by ws-indx.
10 name pic x(10).
10 roll-no pic 9(5).
10 class pic x(5).

after receiving the field from the main program use this fr search ..

set ws-indx to 1
search ws-arr
at end display 'not found'
when name(ws-indx) = 'received var' or
roll-no(ws-idx) = 'received var' or
class(ws-idx) = 'received var'

move name(ws-idx) to ws-sent-name
move roll-no(ws-idx) to ws-sent-roll
move class(ws-idx) to ws-sent-class.

this is a rough idea ...try this approach ...
Back to top
View user's profile Send private message
siddhartha biswas
Currently Banned

New User


Joined: 04 May 2008
Posts: 15
Location: india

PostPosted: Fri May 30, 2008 3:37 pm    Post subject: Reply to: Declare array with 3 fields. Pass 1 field & ge
Reply with quote

Thanks, but i need to hard code the data in the array, how can i do that?
Back to top
View user's profile Send private message
ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Fri May 30, 2008 3:45 pm    Post subject:
Reply with quote

asy the array has 2 occurences

01 tab.
02 tab-val.
05 filler pic X(7) value 'sid99AB'
05 filler pic X(7) value 'idd33CD'

02 ws-array redefines tab-val occurs 2 times indexed by ws-indx.
05 name pic x(3).
05 roll-no pic 9(2).
05 class pic x(2).

this will have 1st array occurance name as 'sid' roll-no as 99 and class as 'AB' ...
just take care of the variable length ....
Back to top
View user's profile Send private message
siddhartha biswas
Currently Banned

New User


Joined: 04 May 2008
Posts: 15
Location: india

PostPosted: Fri May 30, 2008 4:06 pm    Post subject: Reply to: Declare array with 3 fields. Pass 1 field & ge
Reply with quote

Thanks Ashimer...that was great
Back to top
View user's profile Send private message
ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Fri May 30, 2008 4:10 pm    Post subject:
Reply with quote

You are welcome Siddharth

Quote:


As per my understanding local variables to the subprogram are static ..meaning their value persists from one invocation to another ...



in general and not always ... unless you CANCEL the program after the call or you declare your subprogram as IS INITIAL .
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Fri May 30, 2008 11:11 pm    Post subject:
Reply with quote

Hello,

Quote:
Thanks, but i need to hard code the data in the array, how can i do that?

Unless this is some one-time "special" or just some experiment, i would recommend that the values in the array not be hard-coded. It is far too trivial to simply read the values from an external file and move them into the array rather than making a program change every time a student name needs to be added, deleted, or changed. The initial array definition should be larger than the expected number of "student" entries.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts SORT VSAM file with each field one by... maxsubrat DFSORT/ICETOOL 6 Tue Mar 14, 2017 1:07 pm
No new posts IMS DB-How to update a record (a sing... Nic Clouston IMS DB/DC 9 Thu Mar 09, 2017 4:38 pm
No new posts outrec field outside range Danielle.Filteau SYNCSORT 10 Sat Mar 04, 2017 2:37 am
No new posts DFSORT MUL FIELDS tspr52 DFSORT/ICETOOL 16 Fri Mar 03, 2017 11:53 pm
No new posts 2 byte YEAR from Y'DATE2' field tecnokrat DFSORT/ICETOOL 2 Tue Feb 07, 2017 12:05 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us