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
 

 

SUM COMP-3 fields VB file

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: SUM COMP-3 fields VB file
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

Site Director


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

PostPosted: Sat Mar 24, 2007 3:34 am    Post subject:
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    Post subject:
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: 3158
Location: Tucson AZ

PostPosted: Sat Mar 24, 2007 5:49 am    Post subject:
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

Site Director


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

PostPosted: Sat Mar 24, 2007 6:04 am    Post subject:
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 Moderator


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

PostPosted: Sat Mar 24, 2007 8:52 pm    Post subject:
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    Post subject:
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 Moderator


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

PostPosted: Tue Mar 27, 2007 4:30 am    Post subject:
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    Post subject:
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    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 SYNCSORT SEQNUM and FI fields. nartcr SYNCSORT 5 Sat Jan 21, 2017 4:02 am
No new posts SORTJOIN - Copy Matched and Unmatched... Steve Ironmonger DFSORT/ICETOOL 5 Tue Jan 17, 2017 4:26 pm
No new posts Syncsort Help to group fields sudhakarraju SYNCSORT 6 Thu Dec 29, 2016 1:38 am
No new posts Copy RECFM =VB TO FB file with RECL =... sahil41352 DFSORT/ICETOOL 3 Wed Dec 28, 2016 11:29 pm
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm


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