Guest User

function conversion_exit_zphon_input

a guest
Feb 19th, 2013
3,250
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function conversion_exit_zphon_input.
  2. *"----------------------------------------------------------------------
  3. *"*"Локальный интерфейс:
  4. *"  IMPORTING
  5. *"     VALUE(INPUT) TYPE  CLIKE
  6. *"  EXPORTING
  7. *"     VALUE(OUTPUT) TYPE  CLIKE
  8. *"----------------------------------------------------------------------
  9. *1234567890
  10. *+7(123)456-78-90
  11. *1234567890123456
  12.  
  13.   data: lv_external(16) type c.
  14.  
  15.   lv_external = input.
  16.  
  17.   replace all occurrences of '+7' in lv_external with ' '.
  18.   replace all occurrences of '-'  in lv_external with ' '.
  19.   replace all occurrences of '('  in lv_external with ' '.
  20.   replace all occurrences of ')'  in lv_external with ' '.
  21.   replace all occurrences of '_'  in lv_external with ' '.
  22.  
  23.   if lv_external cn '1234567890 '.
  24.     message 'Недопустимые знаки для номера телефона' type 'E'.
  25.   endif.
  26.  
  27.   condense lv_external no-gaps.
  28.  
  29.   if strlen( lv_external ) = 6.
  30.     concatenate '7172' lv_external into lv_external.
  31.   endif.
  32.   if strlen( lv_external ) = 7.
  33.     concatenate '727' lv_external into lv_external.
  34.   endif.
  35.  
  36.   data: lv_zero type i.
  37.   lv_zero = 10 - strlen( lv_external ).
  38.   do lv_zero times.
  39.     concatenate '0' lv_external into lv_external.
  40.   enddo.
  41.  
  42.   output = lv_external(10).
  43.  
  44. endfunction.
RAW Paste Data