Searching number with various formats



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

Searching number with various formats

Postby nikesh_rai » Fri Jul 26, 2013 1:44 pm

Hi guys,

I need a suggestion from you. I have a requirement where I will have a 2 lists of dial-able numbers. In first list, the dial-able number will be present with specified format e.g.;

2260018000
3322619948
3323513216

now the second list will also consist of dial-able number but not in fixed format. The list may looks like

+912260018000
00913322623148
23513216
3322619948

Now the thing is.. I have to search the numbers in list 2 in list 1. I tried with striping the numbers in list 1 and 2 up to 8 digit and then searching it, but it is taking two much CPU..

Can anyone please suggest me a better approach for this.
Thanks
Nikesh Rai
nikesh_rai
 
Posts: 192
Joined: Tue Oct 18, 2011 1:27 am
Has thanked: 17 times
Been thanked: 0 time

Re: Searching number with various formats

 

Re: Searching number with various formats

Postby prino » Fri Jul 26, 2013 2:00 pm

And no doubt you are using a linear search on two unsorted lists?
Robert AH Prins
robert.ah.prins @ the.17+Gb.Google thingy
User avatar
prino
 
Posts: 536
Joined: Wed Mar 11, 2009 12:22 am
Location: Oostende, Belgium
Has thanked: 3 times
Been thanked: 21 times

Re: Searching number with various formats

Postby nikesh_rai » Fri Jul 26, 2013 2:15 pm

Yes I am using linear search, but only first list is sorted.. second list is not sorted..
Thanks
Nikesh Rai
nikesh_rai
 
Posts: 192
Joined: Tue Oct 18, 2011 1:27 am
Has thanked: 17 times
Been thanked: 0 time

Re: Searching number with various formats

Postby NicC » Fri Jul 26, 2013 2:54 pm

so - do you search the sorted list for a number from the unsorted list or do you search the unsorted list?
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 2690
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisys (almost)
Has thanked: 4 times
Been thanked: 105 times

Re: Searching number with various formats

Postby nikesh_rai » Fri Jul 26, 2013 4:03 pm

i am searching numbers from unsorted list List 2 in sorted list List 1
Thanks
Nikesh Rai
nikesh_rai
 
Posts: 192
Joined: Tue Oct 18, 2011 1:27 am
Has thanked: 17 times
Been thanked: 0 time

Re: Searching number with various formats

Postby BillyBoyo » Fri Jul 26, 2013 4:40 pm

Before doing any coding, you need to design, design, design.

Spend an hour concentrating on File 1, and describing everything you'd need to do, as a human, to process each record so that it could be matched against File 2 if it were presented as the simple subscriber's telephone number (no country code, no local code, just their personal number).

Spend two hours doing the same thing with File 2, everthing you'd need to do to match that to the ideal File 1, doing it as a human.

Start getting to know your data. Know it well.

Don't think about programming yet. Think about how you'd need to manipulate the data. Make some good samples for both files. Make some expected output. Work out how you'd get from one to the other.

You may get to the stage that you don't think it can be done. Then post your findings here.

If you get to the stage of a solution, post your solution here.

The reason for not just giving you an answer is because the process of the deisgn is a really good exercise for you. Going through it will pay you back many times over in your career - if you learn how to do it.

There is an answer. See if you can find it. Once you have the answer, the programming is very easy. That's the point of doing the design.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: Searching number with various formats

Postby richiewu » Fri Jul 26, 2013 7:54 pm

nikesh_rai wrote:Hi guys,

I need a suggestion from you. I have a requirement where I will have a 2 lists of dial-able numbers. In first list, the dial-able number will be present with specified format e.g.;

2260018000
3322619948
3323513216

now the second list will also consist of dial-able number but not in fixed format. The list may looks like

+912260018000
00913322623148
23513216
3322619948

Now the thing is.. I have to search the numbers in list 2 in list 1. I tried with striping the numbers in list 1 and 2 up to 8 digit and then searching it, but it is taking two much CPU..

Can anyone please suggest me a better approach for this.


Base on list 2, generate a new list 3 that only contains fixed format numbers, then search it in list 1
richiewu
 
Posts: 9
Joined: Mon Jul 12, 2010 8:10 am
Has thanked: 2 times
Been thanked: 0 time

Re: Searching number with various formats

Postby BillyBoyo » Fri Jul 26, 2013 8:38 pm

OK, but look at the four examples for list 2. One has "+" for the "dial-out-of-country" code, another has 00, it would be possible (at least in the past) to hav 99.

Then, one has a country-code, another no country-code. Country-codes are 1 to 4 digits (perhaps longer, I haven't checked recently). Then the final one has no country-code, but does it have an area-code?

Are all the subscriber numbers for all countries the same length? No. (so list 1 is not so fixed).

Do all countries have an area-code? No.

OK, so how to "normalise" lists 1 and 2 so they can be matched?
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post