All files / src/ui/routing zcl_abapgit_services_abapgit.clas.abap

100% Statements 100/100
100% Branches 0/0
100% Functions 0/0
100% Lines 100/100

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 1011x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x  
CLASS zcl_abapgit_services_abapgit DEFINITION
  PUBLIC
  FINAL
  CREATE PUBLIC .
 
  PUBLIC SECTION.
 
    CONSTANTS c_abapgit_repo TYPE string VALUE 'https://github.com/abapGit/abapGit' ##NO_TEXT.
    CONSTANTS c_abapgit_homepage TYPE string VALUE 'https://www.abapgit.org' ##NO_TEXT.
    CONSTANTS c_abapgit_wikipage TYPE string VALUE 'https://docs.abapgit.org' ##NO_TEXT.
    CONSTANTS c_dotabap_homepage TYPE string VALUE 'https://dotabap.org' ##NO_TEXT.
    CONSTANTS c_changelog_path TYPE string VALUE '/blob/main/changelog.txt' ##NO_TEXT.
 
    CLASS-METHODS open_abapgit_homepage
      IMPORTING
        iv_page TYPE string OPTIONAL
      RAISING
        zcx_abapgit_exception .
    CLASS-METHODS open_abapgit_wikipage
      IMPORTING
        iv_page TYPE string OPTIONAL
      RAISING
        zcx_abapgit_exception .
    CLASS-METHODS open_dotabap_homepage
      RAISING
        zcx_abapgit_exception .
    CLASS-METHODS open_abapgit_changelog
      RAISING
        zcx_abapgit_exception .
    CLASS-METHODS get_abapgit_tcode
      RETURNING
        VALUE(rv_tcode) TYPE tcode .
  PROTECTED SECTION.
  PRIVATE SECTION.
    CLASS-METHODS open_url_in_browser
      IMPORTING
        !iv_url TYPE string
      RAISING
        zcx_abapgit_exception.
ENDCLASS.
 
 
 
CLASS zcl_abapgit_services_abapgit IMPLEMENTATION.
 
 
  METHOD get_abapgit_tcode.
    CONSTANTS lc_report_tcode_hex TYPE x VALUE '80'.
    DATA lt_tcodes TYPE STANDARD TABLE OF tcode.
 
    TRY.
        SELECT tcode
          FROM ('TSTC')
          INTO TABLE lt_tcodes
          WHERE pgmna = sy-cprog
          AND cinfo = lc_report_tcode_hex
          ORDER BY tcode.
      CATCH cx_sy_dynamic_osql_error.
* ABAP Cloud/Steampunk compatibility
        RETURN.
    ENDTRY.
 
    IF lines( lt_tcodes ) > 0.
      READ TABLE lt_tcodes INDEX 1 INTO rv_tcode.
    ENDIF.
  ENDMETHOD.
 
 
  METHOD open_abapgit_changelog.
    open_url_in_browser( |{ c_abapgit_repo }{ c_changelog_path }| ).
  ENDMETHOD.
 
 
  METHOD open_abapgit_homepage.
    open_url_in_browser( |{ c_abapgit_homepage }/{ iv_page }| ).
  ENDMETHOD.
 
 
  METHOD open_abapgit_wikipage.
    open_url_in_browser( |{ c_abapgit_wikipage }/{ iv_page }| ).
  ENDMETHOD.
 
 
  METHOD open_dotabap_homepage.
    open_url_in_browser( c_dotabap_homepage ).
  ENDMETHOD.
 
 
  METHOD open_url_in_browser.
    DATA lx_error TYPE REF TO zcx_abapgit_exception.
 
    TRY.
        zcl_abapgit_ui_factory=>get_frontend_services( )->execute( iv_document = iv_url ).
      CATCH zcx_abapgit_exception INTO lx_error.
        zcx_abapgit_exception=>raise( iv_text     = 'Opening page in external browser failed.'
                                      ix_previous = lx_error ).
    ENDTRY.
  ENDMETHOD.
 
ENDCLASS.