SHARE
TWEET

ZSA_REGEX_FIND

a guest Apr 23rd, 2011 1,028 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. *&---------------------------------------------------------------------*
  2. *& Report  ZSA_REGEX_FIND
  3. *&
  4. *&---------------------------------------------------------------------*
  5. *& Тест поиска строк с использованием регулярных выражений
  6. *&
  7. *&---------------------------------------------------------------------*
  8.  
  9. REPORT  zsa_regex_find.
  10.  
  11. DATA: lt_result_tab TYPE match_result_tab.
  12. DATA: ls_result_tab TYPE LINE OF match_result_tab.
  13.  
  14. DATA: ls_submatches     TYPE LINE OF submatch_result_tab.
  15. DATA: lv_test(255) TYPE c.
  16. lv_test = ':86:Операция:Платеж,БИК:12345678,Счет:987654321,Контрагент:ТОО ТЕСТ,РНН:120100000001,Выплата за XYZ   /KNP/1719311 /BCLASS/'.
  17.  
  18. DATA lv_name1 LIKE lfa1-name1.
  19. DATA lv_stcd1 LIKE lfa1-stcd1.
  20. DATA lv_sgtxt LIKE bseg-sgtxt.
  21.  
  22. FIND ALL OCCURRENCES OF REGEX `.*Контрагент:(.*),РНН:(\d*),(.*)/KNP/.*`
  23.      IN lv_test
  24.      RESULTS lt_result_tab.
  25. IF LINES( lt_result_tab ) = 1.
  26.   READ TABLE lt_result_tab INDEX 1 INTO ls_result_tab.
  27.   IF LINES( ls_result_tab-submatches ) = 3.
  28.     READ TABLE ls_result_tab-submatches INDEX 1 INTO ls_submatches.
  29.     lv_name1 = lv_test+ls_submatches-offset(ls_submatches-length).
  30.  
  31.     READ TABLE ls_result_tab-submatches INDEX 2 INTO ls_submatches.
  32.     lv_stcd1 = lv_test+ls_submatches-offset(ls_submatches-length).
  33.  
  34.     READ TABLE ls_result_tab-submatches INDEX 3 INTO ls_submatches.
  35.     lv_sgtxt = lv_test+ls_submatches-offset(ls_submatches-length).
  36.   ENDIF.
  37. ENDIF.
  38.  
  39. WRITE: / 'lv_name1 =', lv_name1.
  40. WRITE: / 'lv_stcd1 =', lv_stcd1.
  41. WRITE: / 'lv_sgtxt =', lv_sgtxt.
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top