MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Reformatting no of records calculated by COUNT in trailer

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
info_seeker
Beginner


Joined: 31 Jan 2005
Posts: 27
Topics: 9

PostPosted: Wed Sep 28, 2005 2:13 pm    Post subject: Reformatting no of records calculated by COUNT in trailer Reply with quote

hi,

I need to extract the record count of a particular type of record in a file and edit the count so that the left blanks will get padded with zeros and expanded by a byte.
Below is my job
Code:

//STEP010  EXEC PGM=SYNCSORT                                       
//SYSOUT   DD SYSOUT=*                                             
//SORTIN   DD *                                                     
00 HEADER                                                           
04 D111111                                                         
05 D222222                                                         
06 D112244                                                         
09 D234344                                                         
05 D878773                                                         
06 D783467                                                         
05 D756576                                                         
99 TRAILER                                                         
//SORTOUT  DD DISP=(,CATLG,DELETE),DSN=XXXX.OUTPUT,             
//            UNIT=SYSDA,SPACE=(TRK,(15,15),RLSE),RECFM=FB,BLKSIZE=0
//SYSIN    DD *                                                     
 SORT FIELDS=COPY                                                   
 INCLUDE COND=(1,2,CH,EQ,C'05')                                     
 OUTFIL REMOVECC,NODETAIL                                                   
 TRAILER1=(DATENS=(4MD),COUNT)
//*

The output I am getting is
20050928 3

My result I am expecting is
20050928000000003

COUNT occuppies 8 bytes of spaces. I want this to be made 9 bytes, as well as padded with zeros to the left. I tried with TRAILER1=(DATENS=(4MD),COUNT,EDIT=(TTTTTTTTT)), but was giving me syntax error.

Help much appreciated!!!
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Wed Sep 28, 2005 2:21 pm    Post subject: Reply with quote

The following OUTFIL statement works with DFSORT and will give you what you want. PGM=SYNCSORT suggests you're using Syncsort - I don't know if this will work with Syncsort.

Code:

  OUTFIL REMOVECC,NODETAIL,                         
    TRAILER1=(DATENS=(4MD),COUNT=(EDIT=(TTTTTTTTT)))

_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Wed Sep 28, 2005 2:28 pm    Post subject: Reply with quote

The latest version of syncsort (syncsort for z/os 1.2 ) supports the control cards Frank has shown. I guess you have older version of sort.

try the following control cards
Code:

//SYSIN    DD *                 
  SORT FIELDS=COPY               
  INCLUDE COND=(1,2,CH,EQ,C'05') 
  OUTREC FIELDS=(SEQNUM,9,ZD,80:X)
  OUTFIL REMOVECC,NODETAIL,       
  TRAILER1=(DATENS=(4MD),1,9)     
//*                             


Hope this helps..

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
info_seeker
Beginner


Joined: 31 Jan 2005
Posts: 27
Topics: 9

PostPosted: Wed Sep 28, 2005 2:53 pm    Post subject: Reply with quote

Kolusu's solution worked. I removed the NODETAIL so that I can have the detail records too. But the OUTREC parameter overwrites that.

Is there a way I can get the following output for the same input?
05 D222222
05 D878773
05 D756576
99 TRAILER00000000320050928

Thanks!
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Wed Sep 28, 2005 3:46 pm    Post subject: Reply with quote

info_seeker,

What is the LRECL and RECFM of the input file?

Do you want the trailer to have

Code:

99 TRAILER


Followed by count and the current date?

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
info_seeker
Beginner


Joined: 31 Jan 2005
Posts: 27
Topics: 9

PostPosted: Wed Sep 28, 2005 5:06 pm    Post subject: Reply with quote

Hi Kolusu,

the LRECL is 160.

What is intended is to have first 10 bytes of the actual file trailer retained and add count and date that. Going a step further, can we update the a particular field in the trailer. For eg: as in the case abbove if the trailer was:-
99 TRAILER00000000720050928 considering entire data, only for record type 05, can I modify the trailer as 99 TRAILER00000000320050928 ???
Back to top
View user's profile Send private message
Phantom
Data Mgmt Moderator
Data Mgmt Moderator


