Page 1 of 1

query on OUTREC statement !

PostPosted: Wed Dec 22, 2010 9:14 pm
by maandi
I had a requirement in which I need to pass a parm through the dataset (because it'll vary on each run) and replace some field in my input with these parms based on some condition. Somehow I got the idea because of reference jcl posted in the following IBM Mainframe forum link:

http://ibmmainframes.com/about6082.html

I used the following JCL :

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file1
//SORTOUT DD DSN=&&S1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//SYSIN    DD    *
  OPTION COPY
* Create a DFSORT symbol as follows:
* TARG,C'abcd'
* where abcd is the value in positions 1-4
  OUTREC FIELDS=(C'TARG,C''',1,4,C'''',80:X)
/*
//S2    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)
//SORTIN DD DSN=...  input file2
//SORTOUT DD DSN=...  output file
//SYSIN    DD    *
  OPTION COPY
* Use the TARG symbol created in S1 to do the overlay.
  INREC IFTHEN=(WHEN=(1,4,CH,EQ,C'1234'),OVERLAY=(1:TARG))
/*


In this overall I understand that input is put into a variable named "TARG" and used in the S2 to pass in the OVERLAY statement present in sysin.But i could understand how the following outrec statement in S1 works:

OUTREC FIELDS=(C'TARG,C''',1,4,C'''',80:X)


When i saw the output of step S1 it was like : TARG,C'abcd'.

Please explain this if possible !

I would like to thank Frank Yaeger for posting this reference JCL in this forum.


Thanks with Regards,
Maandi.

Re: query on OUTREC statement !

PostPosted: Wed Dec 22, 2010 9:16 pm
by maandi
Sorry for the mistake in the post

But i couldn't understand how the following outrec statement in S1 works: :)

Re: query on OUTREC statement !

PostPosted: Wed Dec 22, 2010 10:47 pm
by MrSpock
If you're picking up the first four positions on the SORTIN datatset in step S1 to assign to the symbolic TARG, what does YOUR input dataset look like?

Re: query on OUTREC statement !

PostPosted: Wed Dec 22, 2010 11:07 pm
by Frank Yaeger
* Create a DFSORT symbol as follows:
* TARG,C'abcd'
* where abcd is the value in positions 1-4
  OUTREC FIELDS=(C'TARG,C''',1,4,C'''',80:X)


I'm not sure what you didn't understand.

C'TARG,C''' writes

TARG,C'

in the output record. It's C'TARG,Cx' but since x is an apostrophe, you need two apostrophes, so it's C'TARG,C'''.

1,4 writes input positions 1-4 in the output record (e.g. abcd).

C'''' writes an apostrophe in the output record. It's C'x' but since x is an apostrophe, you need two apostrophes, so it's C''''.

So the OUTREC statement gives us this output record for SYMNAMES:

TARG,C'abcd'

This is a valid DFSORT Symbol.