Page 1 of 1

JCL to Copy a file in to another file along with the Header

PostPosted: Tue Dec 01, 2009 5:32 pm
by siva219734
All,

let us suppose that I have a dataset with XXXX records. Please provide me the JCL using which I can copy the data(XXXX records) in to another Dataset(same record length of source dataset and FIXED dataset) from the source dataset(FIXED dataset) with Header as " Processing date: <Todays date> Number of Records: XXXX "
For e.g.

Source Dataset:
********************************* Top of Data **********************************
12/01/2009 02:06:55 113 00.034 00.010 00.120
12/01/2009 02:21:56 148 00.036 00.010 00.120
12/01/2009 02:36:56 183 00.037 00.010 00.150

Destination dataset after copying should be:
********************************* Top of Data **********************************
Processing date: 12/01/2009 Number of Records: 3
12/01/2009 02:06:55 113 00.034 00.010 00.120
12/01/2009 02:21:56 148 00.036 00.010 00.120
12/01/2009 02:36:56 183 00.037 00.010 00.150

Thanks in advance.

Re: JCL to Copy a file in to another file along with the Header

PostPosted: Tue Dec 01, 2009 9:10 pm
by Frank Yaeger
Here's a DFSORT job that will do what you asked for:

//S1    EXEC  PGM=SORT
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file
//SORTOUT DD DSN=&&S1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//SYSIN    DD    *
  OPTION COPY
  OUTFIL REMOVECC,NODETAIL,
    TRAILER1=('CT,''',COUNT=(M10,LENGTH=4),'''',80:X)
/*
//S2 EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)
//SORTIN DD DSN=...  input file
//SORTOUT DD DSN=...  output file
//SYSIN    DD    *
 OPTION COPY
 OUTFIL REMOVECC,
   HEADER1=('Processing date:',18:DATE=(MD4/),
     33:'Number of Records:',CT)
/*

Re: JCL to Copy a file in to another file along with the Header

PostPosted: Wed Dec 02, 2009 11:43 am
by siva219734
Hi Frank,

Thanks for the details. I will try this out and check.

Re: JCL to Copy a file in to another file along with the Header

PostPosted: Wed Dec 02, 2009 2:40 pm
by siva219734
Hi Frank,

I had customized above code provided by you and ran the job. But I am getting syntax error shown below:

SYSIN :
OPTION COPY
OUTFIL REMOVECC,
HEADER1=('PROCESSING DATE:',18:DATE=(DM4/),
33:'NUMBER OF RECORDS:',CT1)
DATA DICTIONARY SYMBOLS SUBSTITUTED :
OPTION COPY
OUTFIL REMOVECC,HEADER1=('PROCESSING DATE:',18:DATE=(DM4/),33:'NUMBER OF RECORD
:',CT1)
*
WER268A OUTFIL STATEMENT : SYNTAX ERROR

WER449I SYNCSORT GLOBAL DSM SUBSYSTEM ACTIVE

Here is the code I am executing:

//S1      EXEC PGM=SORT                                           
//SYSOUT    DD SYSOUT=*                                           
//SORTIN    DD DSN=...Input datset,DISP=SHR     
//SORTOUT   DD DSN=&&S1,UNIT=(SYSDA),SPACE=(TRK,(5,1)),DISP=(,PASS)
//SYSIN     DD *                                                   
  OPTION COPY                                                     
  OUTFIL REMOVECC,NODETAIL,                                       
    TRAILER1=('CT,''',COUNT=(M10,LENGTH=10),'''',80:X)             
/*                                                                 
//*                                                               
//S2      EXEC PGM=ICEMAN                                         
//SYSOUT    DD SYSOUT=*                                           
//SYMNAMES  DD DSN=&&S1,DISP=(OLD,PASS)                           
//SORTIN    DD DSN=...Input datset,DISP=SHR     
//SORTOUT   DD DSN=HLQ.FINAL.OUTPUT.GDG(+1),         
//             DISP=(,CATLG,DELETE),                           
//             RECFM=FB,UNIT=(SYSDA,3),
//             SPACE=(CYL,(5,1),RLSE)                             
//SYSIN     DD *                                   
  OPTION COPY                                       
  OUTFIL REMOVECC,                                 
   HEADER1=('PROCESSING DATE:',18:DATE=(DM4/),     
   33:'NUMBER OF RECORDS:',CT)                     
/*                                                 

Re: JCL to Copy a file in to another file along with the Header

PostPosted: Wed Dec 02, 2009 2:43 pm
by siva219734
Sorry... Frank.. Corresponding error message for the above code is shown below:

SYSIN :
OPTION COPY
OUTFIL REMOVECC,
HEADER1=('PROCESSING DATE:',18:DATE=(DM4/),
33:'NUMBER OF RECORDS:',CT)
DATA DICTIONARY SYMBOLS SUBSTITUTED :
OPTION COPY
OUTFIL REMOVECC,HEADER1=('PROCESSING DATE:',18:DATE=(DM4/),33:'NUMBER OF RECORD
:',CT)
*

WER268A OUTFIL STATEMENT : SYNTAX ERROR
WER449I SYNCSORT GLOBAL DSM SUBSYSTEM ACTIVE

Moderator Note: The above messages:
WER268A OUTFIL STATEMENT : SYNTAX ERROR
WER449I SYNCSORT GLOBAL DSM SUBSYSTEM ACTIVE

obviously indicate that the product is SYNCSORT, not DFSORT. This topic has been moved to the Syncsort Forum.

Re: JCL to Copy a file in to another file along with the Header

PostPosted: Wed Dec 02, 2009 10:56 pm
by Alissa Margulies
Siva,

I was able to successfully execute your code with no errors. Please forward me your complete and unedited job listing as a text attachment to alissa.margulies@syncsort.com and I would be happy to further assist you.

Regards,
Alissa

Re: JCL to Copy a file in to another file along with the Header

PostPosted: Thu Dec 03, 2009 12:34 pm
by siva219734
Hi Alissa,

Thanks for your reply. Sent you the details in an email as requested.

Thanks again.

Re: JCL to Copy a file in to another file along with the Header

PostPosted: Thu Dec 03, 2009 10:20 pm
by Alissa Margulies
Siva,

Since your data is variable length, you need to slightly modify the control statements in the first step:

//SYSIN   DD *   
  OPTION COPY                                       
  OUTFIL REMOVECC,NODETAIL,                         
    TRAILER1=('CT,''',COUNT=(M10,LENGTH=10),''''),   
    OUTREC=(5,80),CONVERT                       
/*

Give that a try and let me know if you still encounter any problems.

Re: JCL to Copy a file in to another file along with the Header

PostPosted: Mon Dec 07, 2009 8:40 pm
by siva219734
Hi Alissa,

Thanks for all your help. It did work!!

Regards,
Siva