Joined: 07 Jan 2003 Posts: 1056 Topics: 91 Location: The Blue Planet
Posted: Thu Jul 22, 2004 11:27 am Post subject: Using wild cards in CHANGE operator
Hi,
Can we use any wild-cards in the CHANGE command? My requirement is to convert a set of FTP id's that start with 167.xxx.yyy.99 to 167.113.75.99. 'xxx' & 'yyy' can be any combination of digits.
In the above example, the first and third Ftp addresses should be changed to the hardcoded value '167.113.75.99'. Can this be done using CHANGE & NOMATCH operators in SORT ?
Note: This is just a sample request. We have couple of similar requests dealing with some alphabetic strings.
Joined: 26 Nov 2002 Posts: 12367 Topics: 75 Location: San Jose
Posted: Thu Jul 22, 2004 11:48 am Post subject:
Phantom,
You can change the 2nd & 4th nodes for any thing that starts with 167. But it gets tricky as the 3rd node is variable.
i.e
Code:
167.113.1.99
167.100.22.99
167.100.256.32
Since you wanted to keep the 3rd node as it is, we will have to split the file into 3 temp files and then change it.
As you said this is only sample request , I am not going to post a solution for that. Let us know the exact requirements and may be we can suggest a solution
Kolusu _________________ Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Note: we have trailing spaces if the data in the field is less than 10 chars.
(AXND11203b, AXNY1103bb).
Here If the data starts with AXN and ends with 03 I need to change it to 'AXNxMMDDYY' (10 char constant) where the leading 'x' at position 4 should remain unchanged, MMDDYY - current date.
The output should look like the one shown below.
AXND123102
AXND072104
AXNY072104
BXYU111103
AXNP122002
In the above example the change is done only in records 2 and 3. (AXNx....03).
3. This one is a bit different. I have a file (LRECL=80, RECFM=FB) with the following data
Note: In the above example, '0' represents LOW-VALUE. What I need is that I need to change all chars other than low=value to '*'.
I thought of doing this using NOMATCH operator, but the problem is that the LOW=VALUE can occur at any position of the file. How do I code a CHANGE command for this case ?
Joined: 07 Jan 2003 Posts: 1056 Topics: 91 Location: The Blue Planet
Posted: Fri Jul 23, 2004 7:32 am Post subject:
Quote:
Since you wanted to keep the 3rd node as it is, we will have to split the file into 3 temp files and then change it.
Kolusu, It would be really helpful if you can provide me the solution for my requirement # 1 (FTP address change). This is a top priority request for me.
Joined: 26 Nov 2002 Posts: 12367 Topics: 75 Location: San Jose
Posted: Fri Jul 23, 2004 9:35 am Post subject:
Phantom,
The following JCL will give you the desired results. If you have syncsort at your shop then change the pgm name to synctool. I assumed that your input IP addresses start from pos1.
Joined: 07 Jan 2003 Posts: 1056 Topics: 91 Location: The Blue Planet
Posted: Fri Jul 23, 2004 9:36 am Post subject:
Thanks a lot Bithead.
I also would like to mention (sorry for not telling this before), the file is a bit huge to be opened in VIEW/EDIT macros. But I learned something new today....thanks a lot..
Joined: 07 Jan 2003 Posts: 1056 Topics: 91 Location: The Blue Planet
Posted: Sat Jul 24, 2004 12:41 am Post subject:
Kolusu, Thanks a lot for the pains you took in coding all possible combinations of values. I thought of this solution but later something said that there would be a better alternative....
Kolusu, which of the following two solutions would be efficient ? (interms of CPU and run time)
1. the one which uses ALTSEQ in SORT.
2. Using COBOL - INSPECT - REPLACING.
Let me tell you that the input file is quite huuuuuuge (millions).
Joined: 26 Nov 2002 Posts: 12367 Topics: 75 Location: San Jose
Posted: Sat Jul 24, 2004 8:53 am Post subject:
phantom,
Based upon a recent discussion here, I would say that the DFSORT'S ALTSEQ is very efficient. check this link which discusses the same(last 4 or 5 posts from the bottom)
Joined: 03 Jan 2003 Posts: 1014 Topics: 13 Location: Atlantis
Posted: Sat Jul 24, 2004 2:41 pm Post subject:
I haven't read through the entire discussion, but the initial requirements could be satisfied by relatively simple application of regular expressions and sed if you are willing to do this on OMVS or USS. Assuming your file is called t :
Code:
sed -e 's/167\.[0-9]+\.[0-9]+\.99/167.113.75.99/g' <t >newfile
the 2nd one is a little more complex because you need to use the date but assuming you have want to hardcode the date you could use
Code:
sed -e 's/AXN\(.\)[0-9]*03/AXN\1yymmdd/g' <t >newfile
I know that the date can be obtained by `date +%m%d%y` but I haven't figured out how to put that into a shell script. Also, these may change the column layout of the data if that is important.
(I know the original question was about SORT. I just felt like playing with it)
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Mon May 15, 2006 3:09 pm Post subject:
With z/OS DFSORT V1R5 PTF UK90007 or DFSORT R14 PTF UK90006 (April, 2006), you can now use DFSORT's new PARSE function to do the original request quite easily in one pass as shown by this DFSORT job:
Code:
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD *
167.2.113.99
aaa.141.196.157
bbb.164.17.219
167.99.4.56
ccc.159.46.152
ddd.139.148.29
167.100.256.99
167.113.117.99
167.90.18.99
167.80.118.98
165.250.89.562
167.125.890.95
168.250.89.99
167.125.890.99
167.9.580.99
167.000.111.222
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC IFOUTLEN=80,
IFTHEN=(WHEN=INIT,
* Input is: n.x.y.m where n, x, y and m may be 1-3 chars.
* Extract n into %00 and m into %01.
PARSE=(%00=(FIXLEN=3,ENDBEFR=C'.'),
%=(ENDBEFR=C'.'),
%=(ENDBEFR=C'.'),
%01=(FIXLEN=3)),
* Add %00 in 81-83 and %01 in 84-86.
OVERLAY=(81:%00,84:%01)),
* If 81-83 = '167' and 84-86 = '99 ',
* change address to '167.113.75.99'
IFTHEN=(WHEN=(81,3,CH,EQ,C'167',AND,84,3,CH,EQ,C'99'),
BUILD=(C'167.113.75.99'))
/*
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Mon May 15, 2006 4:21 pm Post subject:
With z/OS DFSORT V1R5 PTF UK90007 or DFSORT R14 PTF UK90006 (April, 2006), you can now use DFSORT's new JFY and SQZ functions to do the second requirement quite easily in one pass as shown by this DFSORT job:
Code:
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD *
AXND123102
AXND11203
AXNY1103
BXYU111103
AXNP122002
AXNP102
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
* Justify 5-10 right to check last two non-blanks for '03'.
INREC IFTHEN=(WHEN=INIT,OVERLAY=(5:5,6,JFY=(SHIFT=RIGHT))),
* If 1-3 = 'AXN' and last two non-blanks = '03',
* overlay 5-10 with mmddyy.
IFTHEN=(WHEN=(1,3,CH,EQ,C'AXN',AND,9,2,CH,EQ,C'03'),
OVERLAY=(5:DATENS=(MDY))),
* If 1-3 not 'AXN' or last two non-blanks not '03',
* squeeze non-blank chars back to left.
IFTHEN=(WHEN=NONE,
OVERLAY=(1,10,SQZ=(SHIFT=LEFT)))
/*
_________________ Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum