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
 

 

Pick email Ids from a report.
Goto page 1, 2  Next
 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
View previous topic :: :: View next topic  
Author Message
abhit007

New User


Joined: 18 Oct 2006
Posts: 10
Location: Bangalore

PostPosted: Wed Mar 07, 2012 12:03 pm    Post subject: Pick email Ids from a report.
Reply with quote

Hi Guys,

I am facing a problem here. I want to write a REXX program to pick up all the email Ids present in a report. for example.

XYZ.ABC.DEF.GIH (PS)
**************************************************************
THIS REPORT IS USED TO FIND OUT THE NEW EMAIL IDS
INTRODUCED
**************************************************************
%EMAIL (ABC@GMAIL.COM,ABC.XYZ@GMAIL.COM ) -
%EMAIL (SUPPORT@GMAIL.COM CARDSSD@GMAIL.COM) -
%EMAIL (REPORT@GMAIL.COM ) -
%EMAIL (SUPPORT@GMAIL.COM ) -
%EMAIL (XXXXXXXXXXX@GMAIL.COM ) -
%EMAIL (SUPPORT@GMAIL.COM ) -
%EMAIL (BONUS@GMAIL.COM, PRODUCTS@YAHOO.CO.IN) -


From the above report I want to pick out all the email ids and write in other pds as:
ABC@GMAIL.COM
ABC.XYZ@GMAIL.COM
SUPPORT@GMAIL.COM
CARDSSD@GMAIL.COM
REPORT@GMAIL.COM
SUPPORT@GMAIL.COM
XXXXXXXXXXX@GMAIL.COM
SUPPORT@GMAIL.COM
BONUS@GMAIL.COM
PRODUCTS@YAHOO.CO.IN

Any idea??

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

enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Wed Mar 07, 2012 12:26 pm    Post subject: Reply to: Pick email Ids from a report.
Reply with quote

where are You stuck ....
in the logic or the code ?
Back to top
View user's profile Send private message
abhit007

New User


Joined: 18 Oct 2006
Posts: 10
Location: Bangalore

PostPosted: Wed Mar 07, 2012 1:03 pm    Post subject: Reply to: Pick email Ids from a report.
Reply with quote

To start with I am struck at the logic itself. :P
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Mar 07, 2012 1:10 pm    Post subject:
Reply with quote

1.
access a record
isolate and store email-address(es)
more records? goto 1
ouput all stored email-addresses

what would your logic in cobol be?

why did you pick REXX for this project?

how many lines in the report?
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7232

PostPosted: Wed Mar 07, 2012 1:11 pm    Post subject: Reply to: Pick email Ids from a report.
Reply with quote

Identify the lines from first word, or by location, being %e-mail.

Get rid of first word, opening and closing brackets, commas.

Take each remaining word and treat as an e-mail address.
Back to top
View user's profile Send private message
prino

Active Member


Joined: 07 Feb 2009
Posts: 984
Location: Oostende, Belgium

PostPosted: Wed Mar 07, 2012 2:06 pm    Post subject:
Reply with quote

Translate everything not alphanumerical, '@' and '.' to space, and use the REXX "word" and "words" functions. Any "word" containing an '@' sign is (probably) an email address.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Wed Mar 07, 2012 2:32 pm    Post subject: Reply to: Pick email Ids from a report.
Reply with quote

faster to write/test post the code that trying to explain


Code:
#!/usr/bin/rexx

list.1 = "%EMAIL (ABC@GMAIL.COM,ABC.XYZ@GMAIL.COM ) "
list.2 = "%EMAIL (SUPPORT@GMAIL.COM CARDSSD@GMAIL.COM) "
list.3 = "%EMAIL (REPORT@GMAIL.COM ) "
list.4 = "%EMAIL (SUPPORT@GMAIL.COM ) "
list.5 = "%EMAIL (XXXXXXXXXXX@GMAIL.COM ) "
list.5 = "%EMAIL (SUPPORT@GMAIL.COM ) "
list.6 = "%EMAIL (BONUS@GMAIL.COM, PRODUCTS@YAHOO.CO.IN) "
list.0 = 6

addr.0 = 0
do  i = 1 to list.0
    buff = list.i
    if  left(buff,6) = "%EMAIL" then do
        /* check for a properly delimited list */
        if  (pos("(",buff)) = 0 | ,
            (pos(")",buff)) = 0 then do
            say " bad EMAIL record" right(i,2) buff
            iterate
        end
        parse var buff with ."(" list ")" .
        /* provide both for comma/wsp delimited addresses */
        list = translate(list," ",",")
        do  j = 1 to words(list)
            a = addr.0 + 1
            addr.a = strip(word(list,j))
            addr.0 = a
        end
    end
end
do  a = 1 to addr.0
    say a addr.a
end


