Prüfung einer Email auf syntaktische Korrektheit aus SAP in ABAP:
function check_email_syntax.
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*" IMPORTING
*" REFERENCE(IV_EMAIL_ADR) TYPE AD_SMTPADR
*" EXPORTING
*" REFERENCE(EV_VALID) TYPE XFELD
*"----------------------------------------------------------------------
data lv_offset type i.
data lv_length type i.
ev_valid = 'X'.
* Checks if the eMail address is syntactically correct
find first occurrence of regex '\w+([-+.]\w+)*@(\w+[-+.])*\w+\w+[-+.]\w+\w+'
in iv_email_adr match offset lv_offset match length lv_length.
if not ( sy-subrc = 0 and
lv_offset = 0 and lv_length = strlen( iv_email_adr ) ).
clear ev_valid.
endif.
endfunction.
Anmerkung: Die regex ist in ABAP nicht ganz korrekt, da das "w" nicht nur Buchstaben, sondern auch gewisse Sonderzeichen "durchlässt". Hier muss eine Anpassung vorgenommen werden, z.B. :xdigit statt w.
Friday, June 10, 2011
Monday, January 3, 2011
Eigene F4-Hilfen auf Selektions-Screens
...
PARAMETER p_matnr type matnr.
...
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_matnr.
PERFORM matnr_f4.
...
FORM matnr_f4.
* Aktuelle Dynpro-Inhalte auslesen
lv_dyname = sy-cprog.
lv_dynumb = sy-dynnr.
CALL FUNCTION 'DYNP_VALUES_READ'
EXPORTING
dyname = lv_dyname
dynumb = lv_dynumb
translate_to_upper = 'X'
TABLES
dynpfields = lt_user_sel_fields
EXCEPTIONS
OTHERS.
...
* F4-Hilfe im Popup darstellen
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'NAME'
window_title = 'Eigene F4-Hilfe'
value_org = 'S'
TABLES
value_tab = lt_value_tab
field_tab = lt_field_tab
return_tab = lt_return_tab
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
IF sy-subrc <> 0.
EXIT.
ENDIF.
* Ausgewählten Wert ermitteln und Feld befüllen
READ TABLE lt_return_tab INDEX 1.
IF sy-subrc = 0.
p_matnr = lt_return_tab-fieldval.
ENDIF.
ENDFORM.
PARAMETER p_matnr type matnr.
...
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_matnr.
PERFORM matnr_f4.
...
FORM matnr_f4.
* Aktuelle Dynpro-Inhalte auslesen
lv_dyname = sy-cprog.
lv_dynumb = sy-dynnr.
CALL FUNCTION 'DYNP_VALUES_READ'
EXPORTING
dyname = lv_dyname
dynumb = lv_dynumb
translate_to_upper = 'X'
TABLES
dynpfields = lt_user_sel_fields
EXCEPTIONS
OTHERS.
...
* F4-Hilfe im Popup darstellen
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'NAME'
window_title = 'Eigene F4-Hilfe'
value_org = 'S'
TABLES
value_tab = lt_value_tab
field_tab = lt_field_tab
return_tab = lt_return_tab
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
IF sy-subrc <> 0.
EXIT.
ENDIF.
* Ausgewählten Wert ermitteln und Feld befüllen
READ TABLE lt_return_tab INDEX 1.
IF sy-subrc = 0.
p_matnr = lt_return_tab-fieldval.
ENDIF.
ENDFORM.
Subscribe to:
Posts (Atom)
SAP ABAP: Determine Timezone for Plant
DATA: lt_tzone TYPE STANDARD TABLE OF tznzone WITH DEFAULT KEY, l_tzone TYPE tznzone. " get time zone for plant ...
-
Sometimes the backend doesn't return the selected rows of an SALV. For my case get_metadata( ) was the solution: go_salv-> get_met...
-
GUIDs or UUIDs can be created with the class cl_system_uuid . try . data (lv_uuid) = cl_system_uuid => if_system_uuid_static...
-
AA PR-AUF(E) Prozessauftrag (eröffnet) AB PR-AUF(F) Prozessauftrag (freigegeben) AC FE...