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

Replace the last record with correct count


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

New User


Joined: 05 Dec 2007
Posts: 82
Location: chennai

PostPosted: Mon Aug 04, 2008 5:38 pm
Reply with quote

Hi All,
My requirement is to rewrite the count in the last/trailer record.
In my input file, there is a header, trailer and detail records.
first 3 characters specify if it is a header/trailer/detail.

001 - header record
002 - detail records
003 - trailer record

In my trailer record which would be the last record in the file, i have a count (8 digits from 7th position). I'm removing the duplicates in the jcl and sum certain fields. So, i need to rewrite the count now with correct count.
My sort card now looks like this..
INREC OVERLAY=(66:66,11,SFF,TO=ZD,LENGTH=11,
77:77,11,SFF,TO=ZD,LENGTH=11,
106:106,13,SFF,TO=ZD,LENGTH=13)
SORT FIELDS=(1,3,CH,A,7,35,CH,A,42,9,ZD,A,56,4,CH,A,97,9,ZD,A,
119,10,CH,A,139,2,CH,A,4,3,CH,A)
SUM FIELDS=(66,11,77,11,106,13),FORMAT=ZD
OUTREC OVERLAY=(66:66,11,ZD,EDIT=(STTTTTT.TTT),SIGNS=(+,-),
77:77,11,ZD,EDIT=(STTTTTT.TTT),SIGNS=(+,-),
106:106,13,ZD,EDIT=(STTTTTTTTT.TT),SIGNS=(+,-))

Can we have the COUNT function with OVERLAY? Please comment...

Thanks...
Back to top
View user's profile Send private message
lanand_hps

New User


Joined: 05 Dec 2007
Posts: 82
Location: chennai

PostPosted: Mon Aug 04, 2008 5:39 pm
Reply with quote

I read the post which would give the count as trailer.. But i need to replace the existing count and do not want a new row.

Thanks..
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: Mon Aug 04, 2008 9:33 pm
Reply with quote

Quote:
Can we have the COUNT function with OVERLAY?


COUNT is a parameter of the TRAILERx operand. It can't be used in OVERLAY.

Instead, you can set up the count you want as a symbol in one step and then use that symbol for the count in your OVERLAY statement in another step.

The DFSORT job would be something like this:

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file (FB)
//SYM DD DSN=&&S1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//SYSIN    DD    *
  OPTION COPY
  OUTFIL FNAMES=SYM,REMOVECC,NODETAIL,
    BUILD=(80X),
    TRAILER1=('NEWCT,''',COUNT=(M11,LENGTH=8),'''')
/*
//S2    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)
//SORTIN DD DSN=...  input file (FB)
//SORTOUT DD SYSOUT=*
//SYSIN DD *
  <Your other control statements>
  OUTFIL IFTHEN=(WHEN=(1,3,CH,EQ,C'003'),OVERLAY=(7:NEWCT))
/*
Back to top
View user's profile Send private message
lanand_hps

New User


Joined: 05 Dec 2007
Posts: 82
Location: chennai

PostPosted: Mon Aug 04, 2008 11:29 pm
Reply with quote

Thanks Frank!!
Instead of using COUNT parameter, Can we do it in a single step by giving sequence number to each detail row and use the maximum of sequence number to overwrite in the last record? Is it possible?
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: Mon Aug 04, 2008 11:53 pm
Reply with quote

Yes, it's possible but it does require adding a sequence number and then removing it. I'll leave it to you to code it up and test it. But here are some thoughts on how I think it could be done: You would have to add the sequence number with the OUTREC statement since you want the count of records after summing. The seqnum for the '003' (last) record will be equal to the count of the summed records. So you can use OUTFIL with IFTHEN for the '003' record to do the OVERLAY of the last seqnum, and finally remove the seqnum (you could do that with IFOUTLEN).
Back to top
View user's profile Send private message
lanand_hps

New User


Joined: 05 Dec 2007
Posts: 82
Location: chennai

PostPosted: Wed Aug 06, 2008 2:39 pm
Reply with quote

Hi Frank,
I need the count of detail records only. If i had used the seqnum, i would have got the count including header and trailer record. I should have started the SEQNUM with -1 so that i get the correct detail count in the last record. But the seqnum, seems can start only from 0.

I have used COUNT-2=(M11,LENGTH=8) to the existing step and used OVERLAY with IFTHEN as you have mentioned in the second step to rewrite the second step. Thanks.


Can we have the sequence number/count for a given condition?
For example, can we give sequence number/count only for records with first 3 characters as '002'?
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: Wed Aug 06, 2008 10:27 pm
Reply with quote

You could use IFTHEN for '002' to get the sequence number for only the '002' records but then you wouldn't have the sequence number in the trailer record ('003') to pick up for the count.

But here's a trick you can use:

SEQNUM,8,ZD,START=99999999

The sequence number will wrap around and you will end up with the sequence number for the count you need in the last record. For example:

Code:

H   ... 99999999
D1  ... 00000000
D2  ... 00000001
D3  ... 00000002
T   ... 00000003
Back to top
View user's profile Send private message
lanand_hps

New User


Joined: 05 Dec 2007
Posts: 82
Location: chennai

PostPosted: Wed Aug 06, 2008 11:24 pm
Reply with quote

Oh.. yes... Thanks a lot..
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 Nov 09, 2010 2:16 am
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 update the trailer count quite easily.

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

www.ibm.com/support/docview.wss?rs=114&uid=isg3T7000242
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 Replace each space in cobol string wi... COBOL Programming 3
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
Search our Forums:

Back to Top