IBM MAINFRAME HELP & SUPPORT FORUMS
Technical Forums for IBM Mainframe Applications like COBOL, JCL, CICS, DB2, FileAid, DFSORT, Endevor, Xpediter, CoolGen, CA-7&11, AbendAid, IMS, IDMS, PL/I, MqSeries, SyncSort, Assembler, ChangeMan, Easytrieve, InterTest, REXX, CLIST etc...
 

Replace the last record with correct count

THIS IS AN ARCHIVE FORUM: CLICK HERE TO GO TO THE ORIGINAL TOPIC

 
       IBMMAINFRAMES.com - IBM Mainframe Support Forums Index -> DFSORT/ICETOOL
View previous topic :: View next topic  
Author Message
lanand_hps



Joined: 05 Dec 2007
Posts: 59
Location: chennai

Posted: Mon Aug 04, 2008 5:38 pm    Post subject: Replace the last record with correct count  

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  
lanand_hps



Joined: 05 Dec 2007
Posts: 59
Location: chennai

Posted: Mon Aug 04, 2008 5:39 pm    Post subject:  

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  
Frank Yaeger



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

Posted: Mon Aug 04, 2008 9:33 pm    Post subject:  

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  
lanand_hps



Joined: 05 Dec 2007
Posts: 59
Location: chennai

Posted: Mon Aug 04, 2008 11:29 pm    Post subject:  

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  
Frank Yaeger



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

Posted: Mon Aug 04, 2008 11:53 pm    Post subject:  

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  
lanand_hps



Joined: 05 Dec 2007
Posts: 59
Location: chennai

Posted: Wed Aug 06, 2008 2:39 pm    Post subject:  

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  
Frank Yaeger



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

Posted: Wed Aug 06, 2008 10:27 pm    Post subject:  

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  
lanand_hps



Joined: 05 Dec 2007
Posts: 59
Location: chennai

Posted: Wed Aug 06, 2008 11:24 pm    Post subject:  

Oh.. yes... Thanks a lot..
Back to top  
 
       IBMMAINFRAMES.com - IBM Mainframe Support Forums Index -> DFSORT/ICETOOL
Page 1 of 1
THIS IS AN ARCIVE FORUM IN READ ONLY MODE. IF YOU WANT TO ASK YOUR DOUBTS USE THE ACTUAL FORUM