Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Specific record count in Trailer

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Specific record count in Trailer
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    Post subject: Reply to: Specific record count in Trailer
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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: 1703
Location: Australia

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

Hi,

this may assist http://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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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
http://www.ibm.com/support/docview.wss?rs=0&uid=isg3T7000085
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


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

PostPosted: Tue Jul 07, 2009 9:03 pm    Post subject:
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:

http://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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts How to update a portion of text in a ... Bill Woodger DFSORT/ICETOOL 25 Wed Nov 09, 2016 9:41 pm
No new posts abend sort based on count records in ... anatol DFSORT/ICETOOL 5 Mon Oct 17, 2016 10:10 pm
No new posts sort with previous record anatol DFSORT/ICETOOL 9 Thu Oct 06, 2016 2:36 am
No new posts how to split records based on specifi... Venkata Ramayya DFSORT/ICETOOL 6 Wed Sep 28, 2016 3:20 am
No new posts Get Record count in summary record fo... Atul Banke DFSORT/ICETOOL 21 Fri Sep 23, 2016 4:17 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us