Page 1 of 1

DFSORT - extract date from the HDR

PostPosted: Fri May 22, 2009 7:57 am
by zaino22
I have source file that contains Header '001...2009-05-20'
date is at position 30 to 39. i want to take just the date field (10 bytes along with '-'), and copy it to a GDG file. I tried DFSORT function but since i am not familiar with it much, i couldn't do it. Can someone write sample program how i can achieve it?

Thanks

Re: DFSORT - extract date from the HDR

PostPosted: Fri May 22, 2009 7:09 pm
by zaino22
I only want to copy the specific field in the header, which is the first line of the file. First line has 105 bytes, but after 62 bytes there are spaces till the end.
i tried using the following program but did not work.
Any suggestions?

//STEP1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD DSN=SOURCE.DS,DISP=SHR
//OUT DD DSN=TARGET.DS
//TOOLIN DD *
COPY FROM(IN) TO(OUT) USING(CTL1)
/*
//CTL1CNTL DD *
INREC BUILD=(30,39)
OPTION STOPAFT=1
/*

ERROR MSG:
0 END OF STATEMENTS FROM CTL1CNTL - PARAMETER LIST STATEMENTS FOLLOW
DEBUG NOABEND,ESTAE
OPTION MSGDDN=DFSMSG,LIST,MSGPRT=ALL,RESINV=0,SORTDD=CTL1,SORTIN=IN,SOR*
TOUT=OUT,DYNALLOC
SORT FIELDS=COPY
F RECORD TYPE IS V - DATA STARTS IN POSITION 5
0 VLSHRT NOT USED FOR SORT, MERGE, INCLUDE, OMIT OR SUM STATEMENT FIELDS
0 MISSING RDW OR DATA FOR *INREC : REASON CODE 03, IFTHEN 0
0 C5-K90014 C6-K90014 C7-K45047 C8-K90014 E9-K40168 E7-K44564
3 END OF DFSORT

Re: DFSORT - extract date from the HDR

PostPosted: Fri May 22, 2009 8:40 pm
by Frank Yaeger
Your input file has RECFM=VB so you need to specify the RDW in the INREC statement. Assuming you want the output data set to have RECFM=VB, you can just change your INREC statement to:

  INREC BUILD=(1,4,30,39)       

Re: DFSORT - extract date from the HDR

PostPosted: Fri May 22, 2009 9:11 pm
by zaino22
i tried following code but it captures before and after bytes as well. Now, I also want to add check if the first record contains '001 then take the date only e.g. 2009-02-04 and copy it to a GDG file without any before and after spaces.
i have tried following as well, which get rid of before bytes, but still contain after bytes.
INREC BUILD=(1,4,34,34)

Header sample:001 2009-02-05 10:55:06 MLK00 2009-02-04 SOURCE.DATASET.NAME(0)

//STEP1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD DSN=SOURCE.DS,DISP=SHR
//OUT DD DSN=TARGET.DS,
// DISP=(NEW,CATLG,DELETE),
// DCB=(SRCDSCB,RECFM=VB,LRECL=43,BLKSIZE=0,DSORG=PS),
// SPACE=(10,(1,1),RLSE),AVGREC=K
//TOOLIN DD *
COPY FROM(IN) TO(OUT) USING(CTL1)
/*
//CTL1CNTL DD *
INREC BUILD=(1,4,30,39)
OPTION STOPAFT=1
/*

Re: DFSORT - extract date from the HDR

PostPosted: Fri May 22, 2009 10:24 pm
by Frank Yaeger
When you specify 34,34, it extracts 34 bytes starting at position 34. If you only want the date, you should be using a length of 10, not 34.
That will only extract 10 bytes. Why would you use a length of 34 to extract 10 bytes?

   INREC BUILD=(1,4,34,10)


If you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from:

http://www.ibm.com/servers/storage/supp ... tmpub.html

Re: DFSORT - extract date from the HDR

PostPosted: Sat May 23, 2009 12:06 am
by zaino22
Consider this my lack of knowledge after making this change, issue is resolved. i went thru few postings on this site, and did like your suggestion on reading on the IBM tutorial 'Getting Started'. I plan to learn more on SORT, and ICETOOL. Thanks for the timely help!!!!!!!!!!