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
 

 

Adding negative ZD with DFSORT

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Adding negative ZD with DFSORT
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: 1439
Location: Bangalore,India

PostPosted: Sat Nov 03, 2007 7:56 am    Post subject:
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    Post subject: Reply to: Adding negative ZD with DFSORT
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: 1439
Location: Bangalore,India

PostPosted: Sat Nov 03, 2007 12:46 pm    Post subject:
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    Post subject:
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 Moderator


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

PostPosted: Sat Nov 03, 2007 8:56 pm    Post subject:
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    Post subject: Reply to: Adding negative ZD with DFSORT
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 Moderator


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

PostPosted: Sun Nov 04, 2007 10:12 pm    Post subject:
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    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 How to get the remainder and quotient... vnktrrd DFSORT/ICETOOL 2 Mon Oct 31, 2016 10:59 am
No new posts Adding records from two files into on... shiitiizz SYNCSORT 4 Mon Sep 19, 2016 8:41 pm
No new posts Change date (DD/MM/YY) in 2nd record ... uday kiran DFSORT/ICETOOL 12 Wed Sep 07, 2016 10:57 pm
No new posts DFSORT sorting only specific records akodakka DFSORT/ICETOOL 4 Thu Aug 04, 2016 11:24 am
No new posts Adding a descending character to a file Steve Ironmonger DFSORT/ICETOOL 3 Fri Jul 15, 2016 4:57 pm


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