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
 

 

Replace the last record with correct count

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Replace the last record with correct count
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    Post subject:
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 Moderator


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

PostPosted: Mon Aug 04, 2008 9:33 pm    Post subject:
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    Post subject:
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 Moderator


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

PostPosted: Mon Aug 04, 2008 11:53 pm    Post subject:
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    Post subject:
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 Moderator


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

PostPosted: Wed Aug 06, 2008 10:27 pm    Post subject:
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    Post subject:
Reply with quote

Oh.. yes... Thanks a lot..
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 Nov 09, 2010 2:16 am    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 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:

http://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    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 CICS Transaction attach count of supp... lind sh CICS 1 Wed Jun 21, 2017 1:33 pm
No new posts Need to write record of PS File in ex... Chandan1993 JCL & VSAM 1 Wed Jun 07, 2017 1:35 am
No new posts Fileaid Update Replace with null string descann Compuware & Other Tools 4 Mon May 15, 2017 3:00 pm
No new posts Replace values in the input data Vikas Maharnawar DFSORT/ICETOOL 10 Thu May 11, 2017 2:18 pm
No new posts Check if any Detail records and extra... V S Amarendra Reddy SYNCSORT 19 Mon May 08, 2017 8:54 pm


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