[Tutor] Script to generate statements
Charles Leviton
charles.leviton at gmail.com
Fri Mar 15 20:42:15 CET 2013
I was recently given this task. it's a very IBM mainframe specific task so
I'm not sure how to find equivalent terms in another environment. I will
just use the mainframe terminology and hopefully y'all can figure out what
I mean.
Given a list of DBRM members create a JCL which has a series of bind
statements for each DBRM.
This is the tack I took. I have 3 input files
a_ contains the fixed part of the JCL
b_ contains the template for the bind statement.
c_ contains the list of DBRMs
This is the script I came up with...Would you critique it and let me know
how I could have done it better?
#create a series of bind statements
fo = open('i:/text/jclout.txt', 'w')
fi = open('i:/text/bindjclfirstpart.txt','rU')
fibindjclvar = open('i:/text/bindjclvariable.txt','rU')
filistofdbrms= open('i:/text/bindjcldbrmlist.txt','rU')
varlines =[]
varlines = fibindjclvar.readlines()
for line in fi: #write out all the lines in the first part of JCL
fo.write(line)
fo.write('\n')
varline = ''
for dbrm in filistofdbrms:
fo.write('\n')
for index in range(0,9):
if varlines[index].find('member') > 0:
varline = varlines[index] + '('+ dbrm + ')' + ' -'
else:
varline = varlines[index]
fo.write(varline)
fo.close()
fi.close()
fibindjclvar.close()
filistofdbrms.close()
The "variable" part of the bind statement is where I have to include the
DBRM name. I look for the word 'member' in the template.
Template looks like this (content of bindjclvariable.txt)
BIND PACKAGE(PROD) -
MEMBER
OWNER(PRODOWNR) -
QUALIFIER(PRODTBLS) -
ISOLATION(CS) -
EXPLAIN(YES) -
ACTION(REPLACE) -
CURRENTDATA(YES) -
VALIDATE(BIND)
Thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20130315/5f14874e/attachment.html>
More information about the Tutor
mailing list