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
 

 

Modify a string in sort dynamically

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Modify a string in sort dynamically
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: 1445
Location: Azeroth

PostPosted: Fri May 20, 2011 7:52 pm    Post subject:
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

Active Member


Joined: 08 May 2006
Posts: 990
Location: Dublin, Ireland / Edinburgh, Scotland

PostPosted: Fri May 20, 2011 7:53 pm    Post subject:
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    Post subject: Reply to: Modify a string in sort dynamically
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    Post subject: Reply to: Modify a string in sort dynamically
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: 1717
Location: UK

PostPosted: Fri May 20, 2011 9:57 pm    Post subject:
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: 578
Location: USA

PostPosted: Fri May 20, 2011 10:37 pm    Post subject:
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 Moderator


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

PostPosted: Fri May 20, 2011 11:21 pm    Post subject:
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    Post subject: Reply to: Modify a string in sort dynamically
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: 1717
Location: UK

PostPosted: Sat May 21, 2011 10:49 am    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7241

PostPosted: Sat May 21, 2011 3:30 pm    Post subject: Reply to: Modify a string in sort dynamically
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7241

PostPosted: Sat May 21, 2011 4:34 pm    Post subject: Reply to: Modify a string in sort dynamically
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 Moderator


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

PostPosted: Mon May 23, 2011 10:32 pm    Post subject:
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    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 Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm
No new posts How to delete second instance from Fl... Gunapala CN DFSORT/ICETOOL 6 Tue Oct 18, 2016 11:42 pm
No new posts abend sort based on count records in ... anatol DFSORT/ICETOOL 5 Mon Oct 17, 2016 10:10 pm


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