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

Sign Leading Sort


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

New User


Joined: 27 Dec 2006
Posts: 36
Location: Chennai

PostPosted: Wed May 06, 2009 3:12 pm
Reply with quote

Can you anyone help me ti get the output of this code?

Code:
//STEP01    EXEC PGM=SORT
//SYSOUT    DD SYSOUT=*   
//SORTIN    DD *         
+12AA                     
-05AA                     
//SORTOUT   DD SYSOUT=*   
//SYSIN     DD *         
 SORT FIELDS=(4,2,CH,A)   
 SUM FIELDS=(1,3,PD)     
/*


My expected answer is 7.
Which datatype should I have to use in SUMFIELDS???
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Wed May 06, 2009 3:22 pm
Reply with quote

FS (floating sign) format
description, C.1
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed May 06, 2009 3:29 pm
Reply with quote

look thru the DFSORT/ICETOOL threads,
recently Frank provided a solution about SUMming leading signed.[/url]
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: Wed May 06, 2009 9:12 pm
Reply with quote

nagarajan.dharani,

You can't use FS format in SUM. You need to do some conversion. Here's a DFSORT job that will do what you asked for:

Code:

//S1    EXEC  PGM=SORT
//SYSOUT    DD  SYSOUT=*
//SORTIN DD *
+12AA
-05AA
//SORTOUT DD SYSOUT=*
//SYSIN    DD    *
 INREC OVERLAY=(81:1,3,FS,TO=PD,LENGTH=2)
 SORT FIELDS=(4,2,CH,A)
 SUM FIELDS=(81,2,PD)
 OUTREC OVERLAY=(1:81,2,PD,EDIT=(STT),SIGNS=(+,-))
/*
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Wed May 06, 2009 9:12 pm
Reply with quote

nagarajan.dharani,


You opened a similar thread in here

ibmmainframes.com/viewtopic.php?t=40320

why cant you just post in the same topic?


Anyway here are two ways for getting the desired results

Code:

//STEP0100 EXEC PGM=SORT                                     
//SYSOUT   DD SYSOUT=*                                       
//SORTIN   DD *                                             
+12AA                                                       
-05AA                                                       
//SORTOUT  DD SYSOUT=*                                       
//SYSIN    DD *                                             
  SORT FIELDS=(4,2,CH,A),EQUALS                             
  OUTFIL REMOVECC,NODETAIL,                                 
  SECTIONS=(4,2,                                             
  TRAILER3=(1:TOT=(1,3,FS,EDIT=(STT),SIGNS=('+','-')),4,77))
/*   


converting FS to PD format and summing it and converting it back again

Code:
                                                       
//STEP0200 EXEC PGM=SORT                                     
//SYSOUT   DD SYSOUT=*                                       
//SORTIN   DD *                                             
+12AA                                                       
-05AA                                                       
//SORTOUT  DD SYSOUT=*                                       
//SYSIN    DD *                                             
  INREC OVERLAY=(1:1,3,FS,PD,LENGTH=3)                     
  SORT FIELDS=(4,2,CH,A),EQUALS                             
  SUM FIELDS=(1,3,PD)                                       
  OUTREC OVERLAY=(1:1,3,PD,EDIT=(STT),SIGNS=('+','-'))       
/*



Cics guy,

Sign leading numbers(FS) cannot be directly used on SUM statement. You need to convert the FS value to PD/ZD, SUM it and convert it back to FS. However, it might be easier to use OUTFIL SECTIONS/TRAILER3/TOT with FS/SFF instead.
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Wed May 06, 2009 9:19 pm
Reply with quote

Skolusu wrote:
Cics guy,

Sign leading numbers(FS) cannot be directly used on SUM statement. You need to convert the FS value to PD/ZD, SUM it and convert it back to FS. However, it might be easier to use OUTFIL SECTIONS/TRAILER3/TOT with FS/SFF instead.
Understood, thanks.

Both you and Frank posted at the same time, what is this, the battle of the Sort Wizards? icon_lol.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: Wed May 06, 2009 9:28 pm
Reply with quote

Just "parallel" posting. Sometimes we discuss who will answer specific posts and sometimes we don't. I'm working at home today so we're not across the aisle from each other as we usually are at the office.
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 Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts JCL sort card - get first day and las... JCL & VSAM 9
No new posts Sort First/last record of a subset th... DFSORT/ICETOOL 7
No new posts how to calculate SUM value for VB fil... DFSORT/ICETOOL 1
Search our Forums:

Back to Top