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

[ABAP] Parse SF Entity Key from URI

  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 *