Page 1 of 1

How to give the outputfile name same as input file name.

PostPosted: Mon Mar 19, 2012 8:04 pm
by mathew28
Hi,

I have jcl, which gets the input file through ftp.
Say, XXXX.INPUT.QC1234

I do some processing like SORT, execute an SQL etc.

Create the Output file with the results.
I have to name the output file having the last qualifiler of the input file during runtime
like
XXXX.OUTPUT.QC1234

is this possible ? Can we make use of symbolics ?

Please advice.

Re: How to give the outputfile name same as input file name.

PostPosted: Mon Mar 19, 2012 8:13 pm
by Robert Sample
Symbolics would not help you. Once the job has been submitted, it goes through the converter / interpreter of JES. After that time, the JCL cannot be changed -- PERIOD. Therefore, your symbolic would have to be populated with the desired value BEFORE you submit the job; if the input file name comes from a step while the job is running, then you cannot do it with a single job. You MIGHT be able to split your processing into two jobs and set the value of the symbolic for the second job - but that would depend upon your site standards and what, precisely, you're trying to do.

Re: How to give the outputfile name same as input file name.

PostPosted: Mon Mar 19, 2012 8:56 pm
by mathew28
I will put it more clearly

//step01 exec pgm=ftp
//ftp dd dsn=XXXX.INPUT.&FNAME {XXXX.INPUT.QC1234 }
// DISP=(NEW,CATLG, DELETE),...
//SYSPRINT DD SYSOUT =*
//SYSIN DD *
GET CV/TEST/QC1234.TXT //* <!-- I want this name to come in the last qualifier to the input file or move it to a symbolic so that i can reuse it. SET FNAME=QC1234
QUIT
//step02 exec pgm=sort
//sortin dd dsn=XXXX.INPUT.&FNAME {XXXX.INPUT.QC1234 }
//sortout dd dsn=XXXX.OUTPUT.&FNAME {XXXX.OUTPUT.QC1234 }

IF this is possible . Please help.
Thanks in advance

Re: How to give the outputfile name same as input file name.

PostPosted: Mon Mar 19, 2012 9:28 pm
by BillyBoyo
For your JCL, at a very quick look, what you want to do can be accomplished with symbols. Problem is, your ftp control cards are not JCL. Unless you are on z/OS 1.13, you can't have symbolics in a stream of data.

You can generate the FTP control cards, for instance from DFSORT using JPn to allow the parameterisation.

Re: How to give the outputfile name same as input file name.

PostPosted: Mon Mar 19, 2012 9:55 pm
by MrSpock
mathew28, what you posted, if I understand it correctly, should theoretically work. What's the problem?

//*                                                                 
// SET FNAME=QC1234                                                 
//*                                                                 
//STEP01   EXEC PGM=FTP                                             
//FTP      DD   DSN=XXXX.INPUT.&FNAME,                               
//         DISP=(,CATLG,DELETE),...                                 
//OUTPUT   DD   SYSOUT =*                                           
//INPUT    DD   *                                                   
GET CV/TEST/QC1234.TXT //DD:FTP                                     
QUIT                                                                 
//*                                                                 
//STEP02   EXEC PGM=SORT                                             
//SORTIN   DD   DSN=XXXX.INPUT.&FNAME,...                           
//SORTOUT  DD   DSN=XXXX.OUTPUT.&FNAME,...                           
//*                                                                 

Re: How to give the outputfile name same as input file name.

PostPosted: Mon Mar 19, 2012 10:04 pm
by BillyBoyo
Whoops. I assumed you were using the symbolic in the control cards....

Re: How to give the outputfile name same as input file name.

PostPosted: Mon Mar 19, 2012 10:22 pm
by BillyBoyo
mathew28 wrote:Hi,

I have jcl, which gets the input file through ftp.
Say, XXXX.INPUT.QC1234

I do some processing like SORT, execute an SQL etc.

Create the Output file with the results.
I have to name the output file having the last qualifiler of the input file during runtime
like
XXXX.OUTPUT.QC1234

is this possible ? Can we make use of symbolics ?

Please advice.


Looking more closely :-) I see you do have some idea related to the ftp control cards.

Do you, want to generate the input dsn name, output dsn name and control cards, all with the same parameter?

Or, do you want to know the file name that you are receiving and use that to create the dsns?

Or something else?

Re: How to give the outputfile name same as input file name.

PostPosted: Mon Mar 19, 2012 11:41 pm
by mathew28
Thanks Billy and MrSpock for your replies.

Billly, I'm trying to figure out possible ways to find a solution to my requirement.

It is basically the combination of your first two questions.

An input file will be ftped. And I don't know the file name. The filename has a fixed pattern say. "QC1234_031912.TXT" and it varies each day.

I have to extract only a part of the ftp file i.e QC1234 and name it along with my output filename.
So, as you said, i need to use the file name that i'm receiving to create the dsns, output in particular. I think input file name doesn't make any difference.
So, the ftp file name should be there in the output filename.

I'm also analysing the possibility, if I give the first record as QC1234 in the input ftp file and then use it to extract it to a Symbolic using DFSORT or any other utility and then use it to name the output file.

Please advice. Thanks

Re: How to give the outputfile name same as input file name.

PostPosted: Tue Mar 20, 2012 2:24 am
by Robert Sample
I'm also analysing the possibility, if I give the first record as QC1234 in the input ftp file and then use it to extract it to a Symbolic using DFSORT or any other utility and then use it to name the output file.
Extract the file name, and use it as part of a new job that you submit into the internal reader to be executed. That is the ONLY way to accomplish this task. Once your original job has started execution, you CANNOT create a new symbolic to be used by that selfsame job -- period. You can submit another job (via the internal reader of JES) that can contain the symbolic, but the currently executing job cannot access that value.