Initialize second level of a two dimensional array



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

Initialize second level of a two dimensional array

Postby abhi24in » Mon Jul 28, 2008 1:21 pm

Hi,

I need to initialize only the second level of a two-d array in cobol and preserve the filrst level without looping using a perform varying statement to the second level. Is there any way without using the subscript?

Ex -

01 ws-item-count occurs 9 times.
05 ws-item-1 X(1).
05 ws-item-2 x(2).
05 ws-item-3 occurs 4 times.
10 ws-it3-a1 X(01).
10 ws-it3-a2 x(01).
10 ws-it3-a3 x(01).


Now i need to initialize only WS-ITEM-3 (which occurs 4 times but need to save the upper items at level 1 of the array)

Thanks in advance.
Abhinav
abhi24in
 
Posts: 3
Joined: Mon Jul 21, 2008 4:43 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Initialize second level of a two dimensional array

Postby dick scherrer » Mon Jul 28, 2008 9:59 pm

Hello and welcome to the forums,

I need to initialize only the second level of a two-d array in cobol and preserve the filrst level without looping using a perform varying statement to the second level. Is there any way without using the subscript?
What determined this requirement? It makes no sense. . .

Is there any way without using the subscript?
Sure, define the arrays with an index instead.

If you better explain the real requirement, someone may have suggestions.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: Initialize second level of a two dimensional array

Postby abhi24in » Tue Jul 29, 2008 10:22 am

Well the code logic is such that we check for broken policies- by populating the 2 dimension first for each 1st D item now if we find that if any variable in the 2D of the array satisfies our criteria of a policy not broken we need to retain the 1st D item and move spaces to all the elements of the 2D indicating that the 1st D item is not broken for the output report.

Thus leading to the requirement - The broken policy pertain to Auto insurance sector where in the 1st D is for the number of vehicles on the policy and the 2 D is for the number of people driving the vehicle. Now if any of the drivers satisfy the condition we are looking for a particular vehicle we need to mark that policy asa not broken. Hope that makes a little sense wrt to the question asked by me.

We cannot move spaces to the vehicle count but need to remove all drivers for that vehicle before writing out the report.
Thanks in advance.
abhi24in
 
Posts: 3
Joined: Mon Jul 21, 2008 4:43 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Initialize second level of a two dimensional array

Postby dick scherrer » Tue Jul 29, 2008 11:42 am

Hello,

How does that info relate to doing what you need without looping or using the subscript?

To navigate thru the array you will both loop and use the subscript.

I see nothng in your explanaton of the requirement that would cause problems if the code looped and used a subscript :?
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: Initialize second level of a two dimensional array

Postby abhi24in » Fri Aug 01, 2008 2:57 pm

Hello,

Well i also know that there would be no problem by looping thru thr array to initialize the second level :) ......but i just wanted to know if there was any other or better way to go about it other...cos writing an initialize statement for a Group variable would be a whole lot simpler than using a Perform varying statement on the array.

Well thanx neways....
abhi24in
 
Posts: 3
Joined: Mon Jul 21, 2008 4:43 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Initialize second level of a two dimensional array

Postby dick scherrer » Fri Aug 01, 2008 6:27 pm

You're welcome :)

d
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post