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

Specific record count in Trailer


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
krishnakanagal

New User


Joined: 27 Feb 2009
Posts: 12
Location: Bangalore

PostPosted: Mon Jul 06, 2009 9:08 pm
Reply with quote

Hi,

I have requirement in which i have to generate header & trailer in a dataset apparently i could generate the header but the trailer is a tricky part for me.

input dataset format
aaa print=y
aaa xxxxxx
aaa yyyyyy
bbb print=y
bbb abscdc
ccc print=y
ccc hdydhd
ccc ndkksj
ccc hhdhsh

the trailer should have the total record count as well as records where print=y so the desired output is

aaa print=y
aaa xxxxxx
aaa yyyyyy
bbb print=y
bbb abscdc
ccc print=y
ccc hdydhd
ccc ndkksj
ccc hhdhsh
00090003
where 9 is total record count & 3 is records with print=y
[/quote]
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Mon Jul 06, 2009 9:44 pm
Reply with quote

krishnakanagal,


The following DFSORT JCL will give you the desired results. I assumed your input is FB recfm and 80 bytes in length

Code:

//STEP0100 EXEC PGM=SORT                                     
//SYSOUT   DD SYSOUT=*                                       
//SORTIN   DD *                                             
AAA PRINT=Y                                                 
AAA XXXXXX                                                   
AAA YYYYYY                                                   
BBB PRINT=Y                                                 
BBB ABSCDC                                                   
CCC PRINT=Y                                                 
CCC HDYDHD                                                   
CCC NDKKSJ                                                   
CCC HHDHSH                                                   
//SORTOUT  DD SYSOUT=*                                       
//SYSIN    DD *                                             
  SORT FIELDS=COPY                                           
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:C'0')),               
  IFTHEN=(WHEN=(5,7,CH,EQ,C'PRINT=Y'),OVERLAY=(81:C'1'))     
                                                             
  OUTFIL BUILD=(1,80),REMOVECC,                             
  HEADER1=('SOME HEADER'),                                   
  TRAILER1=(COUNT=(M11,LENGTH=4),                           
            TOT=(81,1,ZD,M11,LENGTH=4))                     
