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

Expand a numeric range


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

New User


Joined: 16 Sep 2015
Posts: 1
Location: Brazil

PostPosted: Fri Sep 18, 2015 6:27 pm
Reply with quote

Hi, idk if its possible:

I have a file with a numeric range and want to expand it.
Preferable using SORT only (if its possible)
Something like:

Input -----------------

00000000 00000003
00011001 00011050

Expected Output ----

00000000
00000001
00000002
00000003
00011001
00011002
...
00011050

Any ideas ?
Thnx in Advance
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: Fri Sep 18, 2015 7:46 pm
Reply with quote

You could, in one step, generate all the possible numbers.

In a second step, use RESIZE to split your records with a first/last marker.

In a third step, use JOINKEYS to match the files, with UNPAIRED,F1 (the generated numbers file).

In the main task, use WHEN=GROUP to define a group which starts at the first and ends at the last, PUSHing the marker to each record.

Use OUTFIL INCLUDE= to extract those that have been marked.

Whether it would be worth doing that rather than doing something simple in another language is up to you.

This also assumes that ranges don't cross.
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


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

PostPosted: Fri Sep 18, 2015 9:01 pm
Reply with quote

I don't know much sort tricks but I have something similar saved in my local PDS, see if this helps and I am sure Bill or others or yourself can help and suggest to what you want.

This will generate the numbers based on value in 12th position.

Code:
//STEP010  EXEC PGM=SORT                                         
//SYSOUT   DD SYSOUT=*                                           
//SORTIN   DD *                                                 
000001     99                                                   
//SORTOUT   DD  DSN=&&T1,DISP=(NEW,PASS),UNIT=SYSDA             
//SYSIN  DD *                                                   
 OPTION COPY                                                     
 OUTFIL REPEAT=99,OVERLAY=(81:12,2,12:SEQNUM,2,ZD,RESTART=(1,11))
//STEP020  EXEC PGM=SORT                                         
//SYSOUT   DD SYSOUT=*                                           
//SORTIN   DD DSN=&&T1,DISP=(OLD,DELETE)                         
//SORTOUT  DD SYSOUT=*                                           
//SYSIN  DD *                                                   
 OPTION COPY                                                     
 INCLUDE COND=(12,2,ZD,LE,81,2,ZD)                               
 OUTREC BUILD=(12,2)                                             
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: Fri Sep 18, 2015 10:50 pm
Reply with quote

To get the range:

Code:
 INCLUDE COND=(12,2,ZD,LE,81,2,ZD,
           AND,12,2,ZD,GE,5,2,ZD)


My concern is that TS/OP shows eight-digt numbers, potentially just shy of 100m generated per pair (if the full value of the eight digits is needed). It would however readily work for overlapping ranges.

A single repeat to get sequence numbers, and generate the INCLUDE COND= (need a sequence to identify formatting for the first, subsequent and a "dummy" condition in TRAILER1 to finish with.

However, won't allow for overlapping ranges.

So, are overlapping ranges possible? Maximum value possible is?
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


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

PostPosted: Sat Sep 19, 2015 1:42 am
Reply with quote

ftp.software.ibm.com/storage/dfsort/mvs/sortpaug.pdf

Code:
REPEAT=n specifies the number of times each OUTFIL output record is to be repeated. The value for n starts at
2 (write record twice) and is limited to 28 digits (15 significant digits).


I tried for 1-99999999 range and it worked.
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


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

PostPosted: Sat Sep 19, 2015 3:42 am
Reply with quote

Bill, You are right, it does overlap after certain significant digit. I have tried up to 3 repeat it works and then it overlaps.
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 To get the count of rows for every 1 ... DB2 3
No new posts Generate random number from range of ... COBOL Programming 3
No new posts REXX code to expand copybook in a cob... CLIST & REXX 2
No new posts Convert HEX to Numeric DB2 3
No new posts Finding faulty logic Subscript out of... COBOL Programming 5
Search our Forums:

Back to Top