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
 

 

Getting spaces in between while doing arithmatic operation

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
useit

Active User


Joined: 05 Oct 2006
Posts: 141

PostPosted: Wed Sep 28, 2011 4:31 pm    Post subject: Getting spaces in between while doing arithmatic operation
Reply with quote

when i run the below jcl.

Code:
//STEP0100 EXEC PGM=SORT                           
//SYSOUT   DD SYSOUT=*                             
//SORTIN   DD *                                     
STORE1X90201020                                     
STORE2X80600505                                     
STORE3X90902515                                     
/*                                                 
//SORTOUT  DD SYSOUT=*                             
//SYSIN    DD *                                     
  SORT FIELDS=COPY                                 
  OUTREC FIELDS=(1,6,8,2,ZD,SUB,12,2,ZD,SUB,14,2,ZD)
/*


subtracted value is written after 13th spaces. could you please tel me the reason and the way to avoid it?

output:

Code:
*********************
STORE1             60
STORE2             70
STORE3             50


Regds,
useit
Back to top
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7230

PostPosted: Wed Sep 28, 2011 4:50 pm    Post subject: Re: Getting spaces in between while doing arithmatic operati
Reply with quote

Please use the code tags for your sample data.

Without specifying anything to the contrary, you are getting the default which is a 15-digit number, and it looks like you get zero-suppression thrown in.

To put it another way, you have forgotten to tell the sort how big you want the result to be, and what you want it to look like, and perhaps even where you want it to start.
Back to top
View user's profile Send private message
useit

Active User


Joined: 05 Oct 2006
Posts: 141

PostPosted: Wed Sep 28, 2011 4:59 pm    Post subject:
Reply with quote

bill,

i want this to start from 7th position in the output file.
plzzz help me in this regard

Regds,
useit
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7230

PostPosted: Wed Sep 28, 2011 5:08 pm    Post subject:
Reply with quote

There are many examples of how to do this available in this forum. I have already spent two minutes doing your work (I looked in the manual, link at the top of the page), for free, to find the answer. If you want the next two minutes for more of your work, I'm afraid it is an hourly charge :-)

Really, you'll learn more if you do the next bit yourself. Might take you longer than two minutes, but the investment of your time will be worth it for your future work.
Back to top
View user's profile Send private message
gylbharat

Active Member


Joined: 31 Jul 2009
Posts: 565
Location: Bangalore

PostPosted: Wed Sep 28, 2011 5:14 pm    Post subject:
Reply with quote

Code:

//STEP0100 EXEC PGM=SORT                               
//SYSOUT   DD SYSOUT=*                                 
//SORTIN   DD *                                       
STORE1X90201020                                       
STORE2X80600505                                       
STORE3X90902515                                       
/*                                                     
//SORTOUT  DD SYSOUT=*                                 
//SYSIN    DD *                                       
  SORT FIELDS=COPY                                     
  INREC FIELDS=(1,6,8,2,ZD,SUB,12,2,ZD,SUB,14,2,ZD)   
  OUTREC FIELDS=(1,6,20,2)                             
/*                                                     
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1445
Location: Azeroth

PostPosted: Wed Sep 28, 2011 5:44 pm    Post subject:
Reply with quote

Gylbharat,
For input data which has a single digit subtraction result, the output of the above job would not start from 7th position.
input:
Code:
STORE1X90208005

output:
Code:
STORE1 5
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1445
Location: Azeroth

PostPosted: Wed Sep 28, 2011 6:01 pm    Post subject:
Reply with quote

Code:
 INREC BUILD=(1,6,8,2,ZD,SUB,12,2,ZD,SUB,14,2,ZD,EDIT=(TT))

would work,
provided that
the subtraction would not result in a negative number.
If there is a negative result, it would still be represented as positive number.
If there is a negative number and exceeds 2 digits, then only last 2 digits would be displayed.

Im open to correction

Link to edit numeric fields
http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/ice1cg20/2.4.8?ACTION=MATCHES&REQUEST=edit,ttttt&TYPE=FUZZY&SHELF=ICE1SH20.bks&DT=20060615173822&CASE=&searchTopic=TOPIC&searchText=TEXT&searchIndex=INDEX&rank=RANK&ScrollTOP=FIRSTHIT#FIRSTHIT
Back to top
View user's profile Send private message
gylbharat

Active Member


Joined: 31 Jul 2009
Posts: 565
Location: Bangalore

PostPosted: Wed Sep 28, 2011 6:03 pm    Post subject:
Reply with quote

Thanks Vasanthz...
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7230

PostPosted: Wed Sep 28, 2011 6:27 pm    Post subject: Reply to: Getting spaces in between while doing arithmatic o
Reply with quote

More like what I was expecting Vasanthz, not unworkable ghybharat, you can still do an edit, can't you?

Ah. Thin soup and a dry crust for lunch then :-)
Back to top
View user's profile Send private message
kratos86

Active User


Joined: 17 Mar 2008
Posts: 148
Location: Anna NGR

PostPosted: Wed Sep 28, 2011 6:53 pm    Post subject:
Reply with quote

We can also do this way, where negative values would be displayed as well.

Code:
SORT FIELDS=COPY                                           
INREC  FIELDS=(1,6,8,2,ZD,SUB,12,2,ZD,SUB,14,2,ZD)         
OUTREC FIELDS=(1,6,X,7,16,JFY=(SHIFT=LEFT))               
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Wed Sep 28, 2011 9:35 pm    Post subject:
Reply with quote

M0 (IIIIIIIIIIIIIIIIIIIIIIIIIIIIIITS) is the default edit mask when you don't specify the output format from arithmetic operations.

Kratos86, gylbharat please do not complicate a simple request.

IF OP wants the output to be restricted to 2 bytes then he will have a problem

ex: 10 - 99 - 99 = -188 how are you going to fit 3 bytes in a 2 byte field?

Zd field has the sign overpunch in the last byte

Code:

{ABCDEFGHI}JKLMNOPQR
CCCCCCCCCCDDDDDDDDDD
01234567890123456789


Hex C0 thru C9 are positive numbers and D0 thru D9 are negative numbers.

The following DFSORT JCL will give you the desired results

Code:

//STEP0100 EXEC PGM=SORT                                       
//SYSOUT   DD SYSOUT=*                                         
//SORTIN   DD *                                               
----+----1----+----2----+----3----+----4----+----5----+----6---
STORE1X90201020                                               
STORE2X80600505                                               
STORE3X90902515                                               
STORE4X10902515                                               
STORE5X10909999                                               
//SORTOUT  DD SYSOUT=*                                         
//SYSIN    DD *                                               
  SORT FIELDS=COPY                                             
  OUTREC BUILD=(1,6,8,2,ZD,SUB,12,2,ZD,SUB,14,2,ZD,ZD,LENGTH=3)
//*


The output of this is
Code:

STORE1060
STORE2070
STORE3050
STORE403}
STORE518Q


Note the last 2 values are negative numbers. However if you do want the readable format with + and - signs then you need 4 bytes.

The following example shows with leading zeroes suppressed.

Code:

//STEP0100 EXEC PGM=SORT                                               
//SYSOUT   DD SYSOUT=*                                                 
//SORTIN   DD *                                                       
STORE1X90201020                                                       
STORE2X80600505                                                       
STORE3X90902515                                                       
STORE4X10902515                                                       
STORE5X10909999                                                       
//SORTOUT  DD SYSOUT=*                                                 
//SYSIN    DD *                                                       
  SORT FIELDS=COPY                                                     
  OUTREC BUILD=(1,6,                                                   
               8,2,ZD,SUB,12,2,ZD,SUB,14,2,ZD,EDIT=(SIIT),SIGNS=(+,-))
//*


The output is
Code:

STORE1 +60
STORE2 +70
STORE3 +50
STORE4 -30
STORE5-188


If you want the leading zeroes then change the edit mask
Code:

//STEP0100 EXEC PGM=SORT                                             
//SYSOUT   DD SYSOUT=*                                               
//SORTIN   DD *                                                       
STORE1X90201020                                                       
STORE2X80600505                                                       
STORE3X90902515                                                       
STORE4X10902515                                                       
STORE5X10909999                                                       
//SORTOUT  DD SYSOUT=*                                               
//SYSIN    DD *                                                       
  SORT FIELDS=COPY                                                   
  OUTREC BUILD=(1,6,                                                 
               8,2,ZD,SUB,12,2,ZD,SUB,14,2,ZD,EDIT=(STTT),SIGNS=(+,-))
//*



The output is
Code:

STORE1+060
STORE2+070
STORE3+050
STORE4-030
STORE5-188
Back to top
View user's profile Send private message
kratos86

Active User


Joined: 17 Mar 2008
Posts: 148
Location: Anna NGR

PostPosted: Thu Sep 29, 2011 10:07 am    Post subject:
Reply with quote

Quote:
Kratos86, gylbharat please do not complicate a simple request.
I should have given a thought of using edit mask effectively icon_redface.gif
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 Joinkeys operation when key1 and key2... Susanta DFSORT/ICETOOL 5 Wed Nov 02, 2016 5:35 pm
No new posts To trim spaces in a pipe delimited da... Nish84 COBOL Programming 16 Mon Oct 10, 2016 1:54 pm
No new posts Joinkeys operation betwen VB and FB file Susanta SYNCSORT 4 Sun Sep 25, 2016 9:49 pm
No new posts Removing Extra Spaces in a comma sepa... Puspojit DFSORT/ICETOOL 3 Tue Sep 13, 2016 7:46 am
No new posts Remove intermediate spaces Pallavi Vishwanath SYNCSORT 1 Fri Jan 15, 2016 2:45 am


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