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
 

 

Write to sequence of files

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler
View previous topic :: :: View next topic  
Author Message
Karthikeyan Subbarayan

New User


Joined: 24 Feb 2008
Posts: 56
Location: Boston

PostPosted: Wed Aug 07, 2013 11:00 pm    Post subject: Write to sequence of files
Reply with quote

Hi,
Is there a way to open all files sequentially in few lines.
For eg i have file with names as File01, File02,....till File99
Instead of coding like below, is there a way to reduce the line of coding
Code:

DCL FILE01                   FILE RECORD OUTPUT; 
DCL FILE02                   FILE RECORD OUTPUT; 
DCL FILE03                   FILE RECORD OUTPUT; 
.
.
.
DCL FILE99                   FILE RECORD OUTPUT; 
Back to top
View user's profile Send private message

Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1738
Location: Bloomington, IL

PostPosted: Wed Aug 07, 2013 11:12 pm    Post subject:
Reply with quote

Code:
DCL (FILE01, FILE02, ...
     FILE98, FILE99)                    FILE RECORD OUTPUT;
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1716
Location: UK

PostPosted: Wed Aug 07, 2013 11:18 pm    Post subject:
Reply with quote

Did you check the manual for syntax?

You can also open/close multiple files in the same sort of way.
Back to top
View user's profile Send private message
Karthikeyan Subbarayan

New User


Joined: 24 Feb 2008
Posts: 56
Location: Boston

PostPosted: Wed Aug 07, 2013 11:36 pm    Post subject: Reply to: Write to sequence of files
Reply with quote

Thanks, I know this .......
I thought, do we can open the file in a while loop since the file names are sequential ? .......
If we do in a loop then it is like dynamic right icon_sad.gif
Back to top
View user's profile Send private message
prino

Active Member


Joined: 07 Feb 2009
Posts: 985
Location: Oostende, Belgium

PostPosted: Thu Aug 08, 2013 1:20 am    Post subject:
Reply with quote

Use a pre-processor loop to write the code for you.
Back to top
View user's profile Send private message
mistah kurtz

Active User


Joined: 28 Jan 2012
Posts: 268
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Thu Aug 08, 2013 10:53 am    Post subject:
Reply with quote

hi..I was just wondering if we can use File Variable for opening..though it will still require the DECLARE statements for all of them..something like below:
Code:
DECLARE OUTFILE   FILE VARIABLE;
DECLARE COUNT     PIC'99'      INIT(0)  ;
.
.
.
DO COUNT =  1 TO 99;
   OUTFILE = 'FILE' || CHAR(COUNT);
   OPEN FILE(OUTFILE);
END;

I don't have access to Mainframe to test it..but just a thought which occured to me..will it work?
Back to top
View user's profile Send private message
prino

Active Member


Joined: 07 Feb 2009
Posts: 985
Location: Oostende, Belgium

PostPosted: Thu Aug 08, 2013 2:53 pm    Post subject:
Reply with quote

NO!
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1738
Location: Bloomington, IL

PostPosted: Thu Aug 08, 2013 4:13 pm    Post subject:
Reply with quote

mistah kurtz wrote:
hi..I was just wondering if we can use File Variable for opening..though it will still require the DECLARE statements for all of them..something like below:
Code:
DECLARE OUTFILE   FILE VARIABLE;
DECLARE COUNT     PIC'99'      INIT(0)  ;
.
.
.
DO COUNT =  1 TO 99;
   OUTFILE = 'FILE' || CHAR(COUNT);
   OPEN FILE(OUTFILE);
END;

I don't have access to Mainframe to test it..but just a thought which occured to me..will it work?

To expand on Mr. Prins' answer, only a file (constant or variable) can be assigned to a file variable; you are attempting to assign a character string to it in your example. No can do.
Back to top
View user's profile Send private message
Garry Carroll

Active Member


Joined: 08 May 2006
Posts: 990
Location: Dublin, Ireland / Edinburgh, Scotland

PostPosted: Thu Aug 08, 2013 5:18 pm    Post subject:
Reply with quote

You can, however, declare the individual files and a FILE VARIABLE as an array. The files can be assigned to the array elements and these can then be processed in a loop.....

Code:

DCL   MYFILE(3)        FILE VARIABLE;
DCL   FILE1            FILE RECORD OUTPUT;   
DCL   FILE2            FILE RECORD OUTPUT;   
DCL   FILE3            FILE RECORD OUTPUT;   

MYFILE(1) = FILE1;
MYFILE(2) = FILE2;
MYFILE(3) = FILE3;

Do I = 1 to 3;
  OPEN FILE(MYFILE(I));
End;


Garry
Back to top
View user's profile Send private message
prino

Active Member


Joined: 07 Feb 2009
Posts: 985
Location: Oostende, Belgium

PostPosted: Thu Aug 08, 2013 10:14 pm    Post subject:
Reply with quote

Garry Carroll wrote:
You can, however, declare the individual files and a FILE VARIABLE as an array. The files can be assigned to the array elements and these can then be processed in a loop.....

Code:

DCL   MYFILE(3)        FILE VARIABLE;
DCL   FILE1            FILE RECORD OUTPUT;   
DCL   FILE2            FILE RECORD OUTPUT;   
DCL   FILE3            FILE RECORD OUTPUT;   

MYFILE(1) = FILE1;
MYFILE(2) = FILE2;
MYFILE(3) = FILE3;

Do I = 1 to 3;
  OPEN FILE(MYFILE(I));
End;

And that just moves the typing from the open statements to the assignments.

Sigh...
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1738
Location: Bloomington, IL

PostPosted: Thu Aug 08, 2013 10:37 pm    Post subject:
Reply with quote

prino wrote:
Use a pre-processor loop to write the code for you.

I believe that Mr. Prins has something like this in mind:
Code:
 foo42:  proc options (main) reorder;                   
 %dcl (i, #) fixed;                                     
 %dcl name char;                                       
                                                       
 %do i = 1 to 99;                                       
   %name = 'FILE' || trim(i);                           
   DCL NAME                         FILE RECORD OUTPUT;
   OPEN FILE(NAME);                                     
 %end;                                                 
                                                       
 end foo42;                                             
Back to top
View user's profile Send private message
prino

Active Member


Joined: 07 Feb 2009
Posts: 985
Location: Oostende, Belgium

PostPosted: Thu Aug 08, 2013 11:00 pm    Post subject:
Reply with quote

Akatsukami wrote:
prino wrote:
Use a pre-processor loop to write the code for you.

I believe that Mr. Prins has something like this in mind:
Code:
 foo42:  proc options (main) reorder;                   
 %dcl (i, #) fixed;
 %dcl name char;

 %do i = 1 to 99;
   %name = 'FILE' || trim(i);
   DCL NAME                         FILE RECORD OUTPUT;
   OPEN FILE(NAME);
 %end;
                                                       
 end foo42;


Do we really have to supply ready-made answers, why not force the wuckfits to open a manual themselves every now and then?
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1738
Location: Bloomington, IL

PostPosted: Thu Aug 08, 2013 11:10 pm    Post subject:
Reply with quote

prino wrote:
Akatsukami wrote:
prino wrote:
Use a pre-processor loop to write the code for you.

I believe that Mr. Prins has something like this in mind:
Code:
 foo42:  proc options (main) reorder;                   
 %dcl (i, #) fixed;
 %dcl name char;

 %do i = 1 to 99;
   %name = 'FILE' || trim(i);
   DCL NAME                         FILE RECORD OUTPUT;
   OPEN FILE(NAME);
 %end;
                                                       
 end foo42;


Do we really have to supply ready-made answers, why not force the wuckfits to open a manual themselves every now and then?

IMNSHO, the PL/I pre-processor is a slightly obscure topic. The average software engineer can no more learn to use it by reading the fine manual than heesh can learn PL/I itself that way,
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 -> PL/I & Assembler All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts High CPU consumption Job using IAM fi... aswinir JCL & VSAM 8 Thu Dec 01, 2016 8:28 pm
No new posts Match or compare two files in VB Format anatol DFSORT/ICETOOL 14 Thu Nov 03, 2016 7:41 pm
This topic is locked: you cannot edit posts or make replies. How to use 2 input files in control c... Gunapala CN DFSORT/ICETOOL 23 Thu Oct 13, 2016 3:42 pm
No new posts Error IEC161I 052(009,XXXRS00)-084 wh... amitc23 JCL & VSAM 10 Wed Oct 12, 2016 5:00 pm
No new posts Adding records from two files into on... shiitiizz SYNCSORT 4 Mon Sep 19, 2016 8:41 pm


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