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 create and write to an output File

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
View previous topic :: :: View next topic  
Author Message
rajman

New User


Joined: 29 Jun 2007
Posts: 2
Location: Singapore

PostPosted: Mon Jul 23, 2007 9:01 am    Post subject: How to create and write to an output File
Reply with quote

Hi All,

I am trying to generate a listing of data sets which are taking more than
150 Tracks and write them to an output file.

In order to do this, I used LISTDSI to get the details of files but I
don't know how to write them into an output file:

Here is what I have coded so far:

Code:

/* REXX */                                                   
"DELETE OUTPUT.FILE"                                 
"ALLOC DA(OUTPUT.FILE) NEW REU RECFM(F,B) LRECL(80)",
"DIR(255) SPACE(10,10) TRACKS UNIT(SYSDA)"                   
                                                             
"ISPEXEC LMDINIT LISTID(IDV) LEVEL(FILES.*)"           
  DO FOREVER                                                 
    "ISPEXEC LMDLIST LISTID("IDV") OPTION(LIST)" ,           
                    "DATASET(DSNVAR) STATS(YES)"             
     IF RC = 0 THEN CALL WRITE_OUTFILE                       
     ELSE LEAVE                                             
  END                                                       
"ISPEXEC LMDLIST LISTID("IDV") OPTION(FREE)"                 
                                                             
EXIT   
                                                             

/*-- WRITE TO AN OUTPUT --*/             
 WRITE_OUTFILE :                     
   X = LISTDSI(DSNVAR)               
   OUTREC = DSNVAR ' ; ' SYSALLOC ';' SYSBLKSTRK             
 /* i want to write outrec to allocated file "OUTPUT.FILE"  */
                                     
 RETURN   

So in a nutshell here are my problems:
1. How do I write the details (e.g. SYSALLOC, SYSBLKSTRK) into the output file I have newly allocated. Sample Coded is greatly appreciated.

2. Is there a way to sort this listing according to SYSALLOC?


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

ofer71

Global Moderator


Joined: 27 Dec 2005
Posts: 2360
Location: Israel

PostPosted: Mon Jul 23, 2007 10:40 am    Post subject:
Reply with quote

First, assign a FILE name to your allocated file. Then use EXECIO with DISKW to write into that file.

If it was my mission, I would probably fill an array with the data, then sort it using a simple bubble sort algorithm, then write the whole array into the file.

O.
Back to top
View user's profile Send private message
rajman

New User


Joined: 29 Jun 2007
Posts: 2
Location: Singapore

PostPosted: Fri Jul 27, 2007 6:24 am    Post subject:
Reply with quote

Hi ofer71,

Thanks for your tips. How do you code a bubble sort algorithm?
Can you provide a sample code to make it easier for me to
understand?

Thanks in advance.
Roni
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: Fri Jul 27, 2007 6:58 am    Post subject:
Reply with quote

Hello and welcome to the forums,

See if this will help - i snagged it from the web and have not actually loaded it onto a system and tried it.

Code:
/*rexx program bubbsort - illustrates a bubble sort */

/* load the array
   may also be loaded by execio, or a call outtrap
*/
name.1 = "marie"
name.2 = "beth"
name.3 = "linda"
name.4 = "maria"
name.5 = "nadia"
name.6 = "angela"
name.7 = "michelle"
count_of_elements = 7

/* loop through the array (count_of_elements - 1) ** 2 times */
do i = 1 to  (count_of_elements - 1)
   do j = 1 to (count_of_elements - 1)
      j_plus1 = j + 1
      /* if an element is greater than the next one higher,
         interchange them */
      if name.j > name.j_plus1 then call flipem
   end j
end i

/* show results*/
do i = 1 to count_of_elements
   say name.i
end i

exit

flipem:
/* reverse the order of the two elements */
temp = name.j
name.j = name.j_plus1
name.j_plus1 = temp
return

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 -> CLIST & REXX All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Split file based on comparsion to 2 f... Div Grad DFSORT/ICETOOL 3 Thu Jul 27, 2017 9:16 pm
No new posts Read two inputs and write into output... murali.andaluri DFSORT/ICETOOL 6 Wed Jul 26, 2017 7:35 pm
No new posts Extra character appears in file when ... Balu5491 All Other Mainframe Topics 1 Wed Jul 26, 2017 2:39 pm
No new posts SSH - known_hosts file configuration vasanthz All Other Mainframe Topics 2 Wed Jul 26, 2017 2:10 am
This topic is locked: you cannot edit posts or make replies. Fetching data from BAI File arunsoods JCL & VSAM 1 Wed Jul 19, 2017 4:28 pm


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