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

extract Top Level Domain of the email-id


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
sashi

New User


Joined: 14 Sep 2005
Posts: 54
Location: Chennai

PostPosted: Wed Mar 24, 2010 9:10 pm
Reply with quote

Hi all,

I have input field WS-EMAIL-ID with PIC X(80).
I may expect input values like
asdfg@yahoo.co.in
xyz@yahoo.com
abc@yahoo.co.in.edu

I need to extract Top Level Domain of the email-id which is
asdfg@yahoo.co.in -- in
xyz@yahoo.com -- com
abc@yahoo.co.in.edu -- edu

we can have more than 6 qualifier in domain name.

in other words need to extract data after last DOT(.)

came any one please help me on this..
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed Mar 24, 2010 9:16 pm
Reply with quote

Hello,

As you requested, the duplicate topic has been removed.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed Mar 24, 2010 9:17 pm
Reply with quote

Hello,

One way to get what you want is to UNSTRING the email-id into multiple work-fields delimiting by the period. The last field filled will contain the "top level domain".
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Wed Mar 24, 2010 10:03 pm
Reply with quote

Or use FUNCTION REVERSE, grab everything before the first period, and then use FUNCTION REVERSE again.
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Thu Mar 25, 2010 12:00 am
Reply with quote

sashi wrote:
in other words need to extract data after last DOT(.)

UNSTRING WS-EMAIL-ID DELIMITED BY '.' INTO Top-Level-Domain where Top-Level-Domain is a pic 80 too....
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Mar 25, 2010 12:04 am
Reply with quote

Hello,

Ok, i'm really slow today. . .

Will this work for multi-dot e-addrs?
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Thu Mar 25, 2010 12:11 am
Reply with quote

AFAIK, the unstring generates a move (with blank padding) to the into field without regard to whether the into field is the same as the one before or not....
Even if the move does not pad, the count in function will make it easy anyway..
This assumes that the email data does not have any trailing 'dots'....
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Mar 25, 2010 12:28 am
Reply with quote

Hello,

From the example "input" - abc@yahoo.co.in.edu

After the unstring i believe the "Top-Level-Domain" will contain "abc@yahoo". . .
Corrected
The requirement (if i understand correctly) is that "edu" should be returned as the Top-Level-Domain . . . What have i missed?
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Thu Mar 25, 2010 1:34 am
Reply with quote

Quote:
What have i missed?
The "DELIMITED BY '.'"?
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Mar 25, 2010 1:54 am
Reply with quote

Hello,

Nope - saw that. . icon_smile.gif . But that will only process one period. . . It will then quit.

This
Code:
       01  EADDR PIC X(30) VALUE 'THENAME@AB.CD.EF.EDU'.
       01  TOP-LEVEL-DOMAIN PIC X(80) VALUE SPACES.     

          UNSTRING EADDR DELIMITED BY '.' INTO TOP-LEVEL-DOMAIN.
          DISPLAY TOP-LEVEL-DOMAIN.           


Gives:
THENAME@AB
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Thu Mar 25, 2010 2:14 am
Reply with quote

Quote:
But that will only process one period. . . It will then quit.
Oops, my bad..... icon_redface.gif
Code:
UNSTRING EADDR
   DELIMITED BY '.'
   INTO TOP-LEVEL-DOMAIN
        TOP-LEVEL-DOMAIN
        TOP-LEVEL-DOMAIN
        .
        .
        .
        TOP-LEVEL-DOMAIN
        TOP-LEVEL-DOMAIN
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Thu Mar 25, 2010 2:35 am
Reply with quote

This works better than the UNSTRING alone:
Robert Sample wrote:
Or use FUNCTION REVERSE, grab everything before the first period, and then use FUNCTION REVERSE again.

or you can:
use FUNCTION REVERSE to inverse the mail-address,
INSPECT TALLYING FOR FIRST '.' to locate the fist point (reversed, it is the last)
COMPUTE pos = length - tally +2 to locate after the last point (in non reversed string)
and MOVE the mail-address (pos:tally - 1) to the domain string
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Thu Mar 25, 2010 2:36 am
Reply with quote

and don't forget to put a MOVE 0 TO tally before the INSPECT.
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 -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts Need help for File Aid JCL to extract... Compuware & Other Tools 23
No new posts How to load to DB2 with column level ... DB2 6
No new posts optim extract file - SAS DB2 2
No new posts ISRSUPC search utility - using high l... TSO/ISPF 2
Search our Forums:

Back to Top