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

Can I replace string with the same string modified ?


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

New User


Joined: 30 Dec 2006
Posts: 4
Location: POLAND/Lodz

PostPosted: Sun Feb 04, 2007 4:15 pm
Reply with quote

Hello,
Is it possible to replace string with :
the same string having all leading zeros (0) removed ?
If string contains only zeros, last one should not be removed.
Eg. :
network ip address :
123.070.001.000 -> 123.70.1.0 .

I've asked about 1 string, because i suppose 123.070.001.000 can be splited into
123
070
001
000.

Thanks for Your replies.
oawo
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Sun Feb 04, 2007 6:33 pm
Reply with quote

Have you looked at some of the things that DFSort can do? I'm pretty sure that it can suppress the leading zeros in the 4 fields, and I know that it can shift left squeezing out the resulting blanks.
Have you checked the manual?
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Sun Feb 04, 2007 9:45 pm
Reply with quote

oawo,

It's not clear what you want to do. Changing 123.070.001.000 to 123.70.1.0 is different than suppressing leading zeros in one number per record. DFSORT can do both, but in different ways.

Does the field you want to change start in position 1? If not, where does it start?

What is the RECFM and LRECL of your input file?

Please show a good example of your input records and what you expect for the output records.
Back to top
View user's profile Send private message
oawo

New User


Joined: 30 Dec 2006
Posts: 4
Location: POLAND/Lodz

PostPosted: Mon Feb 05, 2007 2:33 am
Reply with quote

Thanks for Your answers,
sorry for lack of precision - I fought that simplification of problem would help to focus on the solution.

The problem is :

I have a dataset with IP addresses of hosts.

RECFM = FB , LRECL = 300.

Each record contains :
string1;string2;string3

where :
string1 and string3 are not important
; - is delimiter
string2 is : W.X.Y.Z where W,X,Y,Z are numbers 0..255. (it is ip address).

In string2 numbers shorter than 3 digits length are completed with leading zeros to be 3 digits length.

For example : "25" contains 2 digits so in dataset is "025" .

I need to convert ip addresses completed with leading zeros to normal ip addresses - without completion.

Ip address starts after first occurrence of delimiter ";".

Example :

INPUT:

domain1;123.070.001.025;comment1
domain2.domain2.asdf;212.021.000.103;comment2

OUTPUT:

domain1;123.70.1.25;comment1
domain2.domain2.asdf;212.21.0.103;comment2
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Mon Feb 05, 2007 4:50 am
Reply with quote

oawo,

Have you looked at the DFSort manual and the Smart DFSORT Tricks manual? I spotted a function that "can extract the delimited fields into %nn parsed fixed fields" and once there I think DFSort can probably give you what you want.

Can you look at Smart DFSORT Tricks and see if your solution is there?

Bill
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Mon Feb 05, 2007 6:05 am
Reply with quote

oawo,

Here's a DFSORT job that will do what you asked for. I assumed field1 has a maximum length of 30 bytes.

You'll need z/OS DFSORT V1R5 PTF UK90007 or DFSORT R14 PTF UK90006 (April, 2006) in order to use DFSORT's PARSE and SQZ functions. If you don't have the April, 2006 PTF, ask your System Programmer to install it (it's free). For complete details on all of the new DFSORT and ICETOOL functions available with the April, 2006 PTF, see:

Use [URL] BBCode for External Links

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file (FB/300)
//SORTOUT DD DSN=...  output file (FB/300)
//SYSIN    DD    *
   OPTION COPY
   INREC IFOUTLEN=300,
     IFTHEN=(WHEN=INIT,
       PARSE=(%01=(ENDAT=C';',FIXLEN=30),
              %02=(ENDBEFR=C'.',FIXLEN=3),
              %03=(ENDBEFR=C'.',FIXLEN=3),
              %04=(ENDBEFR=C'.',FIXLEN=3),
              %05=(ENDBEFR=C';',FIXLEN=3),
              %06=(FIXLEN=300)),
       BUILD=(%01,
              %02,UFF,EDIT=(IIT),C'.',
              %03,UFF,EDIT=(IIT),C'.',
              %04,UFF,EDIT=(IIT),C'.',
              %05,UFF,EDIT=(IIT),C';',
              %06)),
     IFTHEN=(WHEN=INIT,
       BUILD=(1,346,SQZ=(SHIFT=LEFT)))
/*
Back to top
View user's profile Send private message
oawo

New User


Joined: 30 Dec 2006
Posts: 4
Location: POLAND/Lodz

PostPosted: Mon Feb 05, 2007 1:26 pm
Reply with quote

Your answers are what what I've been looking for.
Frank's solution shows exactly how to handle this kind of problems.
I've checked William's link - it contains PARSE - also answer to my question.
Thanks for help !
oawo
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 Replace each space in cobol string wi... COBOL Programming 3
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts replace word 'MONTH' with current mon... SYNCSORT 11
Search our Forums:

Back to Top