IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Pass STARTREC & ENDREC - Syncsort


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
ramsri

Active User


Joined: 18 Oct 2008
Posts: 380
Location: India

PostPosted: Wed Oct 22, 2008 2:52 pm
Reply with quote

Hi,

We have a file (RECFM=FB & LRECL=300) with 2 lac records in it. I need to copy the records from particular number to particular number to output file (we can use STARTREC & ENDREC with OPTION COPY). But, the starting record should have "HDR" at column position 21 and ending record should have "TLR" at column position 31. So, I need to copy only the records between these.

My thought is like using INCLUDE with condition to search the file for "HDR" or "TLR" and passing on the record number to STARTREC and ENDREC respectively. I am not able to convert my idea into coding.

Please help.

Thanks.
Back to top
View user's profile Send private message
acevedo

Active User


Joined: 11 May 2005
Posts: 344
Location: Spain

PostPosted: Wed Oct 22, 2008 4:48 pm
Reply with quote

I'do it in 2 steps.

1-to get the SEQNUM associated to HDR and LTR (using INREC), the output would be the sysin to the second step.
OUTFIL STARTREC=positionofHDRhere,ENDREC=positionofLTRhere

2-sort with the previous sysin (+ option copy)

sure other members could achieved in one step.

hth
Back to top
View user's profile Send private message
ramsri

Active User


Joined: 18 Oct 2008
Posts: 380
Location: India

PostPosted: Wed Oct 22, 2008 6:44 pm
Reply with quote

Hi,

Based on your suggestions this is how I could write my job but unsuccessful icon_sad.gif

Code:

