Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Trying to assign a variable input a numerical 'label'

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
HammerTime

New User


Joined: 26 Sep 2012
Posts: 14
Location: UK

PostPosted: Fri Feb 07, 2014 1:47 am    Post subject: Trying to assign a variable input a numerical 'label'
Reply with quote

Hi all, i'm pulling my hair out with what I can only imagine is a simple bit of logic!

I have an input which looks something like this:
Code:

1234567890
----------
A   CODE1
A   CODE4
B   CODE3
B   CODE9
B   CODEX
C   CODEEE


I'm trying to achieve an output where each unique value in pos 1 is replaced with it's own unique sequence number like so:
Code:

1234567890
----------
01  CODE1
01  CODE4
02  CODE3
02  CODE9
02  CODEX
03  CODEEE


The reason I'm struggling here is that the values I have provided in my example of A/B/C are very variable inputs (hundreds of possibilities here), so I can't just use a simple replace. What that incoming value is, is not important. What is important is that I have a 'sequence number' (or incremental numerical label starting at 1), which increments whenever the value in pos 1 changes.

I tried using SEQNUM, with a RESTART on the value in pos 1, but that gave me the following, quickly followed with me slapping my head when I realised I was asking the impossible of good old RESTART :
Code:

1234567890
----------
01  CODE1
02  CODE4
01  CODE3
02  CODE9
03  CODEX
01  CODEEE


Can anyone point me in the direction of an alternative approach with DFSORT (or even ICETOOL - i'm not a fussy man icon_biggrin.gif ) which will give me the results i'm after.

Thanks in advance.
Back to top
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7225

PostPosted: Fri Feb 07, 2014 2:43 am    Post subject: Reply to: Trying to assign a variable input a numerical 'lab
Reply with quote

Instead of the SEQNUM with RESTART, use IFTHEN=(WHEN=GROUP( with PUSH=(col:ID=2).
Back to top
View user's profile Send private message
HammerTime

New User


Joined: 26 Sep 2012
Posts: 14
Location: UK

PostPosted: Fri Feb 07, 2014 3:03 am    Post subject:
Reply with quote

Thanks Bill, I'll give that a go in the morning. I've been using DFSORT for years, but only very recently discovered SEQNUM, and I've never seen the GROUP function.

Every day is a school day!

Will report back tomorrow.
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Fri Feb 07, 2014 5:20 am    Post subject: Re: Trying to assign a variable input a numerical 'label'
Reply with quote

HammerTime wrote:
Hi all, i'm pulling my hair out with what I can only imagine is a simple bit of logic!

I have an input which looks something like this:
Code:

1234567890
----------
A   CODE1
A   CODE4
B   CODE3
B   CODE9
B   CODEX
C   CODEEE


The reason I'm struggling here is that the values I have provided in my example of A/B/C are very variable inputs (hundreds of possibilities here), so I can't just use a simple replace. What that incoming value is, is not important. What is important is that I have a 'sequence number' (or incremental numerical label starting at 1), which increments whenever the value in pos 1 changes.


Hammertime,

As bill suggested it is quite easy. However if you have hundreds of possible values how are you going to fit it in 2 bytes? Don't you need more than that?

Either way here is a sample for 2 byte id. You can adjust length of n in ID=n based on your requirements.

Code:

//STEP0100 EXEC PGM=SORT                             
//SYSOUT   DD SYSOUT=*                               
//SORTIN   DD *                                       
A   CODE1                                             
A   CODE4                                             
B   CODE3                                             
B   CODE9                                             
B   CODEX                                             
C   CODEEE                                           
//SORTOUT  DD SYSOUT=*                               
//SYSIN    DD *                                       
  OPTION COPY                                         
  INREC IFTHEN=(WHEN=GROUP,KEYBEGIN=(1,1),PUSH=(ID=2))
//*
Back to top
View user's profile Send private message
HammerTime

New User


Joined: 26 Sep 2012
Posts: 14
Location: UK

PostPosted: Fri Feb 07, 2014 1:42 pm    Post subject:
Reply with quote

Thank you so much guys, that is exactly what I wanted. Interesting to see that the PUSH=(ID=X) actually overlays the incoming data with the sequence. Perfect for my needs (as mentioned, I'm not actually interested in my incoming identifier, only in the grouping), but worth noting for others.

Skolusu, the incoming identifier field which I represented in my example above as A/B/C is actually 7 bytes. As mentioned, the PUSH overlays the first X bytes of that, for my purposes I needed X to be 3 (this will be compared against a matching sequence later in my JCL), so to clean things up for my purposes I just space filled the remainder of my incoming identifier (eg: the 4 byes after X).

The code i've used in the end is:

Code:
//SYSIN    DD *                                           
    SORT   FIELDS=COPY                                   
    INREC  IFTHEN=(WHEN=GROUP,KEYBEGIN=(1,7),PUSH=(ID=3))
    OUTREC FIELDS=(1,3,C'    ',8,72)                     


Once again, sincere thanks. It's great to learn more about the seemingly endless functionality of DFSORT!
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7225

PostPosted: Fri Feb 07, 2014 2:10 pm    Post subject: Reply to: Trying to assign a variable input a numerical 'lab
Reply with quote

Not exactly. PUSH has a column-number. For fixed-length records the default column is one. For variable-length records the default column is five.

Code:

//SYSIN    DD *                                           
    SORT   FIELDS=COPY                                   
    INREC  IFTHEN=(WHEN=GROUP,KEYBEGIN=(1,7),PUSH=(1:ID=3)),
           IFTHEN=(WHEN=INIT,OVERLAY=(4:4X))               
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 -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts High CPU consumption Job using IAM fi... aswinir JCL & VSAM 8 Thu Dec 01, 2016 8:28 pm
This topic is locked: you cannot edit posts or make replies. How to use 2 input files in control c... Gunapala CN DFSORT/ICETOOL 23 Thu Oct 13, 2016 3:42 pm
No new posts Format to pipe delimited with variabl... pshongal SYNCSORT 6 Wed Sep 14, 2016 2:48 pm
No new posts Variable for cursor names ravikumar15 DB2 5 Sun Jul 17, 2016 7:08 am
No new posts OPC JCL Variable passion_sujesh IBM Tools 5 Fri Jul 01, 2016 4:21 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us