FUNCTION ZUTILS_DADSU_CHECK_ORT01 .
*"----------------------------------------------------------------------
*"*"Interface locale :
*" IMPORTING
*" REFERENCE(P_ORT01) TYPE PAD_ORT01 OPTIONAL
*" EXPORTING
*" REFERENCE(P_SUCCESS) TYPE C
*" EXCEPTIONS
*" CARACTERS_NOT_ALLOWED
*" WRONG_FIRST_CARACTER
*" NO_FOLLOWING_SPACE
*" NO_CEDEX
*"----------------------------------------------------------------------
DATA : l_length TYPE i,
l_str(40) TYPE c,
l_count TYPE i,
l_first TYPE c.
" Caractères autorisés
IF NOT p_ort01 IS INITIAL.
IF p_ort01 CN 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz '.
RAISE caracters_not_allowed.
ENDIF.
l_length = STRLEN( p_ort01 ).
" Premier caractère incorrect
IF p_ort01(1) CA ' '.
RAISE wrong_first_caracter.
ENDIF.
" Les espaces ne doivent pas se suivre
CLEAR l_count.
MOVE p_ort01 TO l_str.
DO.
ADD 1 TO l_count.
IF l_count GT l_length.
EXIT.
ENDIF.
l_first = l_str(1).
SHIFT l_str BY 1 PLACES.
IF l_str(1) EQ space AND l_first EQ space.
RAISE no_following_space.
ENDIF.
ENDDO.
" Chaîne CEDEX interdite
IF p_ort01 CS 'CEDEX'.
RAISE no_cedex.
ENDIF.
ENDIF.
p_success = 'X'.
ENDFUNCTION.