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
 

 

How to Sum an editable field using sort

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
View previous topic :: :: View next topic  
Author Message
Abi

New User


Joined: 27 Jul 2005
Posts: 35
Location: Chennai

PostPosted: Tue Mar 30, 2010 4:50 pm    Post subject: How to Sum an editable field using sort
Reply with quote

Hi,
I have a file in which i have policy number and premium amount .
Layout is
Policy numebr x(08)
Sign byte x(01)
Premium 9(6)V99

I/p file
P1234568+00036039
P1234568-00024733
P1234569+00036039
P1234569+00036039
P1234578+00036039
P1234578-00054733

i should get the o/p file in this format
P1234568+00011306
P1234569+00072078
P1234578-00018694

While adding the sum,i need to take the sign into consideration.
Back to top
View user's profile Send private message

anshul_gugnani

New User


Joined: 02 Nov 2009
Posts: 73
Location: Mumbai

PostPosted: Tue Mar 30, 2010 6:13 pm    Post subject:
Reply with quote

Hi,

The below sort card might will help you -
Code:

//STEP110  EXEC PGM=SORT                               
//SORTIN   DD  DSN=[b]Input File[/b],               
//             DISP=SHR                                 
//SORTOUT  DD  DSN=[b][i]Output File[/i][/b],           
//             DISP=(NEW,CATLG,DELETE),                 
//             DCB=AMX.MODLDSCB,                       
//             RECFM=FB,                               
//             LRECL=17,                               
//             UNIT=SYSDA,                             
//             DATACLAS=HUGE                           
//*                                                     
//SYSIN    DD  *   
 INREC FIELDS=(01,17,09,09,FS,PD,LENGTH=6)                           
 SORT FIELDS=(01,08,CH,A)                                           
 SUM FIELDS=(18,06,PD)                                               
 OUTREC FIELDS=(01,08,18,06,PD,EDIT=(STTTTTTTT),SIGNS=(+,-)),CONVERT
//*                     
//SYSOUT   DD  SYSOUT=*
//SYSPRINT DD  SYSOUT=*
//SYSUDUMP DD  SYSOUT=*


Hope this helps.

Thanks. icon_biggrin.gif
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Tue Mar 30, 2010 9:02 pm    Post subject:
Reply with quote

Hi Abi,

You could also use:
Code:
//SYSIN DD *                                             
  OPTION EQUALS                                         
  SORT FIELDS=(1,8,CH,A)                                 
  OUTFIL REMOVECC,NODETAIL,                             
    SECTIONS=(1,8,                                       
      TRAILER3=(1,8,                                     
        TOT=(9,10,SFF,EDIT=(STTTTTTTT),SIGNS=(+,-))))   
/*                                                       
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Tue Mar 30, 2010 9:11 pm    Post subject:
Reply with quote

Anshul - for a sort job, you dont really need the folloing parameters for the SORTOUT:
Code:
//             DCB=AMX.MODLDSCB,                       
//             LRECL=17,                               
//             DATACLAS=HUGE
And "DCB=AMX.MODLDSCB" is local to your shop and has no meaning on other shops. Additionally, it looks like a Model DSCB, which is really not required for a QSAM-file for sure.

Also, you don't need
Code:
//SYSPRINT DD  SYSOUT=*
//SYSUDUMP DD  SYSOUT=*
for sort products (at least for DFSort and SyncSort).
Back to top
View user's profile Send private message
anshul_gugnani

New User


Joined: 02 Nov 2009
Posts: 73
Location: Mumbai

PostPosted: Tue Mar 30, 2010 11:18 pm    Post subject:
Reply with quote

Hi Anuj,

Thanks for info.
Nevertheless, The sort card I posted will work fine. icon_smile.gif

Thanks.
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Wed Mar 31, 2010 4:28 pm    Post subject:
Reply with quote

You're welcome icon_smile.gif.
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 -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Innovations in Your Mainframe Sort Arun Raj PC Guides & IT News 4 Wed Mar 15, 2017 10:38 pm
No new posts SORT VSAM file with each field one by... maxsubrat DFSORT/ICETOOL 6 Tue Mar 14, 2017 1:07 pm
No new posts SORT requirement sjiraga COBOL Programming 6 Thu Mar 09, 2017 9:11 pm
No new posts IMS DB-How to update a record (a sing... Nic Clouston IMS DB/DC 9 Thu Mar 09, 2017 4:38 pm
No new posts SORT to append Month and YEAR in MMYY... tisamf DFSORT/ICETOOL 1 Wed Mar 08, 2017 4:46 pm


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