How to add characters to a variable length record



IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

How to add characters to a variable length record

Postby hihui » Thu Mar 13, 2014 2:12 pm

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.
hihui
 
Posts: 9
Joined: Mon Oct 14, 2013 12:34 pm
Has thanked: 2 times
Been thanked: 0 time

Re: How to add characters to a variable length record

Postby BillyBoyo » Thu Mar 13, 2014 2:16 pm

You can look at JFY, using it to add the "('" and "')".

These users thanked the author BillyBoyo for the post:
hihui (Thu Mar 13, 2014 3:16 pm)
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: How to add characters to a variable length record

Postby hihui » Thu Mar 13, 2014 3:08 pm

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.
hihui
 
Posts: 9
Joined: Mon Oct 14, 2013 12:34 pm
Has thanked: 2 times
Been thanked: 0 time

Re: How to add characters to a variable length record

Postby BillyBoyo » Thu Mar 13, 2014 4:23 pm

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.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: How to add characters to a variable length record

Postby skolusu » Thu Mar 13, 2014 10:00 pm

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))                                   
//*                                                             
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
skolusu
 
Posts: 586
Joined: Wed Apr 02, 2008 10:38 pm
Has thanked: 0 time
Been thanked: 39 times

Re: How to add characters to a variable length record

Postby hihui » Fri Mar 14, 2014 7:29 am

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.
hihui
 
Posts: 9
Joined: Mon Oct 14, 2013 12:34 pm
Has thanked: 2 times
Been thanked: 0 time

Re: How to add characters to a variable length record

Postby hihui » Fri Mar 14, 2014 8:00 am

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.
hihui
 
Posts: 9
Joined: Mon Oct 14, 2013 12:34 pm
Has thanked: 2 times
Been thanked: 0 time

Re: How to add characters to a variable length record

Postby fatmonster » Tue Mar 18, 2014 9:12 am

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]
fatmonster
 
Posts: 9
Joined: Tue Mar 18, 2014 6:46 am
Has thanked: 2 times
Been thanked: 0 time

Re: How to add characters to a variable length record

Postby fatmonster » Tue Mar 18, 2014 12:43 pm

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?
fatmonster
 
Posts: 9
Joined: Tue Mar 18, 2014 6:46 am
Has thanked: 2 times
Been thanked: 0 time

Re: How to add characters to a variable length record

Postby BillyBoyo » Tue Mar 18, 2014 1:06 pm

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?
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Next

Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post