to write to a file



IBM's Command List programming language & Restructured Extended Executor

to write to a file

Postby mainframe1 » Fri Dec 10, 2010 1:21 pm

I need to get all the datasets from the qualifier abc. I've wriiten rexx code for that. now I need to write all these datasets + creation date+volume occupied to a file.pls help me in the code

DSLEVEL = 'abc.*'                                             
"ALLOC F(INPUT) SHR DS(Q5O100.DATA.LIST)"                         
ADDRESS 'ISPEXEC'                                                 
"LMDINIT LISTID(LISTID) LEVEL("DSLEVEL")"                         
IF RC > 0 THEN RETURN 0                                           
"LMDLIST LISTID("LISTID") DATASET(DSNAME) STATS(YES)             
       OPTION(LIST)"                                             
DO WHILE RC = 0                                                   
SAY DSNAME ZDLCDATE ZDLVOL ZDLSPACU                           
   PARSE VAR DSNAME ZDLCDATE ZDLVOL ZDLSPACU TEST.               
 "EXECIO *  DISKW INPUT (FINIS TEST."       
                                                                 
  "LMDLIST LISTID("LISTID") DATASET(DSNAME) STATS(YES) OPTION(LIST
END
mainframe1
 
Posts: 35
Joined: Wed Oct 08, 2008 11:39 am
Has thanked: 0 time
Been thanked: 0 time

Re: to write to a file

Postby NicC » Fri Dec 10, 2010 5:07 pm

just assign your values to a variable and write it using EXECIO. And write one variable at a time as you create it. Also, INPUT as an output file DDNAME - NO!. Use something more appropriate.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Re: to write to a file - A SOLUTION

Postby Steve Coalbran » Wed Nov 13, 2013 12:33 pm

Hi Nic!
Just for interest, as it is sooooooooooooooo OLD!
I think I understood what he meant but had to use the psychic-option on turbo-boost!
This writes the dataset information he wanted as a CSV file but you could easily change the "w1" assignments ?
It includes a very simple example of BPXWDYN. This also could be switched for a straight TSO ALLOC?
/*REXX*/                                                               
TRACE "N"
ADDRESS ISPEXEC
"CONTROL ERRORS RETURN " 
pfx = 'K248610.USER'      /* -OR- ...                  */
/*----------------------------------------------------------*/
/* accept the prefix as an argument?  Uncomment to activate */
/*----------------------------------------------------------*/
/* ARG pfx */     
                                             
/*-----------------------------------------------------------*/
/* create a temporary list area in VIO for the CSV data      */
/*-----------------------------------------------------------*/
RC = BPXWDYN("ALLOC NEW REUSE RTDDN(TDD) LRECL(255)",
 "RECFM(VB) UNIT(VIO) SPACE(5,5)TRACKS ")                           
IF( RC<>0 )THEN EXIT ABS(RC)             
                                     
/*-------------------------------------------------------------*/
/* recall all dsns matching the prefix?  Uncomment to activate */
/*-------------------------------------------------------------*/
/* ADDRESS TSO "HRECALL '"pfx"' " */   

/*-----------------------------------------------------------*/
/* scan through all datasets matching the prefix             */
/*-----------------------------------------------------------*/
"LMDINIT LISTID(LID) LEVEL("pfx") "       
IF( RC<>0 )THEN EXIT ABS(RC)       
h1 = "Dataset Name ,Create Date , Volume ,Space Units ,"
ADDRESS TSO "EXECIO 1 DISKW" tdd "(STEM H "
lst = "LISTID(&LID) DATASET(DSN) STATS(YES) OPTION(LIST) "
"LMDLIST" lst             
DO WHILE RC = 0               
   w1 = STRIP(dsn)" ,",                 
      !!STRIP(zdlcdate)" ,",           
      !!STRIP(zdlvol)" ,",                       
      !!STRIP(zdlspacu)" ,"             
   ADDRESS TSO "EXECIO 1 DISKW" tdd "(STEM W " 
   "LMDLIST" lst                             
END                                       
"LMDLIST LISTID(&LID) OPTION(FREE) "           
"LMDFREE LISTID(&LID) "                     
ADDRESS TSO "EXECIO 0 DISKW" tdd "(FINIS "         
                                               
/*-----------------------------------------------------------*/
/* view the generated dataset 'CSV' file                     */
/*-----------------------------------------------------------*/
"LMINIT DATAID(VID) DDNAME("tdd") "   
             
"VIEW   DATAID(&VID) "                   
"LMFREE DATAID(&VID) "               
                                     
EXIT /*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
Steve
User avatar
Steve Coalbran
 
Posts: 138
Joined: Wed Apr 06, 2011 11:49 am
Location: Stockholm, Sweden
Has thanked: 13 times
Been thanked: 1 time


Return to CLIST & REXX

 


  • Related topics
    Replies
    Views
    Last post