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

Getting spaces in between while doing arithmatic operation


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

Active User


Joined: 05 Oct 2006
Posts: 152

PostPosted: Wed Sep 28, 2011 4:31 pm
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Sep 28, 2011 4:50 pm
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: 152

PostPosted: Wed Sep 28, 2011 4:59 pm
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Sep 28, 2011 5:08 pm
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
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: 1742
Location: Tirupur, India

PostPosted: Wed Sep 28, 2011 5:44 pm
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: 1742
Location: Tirupur, India

PostPosted: Wed Sep 28, 2011 6:01 pm
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
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
Reply with quote

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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Sep 28, 2011 6:27 pm
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
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts leading spaces can be removed in trai... DFSORT/ICETOOL 1
No new posts Cobol program with sequence number ra... COBOL Programming 5
No new posts To Remove spaces (which is in hex for... JCL & VSAM 10
No new posts How to remove spaces in between. SYNCSORT 12
No new posts File transfer from host with filler f... TSO/ISPF 15
Search our Forums:

Back to Top