/*


The output is

Code:

SOME HEADER   
AAA PRINT=Y   
AAA XXXXXX   
AAA YYYYYY   
BBB PRINT=Y   
BBB ABSCDC   
CCC PRINT=Y   
CCC HDYDHD   
CCC NDKKSJ   
CCC HHDHSH   
00090003     
Back to top
View user's profile Send private message
krishnakanagal

New User


Joined: 27 Feb 2009
Posts: 12
Location: Bangalore

PostPosted: Mon Jul 06, 2009 10:47 pm
Reply with quote

Hi Kolusu,

Thanks a ton if possible can you elaborate on this
Code:
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:C'0')),               
  IFTHEN=(WHEN=(5,7,CH,EQ,C'PRINT=Y'),OVERLAY=(81:C'1'))     
                                                             
  OUTFIL BUILD=(1,80),REMOVECC,                             
  HEADER1=('SOME HEADER'),                                   
  TRAILER1=(COUNT=(M11,LENGTH=4),                           
            TOT=(81,1,ZD,M11,LENGTH=4))                     
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Mon Jul 06, 2009 11:23 pm
Reply with quote

Code:
INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:C'0')),


This will a value of '0' for all records in pos 81.

Code:

IFTHEN=(WHEN=(5,7,CH,EQ,C'PRINT=Y'),OVERLAY=(81:C'1')) 


This will overlay pos 81 with '1' when the string at pos 5 for 7 bytes equal to PRINT=Y

Code:

OUTFIL BUILD=(1,80),REMOVECC,                                                 


BUILD=(1,80) will only write the first 80 bytes to output file as we don't want the additional 1 byte we added for counting the no: of print=y records and removeCC will remove the carriage control character which is printed when using reporting features.

Code:
HEADER1=('SOME HEADER'),


will put the header with text 'SOME HEADER'

Code:
TRAILER1=(COUNT=(M11,LENGTH=4),                           
            TOT=(81,1,ZD,M11,LENGTH=4)) 


Trailer1 will write the last record with a count of no: of records and the length is limited to 4 bytes and now since you wanted the count of print=y records we use the 1 byte field we added using inrec at pos 81. Since all the records except the print=y record have a zero , when we total it up we will have the count of all print=y records and length is limited to 4 bytes
Back to top
View user's profile Send private message
krishnakanagal

New User


Joined: 27 Feb 2009
Posts: 12
Location: Bangalore

PostPosted: Tue Jul 07, 2009 12:37 am
Reply with quote

Thanks Kolusu,

Thats a great learning experience for me
Back to top
View user's profile Send private message
sajjan jindal
Warnings : 1

New User


Joined: 09 Sep 2007
Posts: 60
Location: india

PostPosted: Tue Jul 07, 2009 10:19 am
Reply with quote

Hi Kolusu,

Wonderfull solution. thats great learning. I remember one scenario for which i couldnt find a solution. I believe you can crack it.

Suppose I have a flat file and i want to start copying the records from a file if certain condition is matched and stop copying when another condition matches.

For example we take a flat file containing list of names. We want to start copyinng the records as soon as we find Kolusu and stop copying the records as soon as we find Sajjan.

I believe you can suggest a feasible solution for this.
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Tue Jul 07, 2009 11:09 am
Reply with quote

Hi,

this may assist ibmmainframes.com/viewtopic.php?t=35351


Gerry
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Tue Jul 07, 2009 11:16 am
Reply with quote

Hi Sajjan, Below DFSORT step will give you desired result..

Code:

//STEP0100 EXEC PGM=SORT                                     
//SYSOUT   DD SYSOUT=*                                       
//SORTIN   DD *                                               
ALEX                                                         
JOHN                                                         
KOLUSU                                                       
KEVIN                                                         
FRANK                                                         
SAJJAN                                                       
OTHER1                                                       
OTHER2                                                       
/*                                                           
//SORTOUT  DD SYSOUT=*                                       
//SYSIN    DD *                                               
  SORT FIELDS=COPY                                           
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,6,CH,EQ,C'KOLUSU'),       
       END=(1,6,CH,EQ,C'SAJJAN'),PUSH=(81:ID=1))             
  OUTFIL INCLUDE=(81,1,ZD,EQ,1),BUILD=(1,80)                 
/*
Back to top
View user's profile Send private message
sajjan jindal
Warnings : 1

New User


Joined: 09 Sep 2007
Posts: 60
Location: india

PostPosted: Tue Jul 07, 2009 4:25 pm
Reply with quote

Hi Sambhaji,

Thanks for the reply.


can you please describe "PUSH=(81:ID=1)" in the above code.

If you have any document or link which breifly describes "IFTHEN", then do forward it to me.

Thanks for your time and efforts.
Back to top
View user's profile Send private message
sajjan jindal
Warnings : 1

New User


Joined: 09 Sep 2007
Posts: 60
Location: india

PostPosted: Tue Jul 07, 2009 5:49 pm
Reply with quote

Hi,

I am getting following error:

PARAMETER 'IFTHEN' IS UNIDENTIFIED.
PARAMETER 'BUILD' IS UNIDENTIFIED.
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Tue Jul 07, 2009 6:09 pm
Reply with quote

Quote:
Hi Sambhaji,

Thanks for the reply.


can you please describe "PUSH=(81:ID=1)" in the above code.


Refer below link for it
www.ibm.com/support/docview.wss?rs=0&uid=isg3T7000085
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: Tue Jul 07, 2009 9:03 pm
Reply with quote

Quote:
I am getting following error:

PARAMETER 'IFTHEN' IS UNIDENTIFIED.
PARAMETER 'BUILD' IS UNIDENTIFIED.


These are JCL Checker errors. Unfortunately, the JCL Checkers do NOT keep up with new functions in DFSORT. Ignore these messages and look at the DFSORT messages (ICExxxs).

Quote:
can you please describe "PUSH=(81:ID=1)" in the above code.


The technique used is described in the S3 example of the "Include or omit groups of records" Smart DFSORT Trick at:

www.ibm.com/support/docview.wss?rs=0&uid=isg3T7000094
Back to top
View user's profile Send private message
sajjan jindal
Warnings : 1

New User


Joined: 09 Sep 2007
Posts: 60
Location: india

PostPosted: Wed Jul 08, 2009 10:26 am
Reply with quote

This forum is exciting. icon_biggrin.gif
Thanks a ton friends.
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 -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts To get the count of rows for every 1 ... DB2 3
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
No new posts To find whether record count are true... DFSORT/ICETOOL 6
Search our Forums:

Back to Top