Minoru Massaki, Norbert had an excellent idea to overcome the issue of having spaces at the beginning or at the end. Converting to hex would overcome the issue of truncation with JFY.
However you do NOT require 2 passes of data to insert the trailing character using VLTRAIL and then use Joinkeys. I have optimized the Job. The trick here is to use the same input file for Joinkeys. The subtask2 file is where we convert to hex and perform the JUSTIFY to RIGHT and pick of the last 16 bytes and then unhex that 16 bytes back to 8 bytes. we are appending a 4 byte sequence number to match the 2 files. And since they are already in order, we also have SORTED and NOSEQCK so that we use a copy operation for Joinkeys. Please note that this approach of converting to HEX can be used only 1. If your input file is F, the max LRECL you can process is 32760/2 = 16380 and you are using 4 bytes for the key there by reducing the LRECL to 32756. So you can only process a file whose LRECL is 32756/2 <= 16378 2. If your input file is V, the max LRECL you can process is 32756/2 = 163780 and you are using 4 bytes for the key there by reducing the LRECL to 32752. So you can only process a file whose LRECL is 32752/2 <= 16376 //STEP0100 EXEC PGM=SORT //SYSOUT DD SYSOUT=* //INA DD DISP=SHR,DSN=Your Input Vb 100 Byte file //INB DD DISP=SHR,DSN=Same Input VB 100 byte file //SORTOUT DD SYSOUT=* //SYSIN DD * OPTION COPY JOINKEYS F1=INA,FIELDS=(5,4,A),SORTED,NOSEQCK JOINKEYS F2=INB,FIELDS=(5,4,A),SORTED,NOSEQCK REFORMAT FIELDS=(F1:1,4,F2:9,8,F1:9) //* //JNF1CNTL DD * INREC BUILD=(1,4, $ RDW SEQNUM,4,BI, $ SEQUENCE AS KEY 5) $ ORIGINAL DATA //* //JNF2CNTL DD * INREC IFTHEN=(WHEN=INIT, BUILD=(1,4, $ RDW SEQNUM,4,BI, $ SEQUENCE AS KEY 5,HEX)), $ ORIGINAL DATA IN HEX IFTHEN=(WHEN=INIT, OVERLAY=(9:9,192,JFY=(SHIFT=RIGHT))), $ SHIFT HEX DATA TO RIGHT IFTHEN=(WHEN=INIT, BUILD=(001,4, $ RDW 005,4, $ SEQUENCE KEY 185,16,TRAN=UNHEX)) $ PICK LAST 16 AND UNHEX //* Further if you have any questions please let me know Thanks, Sri Hari Kolusu DFSORT Development IBM Corporation IBM Mainframe Discussion List <IBM-MAIN@LISTSERV.UA.EDU> wrote on 06/09/2015 10:49:39 PM: > From: Minoru Massaki <mmass...@gmail.com> > To: IBM-MAIN@LISTSERV.UA.EDU > Date: 06/09/2015 10:50 PM > Subject: Re: DFSORT - How to select last 8 bytes in variable length records > Sent by: IBM Mainframe Discussion List <IBM-MAIN@LISTSERV.UA.EDU> > > Hi Kolusu-san, > > I have sent JOB JCLs and executed output to DFSORT helpline. > > Thank you, > > Minoru Massaki - (M*M) > > > 2015-06-10 2:43 GMT+09:00 Sri h Kolusu <skol...@us.ibm.com>: > > > Minoru Massaki, > > > > I did not test out Norbert Friemel solution as it involves 2 passes of > > data along with joinkeys which is not required. However I would like to > > diagnose the error you are getting when you used his JCL. Can you send me > > the complete sysout and JCL you used and if possible send the input file > > to our hotline ? > > > > Thanks, > > Sri Hari Kolusu > > DFSORT Development > > IBM Corporation > > > > IBM Mainframe Discussion List <IBM-MAIN@LISTSERV.UA.EDU> wrote on > > 06/09/2015 10:37:49 AM: > > > > > From: Minoru Massaki <mmass...@gmail.com> > > > To: IBM-MAIN@LISTSERV.UA.EDU > > > Date: 06/09/2015 10:38 AM > > > Subject: Re: DFSORT - How to select last 8 bytes in variable length > > records > > > Sent by: IBM Mainframe Discussion List <IBM-MAIN@LISTSERV.UA.EDU> > > > > > > Hello Friemel-san, > > > > > > Thank you for your DFSORT JCL. > > > > > > In our z/OS V2.1 system, your JCL didn't work correctly. > > > (output looked like all blank) > > > > > > After changing VLTRAIL parameter from two characters '<|' to > > > three characters such as C'<|>', it does work fine. > > > > > > Thank you! > > > > > > Minoru Massaki - (M*M) > > > > > > > > > 2015-06-08 22:06 GMT+09:00 Norbert Friemel <nf.ibmm...@web.de>: > > > > > > > On Mon, 8 Jun 2015 17:14:33 +0900, Minoru Massaki wrote: > > > > > > > > >Hello Kolusu-san, > > > > > > > > > >Thank you very much for giving the answer by using DFSORT. > > > > >That is what the customer wants to. > > > > > > > > > >I have additional questions. > > > > >If the 8 bytes key is binary data and some records include x'40' of > > the > > > > >last byte of the key, > > > > > (ex. if the key is binary number 64 --> x'0000000000000040') > > > > >Does the shifting to right (JFY=(SHIFT=RIGHT)) work as I expected? > > > > > > > > > >In case of the last and the first byte of the records contain x'40', > > > > >what should I modify the DFSORT control statements you gave me. > > > > > > > > > > > > > On z/OS 2.1 (VLTRAIL is new in 2.1) try: > > > > > > > > //* > > > > //STEP1 EXEC PGM=ICETOOL > > > > //* > > > > //TOOLMSG DD SYSOUT=* > > > > //DFSMSG DD SYSOUT=* > > > > //IN DD DISP=OLD,DSN=VB-INPUT-DS > > > > //TEMP1 DD SPACE=(TRK,(75,75),RLSE) > > > > //TEMP2 DD SPACE=(TRK,(150,150),RLSE) > > > > //OUT DD DISP=(NEW,CATLG,DELETE), > > > > // SPACE=(TRK,(75,75),RLSE), > > > > // DSN=VB-OUTPUT-DS > > > > //CTL1CNTL DD * > > > > OUTFIL FNAMES=TEMP1,BUILD=(1,4,SEQNUM,4,BI,C' ',5) > > > > OUTFIL FNAMES=TEMP2,BUILD=(1,4,SEQNUM,4,BI,5,HEX),VLTRAIL=C'<|' > > > > /* > > > > //CTL2CNTL DD * > > > > JOINKEYS F1=TEMP1,FIELDS=(5,4,A),TASKID=T1,SORTED > > > > JOINKEYS F2=TEMP2,FIELDS=(5,4,A),TASKID=T1,SORTED > > > > REFORMAT FIELDS=(F1:1,4,F2:9,8,F1:9,1,F1:10) > > > > /* > > > > //T1F1CNTL DD * > > > > /* > > > > //T1F2CNTL DD * > > > > INREC PARSE=(%00=(STARTAFT=C'<',FIXLEN=1), > > > > %01=(SUBPOS=18,FIXLEN=16)), > > > > BUILD=(1,4,5,4,%01,TRAN=UNHEX) > > > > /* > > > > //TOOLIN DD * > > > > COPY FROM(IN) USING(CTL1) > > > > COPY JKFROM TO(OUT) USING(CTL2) > > > > /* > > > > > > > > Norbert Friemel > > > > > > > > ---------------------------------------------------------------------- > > > > For IBM-MAIN subscribe / signoff / archive access instructions, > > > > send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN > > > > > > > > > > > > > > > > -- > > > > > > 全先 実 - Minoru Massaki (M*M) > > > E-mail: mmass...@gmail.com > > > > > > ---------------------------------------------------------------------- > > > For IBM-MAIN subscribe / signoff / archive access instructions, > > > send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN > > > > > > > ---------------------------------------------------------------------- > > For IBM-MAIN subscribe / signoff / archive access instructions, > > send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN > > > > > > -- > > 全先 実 - Minoru Massaki (M*M) > E-mail: mmass...@gmail.com > > ---------------------------------------------------------------------- > For IBM-MAIN subscribe / signoff / archive access instructions, > send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN > ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN