Page 1 of 2

How to add characters to a variable length record

PostPosted: Thu Mar 13, 2014 2:12 pm
by hihui
Hi,
I have a variable length records dataset (RECFM=VBA, LRECL=125), its content may looks as
FILENAME=AREALFILENAME1
FILENAME=AREALFILENAME2SAMPLE
FILENAME=AREALFILENAME3F
...

The left side of equal(=) is constants, i.e., "FILENAME", and the right side of equal(=) is different for each record.

I want to change above dataset content into following format:
LISTDS ('AREALFILENAME1')
LISTDS ('AREALFILENAME2SAMPLE')
LISTDS ('AREALFILENAME3F')
...

(in fact, this is used as a SYSIN data for IKJEFT01 utility to get dataset DCB informationi)

I have tried many way using DFSORT, but it still failed. can any body help with me ? thanks.

Re: How to add characters to a variable length record

PostPosted: Thu Mar 13, 2014 2:16 pm
by BillyBoyo
You can look at JFY, using it to add the "('" and "')".

Re: How to add characters to a variable length record

PostPosted: Thu Mar 13, 2014 3:08 pm
by hihui
BillyBoyo, thanks, it works.

See following SYSIN content:
//SYSIN DD *
OPTION COPY
OUTREC PARSE=(%01=(ABSPOS=14,FIXLEN=80)),
FIELDS=(1,4,C'LISTDS ',
12:%01,JFY=(SHIFT=LEFT,LEAD=C'(''',TRAIL=C''')'))
/*

The output is:
LISTDS ('AREALFILENAME1')
...

This is what i expected.

Re: How to add characters to a variable length record

PostPosted: Thu Mar 13, 2014 4:23 pm
by BillyBoyo
Good work. Not enough people just use the hint and do some work themselves. Did you deliberately use the PARSE, or just get lucky first time? If they are z/OS dataset-names, you only need 44 for the FIXLEN, However, if using 44 you'd need LENGTH on the JFY to allow for the additional characters. If you use 48 for the FIXLEN, explain why in comments/documentation.

Re: How to add characters to a variable length record

PostPosted: Thu Mar 13, 2014 10:00 pm
by skolusu
A better approach would be

//SYSIN    DD *                                                 
  OPTION COPY,VLSCMP                                           
  INCLUDE COND=(14,8,CH,EQ,C'FILENAME')                         
                                                               
  OUTFIL VTOF,                                                 
  PARSE=(%01=(ABSPOS=14,STARTAFT=C'FILENAME=',FIXLEN=44)),     
  BUILD=(%01,JFY=(SHIFT=LEFT,LEAD=C'  LISTDS (''',TRAIL=C''')',
                  LENGTH=80))                                   
//*                                                             

Re: How to add characters to a variable length record

PostPosted: Fri Mar 14, 2014 7:29 am
by hihui
BillyBoyo wrote:Good work. Not enough people just use the hint and do some work themselves. Did you deliberately use the PARSE, or just get lucky first time? If they are z/OS dataset-names, you only need 44 for the FIXLEN, However, if using 44 you'd need LENGTH on the JFY to allow for the additional characters. If you use 48 for the FIXLEN, explain why in comments/documentation.


Yes, this is my first time using a PARSE, i searched it out from "DFSORT Programming Guide".
They do are dataset names, the rule is they are started from position 14 to the end of record, so i set a maximum value 80. Anyway i will change it to 44, since it's enough.

Re: How to add characters to a variable length record

PostPosted: Fri Mar 14, 2014 8:00 am
by hihui
skolusu wrote:A better approach would be

//SYSIN    DD *                                                 
  OPTION COPY,VLSCMP                                           
  INCLUDE COND=(14,8,CH,EQ,C'FILENAME')                         
                                                               
  OUTFIL VTOF,                                                 
  PARSE=(%01=(ABSPOS=14,STARTAFT=C'FILENAME=',FIXLEN=44)),     
  BUILD=(%01,JFY=(SHIFT=LEFT,LEAD=C'  LISTDS (''',TRAIL=C''')',
                  LENGTH=80))                                   
//*                                                             


This is a perfect solution for me; I do had tried to convert to fixed-length LISTDS command file, but failed. Thank you very much.
I attached the final JCL job (The <data> should be changed on specific mainframe).
//TESTJCL   JOB CLASS=A,MSGCLASS=X,MSGLEVEL=(1,1),NOTIFY=&SYSUID
//*-------------------------------------------------------------*
//* DELETE COMMAND FILE
//*-------------------------------------------------------------*
//DEL      EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSOUT   DD SYSOUT=*
//SYSIN DD *
  DELETE <data>.TEST.COLLCATA.DSCMD
  SET MAXCC=0
/*
//*-------------------------------------------------------------*
//* GENERATE COMMAND FILE
//*-------------------------------------------------------------*
//GEN      EXEC PGM=IEFBR14
//SYSPRINT DD   SYSOUT=*
//SYSOUT   DD   SYSOUT=*
//OUTDD    DD SPACE=(CYL,(40,5),RLSE),
//            DISP=(NEW,CATLG,DELETE),
//            UNIT=SYSDA,
//            DCB=(RECFM=FB,LRECL=80,BLKSIZE=800),
//            DSN=<data>.TEST.COLLCATA.DSCMD
//*-------------------------------------------------------------*
//* ADD CONTENT INTO COMMAND FILE
//*-------------------------------------------------------------*
//STEP02   EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SORTIN   DD DSN=<data>.TEST.COLLCATA.DSFILES,DISP=SHR
//SORTOUT  DD DSN=<data>.TEST.COLLCATA.DSCMD,DISP=OLD
//SYSIN   DD *
  OPTION COPY,VLSCMP,STOPAFT=3
  INCLUDE COND=(14,8,CH,EQ,C'FILENAME')
  OUTFIL VTOF,
         PARSE=(%01=(ABSPOS=14,STARTAFT=C'FILENAME=',FIXLEN=44)), 
         BUILD=(%01,JFY=(SHIFT=LEFT,LEAD=C'  LISTDS (''',TRAIL=C''')',
                  LENGTH=80))
/*
//*-------------------------------------------------------------*
//* EXECUTE COMMAND FILE
//*-------------------------------------------------------------*
//COLLPS   EXEC PGM=IKJEFT01
//SYSTSPRT DD SYSOUT=*
//SYSTSIN  DD DSN=<data>.TEST.COLLCATA.DSCMD,DISP=OLD
//

Thanks.

Re: How to add characters to a variable length record

PostPosted: Tue Mar 18, 2014 9:12 am
by fatmonster
Just read this thread and inspire me to raise another question similar to this one. In my case, I need to add an end mark x'FF' at the end of each variable length record.

Input file (256byte VB):
TESTING RECORD 1
TESTING RECORD 22
TESTING RECORD 333
TESTING RECORD 4444

Output (256byte VB):
TESTING RECORD 1[END MARK]
TESTING RECORD 22X[END MARK]
TESTING RECORD 333X[END MARK]
TESTING RECORD 4444X[END MARK]

Re: How to add characters to a variable length record

PostPosted: Tue Mar 18, 2014 12:43 pm
by fatmonster
Sorry, correct some typos about the output record:

Output (256byte VB):
TESTING RECORD 1[END MARK]
TESTING RECORD 22[END MARK]
TESTING RECORD 333[END MARK]
TESTING RECORD 4444[END MARK]

I am thinking about using VFILL+VTRIM or Justify function to archive that, however, it is possible for the last character of the record will be truncated. Any idea?

Re: How to add characters to a variable length record

PostPosted: Tue Mar 18, 2014 1:06 pm
by BillyBoyo
Can you post the sysout from any SORT step so that we can see your software level? The latest DFSORT has a standard function which can do this, so you may get lucky there.

Otherwise, there will be other ways, dependng on what you have, and the data.

How many records?

All "text"?

Can a record ever be "full" with data - what to do then?