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

Sort numeric fields with trailing spaces


IBM Mainframe Forums -> SYNCSORT
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
sancraig16

New User


Joined: 27 Mar 2018
Posts: 26
Location: usa

PostPosted: Tue Apr 03, 2018 1:21 am
Reply with quote

Hi ,

Trying to SORT a file with input as given below

SORT :

SORT FIELDS=(1,2,ZD,A)

Input :

18
6
15
31
27
6
37
38
23
28
35
33
15
26
38
38
37
38
37

Output:

15
15
18
23
26
27
28
31
33
35
37
37
37
38
38
38
38
6
6

The output is incorrect with 2 rows of 6 at the bottom. The trailing spaces is obviously causing the issue for these records . Any way to overcome this?
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1742
Location: Tirupur, India

PostPosted: Tue Apr 03, 2018 2:17 am
Reply with quote

Try this,
Code:
  INREC OVERLAY=(1:1,2,JFY=(SHIFT=RIGHT)) 
  SORT FIELDS=(1,2,ZD,A)             


You will get leading zeros though in the output
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2010
Location: USA

PostPosted: Tue Apr 03, 2018 2:58 am
Reply with quote

vasanthz wrote:
You will get leading zeros though in the output

Not leading ZEROES, but leading BLANKS.
Blanks would cause sorting format ZD to fail; SORT FIELDS=(1,2,CH,A) is more robust.
Back to top
View user's profile Send private message
sancraig16

New User


Joined: 27 Mar 2018
Posts: 26
Location: usa

PostPosted: Tue Apr 03, 2018 3:31 am
Reply with quote

I did get leading BLANKS and SORT worked. As suggested , I will change the format to CH.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2010
Location: USA

PostPosted: Tue Apr 03, 2018 7:57 am
Reply with quote

sancraig16 wrote:
I did get leading BLANKS and SORT worked. As suggested , I will change the format to CH.

If SORT FIELDS=(...,ZD,...) did not fail with some blanks in the field, that means the sort utility code performed extra check on ZD field before handling it in decimal manner. At the level of machine instructions it might fail with decimal ABEND like S0C7.
SORT FIELDS=(...,CH,...) deals in the same manner as ZD, but CH is also irrelevant to not fully correct ZD values.
This is known as more robust code.
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Tue Apr 03, 2018 6:38 pm
Reply with quote

sancraig16,

You might be able to achieve this without altering the input data by using the UFF format:

UNTESTED:
Code:
 SORT FIELDS=(1,2,UFF,A)
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3048
Location: NYC,USA

PostPosted: Tue Apr 03, 2018 10:12 pm
Reply with quote

UFF will work but if you have -ve values also then UFF won't work you will then need SFF.
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Tue Apr 03, 2018 10:51 pm
Reply with quote

The OPs representative sample does not show any negative symbols in it, so I would leave it to the OP's discretion.
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 -> SYNCSORT

 


Similar Topics
Topic Forum Replies
No new posts JCL sort card - get first day and las... JCL & VSAM 9
No new posts Sort First/last record of a subset th... DFSORT/ICETOOL 7
No new posts how to calculate SUM value for VB fil... DFSORT/ICETOOL 1
No new posts how to calculate SUM for VB file usin... JCL & VSAM 1
No new posts leading spaces can be removed in trai... DFSORT/ICETOOL 1
Search our Forums:

Back to Top