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: 

remove the word after '@' in a string

manish_malakar0316
Active Participant
0 Kudos
571

Hello ,

While storing a list of email IDs in the SAP standard field FINAA-INTAD, we found that it has only 130 characters. So the rest of the mail IDs had to be stored in FINAA-INTAD_CC which also has 130 characters.

However, in some cases FINAA-INTAD has some incomplete IDs which need to be removed, especially the ones after '@'.

In the above screenshot, the highlighted email is incomplete (as it exceeds 130 characters) as well as invalid. So I am putting this mail ID inside C_FINAA-INTAD_CC .

But as the control goes to the FM PRINT_DUNNING_NOTICE, there is another FM SX_INTERNET_ADDRESS_TO_NORMAL which is regarding the mail ID as valid since it has '@' followed by characters.

So my requirement is to check if there is any incomplete/invalid mail ID inside C_FINAA-INTAD and to remove it so that it does not show up in transaction SOST.

Please refer to the source code snippet which is written inside a custom FM.

Regards,

Manish

    IMPORT lt_addressdata TO lt_add FROM MEMORY ID 'EMAIL_LIST'. "Import the list of email addresses from FM ZFI_SOA_DUNNING_NOTICES as finaa-intad has only 130 characters
SPLIT c_finaa-intad AT '' INTO l_str1 l_str2 l_str3 l_str4 l_str5 l_str6 l_str7 l_str8 l_str9 l_str10.
LOOP AT lt_add ASSIGNING FIELD-SYMBOL(<fs_add>).
IF <fs_add>-e_mail = l_str1 OR <fs_add>-e_mail = l_str2 OR <fs_add>-e_mail = l_str3 OR <fs_add>-e_mail = l_str4 OR <fs_add>-e_mail = l_str5
OR <fs_add>-e_mail = l_str6 OR <fs_add>-e_mail = l_str7 OR <fs_add>-e_mail = l_str8 OR <fs_add>-e_mail = l_str9 OR <fs_add>-e_mail = l_str10.
CONTINUE.
ELSE.
CONCATENATE c_finaa-intad_cc <fs_add>-e_mail INTO c_finaa-intad_cc SEPARATED BY space. "store in INTAD_CC in case INTAD is full
ENDIF.
ENDLOOP.
1 ACCEPTED SOLUTION

adityaIngale
Active Participant
446

Hi manish.malakar0316,

Try this.

LOOP AT lt_add ASSIGNING FIELD-SYMBOL(<fs_add>).

DATA(lv_count) = count( val = c_finaa-intad sub = <fs_add>-e_mail ).

IF lv_count NE 0.
CONTINUE.
ELSE.
c_finaa-intad_cc = c_finaa-intad_cc && ` ` && <fs_add>-e_mail.
CONDENSE c_finaa-intad_cc.
ENDIF.

CLEAR lv_count.

ENDLOOP.
4 REPLIES 4

SURYA_ABAP
Participant
0 Kudos
446

Hi manish.malakar0316,

Please check all in descending order where dont have data.
l_str1 l_str2 l_str3 l_str4 l_str5 l_str6 l_str7 l_str8 l_str9 l_str10,

Use replace all command.

Sandra_Rossi
Active Contributor
446

There are already some answers in the forum concerning "email address validation".

NB: better rewrite your code by using INTO TABLE (get unlimited list) rather than INTO (you have limited to 10), after SPLIT (see ABAP documentation).

Amit_Joshi
Explorer
0 Kudos
446

Hi manish

it will remove value after @

data(lv_str) = l_str1." nth

find REGEX '(.+@)' in lv_str SUBMATCHES data(lv_var).
if lv_var is not INITIAL.
data(lv_new_str) = lv_var.
ENDIF.

move lv_new_string where you want don't forget to clear values in loop.

hope it helps.

adityaIngale
Active Participant
447

Hi manish.malakar0316,

Try this.

LOOP AT lt_add ASSIGNING FIELD-SYMBOL(<fs_add>).

DATA(lv_count) = count( val = c_finaa-intad sub = <fs_add>-e_mail ).

IF lv_count NE 0.
CONTINUE.
ELSE.
c_finaa-intad_cc = c_finaa-intad_cc && ` ` && <fs_add>-e_mail.
CONDENSE c_finaa-intad_cc.
ENDIF.

CLEAR lv_count.

ENDLOOP.