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: 7992
Location: Bellevue, IA

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 JCL to Set Return code based on DB2 S... vinu78 DB2 17 Mon Mar 13, 2017 9:47 pm
No new posts what is meaning of the number in dcl Martylin PL/I & Assembler 2 Thu Mar 09, 2017 7:18 am
No new posts Join giving more records than expected Danielle.Filteau SYNCSORT 2 Thu Mar 09, 2017 3:28 am
No new posts TSO or command line utility to genera... kishpra JCL & VSAM 3 Thu Mar 09, 2017 1:11 am
No new posts Extract set of records matching on ac... bhaskar_kanteti DFSORT/ICETOOL 3 Mon Mar 06, 2017 7:19 am


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