IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

rexx pgm to create multiple ps file


IBM Mainframe Forums -> IBM Tools
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Saranya Mani

New User


Joined: 07 May 2021
Posts: 2
Location: India

PostPosted: Fri May 07, 2021 6:27 am
Reply with quote

Hi,
This is my first post and very excited to see the results.

I am new to REXX..
To create bulk ps file in same record length and format i need code..
My code is not working
This is my code.

ADDRESS TSO
"alloc da('******.jcl.lib(T5358S1V)') fi(gdgver) shr reuse"
"execio * diskr gdgver (stem write. finis"
write.1 = '//******* JOB ''NEW VER'','
write.2 = '// MSGCLASS=M,'
write.3 = '// CLASS=B,'
write.4 = '// MSGLEVEL=(1,1)'
write.5 = '//*'
write.6 = '//STEP01 EXEC PGM=IEFBR14'
write.7 = '//INPUT DD'
w=7
"alloc da('********.C.LIST') fi(input) shr reuse"
"execio * diskr input (stem read. finis"
do i=1 to read.0 by 1
dsname = word(read.i,1)
w=w+1
write.w= '// DSN=('dsname'),'
w=w+1
write.w= '// DISP=(NEW,KEEP,DELETE),'
w=w+1
write.w= '// UNIT=SYSDA,SPACE=(TRK,5),'
w=w+1
write.w= '// DCB=(LRECL=1000,RECFM=FB,DSORG=PS)'
w=w+1
end
"execio * diskw gdgver (stem write. finis"

in *******.c.list i have the new file names
I am trying to create multiple
dd dsn=aaaaa, disp=(new,catlg,delete)
dd dsn=bbbbb, disp=(new,catlg,delete)
.
.
.
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1231
Location: Bamberg, Germany

PostPosted: Fri May 07, 2021 6:52 am
Reply with quote

Please, use code tags (button) when presenting code/data. They work as a toggle but allow us to help you better.

Show error msgs!
Back to top
View user's profile Send private message
Saranya Mani

New User


Joined: 07 May 2021
Posts: 2
Location: India

PostPosted: Fri May 07, 2021 7:22 am
Reply with quote

Code:
The result is its creating jcl to create bulk ps files, like the below
//***** JOB 'NEW VER',                           
//           MSGCLASS=M,                           
//           CLASS=B,                               
//           MSGLEVEL=(1,1)                         
//*                                                 
//STEP01  EXEC PGM=IEFBR14                         
//INPUT DD                                         
//       DSN=(*******.GDG1),                       
//       DISP=(NEW,KEEP,DELETE),                   
//       UNIT=SYSDA,SPACE=(TRK,5),                 
//       DCB=(LRECL=1000,RECFM=FB,DSORG=PS)         
//       DCB=(LRECL=1000,RECFM=FB,DSORG=PS)         
//       DSN=(******.GDG2),                       
//       DISP=(NEW,KEEP,DELETE),                   
//       UNIT=SYSDA,SPACE=(TRK,5),                 
//       DCB=(LRECL=1000,RECFM=FB,DSORG=PS)         
//       DCB=(LRECL=1000,RECFM=FB,DSORG=PS)         
//       DCB=(LRECL=1000,RECFM=FB,DSORG=PS)         


The jcl is creating wrong..
I have create multiple gdg bases and want to create dummy generations for all gdg bases created
Back to top
View user's profile Send private message
Willy Jensen

Active Member


Joined: 01 Sep 2015
Posts: 712
Location: Denmark

PostPosted: Fri May 07, 2021 11:28 am
Reply with quote

