Skip to content

Instantly share code, notes, and snippets.

@qmacro
Created September 21, 2009 16:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save qmacro/190363 to your computer and use it in GitHub Desktop.
Save qmacro/190363 to your computer and use it in GitHub Desktop.
method DERIVE_HANDLER.
* Loops through the patterns trying to find a match on the URL's path info
* If it finds one, it returns the corresponding handler class name, plus
* an optional list of matched strings from parentheses in the pattern
data:
l_path type char255
, ls_handler type ty_handler
, lt_match type match_result_tab
, ls_match type match_result
, ls_submatch type submatch_result
.
field-symbols: <submatch> type any.
loop at handlers into ls_handler.
find regex ls_handler-pattern in path results lt_match.
if sy-subrc = 0.
class = ls_handler-handler.
read table lt_match into ls_match index 1.
l_path = path.
loop at ls_match-submatches into ls_submatch.
assign l_path+ls_submatch-offset(ls_submatch-length) to <submatch>.
append <submatch> to matches.
endloop.
exit.
endif.
endloop.
endmethod.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment