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

SUM COMP-3 fields VB file


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

New User


Joined: 02 Jun 2006
Posts: 6

PostPosted: Sat Mar 24, 2007 2:54 am
Reply with quote

I would like to SUM fields of my file. The file was created using a cobol program is VB Lrecl 425. The field is PIC S9(9)V99 comp-3 can be negative or positive.
Output can be FB or VB should be like this:
Code:
//STEP2    EXEC SORT,REGION=32M                     
//SYSOUT    DD SYSOUT=*                             
//SORTIN    DD DSN=input file(0),  (VB-425)
//          DISP=SHR                                 
//SORTOUT   DD DSN=output file,                 
//             DISP=(NEW,CATLG,KEEP),               
//             SPACE=(CYL,(99,99),RLSE),             
//             VOL=SER=PROD01,                       
//             UNIT=SYSDA                           
//*            DCB=(LRECL=425,RECFM=FB,BLKSIZE=0)
//SYSIN DD *           
 SORT FIELDS=COPY     
 SUM FIELDS=(115,6,PD)
/*                         

Output can be FB or VB should be like this:
TOTAL:   69649624.36 
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Sat Mar 24, 2007 3:34 am
Reply with quote

Hello,

A bit more information, please.

In the VB file, will the number to sum always begin in pos 115?

Is all of the data to be copied as well as creating the TOTAL line? If all of the data is to be copied into the output file, should the TOTAL be placed at the end of the output file or in a different place?
Back to top
View user's profile Send private message
adushkin

New User


Joined: 02 Jun 2006
Posts: 6

PostPosted: Sat Mar 24, 2007 5:11 am
Reply with quote

I need only one record with total, field start in pos 115
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Sat Mar 24, 2007 5:49 am
Reply with quote

Have you looked at a sort manual? SUM parms are quite easy and packed decimal is no problem.
Do you need more help?
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Sat Mar 24, 2007 6:04 am
Reply with quote

Hello,

Something like:

Code:
OPTION COPY
   OUTFIL REMOVECC,NODETAIL,
      OUTREC=(TOT=(115,6,PD,EDIT=(STTTTTTTTTT.TT),SIGNS=(,-)))         

may get you moving forward. I don't have DFSORT available just now. so i can't run a test to verify that i've not fat-fingered something icon_smile.gif
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: Sat Mar 24, 2007 8:52 pm
Reply with quote

adushkin,

Here's a DFSORT job that will do what you asked for. I assumed that your starting position of 115 included the RDW in positions 1-4. If not, change 115 to 119 to account for the RDW. If the format of the total is not what you want, you can change the edit mask accordingly.

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file (VB)
//SORTOUT DD DSN=...  output file (VB)
//SYSIN    DD    *
  OPTION COPY
  OUTFIL REMOVECC,NODETAIL,
    TRAILER1=('TOTAL: ',
              TOT=(115,6,PD,EDIT=(SIIIIIIIIIT.TT),SIGNS=(,-)))
/*
Back to top
View user's profile Send private message
adushkin

New User


Joined: 02 Jun 2006
Posts: 6

PostPosted: Tue Mar 27, 2007 2:27 am
Reply with quote

Thank you Frank,
I need something else.


The following JCL is working for one field A and no header, now I need to add field B to get sub-total and add header.
If is possible please help me
Code:
//STEP2    EXEC SORT,REGION=32M                       
//SYSOUT    DD SYSOUT=*                               
//SORTIN    DD DSN=input file,
//          DISP=SHR                                 
//SORTOUT   DD DSN=output file,       
//             DISP=(NEW,CATLG,KEEP),                 
//             SPACE=(CYL,(99,99),RLSE),             
//             VOL=SER=PROD01,                       
//             UNIT=SYSDA 
//SYSIN DD *                           
 SORT FIELDS=(85,14,CH,A,76,9,CH,A)                             
  OUTFIL REMOVECC,NODETAIL,                                     
  SECTIONS=(85,14,                                             
    TRAILER3=(85,14,                                           
              TOT=(115,6,PD,EDIT=(SIIIIIIIIIT.TT),SIGNS=(,-)))),
    TRAILER1=('TOTAL:        ',                                 
              TOT=(115,6,PD,EDIT=(SIIIIIIIIIT.TT),SIGNS=(,-))) 

Input:
Field A pos 85:14
Field B pos 76:9
Field C pos 115:6 (com-3)

output
Output:
Field A Field B Field C
----+----1----+----2----+----3----+----4
***************************** Top of Dat
HEADER 1 HEADER 2 AMOUNT
-------------- -------- -----------
YYY NNNNNNN703 00AAAAAAA 0.46
YYY NNNNNNN703 00BBBBBBB -0.14
YYY NNNNNNN703 00CCCCCCC 0.00
Sub total: 0.32
YYY PPPPPPP703 00AAAAAAA -1310.78
Sub total: -1310.78
YYY RRRRRRR701 00AAAAAAA -1940.00
YYY RRRRRRR701 00BBBBBBB -0.66
Sub total: -1940.66
TOTAL: -3251.12
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 Mar 27, 2007 4:30 am
Reply with quote

Here's a DFSORT job that will do what you asked for:

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file (VB)
//SORTOUT DD DSN=...  output file (VB)
//SYSIN    DD    *
  SORT FIELDS=(85,14,CH,A,76,9,CH,A)
  OUTFIL REMOVECC,
    BUILD=(1,4,5:85,14,20:76,9,
      32:115,6,PD,EDIT=(SIIIIIIIIIT.TT),SIGNS=(,-)),
    HEADER2=('HEADER 1',16:'HEADER 2',28:'AMOUNT',/,
            14'-',16:9'-',28:14'-'),
    SECTIONS=(85,14,
      TRAILER3=('Sub total:',
        28:TOT=(115,6,PD,EDIT=(SIIIIIIIIIT.TT),SIGNS=(,-)))),
      TRAILER1=('Total:        ',
        28:TOT=(115,6,PD,EDIT=(SIIIIIIIIIT.TT),SIGNS=(,-)))
/*


SORTOUT will be a VB file with:

Code:

HEADER 1       HEADER 2    AMOUNT           
-------------- ---------   --------------   
YYY NNNNNNN703 00AAAAAAA             0.46   
YYY NNNNNNN703 00BBBBBBB            -0.14   
YYY NNNNNNN703 00CCCCCCC             0.00   
Sub total:                           0.32   
YYY PPPPPPP703 00AAAAAAA         -1310.78   
Sub total:                       -1310.78   
YYY RRRRRRR701 00AAAAAAA         -1940.00   
YYY RRRRRRR701 00BBBBBBB            -0.66   
Sub total:                       -1940.66   
Total:                           -3251.12   
Back to top
View user's profile Send private message
adushkin

New User


Joined: 02 Jun 2006
Posts: 6

PostPosted: Wed Mar 28, 2007 3:11 am
Reply with quote

Thank you Frank for all that you do!!!
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 Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
Search our Forums:

Back to Top