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

Modify a string in sort dynamically


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

New User


Joined: 22 Jul 2005
Posts: 17

PostPosted: Fri May 20, 2011 7:06 pm
Reply with quote

Hello,

I have the following requirement from a client.

The file is 80 bytes length and a record can contain 10 digit phone number . All we have to do is to add the international calling code +XX before the phone #. The 10 digit phone # can come in any position between 1 73.


Is there a way to accomplish this in sort/icetool.
Our installation uses ICE201I G version of sort.
I thought of using parse with a combination of numeric check..but not sure how to implement the solution.

Thanks,
PJoe
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1742
Location: Tirupur, India

PostPosted: Fri May 20, 2011 7:52 pm
Reply with quote

Hello,
Please show us some sample records of the input file. & the output file required.
Back to top
View user's profile Send private message
Garry Carroll

Senior Member


Joined: 08 May 2006
Posts: 1193
Location: Dublin, Ireland

PostPosted: Fri May 20, 2011 7:53 pm
Reply with quote

Is the phone number the only field in this record? How do you identify where the phone number starts? Simply the first non-blank,non-numeric , or what? Is it always 3 characters you want to prefix? What do you want to do if the number starts in pos 71, 72 or 73 - extend the record length?

Garry.
Back to top
View user's profile Send private message
Pjoe

New User


Joined: 22 Jul 2005
Posts: 17

PostPosted: Fri May 20, 2011 8:26 pm
Reply with quote

Here is a sample input record..
Input record
Record 1 - 1 park way North, City name , Country 9535132135

Record 2 - 1 GB,9531132135 Ext 1235 do not use in weekend

Output records
Out rec1-1 park way North, City name , Country (+91)9535132135
Out rec2-1 GB,(+91)9531132135 Ext 1235 do not use in weekend

The golden rule is that phone number is 10 bytes and it can come at any position between 1-73 number .

Since the record length is 80 characters we have enough space to add
the (+XX) character even if the phone number ends at 73 position.

Thanks,
Back to top
View user's profile Send private message
Pjoe

New User


Joined: 22 Jul 2005
Posts: 17

PostPosted: Fri May 20, 2011 8:30 pm
Reply with quote

one more clarification:-

The input file will have spaces between 73-80 column.. The output file can utilize this vacant space when adding (+XX) before the phone number. to be more precise, the output file can be have non blank characters between 73-80 cloumns
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Fri May 20, 2011 9:57 pm
Reply with quote

How about 3 digit country codes?
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 577
Location: USA

PostPosted: Fri May 20, 2011 10:37 pm
Reply with quote

Pjoe,
This "may be" easily (compared to dfsort) done in Cobol. Here is a 5 digit phone number solution. If that works for you, it can be extended for 10 digit phone number solution.

I am afraid this may or may not be efficient solution and I am not sure what Frank or Kolusu's reaction going to be... icon_cry.gif

Code:

//STEP0001 EXEC PGM=SORT                                       
//SYSOUT   DD SYSOUT=*                                         
//SORTIN   DD *                                               
AAAAA12345                                                     
23456BBBBB                                                     
//SORTOUT  DD SYSOUT=*                                         
//SYSIN    DD *                                               
  INREC IFTHEN=(WHEN=(01,5,ZD,EQ,NUM),BUILD=(01:C'(+91)',     
                                             06:1,10)),       
        IFTHEN=(WHEN=(02,5,ZD,EQ,NUM),BUILD=(01:01,01,         
                                             02:C'(+91)',     
                                             07:02,09)),       
        IFTHEN=(WHEN=(03,5,ZD,EQ,NUM),BUILD=(01:01,02,         
                                             03:C'(+91)',     
                                             08:03,08)),       
        IFTHEN=(WHEN=(04,5,ZD,EQ,NUM),BUILD=(01:01,03,         
                                             04:C'(+91)',     
                                             09:04,07)),       
        IFTHEN=(WHEN=(05,5,ZD,EQ,NUM),BUILD=(01:01,04,         
                                             05:C'(+91)',     
                                             10:05,06)),       
        IFTHEN=(WHEN=(06,5,ZD,EQ,NUM),BUILD=(01:01,05,         
                                             06:C'(+91)',     
                                             11:06,05))       
  OPTION COPY                                                 
/*                                                             


OUTPUT
Code:

AAAAA(+91)12345
(+91)23456BBBBB


Thanks,
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: Fri May 20, 2011 11:21 pm
Reply with quote

Quote:
The golden rule is that phone number is 10 bytes and it can come at any position between 1-73 number


This golden "rule" is ambiguous. For example, if we have an 11-byte number:

ABC12345678901DEF

do we interpret this as NOT a phone number, or could it be a digit followed by a phone number, or a phone number followed by a digit?
Back to top
View user's profile Send private message
Pjoe

New User


Joined: 22 Jul 2005
Posts: 17

PostPosted: Sat May 21, 2011 10:37 am
Reply with quote

After looking at the data and based on the business rules, there will be only 10 digit phone numbers in this data stream..
After looking at the data for the last 2 years, I could not find a case
where a record has 10+ digit numbers.Also there is a leading and trailing space between the phone numbers.Please note that there can be 4 digit or 5 digit numbers in this stream


sorry when I typed the second input record in my earlier post, the leading space is missing
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Sat May 21, 2011 10:49 am
Reply with quote

Quote:
when I typed the second input record in my earlier post


Why go to all that effort? Why not just use 'cut and paste'?
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: Sat May 21, 2011 3:30 pm
Reply with quote

A Lodon telephone number - 020 8123 1234, where 020 is the "area code" and you drop the zero to call from outside the UK, so
+44 20 8123 1234. Are you storing with or without the leading zero?

A Lisbon telephone number - 211 111 111. No area codes in Portugal.

You have 1 digit, 2 digit, 3 digit and 4 digit international codes.
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: Sat May 21, 2011 4:34 pm
Reply with quote

While we are at it, do you have a dataset for each country? If not, where are you going to get the Country from and how are you going to look-up the specific code?

I marvel at what DFSORT/ICETOOL can do, but this requirement is complex, and perhaps more complex than you know.

How are you going to be using the data? Presumably the Country is in the address (you are up the creek there if not, someone will have to guess the Country from the City/postal code). The International Code for that country is "static", as would be the Timezone, useful for anyone who wants to make use of the data for calling.

If this is going into some application for someone to use, why don't you ensure the Country is in the data (and recognizable programmatically) and then provide the International Code and Timezone when displaying the data? Else you are making things complicated by adding "redundant" data to your existing data.
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 May 23, 2011 10:32 pm
Reply with quote

PJoe,

Even the "simple" case of replacing bddddddddddb (b=blank, d=0-9) anywhere it appears in a record with b(+91)ddddddddddb is quite complex. I can't think of a practical way to do that with DFSORT's built-in functions. I'd suggest you write a program or exit with the appropriate logic.
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 Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts How to split large record length file... DFSORT/ICETOOL 10
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
Search our Forums:

Back to Top