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
 

 

vary occurs clause based on the number of Records

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

New User


Joined: 28 Aug 2006
Posts: 50
Location: London

PostPosted: Mon Jul 07, 2008 7:15 pm    Post subject: vary occurs clause based on the number of Records
Reply with quote

I have a File which contains 10 records. And i need to declare an Array whose occurs clause should be based on the Number of records, In my case it is 10.

Sree
Back to top
View user's profile Send private message

Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Mon Jul 07, 2008 7:20 pm    Post subject:
Reply with quote

What is the problem?
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8057
Location: East Dubuque, Illinois, USA

PostPosted: Mon Jul 07, 2008 7:43 pm    Post subject:
Reply with quote

As long as the number of records in the file is fixed, no problem. If the number of records in the file is not fixed, you'll have to devise a method to find the record count, update the array in your COBOL source, and recompile the program before you can use it. Not really a good use of COBOL -- there's other, better ways to do this.
Back to top
View user's profile Send private message
sreekusr
Warnings : 1

New User


Joined: 28 Aug 2006
Posts: 50
Location: London

PostPosted: Mon Jul 07, 2008 8:01 pm    Post subject: Reply to: vary occurs clause based on the number of Records
Reply with quote

Hi Robert/Craig,

Thanks a Lot for the Response.

Robert ,can you please let me know on the other solutions.

Thanks,
Sree
Back to top
View user's profile Send private message
ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Mon Jul 07, 2008 8:08 pm    Post subject:
Reply with quote

Y u want to recompile and all ??? if you have an idea of the maximum records that can be there in the file (atleast somewhere near the max count) declare an array with the max count using depending on clause which will be based on the rec count ....
Back to top
View user's profile Send private message
sreekusr
Warnings : 1

New User


Joined: 28 Aug 2006
Posts: 50
Location: London

PostPosted: Mon Jul 07, 2008 8:39 pm    Post subject:
Reply with quote

Hi Ashimer,

Thanks a lot for the reply.

Sree
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: Mon Jul 07, 2008 9:06 pm    Post subject:
Reply with quote

Hello,

If you know the maximum possible number of records you might use an "occurs depending on" and populate that value with the record count.

The code would need to make sure the total number of records did not exceed the maximum and abend accordingly.
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Tue Jul 08, 2008 2:30 pm    Post subject:
Reply with quote

Hi,

You might like to use something like..(just the code-extension of above replies)
Code:
01  TABLE.                                     
     05 COUNT           PIC S9(03)    COMP-3. 
     05 TBL OCCURS 100 TIMES                   
                   DEPENDING ON COUNT         
                   INDEXED BY IDX.               
        10 VAR-1            PIC X(03).             
        10 VAR-2              PIC X(02).             


And the valuse of
Code:
05 COUNT           PIC S9(03)    COMP-3. 

can come from input-files (right-away) or you might get it from the 'current' program itself.
Back to top
View user's profile Send private message
Antonio Barata
Warnings : 1

New User


Joined: 04 Apr 2007
Posts: 37
Location: Lisbon, Portugal

PostPosted: Tue Jul 08, 2008 4:33 pm    Post subject: Reply to: vary occurs clause based on the number of Records
Reply with quote

Hi
I don't know whether this applies or not but, alternatively you can increment the count as you read the file. Anyway, you won't have access to the data until you read it right?
Something like this:

READ infile
IF valid record
ADD 1 to count
END-IF
END-READ
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 Check if any Detail records and extra... V S Amarendra Reddy SYNCSORT 19 Mon May 08, 2017 8:54 pm
No new posts SMTP the current generation number of... Jyothi Kulunde JCL & VSAM 4 Thu May 04, 2017 4:08 pm
No new posts Group Data based on a key Arun Raj DFSORT/ICETOOL 7 Thu Apr 27, 2017 11:29 pm
No new posts Edit large number of datasets (QSAM) zh_lad TSO/ISPF 3 Tue Apr 04, 2017 6:08 pm
No new posts how to mask the phone number kumarinfy DB2 4 Mon Apr 03, 2017 5:23 pm


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