Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Sort numeric fields with trailing spaces

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> SYNCSORT
View previous topic :: :: View next topic  
Author Message
sancraig16

New User


Joined: 27 Mar 2018
Posts: 22
Location: usa

PostPosted: Tue Apr 03, 2018 1:21 am    Post subject: Sort numeric fields with trailing spaces
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: 1619
Location: Oregon

PostPosted: Tue Apr 03, 2018 2:17 am    Post subject:
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

Active User


Joined: 29 Apr 2008
Posts: 365
Location: Maryland

PostPosted: Tue Apr 03, 2018 2:58 am    Post subject:
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: 22
Location: usa

PostPosted: Tue Apr 03, 2018 3:31 am    Post subject:
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

Active User


Joined: 29 Apr 2008
Posts: 365
Location: Maryland

PostPosted: Tue Apr 03, 2018 7:57 am    Post subject:
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: 2409
Location: @my desk

PostPosted: Tue Apr 03, 2018 6:38 pm    Post subject: Reply to: Sort numeric fields with trailing spaces
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

Senior Member


Joined: 21 Sep 2010
Posts: 2031
Location: NY,USA

PostPosted: Tue Apr 03, 2018 10:12 pm    Post subject:
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: 2409
Location: @my desk

PostPosted: Tue Apr 03, 2018 10:51 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> SYNCSORT All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Need help on the multiple files refor... wik123 DFSORT/ICETOOL 7 Wed Sep 19, 2018 10:47 am
No new posts Remove selected duplicate rows from t... hnharish DFSORT/ICETOOL 3 Wed Sep 05, 2018 3:11 am
No new posts Sort card to find duplicates, without... anand1204 DFSORT/ICETOOL 15 Fri Aug 31, 2018 12:13 am
This topic is locked: you cannot edit posts or make replies. remove the gap b/w 2 fields shymala COBOL Programming 5 Thu Aug 02, 2018 12:05 pm
No new posts How to remove spaces between variable... Selvarajars DFSORT/ICETOOL 7 Fri Jul 27, 2018 3:58 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us