//STEP0101 EXEC PGM=SORT                                           
//SORTOUT  DD DSN=&&T1,DISP=(MOD,PASS,DELETE),SPACE=(TRK,(1,1),RLSE)
//SYSOUT   DD SYSOUT=*                                             
//SORTIN   DD *                                                     
ABCD1111                                                           
BCDE2222                                                           
CDEF3333                                                           
DEFG4444                                                           
EFGH5555                                                           
FGHI6666                                                           
GHIJ7777                                                           
HIJK8888                                                           
IJKL9999                                                           
JKL10000                                                           
/*                                                                 
//SYSIN    DD *                                                     
 OPTION COPY                                                       
 INREC BUILD=(1,8,10:SEQNUM,3,ZD)                                   
/*                                                                 
//STEP0102 EXEC PGM=SORT                                           
//SYSOUT   DD SYSOUT=*                                             
//SORTOUT  DD DSN=&&T2,DISP=(MOD,PASS,DELETE),SPACE=(TRK,(1,1),RLSE)
//SORTIN   DD DSN=&&T1,DISP=(MOD,DELETE,DELETE)                     
//SYSIN    DD *                                                     
 OPTION COPY                                                       
 INCLUDE COND=(5,4,ZD,EQ,2222,OR,5,4,ZD,EQ,8888)                   
 OUTFIL IFTHEN=(WHEN=(5,4,ZD,EQ,2222),                             
                BUILD=(2:C'OPTION COPY',/,                         
                       2:C'OUTFIL',X,C'STARTREC=',10,3,C',')),     
        IFTHEN=(WHEN=(5,4,ZD,EQ,8888),BUILD=(1:C'ENDREC=',10,3))   
/*             
//STEP0103 EXEC PGM=SORT                       
//SYSOUT   DD SYSOUT=*                         
//SORTOUT  DD SYSOUT=*                         
//SORTIN   DD *                               
ABCD1111                                       
BCDE2222                                       
CDEF3333                                       
DEFG4444                                       
EFGH5555                                       
FGHI6666                                       
GHIJ7777                                       
HIJK8888                                       
IJKL9999                                       
JKL10000                                       
//SYSIN    DD DSN=&&T2,DISP=(MOD,DELETE,DELETE)                                                   
/*


I am not able to understand why am getting all the 10 records into the output file where as it should be only 7.

The STEP0102 creates the temporary output file as given below:

Code:

 OPTION COPY         
 OUTFIL STARTREC=002,
ENDREC=008           


But when I look at the SYSOUT after completion of the job the SYSIN supplied to STEP0103 looks like this icon_confused.gif

Code:

SYSIN :                                             
 OPTION COPY          OUTFIL STARTREC=002,ENDREC=008
 OUTFIL STARTREC=002,ENDREC=008                     
ENDREC=008                                         


I have tried hard but could not fix it......

Any suggestions or alternatives please

Thanks.
Back to top
View user's profile Send private message
ramsri

Active User


Joined: 18 Oct 2008
Posts: 380
Location: India

PostPosted: Wed Oct 22, 2008 7:04 pm
Reply with quote

Ok......at last, I have achieved it (per my thinking).......

The SYSIN in STEP0102 has been modified to get through it...... icon_biggrin.gif

Code:

//SYSIN    DD *                                                   
 OPTION COPY                                                     
 INCLUDE COND=(5,4,ZD,EQ,2222,OR,5,4,ZD,EQ,8888)                 
 OUTFIL IFTHEN=(WHEN=(5,4,ZD,EQ,2222),                           
                BUILD=(2:C'OPTION COPY',77X,/,                   
                       2:C'OUTFIL',X,C'STARTREC=',10,3,C',',67X)),
        IFTHEN=(WHEN=(5,4,ZD,EQ,8888),BUILD=(2:C'ENDREC=',10,3)) 
/*                                                               


I request the SYNCSORT experts to fine tune this so that lots of junk can be removed....... icon_smile.gif

Thanks a lot to acevedo for giving the idea........ icon_cool.gif
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Wed Oct 22, 2008 9:22 pm
Reply with quote

For those of you who have DFSORT, you can do this kind of thing quite easily with the new WHEN=GROUP function available with z/OS DFSORT V1R5 PTF UK90013 (July, 2008).

Quote:
the starting record should have "HDR" at column position 21 and ending record should have "TLR" at column position 31. So, I need to copy only the records between these.


Here's the DFSORT job for this one:

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file (FB/300)
//SORTOUT DD DSN=..  output file (FB/300)
//SYSIN    DD    *
  OPTION COPY
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(21,3,CH,EQ,C'HDR'),
    END=(31,3,CH,EQ,C'TLR'),PUSH=(301:ID=1))
  OUTFIL INCLUDE=(301,1,CH,NE,C' '),BUILD=(1,300)
/*


Here's the DFSORT job for the 2222-8888 one:

Code:

//S2    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD *
ABCD1111
BCDE2222
CDEF3333
DEFG4444
EFGH5555
FGHI6666
GHIJ7777
HIJK8888
IJKL9999
JKL10000
/*
//SORTOUT DD SYSOUT=*
//SYSIN    DD    *
  OPTION COPY
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(5,4,ZD,EQ,2222),
    END=(5,4,ZD,EQ,8888),PUSH=(81:ID=1))
  OUTFIL INCLUDE=(81,1,CH,NE,C' '),BUILD=(1,80)
/*


For complete details on all of the new DFSORT and ICETOOL functions available with the July, 2008 PTF, see:

Use [URL] BBCode for External Links
Back to top
View user's profile Send private message
ramsri

Active User


Joined: 18 Oct 2008
Posts: 380
Location: India

PostPosted: Wed Oct 22, 2008 9:58 pm
Reply with quote

wow.......very useful and simplified..... icon_biggrin.gif

Thank you Frank.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts How to pass the PARM value to my targ... COBOL Programming 8
No new posts Dynamically pass table name to a sele... DB2 2
No new posts Count Records with a crietaria in a f... DFSORT/ICETOOL 5
No new posts pass data as symbolic parameter from ... CLIST & REXX 2
Search our Forums:

Back to Top