View previous topic :: View next topic
|
Author |
Message |
Ezhil Murugan
New User
Joined: 10 Jul 2008 Posts: 14 Location: Chennai
|
|
|
|
Hi ,
I've a group variable which has 4 subvariables. The group variable has an occurs of 250. I need to initialize all the occurences of a specific sub variable
See below
01 FILE-DATA OCCURS 250 TIMES.
05 NAME PIC X(20).
05 AGE PIC 9(3).
05 TOTAL-PREM PIC S9(5)V99 COMP-3
In the above, I need to initialize all the 250 occurences of TOTAL-PREM alone. Is there any way to do it other than looping 250 times and initializing it ? |
|
Back to top |
|
|
ashimer
Active Member
Joined: 13 Feb 2004 Posts: 551 Location: Bangalore
|
|
|
|
Occurs cannot be at 01 level ... i dont think MOVE or INITIALIZE would work here ... you will have to use PERFORM ... |
|
Back to top |
|
|
sri_mf
Active User
Joined: 31 Aug 2006 Posts: 218 Location: India
|
|
|
|
I have tried the following cases.
Code: |
01 WS-VARIABLES.
05 WS-OCCURS.
10 WS-A1 OCCURS 3 TIMES
INDEXED BY I.
20 WS-A1-1 PIC 9(9).
20 WS-A1-2 PIC X(9).
01 WS-OCCURS.
10 WS-A1 OCCURS 3 TIMES
INDEXED BY I.
20 WS-A1-1 PIC 9(9).
20 WS-A1-2 PIC X(9). |
INITIALIZE WS-OCCURS worked fine.
Please correct me if i am wrong. |
|
Back to top |
|
|
ashimer
Active Member
Joined: 13 Feb 2004 Posts: 551 Location: Bangalore
|
|
|
|
Sri, You are right it will initialize both WS-A1-1 and WS-A1-2 ... but INITIALIZE WS-A1-1 will not work .... |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
Assign a VALUE clause to each elementary array-field and it will be initialized to the specified value prior to program execution.
This has been valid since COBOL2 or COBOL/370, can't recall.
Code: |
01 WS-VARIABLES.
05 WS-OCCURS.
10 WS-A1 OCCURS 3 TIMES
INDEXED BY I.
20 WS-A1-1 PIC 9(9) VALUE ZERO.
20 WS-A1-2 PIC X(9) VALUE SPACES.
|
Bill |
|
Back to top |
|
|
sri_mf
Active User
Joined: 31 Aug 2006 Posts: 218 Location: India
|
|
|
|
ashimer wrote: |
but INITIALIZE WS-A1-1 will not work .... |
Yes ashmir,I too accept with you.
If that is the case then OP has to follow your first solution ie.using perform. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
If that is the case then OP has to follow your first solution ie.using perform. |
Or simply provide a VALUE in the definition as Bill suggests. |
|
Back to top |
|
|
ashimer
Active Member
Joined: 13 Feb 2004 Posts: 551 Location: Bangalore
|
|
|
|
true, and second time you want to initialize use perform ... |
|
Back to top |
|
|
Ezhil Murugan
New User
Joined: 10 Jul 2008 Posts: 14 Location: Chennai
|
|
|
|
Thanks all for your help ! |
|
Back to top |
|
|
|