Page 1 of 2

To append one field from file1 to all recs in another file

PostPosted: Thu Aug 06, 2015 7:14 pm
by hariharan_bk
Hi All,

File 1 has only one record with date value available.

File 2 has more records with lrecl - 96.

I want the date field from file1 to be appended at a specified position in file 2 for all records.

File 1: CCCCAAAA10/10/2014AAAAAAA (LRECL - 80)

File 2: (LRECL - 96)
afafafafafafafafafa
afafafafafafafafafa
afafafafafafafafafa

OUPUT: (LRECL - 106)
afaf10/10/2014afafafafafafafafa
afaf10/10/2014afafafafafafafafa
afaf10/10/2014afafafafafafafafa

I have tried searching but could see only a static value is appended and not a value from another file. Hence I am not sure how to do it.

Could you please help me.

Re: To append one field from file1 to all recs in another fi

PostPosted: Thu Aug 06, 2015 7:30 pm
by BillyBoyo
Two step process. First, take your date file and generate a SYMNAMES dataset. FB 80. Containing a named constant.

  INREC BUILD=(C'DATE-FROM-1421-CONTROL-FILE',C''',1,10,C''')


Then include a SYMNAMES and a SYMNOUT DD in your actual step, and then use the named constant:
  INREC BUILD=(1,20,DATE-FROM-1421-CONTROL-FILE,21,30)


Those numbers in the second BUILD are not intended to bear any relationship to your data, just example numbers which you will replace with those you need.

Re: To append one field from file1 to all recs in another fi

PostPosted: Thu Aug 06, 2015 7:42 pm
by hariharan_bk
Thanks !!

What does here mean by symnames dataset? I have never used it.

If I copy the date from input to another record using this INREC BUILD, do the date get stored in this symname variable and is available for the entire JCL steps?

Re: To append one field from file1 to all recs in another fi

PostPosted: Thu Aug 06, 2015 10:51 pm
by BillyBoyo
You use a SYMNAMES DD to define SORT symbols. These can be record fields, or constants.

//SYMNAMES DD *
A-FIELD-ON-THE-FILE,1,10,CH
RECORD-NEEDS-DEFAULT,11,1,CH
DEFAULT-VALUE,C'1234567890'
DEFAULT-FLAG-YES,C'Y'
//SYMNOUT DD SYSOUT=*
//SYSIN DD *
  INREC IFTHEN=(WHEN=(RECORD-NEEDS-DEFAULT,
                     EQ,
                       DEFAULT-FLAG-YES),
                 OVERLAY=(A-FIELD-ON-THE-FILE:
                          DEFAULT-VALUE))


That's the same as (11,1,CH,EQ,C'Y'),OVERLAY=(1:C'1234567890'))... but easier to understand.

Have a look in the DFSORT Getting Started and especially the Application Programming Guide, Chapter 8.

Re: To append one field from file1 to all recs in another fi

PostPosted: Fri Aug 07, 2015 1:11 am
by hariharan_bk
Thanks billyboyo

Re: To append one field from file1 to all recs in another fi

PostPosted: Fri Aug 07, 2015 3:47 pm
by hariharan_bk
I have coded and achieved this. Thanks for the help !!

I am able to do this in 2 ICETOOL STEPS and when I try in single step, I am getting return code - 16 in TOOLMSG.

Could you please advise if these steps can be merged into multiple statements under one TOOLIN (under one JCL step) ?

//SORT1 EXEC PGM=ICETOOL
//IN1    DD DISP=SHR,DSN=***.****.****..DTFILE
//OUT1   DD DSN=***.****.DT,
//             DISP=(OLD,CATLG,DELETE),
//             UNIT=SYSDA,
//             DCB=(LRECL=80,RECFM=FB,BLKSIZE=0,DSORG=PS)
//TOOLIN DD *
  COPY FROM(IN1) TO(OUT1) USING(CTL1)
/*
//CTL1CNTL DD *
  INREC BUILD=(C'CYC-END-DT,C''',25,10,C'''',80:X)
/*
//SORT2 EXEC PGM=ICETOOL
//SYMNAMES   DD DSN=***.****.DT,
//IN2         DD DISP=SHR,DSN=*****.FILE1
//TOOLIN DD *
  COPY FROM(IN2) TO(TMP2) USING(CTL1)
/*
//CTL1CNTL DD *
 INREC BUILD=(1,96,CYC-END-DT)
/*


ERROR I m getting is like this
SYT000I  SYNCTOOL RELEASE 2.1.0 - COPYRIGHT 2014  SYNCSORT INC.
SYT001I  INITIAL PROCESSING MODE IS "STOP"


TOOLIN USED WHICH FAILED:

COPY FROM(IN1) TO(SYMNAMES) USING(CTL1)
COPY FROM(SYMNAMES) TO(IN2)
*/

//IN1    DD DISP=SHR,DSN=***.****.****..DTFILE
//SYMNAMES   DD DSN=***.****.DT,

//IN2         DD DISP=SHR,DSN=*****.FILE1