if the input format changes, do a bit of work Yourself
for example You might need to build from multi card list
Back to top
View user's profile Send private message
abhit007

New User


Joined: 18 Oct 2006
Posts: 10
Location: Bangalore

PostPosted: Wed Mar 07, 2012 3:57 pm    Post subject: Reply to: Pick email Ids from a report.
Reply with quote

Hi Enrico,

The code you have provided is working perfectly after a little tweaking.

I am reading the report from my dataset into a stem and then running the piece of code you have given to filter out the mail addresses. Comma and spaces were the only delimiters.
Since %EMAIL is not the only thing at the first place in a line, so I have removed the first para of your code. However, there are still some minor glitches as it is taking special characters like '-' and writing it in a new line.

Hi All,

Thanks for your help as well.



Many thanks for all the help.
Abhishek
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Wed Mar 07, 2012 8:24 pm    Post subject: Reply to: Pick email Ids from a report.
Reply with quote

post an example of where MY the code fails,
my snippet as posted will parse correctly ANY list within parentheses
and build the single appearances correctly unless it contains commas or spaces
Back to top
View user's profile Send private message
don.leahy

Active Member


Joined: 06 Jul 2010
Posts: 641
Location: Whitby, ON, Canada

PostPosted: Wed Mar 07, 2012 9:45 pm    Post subject:
Reply with quote

Enrico, re your code sample: on my display, the lowercase "l" and the numeral "1" appear identical in the code window.

ie the line "do l = 1 to list.0" looks like "do l = l to list.0" icon_smile.gif
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7232

PostPosted: Wed Mar 07, 2012 10:12 pm    Post subject: Reply to: Pick email Ids from a report.
Reply with quote

1l1l1l1l1l1l1l1l1l1
Code:
1l1l1l1l1l1l1l1l1l1


1l1l1l1l1l1l1l1l1l1

It is not just enrico's stuff, it seems. How many years has it taken for anyone to spot that (well done Don!)? When you copy/paste from the coded stuff, you get the right ones, as above (first typed, copy/paste, coded, preview, copy/paste from Coded stuff on Preview).

Or is this a recent change? How could we tell :-)

EDIT: This is with Firefox, anyway.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Wed Mar 07, 2012 10:19 pm    Post subject: Reply to: Pick email Ids from a report.
Reply with quote

Quote:
Enrico, re your code sample: on my display, the lowercase "l" and the numeral "1" appear identical in the code window.

that' a common problem with some fonts

my code sample worked well AS CODED

just as a courtesy to Your eyes I edited the code to use j for the inner loop and i for the outer
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Mar 07, 2012 10:52 pm    Post subject:
Reply with quote

i personally never use the single alpha i, l, or o as a variable
since people tend to see what they want
instead of what is there.
Back to top
View user's profile Send private message
abhit007

New User


Joined: 18 Oct 2006
Posts: 10
Location: Bangalore

PostPosted: Thu Mar 08, 2012 1:00 am    Post subject: Reply to: Pick email Ids from a report.
Reply with quote

Hi Enrico,

Your code is working perfectly. I just had to alter it to suit my needs.

Hi All,

Next part of the problem:

Now I have to take each of these Ids from one dataset and search in my database (another dataset) for existence. If any of the address is not present then write in another file.

This database is again not a formatted one, having email Ids randomly, so we might have to use POS or something like that.

Can you please help?

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

Senior Member


Joined: 01 Sep 2006
Posts: 2019
Location: Silicon Valley

PostPosted: Thu Mar 08, 2012 10:44 pm    Post subject: Reply to: Pick email Ids from a report.
Reply with quote

Quote:
This database is again not a formatted one, having email Ids randomly, so we might have to use POS or something like that.


1. Change all '(', ')', and ',' to blanks.
2. for each word of each line, use POS function to see if it has the '@' character.
Back to top
View user's profile Send private message
abhit007

New User


Joined: 18 Oct 2006
Posts: 10
Location: Bangalore

PostPosted: Fri Mar 09, 2012 11:10 am    Post subject: Re: Reply to: Pick email Ids from a report.
Reply with quote

enrico-sorichetti wrote:
post an example of where MY the code fails,
my snippet as posted will parse correctly ANY list within parentheses
and build the single appearances correctly unless it contains commas or spaces


Hi Enrico,

There is one problem. There are certain instances where parenthesis are not there. For example

