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

Record count and sum


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
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
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

Moderator Emeritus


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

PostPosted: Sat Mar 06, 2010 2:47 am
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 Developer


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

PostPosted: Sat Mar 06, 2010 4:30 am
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
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> JCL & VSAM

 


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