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
 

 

How to Initialize all occurences of a specific Sub Variable

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
Ezhil Murugan

New User


Joined: 10 Jul 2008
Posts: 14
Location: Chennai

PostPosted: Wed Aug 06, 2008 3:21 pm    Post subject: How to Initialize all occurences of a specific Sub Variable
Reply with quote

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

ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Wed Aug 06, 2008 3:36 pm    Post subject:
Reply with quote

Occurs cannot be at 01 level ... i dont think MOVE or INITIALIZE would work here ... you will have to use PERFORM ...
Back to top
View user's profile Send private message
sri_mf

Active User


Joined: 31 Aug 2006
Posts: 216
Location: India

PostPosted: Wed Aug 06, 2008 5:56 pm    Post subject: Reply to: How to Initialize all occurences of a specific Sub
Reply with quote

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

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Wed Aug 06, 2008 5:59 pm    Post subject:
Reply with quote

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

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Wed Aug 06, 2008 6:05 pm    Post subject: Re: How to Initialize all occurences of a specific Sub Varia
Reply with quote

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

Active User


Joined: 31 Aug 2006
Posts: 216
Location: India

PostPosted: Wed Aug 06, 2008 6:18 pm    Post subject:
Reply with quote

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

Site Director


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

PostPosted: Wed Aug 06, 2008 9:42 pm    Post subject:
Reply with quote

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

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Wed Aug 06, 2008 9:48 pm    Post subject:
Reply with quote

true, and second time you want to initialize use perform ...
Back to top
View user's profile Send private message
Ezhil Murugan

New User


Joined: 10 Jul 2008
Posts: 14
Location: Chennai

PostPosted: Thu Aug 07, 2008 9:03 pm    Post subject:
Reply with quote

Thanks all for your help !
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 how to split records based on specifi... Venkata Ramayya DFSORT/ICETOOL 6 Wed Sep 28, 2016 3:20 am
No new posts Format to pipe delimited with variabl... pshongal SYNCSORT 6 Wed Sep 14, 2016 2:48 pm
No new posts How to calculate an specific transact... lind sh CICS 2 Tue Sep 13, 2016 9:20 pm
No new posts DFSORT sorting only specific records akodakka DFSORT/ICETOOL 4 Thu Aug 04, 2016 11:24 am
No new posts Variable for cursor names ravikumar15 DB2 5 Sun Jul 17, 2016 7:08 am


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