Skip to Content
0
Former Member
Apr 14, 2010 at 07:32 AM

Help to understand the following code

31 Views

Hello ,

I am trying to analyze URL parameters and i found this following code and i am not sure

what it's doing (I know that this is doing some analyze on the url ) but how am not sure

what is the benefit of using the wildcard and how it's acutuliy done the analyze of the url ?

Assume that the input is :

/scarr/LH/SPFLI/*

DATA: lt_routing_tab TYPE z_resource_routing_tab,
      
  CONSTANTS: param_wildcard TYPE string VALUE '([^/])*'.
 
  FIELD-SYMBOLS: <ls_routing> LIKE LINE OF lt_routing_tab.
 
  LOOP AT lt_routing_tab ASSIGNING <ls_routing>.
*   replace all parameters placeholders by regex
    lv_verif_pattern = <ls_routing>-url_info.
    lv_signature = <ls_routing>-url_info.
    REPLACE ALL OCCURRENCES OF REGEX '\{([A-Z]*[_]*[a-z]*[0-9]*)*\}'
    IN lv_verif_pattern WITH param_wildcard.
 
    CONCATENATE '^' lv_verif_pattern '$'  INTO lv_verif_pattern.
 
*   check if pattern matches current entry
    FIND ALL OCCURRENCES OF REGEX lv_verif_pattern
    IN url_info MATCH COUNT lv_count.

This sample of code beed taken from the following link

/people/community.user/blog/2009/06/09/restful-webservices-in-abap-using-a-generic-controller

/scarr/LH/SPFLI/*

Regards

James