View previous topic :: View next topic
Author
Message
useit Active User Joined: 05 Oct 2006Posts: 152
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
Bill Woodger Moderator Emeritus Joined: 09 Mar 2011Posts: 7309 Location: Inside the Matrix
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
useit Active User Joined: 05 Oct 2006Posts: 152
bill,
i want this to start from 7th position in the output file.
plzzz help me in this regard
Regds,
useit
Back to top
Bill Woodger Moderator Emeritus Joined: 09 Mar 2011Posts: 7309 Location: Inside the Matrix
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
gylbharat Active Member Joined: 31 Jul 2009Posts: 565 Location: Bangalore
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
vasanthz Global Moderator Joined: 28 Aug 2007Posts: 1742 Location: Tirupur, India
Gylbharat,
For input data which has a single digit subtraction result, the output of the above job would not start from 7th position.
input:
output:
Back to top
vasanthz Global Moderator Joined: 28 Aug 2007Posts: 1742 Location: Tirupur, India
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 correct ion
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
gylbharat Active Member Joined: 31 Jul 2009Posts: 565 Location: Bangalore
Thanks Vasanthz...
Back to top
Bill Woodger Moderator Emeritus Joined: 09 Mar 2011Posts: 7309 Location: Inside the Matrix
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
kratos86 Active User Joined: 17 Mar 2008Posts: 148 Location: Anna NGR
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
Skolusu Senior Member Joined: 07 Dec 2007Posts: 2205 Location: San Jose
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
kratos86 Active User Joined: 17 Mar 2008Posts: 148 Location: Anna NGR
Quote:
Kratos86, gylbharat please do not complicate a simple request.
I should have given a thought of using edit mask effectively
Back to top
Please enable JavaScript!