Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Need to retrive mail id from String

Former Member
0 Kudos
123

Hi

my requiremnet is to capture the mail id from a string which contians URL,

and the format og string is mail to: mail id?remaining part of URL

so i need to capture only mail id .

please help thanks in advance.

2 REPLIES 2

Kiran_Valluru
Active Contributor
0 Kudos
50

Hi,

try the below code:

DATA: url  TYPE string VALUE 'mailto:xyz@sap.com?value',

       pos1 TYPE i,

       pos2 TYPE i,

       len  TYPE i,

       mail TYPE string.

SEARCH url FOR ':'.

pos1 = sy-fdpos + 1.

SEARCH url FOR '?'.

pos2 = sy-fdpos + 1.

len = pos2 - pos1 - 1.

mail = url+pos1(len).

WRITE mail.

Hope this helps u.,

Regards,

Kiran

Former Member
0 Kudos
50

Hi Ashish,

You can try this code:

DATA: url TYPE string VALUE 'mail to:mail id?remaining part of URL',

          st1 TYPE string,

          st2 TYPE string,

          email TYPE string.

SPLIT url AT ':' INTO st1 st2.

SPLIT st2 AT '?' INTO email st1.

WRITE email.

regards,

Susmitha Pritam