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 add amount field with '-' in flat file

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: How to add amount field with '-' in flat file
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: 2150
Location: At my coffee table

PostPosted: Mon May 31, 2010 6:24 pm    Post subject:
Reply with quote

Have you looked at SFF?
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: Tue Jun 01, 2010 11:05 pm    Post subject:
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    Post subject:
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: 8593
Location: Back in jolly old England

PostPosted: Wed Jun 02, 2010 1:43 pm    Post subject:
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    Post subject:
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 Moderator


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

PostPosted: Wed Jun 02, 2010 10:21 pm    Post subject:
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    Post subject:
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 Moderator


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

PostPosted: Thu Jun 03, 2010 12:57 am    Post subject:
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    Post subject:
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 Moderator


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

PostPosted: Thu Jun 03, 2010 1:10 am    Post subject:
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:

http://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    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 Changing of LRECL of a file abdulrafi DFSORT/ICETOOL 2 Fri Mar 24, 2017 3:25 pm
No new posts splitting a file abdulrafi DFSORT/ICETOOL 4 Fri Mar 24, 2017 11:51 am
No new posts Receive a file using PCOMM macro Harald.v.K IBM Tools 0 Thu Mar 23, 2017 6:50 pm
No new posts Export flat file data into excel sheet murali.andaluri DFSORT/ICETOOL 2 Mon Mar 20, 2017 5:39 pm
No new posts Formatting VB File Learncoholic DFSORT/ICETOOL 3 Mon Mar 20, 2017 12:29 pm


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