//SYMNAMES DD DSN=&&TMP1,
//             DISP=(MOD,PASS),
//             SPACE=(CYL,(20,20),RLSE),
//             UNIT=DISK,VOL=(,,,10)

Re: To append one field from file1 to all recs in another fi

PostPosted: Fri Aug 07, 2015 4:25 pm
by BillyBoyo
You're using SyncSORT, which lives in another part of the forum.

You need to show all the messages for what failed. Just looking at what you've shown, you don't seem to be using the same dataset for your symbols file. Also, 20 cylinders is somewhere excessive. A track it likely sufficient, that would allow you more than 600 symbols. 20 cylinders would give you space for over 180,000 symbols - which would be too many :-)

Re: To append one field from file1 to all recs in another fi

PostPosted: Fri Aug 07, 2015 8:12 pm
by hariharan_bk
hi BillyBoyo,

This is what I tried now...

//SORT1 EXEC PGM=ICETOOL   
//TOOLMSG DD SYSOUT=*     
//DFSMSG  DD SYSOUT=*     
//LIST1   DD SYSOUT=*     
//SYMNOUT DD SYSOUT=*     
//IN1    DD DISP=SHR,DSN=AB
//IN1    DD DISP=SHR,DSN=*******.********.DATEFIL(0)
//IN2         DD DISP=SHR,DSN=****.****.INP                   
//SYMNAMES DD DSN=&&TMP1,                                       
//             DISP=(MOD,PASS),                                 
//             SPACE=(TRK,(20,20),RLSE),                       
//             UNIT=SYSDA                                       
//OUT1   DD DSN=****.*****.OUTTEST,                           
//             DISP=(NEW,CATLG,DELETE),                         
//             UNIT=SYSDA,                                     
//             DCB=(MODLDSCB,RECFM=FB,BLKSIZE=0,DSORG=PS),     
//             SPACE=(TRK,(20,20),RLSE)                         
//TOOLIN DD *                                                   
  COPY FROM(IN1) TO(SYMNAMES) USING(CTL1)                       
  COPY FROM(SYMNAMES) TO(LIST1)                                 
  COPY FROM(IN2) TO(OUT1) USING(CTL2)                           
/*                                                             
//CTL1CNTL DD *                                                 
  INREC BUILD=(C'CYC-END-DT,C''',25,10,C'''',80:X)             
/*                                                             
//CTL2CNTL DD *                                                 
* INREC BUILD=(1,96,CYC-END-DT)                                 
  INREC BUILD=(1,74,18X,93:75,22,CYC-END-DT)                   
/*                                                             
//*                                                             


ABEND S013

********************************* TOP OF DATA ********************
SYT000I SYNCTOOL RELEASE 2.1.0 - COPYRIGHT 2014 SYNCSORT INC.
SYT001I INITIAL PROCESSING MODE IS "STOP"
******************************** BOTTOM OF DATA ******************

Yes since this is taking SYNCTOOL automatically based on installation, I am not sure what is the real problem of having these actions to be executed in single step.

The above works if these are done in two steps.

Re: To append one field from file1 to all recs in another fi

PostPosted: Fri Aug 07, 2015 10:59 pm
by BillyBoyo
You should be able to do it with two SyncTOOL operators. but really I don't see the benefit. Do it in two SORT steps is the clearest.

Re: To append one field from file1 to all recs in another fi

PostPosted: Mon Aug 10, 2015 12:17 pm
by hariharan_bk
I have tried the following code to perform the operation in single step. But facing the following issue.

JCL details are:
 //SORT1 EXEC PGM=SYNCTOOL                                     
 //TOOLMSG DD SYSOUT=*                                         
 //DFSMSG  DD SYSOUT=*                                         
 //LIST1   DD SYSOUT=*                                         
 //IN1    DD DISP=SHR,DSN=*****.DATE.G0001V00
 //IN2         DD DISP=SHR,DSN=***.INPUT             
 //OUT2   DD DSN=****.OUTPUT,                             
 //             DISP=(OLD,CATLG,DELETE),                       
 //             UNIT=SYSDA,SPACE=(TRK,(1,1),RLSE),             
 //             DCB=(MODLDSCB,RECFM=FB,BLKSIZE=0,DSORG=PS)     
 //TOOLIN DD *                                                 
   COPY FROM(IN1) USING(CTL1)                                 
   COPY FROM(IN2) TO(OUT2) USING(CTL2)                         
 /*                                                           
 //CTL1CNTL DD *                                               
   OUTFIL FNAMES=CTL2CNTL,                                     
   OUTREC=(C' OUTREC BUILD=(1,96,',C'97:C''',25,10,C''')')     
 /*                                                           
 //CTL2CNTL DD DSN=&T1,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)     


the error details from spool are:

 CTL2CNTL :                                                     
  OUTREC BUILD=(1,96,97:C'06/23/2015')                           
  WER428I  CALLER-PROVIDED IDENTIFIER IS "0002"                   
 WER274A  CONTINUATION STATEMENT ERROR FOUND                     
 WER211B  SYNCSMF  CALLED BY SYNCSORT; RC=0000                   


Can you please check and let me know what I am missing here?