%YMAIL (XYZVITY@GMAIL.COM,XG.RPCZPYRATIZNX@GMAIL.COM, -
CZYRYL.CZIAM@GMAIL.COM,XYNGCZAI.CZAN@GMAIL.COM, -
(DZZZA.AZMAD@GMAIL.COM,MARIYTTA.BZZCZRRYJADZ@GMAIL.COM, -
DYVAXXY.ATTZKARYN@GMAIL.COM,ALKA.JZA@GMAIL.COM, -
AAAT.XINGZ3@GMAIL.COM,VIXZAL.ZJZA@GMAIL.COM) -
FRZM (XYZVITY@GMAIL.COM) -

How this can be parsed?

Thanks,
Abhishek.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Fri Mar 09, 2012 11:36 am    Post subject: Reply to: Pick email Ids from a report.
Reply with quote

I made a note about ....
Quote:
for example You might need to build from multi card list

implied some kind of continuation ...

but You must set some rules ...

a string concatenation/sequence from a parsing point of view is an expression
and in any language in an expression the parentheses must be balanced

the example You posted is NOT parsable because the open and close parentheses are not balanced

You cannot blame on the parsing if Your input is wrong!
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Fri Mar 09, 2012 11:40 am    Post subject: Reply to: Pick email Ids from a report.
Reply with quote

here is a snippet that will parse a properly parenthesized string

Code:


#!/usr/bin/rexx

list.1 = "%EMAIL (ABC@GMAIL.COM,ABC.XYZ@GMAIL.COM ) "
list.2 = "%EMAIL (SUPPORT@GMAIL.COM CARDSSD@GMAIL.COM -"
list.3 = "REPORT@GMAIL.COM - "
list.4 = "SUPPORT@GMAIL.COM ) "
list.5 = "%EMAIL (XXXXX_XXX.XXX@somefuckng-strange.address.COM ) "
list.6 = "%EMAIL (SUPPORT@GMAIL.COM ) "
list.7 = "%EMAIL (BONUS@GMAIL.COM, PRODUCTS@YAHOO.CO.IN) "
list.0 = 7

addr.0 = 0
indx = 1
buff = ""
do while ( indx <= list.0 )

    buff = strip(list.indx)
    say indx "*1 " buff
    indx = indx + 1
    do  while ( right(buff,1) = "-" & indx <= list.0 )
        buff = strip(buff,,"-") strip(list.indx)
        say indx "*2 " buff
        indx = indx + 1
    end
    /* do some checking for a wrongful continuation on last card */
    say indx "*3 " buff
    if  left(buff,6) = "%EMAIL" then do
        /* check for a properly delimited list */
        if  (pos("(",buff)) = 0 | ,
            (pos(")",buff)) = 0 then do
            say "bad EMAIL record" right(indx,2) buff
            iterate
        end
        parse var buff with ."(" list ")" .
        /* provide both for comma/wsp delimited addresses */
        list = translate(list," ",",")
        do  i = 1 to words(list)
            a = addr.0 + 1
            addr.a = strip(word(list,i))
            addr.0 = a
        end
    end
end
do  a = 1 to addr.0
    say a addr.a
end


Back to top
View user's profile Send private message
abhit007

New User


Joined: 18 Oct 2006
Posts: 10
Location: Bangalore

PostPosted: Fri Mar 09, 2012 11:42 am    Post subject: Re: Reply to: Pick email Ids from a report.
Reply with quote

Quote:

the example You posted is NOT parsable because the open and close parentheses are not balanced


Hi Enrico,

%EMAIL (XYZVITY@GMAIL.COM,XG.RPCZPYRATIZNX@GMAIL.COM, -
CZYRYL.CZIAM@GMAIL.COM,XYNGCZAI.CZAN@GMAIL.COM, -
DZZZA.AZMAD@GMAIL.COM,MARIYTTA.BZZCZRRYJADZ@GMAIL.COM, -
DYVAXXY.ATTZKARYN@GMAIL.COM,ALKA.JZA@GMAIL.COM, -
AAAT.XINGZ3@GMAIL.COM,VIXZAL.ZJZA@GMAIL.COM) -
FRZM (XYZVITY@GMAIL.COM) -

Ignore the example in prev post , consider this example where parenthesis is balanced.
Since there are multiple Ids it is coming in multiple lines.

Thanks
Abhishek
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Fri Mar 09, 2012 11:44 am    Post subject: Reply to: Pick email Ids from a report.
Reply with quote

and what about the
Quote:
FRZM (XYZVITY@GMAIL.COM)
?
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 -> CLIST & REXX All times are GMT + 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Detailed Transaction History report f... Kyle Carroll CICS 5 Tue Oct 18, 2016 12:42 am
No new posts Reading data from PS file and send it... rajatbagga All Other Mainframe Topics 18 Fri Sep 23, 2016 12:51 pm
No new posts Easytrieve - Report writing - Only 1 ... Abhi Nature CA Products 2 Wed Sep 14, 2016 11:40 am
No new posts Daily report to be extracted from CA ... polymathtarun DFSORT/ICETOOL 5 Mon Jul 11, 2016 4:33 pm
No new posts Report view in Mobile devices Robert Sample All Other Mainframe Topics 0 Thu Jun 23, 2016 7:05 pm


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