A couple of things...
Never ever use '*' for record count in EXECIO DISKW, use the actual number. And you haven't set write.0, which would be required for EXECIO * DISKW.
You are using the same dataset for output as for input, do you really intend to destroy your input?
You are not freeing the dataset(s) when you are finished.
In this case I would recommend using QUEUE in stead of a stem for generating the statements.
I will recommend the BPXWDYN program instead of ALLOCATE and FREE.
Don't call them files, they are datasets (you will offend some people when saying 'file').
Have a look at this:
Code:
 /* get list of datasets */                                 
 cc=Bpxwdyn('alloc da(dataset.with.list) shr rtddn(ldd)')   
 if cc<>0 then exit xmsg('alloc listds rc' cc)             
 "execio * diskr" ldd "(stem list. finis)"                 
 cc=Bpxwdyn('free dd('ldd')')                               
                                                           
 /* make job stmt */                                       
 queue "//JOB1 JOB ..."                                     
 queue "//... etc  ..."                                     
                                                           
 /* make allocation steps */                               
 do n=1 to list.0                                           
   queue '//DS'right(n,6,0) 'DD DSN='word(list.n,1)','     
   queue left('//',13) 'UNIT=SYSDA,SPACE=(TRK,5),'         
   queue left('//',13) 'LRECL=1000,RECFM=FB,DSORG=PS'       
 end                                                       
                                                           
 /* write generated job */                                 
 cc=Bpxwdyn('alloc da(output.dataset) shr rtddn(odd)')     
 if cc<>0 then exit xmsg('alloc output rc' cc)             
 "execio" queued() "diskw" odd "(finis)"                   
 cc=Bpxwdyn('free dd('odd')')                               
                                                           
 exit xmsg('Done..')                                       
XMsg: if arg(1)<>'' then say arg(1);return word(arg(2) 0,1)

And once you have it working, you can write the output directly to spool by
Code:
cc=Bpxwdyn('sysout(x) lrecl(80) recfm(f,b) blksize(0)',
           'writer(intrdr) rtddn(odd)')   
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1231
Location: Bamberg, Germany

PostPosted: Fri May 07, 2021 11:40 am
Reply with quote

Thanks Willy for the update.

I would also add to check Return Codes when executing functions, see Willy's sample. Were data read, was open/close successful and such. These are basics in programming.
Back to top
View user's profile Send private message
Willy Jensen

Active Member


Joined: 01 Sep 2015
Posts: 712
Location: Denmark

PostPosted: Fri May 07, 2021 12:23 pm
Reply with quote

Forgot to mention, you should have a "DELSTACK" at the front, or even better a "NEWSTACK" at the front and a "DELSTACK" at the back to prevent include of a residual stack.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2012
Location: USA

PostPosted: Fri May 07, 2021 7:30 pm
Reply with quote

Willy Jensen wrote:
Never ever use '*' for record count in EXECIO DISKW, use the actual number. And you haven't set write.0, which would be required for EXECIO * DISKW.

This is partially true.

1) "EXECIO * DISKW ddname (STEM write." (unlike DISKR) doesn't use the value from write.0 directly. One needs to specify it explicitly (out of quotes!, for REXX to substitute its value into EXECIO command):
Code:
"EXECIO" write.0 "DISKW ddname (STEM write. … "
This is true also for writing from program stack
Code:
"EXECIO" write.0 "DISKW ddname"
or
"EXECIO" w "DISKW ddname"


2) "EXECIO * DISKW ddname (STEM write." tries to write stem or stack elements until either the first not-defined one found, or the first empty string value (e.g. "") detected. This behavior is inconvenient in many cases, that's why using the option "EXECIO * DISKW" is not recommended
Back to top
View user's profile Send private message
Willy Jensen

Active Member


Joined: 01 Sep 2015
Posts: 712
Location: Denmark

PostPosted: Sat May 08, 2021 4:16 pm
Reply with quote

sergeyken is quite correct, thank you for correcting, stem.0 is not required for DISKW *, so DISKW * would work in your case, and indeed for my sample too, as there are no null items.
I still will recommend using a number, as I know people who have been bitten by that null value.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> IBM Tools

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Running REXX through JOB CLIST & REXX 13
No new posts Error to read log with rexx CLIST & REXX 11
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
Search our Forums:

Back to Top