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
 

 

Record count and sum

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
View previous topic :: :: View next topic  
Author Message
die7nadal

Active User


Joined: 23 Mar 2005
Posts: 156

PostPosted: Sat Mar 06, 2010 2:41 am    Post subject: Record count and sum
Reply with quote

Here is my input file 30/FB
Code:
AA1111111012345678901234
DDDDDDDDD000000000000234
DDDDDDDDD000000000000234
DDDDDDDDD000000000000234
DDDDDDDDD000000000000234
DDDDDDDDD000000000000234
DDDDDDDDD000000000000234


My output file should look like

Code:
AA0000003000000000000468
DDDDDDDDD000000000000234
DDDDDDDDD000000000000234

I should pick the first 3 records including the header record identified by 'AA' in the first 2 chars. Then I will have to adjust the record count to 3 in 3,7 and sum in 10,15 of the header. I should sum the detail records in 13,3. The number of records that I pick is variable, so it will not always be 3.

I know how to arrive at the solution using multiple passes of the file. But is there any solution using just one ot two passes of the file (using SECTIONS). I am just trying to figure if there is a better way than mine.
Back to top
View user's profile Send private message

dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Sat Mar 06, 2010 2:47 am    Post subject:
Reply with quote

Hello,

It may help someone help you if you post what you have working now. . .
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: Sat Mar 06, 2010 4:30 am    Post subject:
Reply with quote

die7nadal,

Here's a two-pass DFSORT/ICETOOL job that will do what you asked for:

Code:

//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD DSN=...  input file (FB/30)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//OUT DD DSN=...  output file (FB/30)
//TOOLIN DD *
COPY FROM(IN) USING(CTL1)
SORT FROM(T1) TO(OUT) USING(CTL2)
/*
//CTL1CNTL DD *
  OPTION COPY,STOPAFT=3
  OUTFIL FNAMES=T1,REMOVECC,
   OMIT=(1,2,CH,EQ,C'AA'),
   TRAILER1=('AA',COUNT+1=(M11,LENGTH=7),
    TOT=(10,15,ZD,TO=ZD,LENGTH=15))
/*
//CTL2CNTL DD *
  OPTION EQUALS
  SORT FIELDS=(1,2,CH,A)
/*


Quote:
The number of records that I pick is variable, so it will not always be 3.


You can change the STOPAFT value to whatever you need.
Back to top
View user's profile Send private message
die7nadal

Active User


Joined: 23 Mar 2005
Posts: 156

PostPosted: Sat Mar 06, 2010 4:48 am    Post subject:
Reply with quote

Frank, I knew you would come up with something. Thanks a lot.
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Sat Mar 06, 2010 6:15 am    Post subject: Reply to: record count and sum
Reply with quote

die7nadal,

FWIW here is a 1 pass solution

Code:

//STEP0100 EXEC PGM=SORT     
//SYSOUT   DD SYSOUT=*       
//SORTIN   DD DSN=Your input fb 30 bytes,DISP=SHR
//SORTOUT  DD SYSOUT=*                                             
//SYSIN    DD *                                                   
  OPTION COPY,STOPAFT=3                                           
  INREC IFTHEN=(WHEN=INIT,BUILD=(1,30,91:SEQNUM,1,ZD)),           
  IFTHEN=(WHEN=GROUP,BEGIN=(91,1,ZD,EQ,1),PUSH=(61:1,30)),         
  IFTHEN=(WHEN=GROUP,BEGIN=(91,1,ZD,EQ,2),PUSH=(31:1,30))         
                                                                   
  OUTFIL INCLUDE=(91,1,ZD,EQ,3),                                   
  BUILD=(61,2,C'0000003',10,15,ZD,ADD,40,15,ZD,ZD,LENGTH=15,85,6,/,
         31,30,/,1,30)                                             
//*
Back to top
View user's profile Send private message
die7nadal

Active User


Joined: 23 Mar 2005
Posts: 156

PostPosted: Mon Mar 08, 2010 10:44 pm    Post subject:
Reply with quote

Thanks a lot Skolusu.
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 -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Check if any Detail records and extra... V S Amarendra Reddy SYNCSORT 19 Mon May 08, 2017 8:54 pm
No new posts Adding big TEXT lines to each record ... bshkris SYNCSORT 4 Sat May 06, 2017 1:40 am
This topic is locked: you cannot edit posts or make replies. Merge two files and update Trailer re... Yashashri JCL & VSAM 1 Thu May 04, 2017 12:54 pm
No new posts Sort Large record length cmsmoon DFSORT/ICETOOL 14 Tue Apr 11, 2017 5:49 pm
No new posts Format record to remove Leading zeroes Learncoholic DFSORT/ICETOOL 14 Wed Apr 05, 2017 2:43 pm


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