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 

Add a summary trailer record at the end of the file.
Goto page 1, 2  Next
 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
heman
Beginner


Joined: 17 Aug 2005
Posts: 18
Topics: 4

PostPosted: Wed Jan 18, 2006 6:26 am    Post subject: Add a summary trailer record at the end of the file. Reply with quote

Hi,

I have a sequential file which looks like this.

XXXXXXXXXXXXXXXXXXX123456789123456.34-
XXXXXXXXXXXXXXXXXXX946545678912345.50
XXXXXXXXXXXXXXXXXXX123456789123456.34-
XXXXXXXXXXXXXXXXXXX123456789123347.89

The file has two fields:
1) ID Nbr - X(19)
2) Amount value - X(19) - this field contains amount values. There's anegative sign at the end if it's a negative value. Thus, 123456789123456.34- is numerically -123456789123456.34.

I need a trailer record at the end of the file with the following values:
1) Count of the number of detail records in the file.
2) Sum of the amount values in each of the detail record. The problem is that the amount value in the detail records is alphanumeric.

Can someone suggest a way to do this without eazytrieve or a program. I
need to do this by something like DFSORT.

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


Joined: 12 Feb 2003
Posts: 358
Topics: 4
Location: Israel

PostPosted: Wed Jan 18, 2006 8:00 am    Post subject: Reply with quote

If you file is not too big, here is a REXX solution:
Code:
/* REXX */                                                         
                                                                   
NUMERIC DIGITS 25                                                 
                                                                   
ADDRESS TSO "ALLOC FI(IN) DA('your.input.dataset') SHR REU"       
ADDRESS TSO "EXECIO * DISKR IN (STEM IN. FINIS"                   
ADDRESS TSO "FREE FI(IN)"                                         
                                                                   
ACCUM = 0                                                         
                                                                   
DO I = 1 TO IN.0                                                   
                                                                   
  NUM = STRIP(TRANSLATE(SUBSTR(IN.I,20,19),' ','-')) + 0           
                                                                   
  IF POS('-',SUBSTR(IN.I,20,19)) > 0 THEN                         
    NUM = NUM * -1                                                 
                                                                   
  ACCUM = ACCUM + NUM                                             
                                                                   
END I                                                             
                                                                   
SAY 'Total Records: 'IN.0                                         
SAY 'Total Amount : 'ACCUM                                         
                                                                   
EXIT                                                               
                                                                   


O.
________
DeSoto Custom


Last edited by ofer71 on Sat Feb 05, 2011 11:29 am; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail
Alain Benveniste
Beginner


Joined: 04 May 2003
Posts: 92
Topics: 4
Location: Paris, France

PostPosted: Wed Jan 18, 2006 8:02 am    Post subject: Reply with quote

Heman,

See the "Sum a number with a decimal point" Smart DFSORT Trick for a solution:

http://www.ibm.com/servers/storage/support/software/sort/mvs/tricks/
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 Jan 18, 2006 11:15 am    Post subject: Reply with quote

You can use a DFSORT job like this to do what you asked for:

Code:

//S1    EXEC  PGM=ICEMAN                                         
//SYSOUT    DD  SYSOUT=*                                         
//SORTIN DD *                                                   
XXXXXXXXXXXXXXXXXXX123456789123456.34-                           
XXXXXXXXXXXXXXXXXXX946545678912345.50                           
XXXXXXXXXXXXXXXXXXX123456789123456.34-                           
XXXXXXXXXXXXXXXXXXX123456789123347.89                           
//SORTOUT DD SYSOUT=*                                           
//SYSIN    DD    *                                               
  OPTION COPY                                                   
  OUTFIL TRAILER1=(COUNT=(M11,LENGTH=8),                         
    20:TOT=(20,21,SFF,EDIT=(TTTTTTTTTTTTTTT.TTS),SIGNS=(,,,-))) 
/*


SORTOUT will have:

Code:

XXXXXXXXXXXXXXXXXXX123456789123456.34- 
XXXXXXXXXXXXXXXXXXX946545678912345.50   
XXXXXXXXXXXXXXXXXXX123456789123456.34- 
XXXXXXXXXXXXXXXXXXX123456789123347.89   
00000004           823088889788780.71   


You'll need z/OS DFSORT V1R5 PTF UQ95214 or DFSORT R14 PTF UQ95213 (Dec, 2004) in order to use DFSORT's SFF and larger numbers functions. Only DFSORT has these functions, so if you don't have DFSORT, you won't be able to use them. If you do have DFSORT, but you don't have the Dec, 2004 PTF, ask your System Programmer to install it (it's free). For complete details on all of the new DFSORT and ICETOOL functions available with the Dec, 2004 PTF, see:

www.ibm.com/servers/storage/support/software/sort/mvs/pdug/
_________________
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
heman
Beginner


Joined: 17 Aug 2005
Posts: 18
Topics: 4

PostPosted: Wed Jan 18, 2006 3:14 pm    Post subject: Reply with quote

Hi Frank,

I have tried executing with the given DFSORT syntax but it gives me the following error which I'm unable to rectify.

SYSIN :
OPTION COPY
OUTFIL TRAILER1=(COUNT=M11,LENGTH=8),
*
20:TOT=(20,21,SFF,EDIT=(TTTTTTTTTTTTTTT.TTS),SIGNS=(,,,-)))
WER268A OUTFIL STATEMENT : SYNTAX ERROR
WER211B SYNCSMF CALLED BY SYNCSORT; RC=0000
WER449I SYNCSORT GLOBAL DSM SUBSYSTEM ACTIVE

Shouid this work even if the amount value field is alphanumeric?

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


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

PostPosted: Wed Jan 18, 2006 3:43 pm    Post subject: Reply with quote

heman,

Syncsort does NOT support SFF and large number functions.

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


Joined: 17 Aug 2005
Posts: 18
Topics: 4

PostPosted: Wed Jan 18, 2006 3:49 pm    Post subject: Reply with quote

Hi Kolusu,

Is there any other way I can do this?

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


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

PostPosted: Wed Jan 18, 2006 3:51 pm    Post subject: Reply with quote

heman,

yes you can but I don't have time to code it now. May be if I find some time , I will post it here

Thanks

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


Joined: 17 Aug 2005
Posts: 18
Topics: 4

PostPosted: Wed Jan 18, 2006 3:55 pm    Post subject: Reply with quote

Kolusu, you can just give me a reference where i might find something. This is a bit urgent.
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 Jan 18, 2006 5:39 pm    Post subject: Reply with quote

heman wrote
Quote:
Hi Frank,

I have tried executing with the given DFSORT syntax but it gives me the following error which I'm unable to rectify.


Gee, I thought I was pretty clear about only DFSORT supporting SFF and larger number functions when I said:

Quote:
You'll need z/OS DFSORT V1R5 PTF UQ95214 or DFSORT R14 PTF UQ95213 (Dec, 2004) in order to use DFSORT's SFF and larger numbers functions. Only DFSORT has these functions, so if you don't have DFSORT, you won't be able to use them.


Or maybe you didn't know you were using Syncsort?
_________________
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: 12382
Topics: 75
Location: San Jose

PostPosted: Thu Jan 19, 2006 5:25 am    Post subject: Reply with quote

Quote:

Kolusu, you can just give me a reference where i might find something. This is a bit urgent.


Check this topic

http://mvsforums.com/helpboards/viewtopic.php?p=18925#18925

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
heman
Beginner


Joined: 17 Aug 2005
Posts: 18
Topics: 4

PostPosted: Thu Jan 19, 2006 5:55 am    Post subject: Reply with quote

Confusions!!!!! Apologies for that!!!!!
My shop doesn't have a DFSORT and there's no way I can have it.

I would need to do this without a DFSORT. Is there any other way to do this?

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


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

PostPosted: Thu Jan 19, 2006 5:57 am    Post subject: Reply with quote

Quote:

Confusions!!!!! Apologies for that!!!!!
My shop doesn't have a DFSORT and there's no way I can have it.


read the link carefully once again and you will find this
Quote:

If your shop has syncsort then change the pgm name to synctool


Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
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: 12382
Topics: 75
Location: San Jose

PostPosted: Thu Jan 19, 2006 9:48 am    Post subject: Reply with quote

heman,

try this JCL

Code:

//STEP0100 EXEC PGM=SORT                                 
//SYSOUT   DD SYSOUT=*                                   
//SORTIN   DD *                                           
XXXXXXXXXXXXXXXXXXX123456789123456.34-                   
XXXXXXXXXXXXXXXXXXX946545678912345.50                     
XXXXXXXXXXXXXXXXXXX123456789123456.34-                   
XXXXXXXXXXXXXXXXXXX123456789123347.89                     
//SORTOUT  DD DSN=&T1,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)
//SYSIN    DD *                                           
  SORT FIELDS=COPY                                       
  OUTREC FIELDS=(C'1',                                   
                 C'00000001',                             
                 20,15,                                   
                 36,01,                                   
                 37,02,CHANGE=(1,C'0-',C'}',             
                                 C'1-',C'J',             
                                 C'2-',C'K',             
                                 C'3-',C'L',             
                                 C'4-',C'M',             
                                 C'5-',C'N',             
                                 C'6-',C'O',             
                                 C'7-',C'P',             
                                 C'8-',C'Q',             
                                 C'9-',C'R',             
                                 C'0 ',C'{',             
                                 C'1 ',C'A',             
                                 C'2 ',C'B',             
                                 C'3 ',C'C',             
                                 C'4 ',C'D',             
                                 C'5 ',C'E',             
                                 C'6 ',C'F',             
                                 C'7 ',C'G',             
                                 C'8 ',C'H',             
                                 C'9 ',C'I'))             
/*
//STEP0200 EXEC PGM=SORT                         
//SYSOUT   DD SYSOUT=*                           
//SORTIN   DD DSN=&T1,DISP=SHR                   
//SORTOUT  DD SYSOUT=*                           
//SYSIN    DD *                                 
  SORT FIELDS=(1,1,CH,A)                         
  SUM FIELDS=(2,8,ZD,                           
              10,17,ZD)                         
  OUTFIL OUTREC=(C'TOTAL NUMBER OF RECORDS : ', 
                 2,8,/,                         
                 C'TOTAL AMOUNT VALUE      : ', 
                 10,15,                         
                 C'.',                           
                 25,02,                         
                 80:X)                           
/*


The output from this step is

Code:

TOTAL NO: OF RECORDS : 00000004           
TOTAL AMOUNT VALUE   : 823088889788780.71 


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
heman
Beginner


Joined: 17 Aug 2005
Posts: 18
Topics: 4

PostPosted: Thu Jan 19, 2006 10:34 am    Post subject: Reply with quote

Hi Kolusu,

Yes, this JCL does work but the only problem is that the negative sign in the output "TOTAL AMOUNT VALUE" doesn't get displayed properly. It gets displayed as '}'.

Thanks.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Goto page 1, 2  Next
Page 1 of 2

 
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