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

Adding negative ZD with DFSORT


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

New User


Joined: 25 Apr 2006
Posts: 32
Location: India

PostPosted: Sat Nov 03, 2007 7:20 am
Reply with quote

Hi

I am trying to sum fields on ZD and my file has some records with negative values.Looks like DFOSRT is not recogizing the negative sign which adding the amounts.

Code:

//SORT02     EXEC PGM=SORT
//*
//SYSPRINT  DD SYSOUT=*
//SYSOUT    DD SYSOUT=*
//SORTIN    DD *
1  200703   -55246
1  200703   -11516
1  200703   -55165
1  200703 -2715081
1  200703     -964
1  200703-17809223
1  200703       10
2  200703       24
2  200703       20
2  200703       10
/*
//SORTOUT DD SYSOUT=*
//*
//SYSIN      DD *
  SORT FIELDS=(1,1,CH,A)
  OUTREC FIELDS=(1,1,C';',10,9,ZD,EDIT=(STTTTTTTTT),SIGNS=(,-))
  SUM FIELDS=(10,9,ZD)
/*


output

Code:

1; 020647205
2; 000000054


Is there any option in DFSORT to recoginze the sign?

Any hekp is appreciated.

Thanks
Satya
Back to top
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1436
Location: Bangalore,India

PostPosted: Sat Nov 03, 2007 7:56 am
Reply with quote

satya,

Try SFF (Signed free format) in place of ZD.
Back to top
View user's profile Send private message
satya12

New User


Joined: 25 Apr 2006
Posts: 32
Location: India

PostPosted: Sat Nov 03, 2007 10:54 am
Reply with quote

I don't think we can use SFF in sum fields option.

I tried n getting an error message saying invalid format.

I tried another option of conveting ZP to PD and then sum up the PD field.But no luck.
Back to top
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1436
Location: Bangalore,India

PostPosted: Sat Nov 03, 2007 12:46 pm
Reply with quote

Satya,

Quote:
I don't think we can use SFF in sum fields option.

You are correct. Sorry for the wrong suggestion.

Try using TRAILERn with SECTIONS option.
Back to top
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Sat Nov 03, 2007 12:57 pm
Reply with quote

satya12
Look at this example
http://ibmmainframes.com/viewtopic.php?t=25352
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 Nov 03, 2007 8:56 pm
Reply with quote

Satya,

DFSORT recognizes negative signs for ZD values just fine. But your values are NOT ZD values.

A 9-byte negative ZD value would look like this:

X'FdFdFdFdFdFdFdFdDd'

whereas your values have a leading floating sign and leading zeros suppressed. Actually, your values are FS values, not ZD values.

You can't use FS for SUM, but you can do what you want using OUTFIL SECTIONS instead of SUM. Here's a DFSORT job that will do what you want:

Code:

//SORT02     EXEC PGM=SORT
//SYSOUT    DD SYSOUT=*
//SORTIN    DD *
1  200703   -55246
1  200703   -11516
1  200703   -55165
1  200703 -2715081
1  200703     -964
1  200703-17809223
1  200703       10
2  200703       24
2  200703       20
2  200703       10
/*
//SORTOUT DD SYSOUT=*
//SYSIN      DD *
  SORT FIELDS=(1,1,CH,A)
  OUTFIL REMOVECC,NODETAIL,
    BUILD=(12X),
    SECTIONS=(1,1,
     TRAILER3=(1,1,C';',TOT=(10,9,FS,EDIT=(STTTTTTTTT),SIGNS=(,-))))
/*


For your example, SORTOUT will have:

Code:

1;-020647185     
2; 000000054     
Back to top
View user's profile Send private message
satya12

New User


Joined: 25 Apr 2006
Posts: 32
Location: India

PostPosted: Sun Nov 04, 2007 1:46 am
Reply with quote

Yup

Both SFF and FS worked when i tried them in the trailer section with TOT option.

Thanks a lot guys

Have a greta weekend.
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: Sun Nov 04, 2007 10:12 pm
Reply with quote

Yes, both work, but less processing is required for FS than SFF, so in general FS is more efficient than SFF. FS is the better choice for values like

-123456789

whereas SFF is required for values like

-1,234,567.89

for which FS cannot be used.
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 Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts Adding QMF and SPUFI to the ISPF menu DB2 20
No new posts DFsort help with SUM() DFSORT/ICETOOL 12
Search our Forums:

Back to Top