Homelab, Linux, JS & ABAP (~˘▾˘)~
 

[ABAP] Parse SF Entity Key from URI

01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
METHOD get_entitykey_from_uri.
 
  " Pattern: Entity\((.*)\),
  DATA(pattern) = iv_entity && `\((.*)\)`.
 
  TRY.
      DATA(matcher) = cl_abap_matcher=>create( pattern     = pattern
                                               text        = iv_uri
                                               ignore_case = abap_true ).
    CATCH cx_sy_invalid_regex.
  ENDTRY.
 
  TRY.
      DATA(lt_matches) = matcher->find_all( ).
      ASSIGN lt_matches[ 1 ] TO FIELD-SYMBOL(<s>).
 
      rv_entity_key = substring( val = iv_uri off = <s>-offset len = <s>-length ).
 
    CATCH cx_sy_no_current_match.
  ENDTRY.
 
ENDMETHOD.

Leave a Reply

Your email address will not be published. Required fields are marked *