View previous topic :: View next topic
|
Author |
Message |
shajeeth
New User
Joined: 25 May 2005 Posts: 20
|
|
|
|
Hi,
I have a requirement to validate email address in a file before its send to a third party. This limitation being that the validation need to be done only using DFSORT.
The validation is to verify @ is present in an email address and first .(dot) is present the domain name. The validation of @ is easy in a an email id using FINDREP.
Basically i should verify there is a @ and there is atleast a .(dot) in the domain name for an email id.
For example:
xyz@gmail.com
abcded@yahoo.co.uk
mnop@aol.com
def@au.com
Since the first dot in the above domain names varies, i dont have an idea as how to validate the email id field for a dot following @.
The file format is FB, the total file length being 300 bytes and the email field starts from 200 and of 100 bytes long.
Since the domain names can vary, the first .(dot) postion can vary. The @ and the first . dot validation be performed in a single DFSORT step?
Please,Any suggestions/help on this ?
Invalid email id's to be written to a reject file.
Thanks |
|
Back to top |
|
|
shajeeth
New User
Joined: 25 May 2005 Posts: 20
|
|
|
|
Please can anyone help/suggest as how this can be performed?
Any queries/suggestions are welcome..
Thanks |
|
Back to top |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
Not many people working today...
This will give you a good lead:
Code: |
//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
xyz@gmail.com
inv#gmail.com
abcded@yahoo.co.uk
inval@yahoocouk
bad@mymail.
mnop@aol.com
def@au.com
@funky.com
//SORTOF01 DD SYSOUT=*
//SORTOF02 DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC PARSE=(%01=(ENDBEFR=C'@',FIXLEN=1,ABSPOS=12),
%02=(ENDBEFR=C'.',FIXLEN=1),
%03=(ENDBEFR=C' ',FIXLEN=1)),
BUILD=(1,80,%01,%02,%03)
OUTFIL FILES=01,INCLUDE=(81,1,CH,NE,C' ',AND,
82,1,CH,NE,C' ',AND,83,1,CH,NE,C' ')
OUTFIL FILES=02,INCLUDE=(81,1,CH,EQ,C' ',OR,
82,1,CH,EQ,C' ',OR,83,1,CH,EQ,C' ')
/* |
I hope you will manage from here... |
|
Back to top |
|
|
shajeeth
New User
Joined: 25 May 2005 Posts: 20
|
|
|
|
Thank you very much for quick reply. I have some point to start with.
I am working today due to this deployment to be submitted on wednesday..
Will keep you posted!
Thanks |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
One of the OUTFIL's can be simplified by using SAVE instead of INCLUDE=/OMIT= with conditions reversed. |
|
Back to top |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
Code: |
OUTFIL FILES=02,SAVE |
Nice!
No matter how many times I look at the documentation, there is always another parameter...
Here is another one:
If the email address doesn't always start exactly at col 200, then you can use 'STARTAT=NONBLANK' in addition to 'ABSPOS=200' |
|
Back to top |
|
|
shajeeth
New User
Joined: 25 May 2005 Posts: 20
|
|
|
|
Thank you very much!
It worked and the files were split into two files based on PARSE.
I tried both of INCLUDE and SAVE, retained the SAVE as the code easy to interpret.
The position will always be 200 as the email id is picked from table unload using join keys and position remains fixed.
Thanks for your help! |
|
Back to top |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
Of course, you have removed in the OUTFIL the 3 bytes added during the INREC.
I forgot about that. |
|
Back to top |
|
|
shajeeth
New User
Joined: 25 May 2005 Posts: 20
|
|
|
|
Marso wrote: |
Of course, you have removed in the OUTFIL the 3 bytes added during the INREC.
I forgot about that. |
Yes, i did by including an additional OUTREC to remove the last three characters.
Thanks again |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
Just a thought ............. as I haven't checked the functionality of the code given
But, what about email addresses such as name.2ndname@whatever.co.uk |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
The validation required is very basic. The PARSE will first find the @. The second field of the PARSE will continue from that point. "." prior to the @ will not cause a problem.
shajeeth,
If you post your code, we can suggest a couple of changes. |
|
Back to top |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
The address is split into 3 parts (X@Y.Z) and we take the 1st letter of each part.
"name.2ndname@whatever.co.uk" should work. |
|
Back to top |
|
|
shajeeth
New User
Joined: 25 May 2005 Posts: 20
|
|
|
|
expat wrote: |
Just a thought ............. as I haven't checked the functionality of the code given
But, what about email addresses such as name.2ndname@whatever.co.uk |
The code works fine for that too. It basically validates the first character presence, a character after @ presence and a character after . presence
It works fine for : j.wan.hendson@yahoo.co.uk too, the Parse will give the characters as jyc and the OUTFIL INCLUDE validates this.
Thanks! |
|
Back to top |
|
|
saiprasadh
Active User
Joined: 20 Sep 2006 Posts: 154 Location: US
|
|
|
|
Shajeeth,
Please test the code for below mentioned email address.
|
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Sai,
The requirement is for a very basic and limited "validation". Yes, it would accept that, but it meets the spec. |
|
Back to top |
|
|
shajeeth
New User
Joined: 25 May 2005 Posts: 20
|
|
|
|
Yes, the requirement still now has been basic and it meets the spec as required.
I will keep you posted if any additional validations would be required.
Thanks! |
|
Back to top |
|
|
shajeeth
New User
Joined: 25 May 2005 Posts: 20
|
|
|
|
Bill Woodger wrote: |
Sai,
The requirement is for a very basic and limited "validation". Yes, it would accept that, but it meets the spec. |
As i had not expected, the requirement has changed. The basic validation works perfectly fine, however as expected it fails for email id's as
xyz@hotmail.c
abc@hotmail.co
Any ideas as how this can also be written into rejects using SORT?
Thanks ! |
|
Back to top |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
Back to top |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
This thread started with:
shajeeth wrote: |
I have a requirement to validate email address in a file before its send to a third party. |
1. If more than basic validation is needed, then SORT is the wrong tool for this.
2. The program that write or update records in this file is the one that should validate the email address.
Escapa,
very interesting link.
I knew that "kuki1234@gmail.com" and "kuki.1234@gmail.com" are in fact the same address, and that you can use tags ("kuki1234+NEWS@gmail.com", useful if you use filters), but I thought it was specific to gmail. |
|
Back to top |
|
|
|