Joined: 07 Jan 2003
Posts: 1056
Topics: 91
Location: The Blue Planet

PostPosted: Thu Sep 29, 2005 2:10 am    Post subject: Reply with quote

info_seeker,

Try this card.
Code:

//SYSIN    DD *                                         
  SORT FIELDS=COPY                                     
  INCLUDE COND=(1,2,CH,EQ,C'05')                       
  OUTREC FIELDS=(1,10,160:X,SEQNUM,9,ZD)               
  OUTFIL REMOVECC,                                     
         TRAILER1=('99 TRAILER',161,9,DATENS=(4MD)),   
         OUTREC=(1,160)                                 
//*                                                     


Quote:

For eg: as in the case abbove if the trailer was:-
99 TRAILER00000000720050928 considering entire data, only for record type 05, can I modify the trailer as 99 TRAILER00000000320050928 ???


I don't understand what you are upto. Do you want two trailers ??? one for 05 records and the other which contains the count of all records ?.

If you remove the include cond, you will get trailer with 000000007 as count else you have count 000000003. Please clarify the requirement (provide input and complete output expected)

Thanks,
Phantom
Back to top
View user's profile Send private message
info_seeker
Beginner


Joined: 31 Jan 2005
Posts: 27
Topics: 9

PostPosted: Thu Sep 29, 2005 12:20 pm    Post subject: Reply with quote

Hi Phantom,

I reuiqre ONLY one trailer with the record count rewritten in that with the no of occurrences of record type '05'.
Giving reference to the trailer above, first 10 bytes "99 TRAILER" will remain as it is in the input modify the count from 000000007 to 000000003 and rest of the trailer as it was in the input.

From the solution you mentioned, the sort program will be inserting "99 TRAILER" as new set of characters. I need to bring in the first 10 bytes whatever may be the trailer (of course, the record type 99 remains the same as is to identify the trailer record), update with count for record type '05', then, the rest of trailer (after count) from the total of 160 (LECL).

Please advise!!!
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Thu Sep 29, 2005 12:52 pm    Post subject: Reply with quote

Info_seeker,

try this job.

Code:

//STEP0100 EXEC PGM=SORT                                 
//SYSOUT   DD SYSOUT=*                                   
//SORTIN   DD *                                         
00 HEADER                                               
04 D111111                                               
05 D222222                                               
06 D112244                                               
09 D234344                                               
05 D878773                                               
06 D783467                                               
05 D756576                                               
99 TRAILER                                               
//SORTOUT  DD SYSOUT=*                                   
//SYSIN    DD *                                         
  SORT FIELDS=COPY                                       
  INCLUDE COND=(1,2,CH,EQ,C'05',OR,1,2,CH,EQ,C'99')     
  OUTREC FIELDS=(01,10,SEQNUM,9,ZD,START=0,DATE1,160:X)
  OUTFIL OUTREC=(01,10,                                 
                 11:1,2,CHANGE=(20,C'05',C' '),         
                 NOMATCH=(11,20),160:X)                 
/*                                                       


Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
info_seeker
Beginner


Joined: 31 Jan 2005
Posts: 27
Topics: 9

PostPosted: Fri Sep 30, 2005 9:14 am    Post subject: Reply with quote

The solution worked.. Thanks a lot kolusu and all !!!!!
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Fri Oct 29, 2010 3:53 pm    Post subject: Reply with quote

With z/OS DFSORT V1R10 PTF UK90025 or z/OS DFSORT V1R12 PTF UK90026 (Oct,2010), you can now use DFSORT's new IFTRAIL function to do this more easily like this:

Code:

//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=...  input file (FB/160)
//SORTOUT DD DSN=...  output file (FB/160)
//SYSIN DD *
  OPTION COPY
  OUTFIL INCLUDE=(1,2,CH,EQ,C'05'),
   IFTRAIL=(TRLID=(1,2,CH,EQ,C'99'),
    TRLUPD=(11:COUNT=(TO=ZD,LENGTH=9)))
/*


For complete details on the new functions for DFSORT and DFSORT's ICETOOL available with the Oct, 2010 PTF, see:

http://www.ibm.com/support/docview.wss?rs=114&uid=isg3T7000242
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group