Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cobol 85 for MVS

Status
Not open for further replies.

CIPA

Technical User
May 2, 2000
5
CL
I need obtain two (or more) files with the same structure from an unique program. In DEC-VMS we use the &quot;VALUE OF ID IS ...&quot;.<br>For example i need to generate in the same program various files like &quot;FILEnnnn&quot;, where nnnn take a variable value.
 
Yep, DEC COBOL is slick that way.&nbsp;&nbsp;The problem with batch COBOL on an IBM mainframe is that the identification of the file you want goes through another level of articulation in the JCL used to execute your program.&nbsp;&nbsp;(I am assuming MVS here.)&nbsp;&nbsp;The name you give inside the program is just the label(the DDNAME) of the DD statement in the JCL which actually identifies the Data Set Name of the file you want by using the DSN= parm of the DD statement.&nbsp;&nbsp;This gives you the ability to do things like concatenate several input files together and present them to the program as if they were a single file; however I don't know whether IBM ever decided to let you dynamically pick the DD statement you want to attach to from within your program.&nbsp;&nbsp;You will probably have to look into your options for dynamically changing the JCL at the time you execute your program.
 
Hi,<br><br>allocate the file using TSO / CLIST commands in the batch.<br>It is the program IKJEFT01. Let it generate your <br>job, rename a file or whatever. Your program will work with the standard dd-name as described by Bprange. Or submit<br>the job using a CLIST- or REXX command, generating the<br>unique filename you need.<br><br>Perhaps you can use also a temporary filename in the step of the job where your COBOL program works.
 
Thanks.<br><br>I'm a chilean engineer, so my spanish is better than my english.<br><br>I would like read some example, because i think that your opinions don't solve my problem.<br><br>I need to generate multiple reports from a same program. For example<br><br>working storage section.<br>01 filename.<br>&nbsp;&nbsp;&nbsp;05 filler pic x(05) value &quot;filen&quot;.<br>&nbsp;&nbsp;&nbsp;05 nfile&nbsp;&nbsp;pic 9(03).<br>Procedure division.<br>&nbsp;&nbsp;&nbsp;move 1 to nfile<br>cycle.<br>&nbsp;&nbsp;&nbsp;open input file<br>&nbsp;&nbsp;* the name is filen001, after takes the name filen002, etc.<br>&nbsp;&nbsp;&nbsp;write something in file<br>&nbsp;&nbsp;&nbsp;close file<br>&nbsp;&nbsp;&nbsp;add 1 to nfile.<br>&nbsp;&nbsp;&nbsp;if nfile &lt; 8 then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;go to cycle.<br>&nbsp;&nbsp;&nbsp;stop run.<br><br>We have some routines written in assembler that solve the problem, but I'd like use only Cobol for this.<br><br>Thanks again<br><br>CIPA
 
If I understand your problem correctly, you're trying to <br>create the same report from a variety of like formatted files.<br><br>The traditional batch COBOL solution to this problem is to execute the report program multiple times, changing the input file DSN with each execution, e.g.:<br><br>//s1 exec pgm=rptpgm<br>//infile&nbsp;&nbsp;dd dsn=myfile.n1,etc<br>//rptfile dd sysout=*<br><br>//s2 exec pgm=rptpgm<br>//infile&nbsp;&nbsp;dd dsn=myfile.n2,etc<br>//rptfile dd sysout=*<br><br>//s3 etc.<br><br>If your input files can be differentiated from one another (e.g. a header record or some sort of file id), the input files can be concatinated and the program can test for the presence of a header rec to begin a new report. This approach requires only only one execution of the report pgm. The JCL would look something like this: <br><br>//s1 exec pgm=rptpgm<br>//infile&nbsp;&nbsp;dd dsn=myfile.n1,etc<br>//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dd dsn=myfile.n2,etc<br>//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dd dsn=myfile.n3,etc<br>//rptfile dd sysout=*<br>&nbsp;&nbsp;&nbsp;
 
Thanks, but My probles is taht I don´t know the output file names previously. They are dynamically given throught reding an input file or a database
 
CIPA,<br><br>You could write a cobol pgm that reads the file that contains the dsnames, creates Jobjcl and writes it to the internal reader. The Jobjcl will contain one step for every file you read. Each step will execute your report program. Each JCL step will contain a DD card containing a different DSN= parameter depending on that file or database you mentioned. It's probably not much different than the Assembler solution you mentioned, but it IS Cobol.<br><br>&nbsp;&nbsp;&nbsp;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top