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

How to add amount field with '-' in flat file


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

New User


Joined: 29 May 2009
Posts: 3
Location: hyderabad

PostPosted: Mon May 31, 2010 5:50 pm
Reply with quote

hi,

I have a flat file in whice amount filed id there. in amount field it have '-' sign.
ex:

-.1.20
-22.56
-123.11
-0.12
12.23
123.23

How can I get the addition of this all the amounts.
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: Mon May 31, 2010 6:24 pm
Reply with quote

Have you looked at SFF?
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: Tue Jun 01, 2010 11:05 pm
Reply with quote

You can use a DFSORT job like the following to do what you asked for:

Code:

//S1 EXEC PGM=SORT                                         
//SYSOUT DD SYSOUT=*                                       
//SORTIN DD *                                             
  -1.20                                                   
 -22.56                                                   
-123.11                                                   
  -0.12                                                   
  12.23                                                   
123.23                                                     
/*
//SORTOUT DD SYSOUT=*                                     
//SYSIN DD *                                               
  OPTION COPY                                             
  OUTFIL REMOVECC,NODETAIL,                               
    TRAILER1=(TOT=(1,7,SFF,EDIT=(SIIIT.TT),SIGNS=(,-)))   
/*
Back to top
View user's profile Send private message
anshul_gugnani

New User


Joined: 02 Nov 2009
Posts: 73
Location: Mumbai

PostPosted: Wed Jun 02, 2010 1:11 pm
Reply with quote

Hello Frank,

I tried to test the above sort card as
Code:

//STEP010 EXEC PGM=SORT                               
//*                                                   
//SYSOUT  DD SYSOUT=*                                 
//*                                                   
//SORTIN DD *                                         
-10.00                                                 
20.00                                                 
-30.00                                                 
10.00                                                 
//SORTOUT DD SYSOUT=*                                 
//SYSIN DD *                                           
   OPTION COPY                                         
   OUTFIL REMOVECC, NODETAIL                           
   TRAILER1=(TOT=(1,6,SFF,EDIT=(SIIT.TT),SIGNS=(-,+)))
//*                                                   


The result I got is +10.00

However, I think it should be -10.00.

Can you please guide where am I going wrong?

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

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Wed Jun 02, 2010 1:43 pm
Reply with quote

Look very very carefully at the code that you have used and the code supplied by Frank. Especially SIGNS=

I have tried Franks code with your data and get the expected result.
Back to top
View user's profile Send private message
anshul_gugnani

New User


Joined: 02 Nov 2009
Posts: 73
Location: Mumbai

PostPosted: Wed Jun 02, 2010 2:18 pm
Reply with quote

Thanks Expat for correcting me.
Got the correct result.
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 Jun 02, 2010 10:21 pm
Reply with quote

To clarify:

Quote:

The result I got is +10.00

However, I think it should be -10.00.

Can you please guide where am I going wrong?


SIGNS=(,-)

indicates a blank for the leading positive sign and a - for the leading negative sign.

SIGNS=(-,+)

indicates a - for the leading positive sign and a + for the leading negative sign - certainly NOT what you want.

SIGNS=(+,-)

indicates a + for the leading positive sign and a - for the leading negative sign - perhaps that's what you want?
Back to top
View user's profile Send private message
anshul_gugnani

New User


Joined: 02 Nov 2009
Posts: 73
Location: Mumbai

PostPosted: Thu Jun 03, 2010 12:11 am
Reply with quote

Hello Frank,

Didnt knew that first symbol will be considered for the positive and next for the negetive.

Thanks a ton for the information. icon_smile.gif

Thanks,
Anshul.
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: Thu Jun 03, 2010 12:57 am
Reply with quote

Yes, the complete syntax for SIGNS is like this:

SIGNS=(lp,ln,tp,tn)

lp = leading positive sign
ln = leading negative sign
tp = trailing positive sign
tn = trailing negative sign

A "silly" example:

EDITS=(STTTS),SIGNS=(+,-,+,-)

If you leave out a sign, a blank is used, for example:

SIGNS=(,-)
Back to top
View user's profile Send private message
anshul_gugnani

New User


Joined: 02 Nov 2009
Posts: 73
Location: Mumbai

PostPosted: Thu Jun 03, 2010 1:04 am
Reply with quote

Hi Frank,

Thanks a lot. This helps a lot.
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: Thu Jun 03, 2010 1:10 am
Reply with quote

Glad I could help.

If you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from:

www.ibm.com/support/docview.wss?rs=114&uid=isg3T7000080
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 Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
Search our Forums:

Back to Top