*&---------------------------------------------------------------------*
*&  Include           ZSOFTCOPY_LINKS                                  *
*&                                                                     *
*&---------------------------------------------------------------------*
*&                                                                     *
*& This file is part of ZSOFTCOPY.                                     *
*&                                                                     *
*& ZSOFTCOPY is free software: you can redistribute it and/or modify   *
*& it under the terms of the GNU General Public License as published   *
*& by the Free Software Foundation, either version 3 of the License,   *
*& or any later version.                                               *
*&                                                                     *
*& ZSOFTCOPY is distributed in the hope that it will be useful,        *
*& but WITHOUT ANY WARRANTY; without even the implied warranty of      *
*& MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the       *
*& GNU General Public License for more details.                        *
*&                                                                     *
*& You should have received a copy of the GNU General Public License   *
*& along with ZDOWNLOAD. If not, see <http://www.gnu.org/licenses/>.   *
*&                                                                     *
*&---------------------------------------------------------------------*
*&                                                                     *
*&  Author:     Ruediger von Creytz     ruediger.creytz@globalbit.net  *
*&  Copyright:  globalBIT, LLC          http://www.globalbit.net       *
*&                                                                     *
*&---------------------------------------------------------------------*


*-----------------------------------------------------------------------
* links
*-----------------------------------------------------------------------
FORM links
  CHANGING
    ct_html TYPE it_string.

  DATA:
  l_descript TYPE as4text.

  clear g_cnt_link_leaves.

  PERFORM get_devclass
    USING
      gs_tdevc-devclass
    CHANGING
      l_descript.

  APPEND '<ul>' TO ct_html.
  PERFORM html_links_node_start
    USING
      'R3TR_DEVC'
      gs_tdevc-devclass
      gs_tdevc-devclass
      l_descript
    CHANGING
      ct_html.

  SORT gt_ztadir BY
      pgmid
      object
      obj_name
      funcname
      subc
      dynpronr
      o2pagekey.


  PERFORM links_ddic CHANGING ct_html.
  PERFORM links_seo  CHANGING ct_html.
  PERFORM links_prog CHANGING ct_html.
  PERFORM links_fugr CHANGING ct_html.
  PERFORM links_incl CHANGING ct_html.
  PERFORM links_tran CHANGING ct_html.
  PERFORM links_para CHANGING ct_html.
  PERFORM links_msag CHANGING ct_html.
  PERFORM links_tobj CHANGING ct_html.
  PERFORM links_xslt CHANGING ct_html.
  PERFORM links_bsp  CHANGING ct_html.


  PERFORM html_links_node_end CHANGING ct_html.
  APPEND '</ul>' TO ct_html.

ENDFORM.                    "links


*-----------------------------------------------------------------------
* links - BSP
*-----------------------------------------------------------------------
FORM links_bsp
  CHANGING
    ct_html TYPE it_string.

  DATA:
  l_step_a TYPE flag.

  PERFORM links_bsp_apps  CHANGING ct_html l_step_a.
  PERFORM links_bsp_tags  CHANGING ct_html l_step_a.

  IF l_step_a = abap_true.
    PERFORM html_links_node_end CHANGING ct_html.
    l_step_a = abap_false.
  ENDIF.

ENDFORM.                    "links_bsp


*-----------------------------------------------------------------------
* links - BSP - APPS
*-----------------------------------------------------------------------
FORM links_bsp_apps
  CHANGING
    ct_html TYPE it_string
    c_step_a TYPE flag.

  DATA:
  l_step_b TYPE flag,
  ls_ztadir TYPE st_ztadir,
  l_id TYPE string.

  LOOP AT gt_ztadir INTO ls_ztadir
      WHERE pgmid = 'R3TR'
      AND object = 'WAPA'
      AND o2pagekey = space.
    IF l_step_b IS INITIAL.
      l_step_b = abap_true.
      IF c_step_a = abap_false.
        c_step_a = abap_true.
        PERFORM html_links_node_start
          USING
            'bsplib'
            txt_bsp_library
            space
            space
          CHANGING
            ct_html.
      ENDIF.
      PERFORM html_links_node_start
        USING
          'R3TR_WAPA'
          txt_bsp_applications
          space
          space
        CHANGING
          ct_html.
    ENDIF.
    PERFORM get_id
      USING 'R3TR_WAPA__' ls_ztadir-obj_name
      CHANGING l_id.
    PERFORM html_links_node_start
      USING
        l_id
        ls_ztadir-o2name
        ls_ztadir-obj_name
        ls_ztadir-descript
      CHANGING
        ct_html.
    PERFORM links_bsp_appl
      USING
        ls_ztadir-obj_name
        gc_o2type_ctrl
      CHANGING
        ct_html.
    PERFORM links_bsp_appl
      USING
        ls_ztadir-obj_name
        gc_o2type_view
      CHANGING
        ct_html.
    PERFORM links_bsp_appl
      USING
        ls_ztadir-obj_name
        gc_o2type_bsp
      CHANGING
        ct_html.
    PERFORM links_bsp_appl
      USING
        ls_ztadir-obj_name
        gc_o2type_incl
      CHANGING
        ct_html.
    PERFORM links_bsp_appl
      USING
        ls_ztadir-obj_name
        gc_o2type_mime
      CHANGING
        ct_html.
    PERFORM html_links_node_end
      CHANGING
        ct_html.
  ENDLOOP.
  IF l_step_b = abap_true.
    CLEAR l_step_b.
    PERFORM html_links_node_end
      CHANGING
        ct_html.
  ENDIF.
ENDFORM.                    "links_bsp_apps


*-----------------------------------------------------------------------
* links - BSP - APPL
*-----------------------------------------------------------------------
FORM links_bsp_appl
  USING
    value(i_obj_name)
    value(i_o2type)
  CHANGING
    ct_html TYPE it_string.

  DATA:
  l_filename TYPE string,
  l_id TYPE string,
  l_type TYPE string,
  l_step_c TYPE flag,
  l_text TYPE string,
  lt_node_new TYPE it_string,
  lt_node_old TYPE it_string,
  l_subdir_cnt TYPE i,
  l_node_id TYPE string,
  l_node_id_cnt(3) TYPE n.

  FIELD-SYMBOLS:
  <ls_ztadir> TYPE st_ztadir,
  <ls_node_new> TYPE string,
  <ls_node_old> TYPE string.

  CASE i_o2type.
    WHEN gc_o2type_ctrl.
      l_type = 'ctrl'.
      l_text = txt_controller.
    WHEN gc_o2type_view.
      l_type = 'view'.
      l_text = txt_views.
    WHEN gc_o2type_bsp.
      l_type = 'bsp'.
      l_text = txt_pages_with_flow_logic.
    WHEN gc_o2type_incl.
      l_type = 'incl'.
      l_text = txt_page_fragments.
    WHEN gc_o2type_mime.
      l_type = 'mime'.
      l_text = txt_mimes.
  ENDCASE.
  PERFORM get_id
    USING l_type i_obj_name
    CHANGING l_id.
  LOOP AT gt_ztadir ASSIGNING <ls_ztadir>
      WHERE pgmid = 'R3TR'
      AND object = 'WAPA'
      AND obj_name = i_obj_name
      AND o2type = i_o2type
      AND o2pagekey <> space.
    IF l_step_c = abap_false.
      l_step_c = abap_true.
      PERFORM html_links_node_start
        USING
          l_id
          l_text
          space
          space
        CHANGING
          ct_html.
    ENDIF.
    SPLIT <ls_ztadir>-o2pagename AT '/' INTO TABLE lt_node_new.
*   close all subdirectories, that are not needed any more
    LOOP AT lt_node_old ASSIGNING <ls_node_old>.
      AT LAST.
        EXIT.
      ENDAT.
      READ TABLE lt_node_new ASSIGNING <ls_node_new>
          INDEX sy-tabix.
      IF sy-subrc <> 0 OR <ls_node_old> <> <ls_node_new>.
        PERFORM html_links_node_end CHANGING ct_html.
        l_subdir_cnt = l_subdir_cnt - 1.
      ENDIF.
    ENDLOOP.
*   create required subdirectories
    LOOP AT lt_node_new ASSIGNING <ls_node_new>.
      AT LAST.
        EXIT.
      ENDAT.
      READ TABLE lt_node_old ASSIGNING <ls_node_old>
          INDEX sy-tabix.
      IF sy-subrc <> 0 OR <ls_node_new> <> <ls_node_old>.
        ADD 1 TO l_node_id_cnt.
        CONCATENATE 'R3TR_WAPA_' l_node_id_cnt INTO l_node_id.
        PERFORM html_links_node_start
          USING
            l_node_id
            <ls_node_new>
            space
            space
          CHANGING
            ct_html.
        l_subdir_cnt = l_subdir_cnt + 1.
      ENDIF.
    ENDLOOP.
*   add leaf for mime
    CONCATENATE <ls_ztadir>-obj_name '-' l_type '/'
        <ls_ztadir>-o2pagename
        INTO l_filename.
    IF l_type = 'mime'.
      PERFORM html_links_leaf_mime
        USING
          'R3TR_WAPA'
          <ls_node_new>
          l_filename
          <ls_ztadir>-descript
        CHANGING
          ct_html.
    ELSE.
      PERFORM html_links_leaf_filename
        USING
          'R3TR_WAPA'
          l_type
          <ls_node_new>
          l_filename
          <ls_ztadir>-descript
        CHANGING
          ct_html.
    ENDIF.
    REFRESH lt_node_old.
    lt_node_old[] = lt_node_new[].
    REFRESH lt_node_new.
  ENDLOOP.
  DO l_subdir_cnt TIMES.
    PERFORM html_links_node_end CHANGING ct_html.
  ENDDO.
  IF l_step_c = abap_true.
    PERFORM html_links_node_end CHANGING ct_html.
    l_step_c = abap_false.
  ENDIF.
ENDFORM.                    "links_bsp_appl


*-----------------------------------------------------------------------
* links - BSP - TAGS
*-----------------------------------------------------------------------
FORM links_bsp_tags
  CHANGING
    ct_html TYPE it_string
    c_step_a TYPE flag.

  DATA:
  l_step_b TYPE flag,
  l_id TYPE string,
  ls_ztadir TYPE st_ztadir.

  LOOP AT gt_ztadir INTO ls_ztadir
      WHERE pgmid = 'R3TR'
      AND object = 'WTAG'
      AND o2type = space.
    IF l_step_b IS INITIAL.
      l_step_b = abap_true.
      IF c_step_a = abap_false.
        c_step_a = abap_true.
        PERFORM html_links_node_start
          USING
            'bsplib'
            txt_bsp_library
            space
            space
          CHANGING
            ct_html.
      ENDIF.
      PERFORM html_links_node_start
        USING
          'R3TR_WTAG'
          txt_bsp_extensions
          space
          space
        CHANGING
          ct_html.
    ENDIF.
    PERFORM get_id
      USING 'R3TR_WTAG__' ls_ztadir-obj_name
      CHANGING l_id.
    PERFORM html_links_node_start
      USING
        l_id
        ls_ztadir-obj_name
        ls_ztadir-obj_name
        ls_ztadir-descript
      CHANGING
        ct_html.
    PERFORM links_bsp_tag
      USING
        ls_ztadir-obj_name
      CHANGING
        ct_html.
    PERFORM html_links_node_end
      CHANGING
        ct_html.
  ENDLOOP.
  IF l_step_b = abap_true.
    CLEAR l_step_b.
    PERFORM html_links_node_end
      CHANGING
        ct_html.
  ENDIF.
ENDFORM.                    "links_bsp_tags


*-----------------------------------------------------------------------
* links - BSP - TAG
*-----------------------------------------------------------------------
FORM links_bsp_tag
  USING
    value(i_obj_name)
  CHANGING
    ct_html TYPE it_string.

  DATA:
  l_filename TYPE string,
  l_id TYPE string.

  FIELD-SYMBOLS:
  <ls_ztadir> TYPE st_ztadir.

  PERFORM get_id
    USING 'tag_' i_obj_name
    CHANGING l_id.
  LOOP AT gt_ztadir ASSIGNING <ls_ztadir>
      WHERE pgmid = 'R3TR'
      AND object = 'WTAG'
      AND obj_name = i_obj_name
      AND o2type = gc_o2type_tag.
    CONCATENATE <ls_ztadir>-obj_name '-'
        <ls_ztadir>-o2name
        INTO l_filename.
    PERFORM html_links_leaf_filename
      USING
        'R3TR_WTAG'
        ''
        <ls_ztadir>-o2name
        l_filename
        <ls_ztadir>-descript
      CHANGING
        ct_html.
  ENDLOOP.
ENDFORM.                    "links_bsp_tag


*-----------------------------------------------------------------------
* links - DDIC
*-----------------------------------------------------------------------
FORM links_ddic
  CHANGING
    ct_html TYPE it_string.

  DATA:
  l_step_a TYPE flag.

  PERFORM links_ddic_db    CHANGING ct_html l_step_a.
  PERFORM links_ddic_view  CHANGING ct_html l_step_a.
  PERFORM links_ddic_ttyp  CHANGING ct_html l_step_a.
  PERFORM links_ddic_struc CHANGING ct_html l_step_a.
  PERFORM links_ddic_dtel  CHANGING ct_html l_step_a.
  PERFORM links_ddic_doma  CHANGING ct_html l_step_a.
  PERFORM links_ddic_shlp  CHANGING ct_html l_step_a.
  PERFORM links_ddic_enqu  CHANGING ct_html l_step_a.
  PERFORM links_ddic_type  CHANGING ct_html l_step_a.

  IF l_step_a = abap_true.
    PERFORM html_links_node_end CHANGING ct_html.
    l_step_a = abap_false.
  ENDIF.

ENDFORM.                    "links_ddic


*-----------------------------------------------------------------------
* links - DDIC - DB
*-----------------------------------------------------------------------
FORM links_ddic_db
  CHANGING
    ct_html TYPE it_string
    c_step_a TYPE flag.

  DATA:
  l_step_b TYPE flag.

  FIELD-SYMBOLS:
  <ls_ztadir> TYPE st_ztadir.

  LOOP AT gt_ztadir ASSIGNING <ls_ztadir>
      WHERE pgmid = 'R3TR'
      AND object = 'TABL'
      AND ( tabclass = 'CLUSTER'
        OR tabclass = 'POOL'
        OR tabclass = 'TRANSP' ).
    IF l_step_b IS INITIAL.
      l_step_b = abap_true.
      IF c_step_a = abap_false.
        c_step_a = abap_true.
        PERFORM html_links_node_start
          USING
            'tabllib'
            txt_dict_objs
            space
            space
          CHANGING
            ct_html.
      ENDIF.
      PERFORM html_links_node_start
        USING
          'R3TR_TABL_2'
          txt_database_tables
          space
          space
        CHANGING
          ct_html.
    ENDIF.
    PERFORM html_links_leaf
      USING
        'R3TR_TABL'
        ''
        <ls_ztadir>-obj_name
        <ls_ztadir>-descript
      CHANGING
        ct_html.
  ENDLOOP.
  IF l_step_b = abap_true.
    CLEAR l_step_b.
    PERFORM html_links_node_end
      CHANGING
        ct_html.
  ENDIF.
ENDFORM.                    "links_ddic_db


*-----------------------------------------------------------------------
* links - DDIC - DOMA
*-----------------------------------------------------------------------
FORM links_ddic_doma
  CHANGING
    ct_html TYPE it_string
    c_step_a TYPE flag.

  DATA:
  l_step_b TYPE flag.

  FIELD-SYMBOLS:
  <ls_ztadir> TYPE st_ztadir.

  LOOP AT gt_ztadir ASSIGNING <ls_ztadir>
      WHERE pgmid = 'R3TR'
      AND object = 'DOMA'.
    IF l_step_b = abap_false.
      l_step_b = abap_true.
      IF c_step_a = abap_false.
        c_step_a = abap_true.
        PERFORM html_links_node_start
          USING
            'tabllib'
            txt_dict_objs
            space
            space
          CHANGING
            ct_html.
      ENDIF.
      PERFORM html_links_node_start
        USING
          'R3TR_DOMA'
          txt_domains
          space
          space
        CHANGING
          ct_html.
    ENDIF.
    PERFORM html_links_leaf
      USING
        'R3TR_DOMA'
        ''
        <ls_ztadir>-obj_name
        <ls_ztadir>-descript
      CHANGING
        ct_html.
  ENDLOOP.
  IF l_step_b = abap_true.
    l_step_b = abap_false.
    PERFORM html_links_node_end CHANGING ct_html.
  ENDIF.
ENDFORM.                    "links_ddic_doma


*-----------------------------------------------------------------------
* links - DDIC - DTEL
*-----------------------------------------------------------------------
FORM links_ddic_dtel
  CHANGING
    ct_html TYPE it_string
    c_step_a TYPE flag.

  DATA:
  l_step_b TYPE flag.

  FIELD-SYMBOLS:
  <ls_ztadir> TYPE st_ztadir.

  LOOP AT gt_ztadir ASSIGNING <ls_ztadir>
      WHERE pgmid = 'R3TR'
      AND object = 'DTEL'.
    IF l_step_b = abap_false.
      l_step_b = abap_true.
      IF c_step_a = abap_false.
        c_step_a = abap_true.
        PERFORM html_links_node_start
          USING
            'tabllib'
            txt_dict_objs
            space
            space
          CHANGING
            ct_html.
      ENDIF.
      PERFORM html_links_node_start
        USING
          'R3TR_DTEL'
          txt_data_elements
          space
          space
        CHANGING
          ct_html.
    ENDIF.
    PERFORM html_links_leaf
      USING
        'R3TR_DTEL'
        ''
        <ls_ztadir>-obj_name
        <ls_ztadir>-descript
      CHANGING
        ct_html.
  ENDLOOP.
  IF l_step_b = abap_true.
    l_step_b = abap_false.
    PERFORM html_links_node_end CHANGING ct_html.
  ENDIF.
ENDFORM.                    "links_ddic_dtel


*-----------------------------------------------------------------------
* links - DDIC - ENQU
*-----------------------------------------------------------------------
FORM links_ddic_enqu
  CHANGING
    ct_html TYPE it_string
    c_step_a TYPE flag.

  DATA:
  l_step_b TYPE flag.

  FIELD-SYMBOLS:
  <ls_ztadir> TYPE st_ztadir.

  LOOP AT gt_ztadir ASSIGNING <ls_ztadir>
      WHERE pgmid = 'R3TR'
      AND object = 'ENQU'.
    IF l_step_b = abap_false.
      l_step_b = abap_true.
      IF c_step_a = abap_false.
        c_step_a = abap_true.
        PERFORM html_links_node_start
          USING
            'tabllib'
            txt_dict_objs
            space
            space
          CHANGING
            ct_html.
      ENDIF.
      PERFORM html_links_node_start
        USING
          'R3TR_ENQU'
          txt_lock_objects
          space
          space
        CHANGING
          ct_html.
    ENDIF.
    PERFORM html_links_leaf
      USING
        'R3TR_ENQU'
        ''
        <ls_ztadir>-obj_name
        <ls_ztadir>-descript
      CHANGING
        ct_html.
  ENDLOOP.
  IF l_step_b = abap_true.
    l_step_b = abap_false.
    PERFORM html_links_node_end CHANGING ct_html.
  ENDIF.
ENDFORM.                    "links_ddic_enqu


*-----------------------------------------------------------------------
* links - DDIC - SHLP
*-----------------------------------------------------------------------
FORM links_ddic_shlp
  CHANGING
    ct_html TYPE it_string
    c_step_a TYPE flag.

  DATA:
  l_step_b TYPE flag.

  FIELD-SYMBOLS:
  <ls_ztadir> TYPE st_ztadir.

  LOOP AT gt_ztadir ASSIGNING <ls_ztadir>
      WHERE pgmid = 'R3TR'
      AND object = 'SHLP'.
    IF l_step_b = abap_false.
      l_step_b = abap_true.
      IF c_step_a = abap_false.
        c_step_a = abap_true.
        PERFORM html_links_node_start
          USING
            'tabllib'
            txt_dict_objs
            space
            space
          CHANGING
            ct_html.
      ENDIF.
      PERFORM html_links_node_start
        USING
          'R3TR_SHLP'
          txt_srch_helps
          space
          space
        CHANGING
          ct_html.
    ENDIF.
    PERFORM html_links_leaf
      USING
        'R3TR_SHLP'
        ''
        <ls_ztadir>-obj_name
        <ls_ztadir>-descript
      CHANGING
        ct_html.
  ENDLOOP.
  IF l_step_b = abap_true.
    l_step_b = abap_false.
    PERFORM html_links_node_end CHANGING ct_html.
  ENDIF.
ENDFORM.                    "links_ddic_shlp


*-----------------------------------------------------------------------
* links - DDIC - STRUC
*-----------------------------------------------------------------------
FORM links_ddic_struc
  CHANGING
    ct_html TYPE it_string
    c_step_a TYPE flag.

  DATA:
  l_step_b TYPE flag.

  FIELD-SYMBOLS:
  <ls_ztadir> TYPE st_ztadir.

  LOOP AT gt_ztadir ASSIGNING <ls_ztadir>
      WHERE pgmid = 'R3TR'
      AND object = 'TABL'
      AND ( tabclass = 'INTTAB'
        OR tabclass = 'VIEW'
        OR tabclass = 'APPEND' ).
    IF l_step_b = abap_false.
      l_step_b = abap_true.
      IF c_step_a = abap_false.
        c_step_a = abap_true.
        PERFORM html_links_node_start
          USING
            'tabllib'
            txt_dict_objs
            space
            space
          CHANGING
            ct_html.
      ENDIF.
      PERFORM html_links_node_start
        USING
          'R3TR_TABL_VIEWAPPEND'
          txt_structures
          space
          space
        CHANGING
          ct_html.
    ENDIF.
    PERFORM html_links_leaf
      USING
        'R3TR_TABL'
        'VIEWAPPEND'
        <ls_ztadir>-obj_name
        <ls_ztadir>-descript
      CHANGING
        ct_html.
  ENDLOOP.
  IF l_step_b = abap_true.
    l_step_b = abap_false.
    PERFORM html_links_node_end CHANGING ct_html.
  ENDIF.
ENDFORM.                    "links_ddic_struc


*-----------------------------------------------------------------------
* links - DDIC - TTYP
*-----------------------------------------------------------------------
FORM links_ddic_ttyp
  CHANGING
    ct_html TYPE it_string
    c_step_a TYPE flag.

  DATA:
  l_step_b TYPE flag.

  FIELD-SYMBOLS:
  <ls_ztadir> TYPE st_ztadir.

  LOOP AT gt_ztadir ASSIGNING <ls_ztadir>
      WHERE pgmid = 'R3TR'
      AND object = 'TTYP'.
    IF l_step_b = abap_false.
      l_step_b = abap_true.
      IF c_step_a = abap_false.
        c_step_a = abap_true.
        PERFORM html_links_node_start
          USING
            'tabllib'
            txt_dict_objs
            space
            space
          CHANGING
            ct_html.
      ENDIF.
      PERFORM html_links_node_start
        USING
          'R3TR_TTYP'
          txt_table_types
          space
          space
        CHANGING
          ct_html.
    ENDIF.
    PERFORM html_links_leaf
      USING
        'R3TR_TTYP'
        ''
        <ls_ztadir>-obj_name
        <ls_ztadir>-descript
      CHANGING
        ct_html.
  ENDLOOP.
  IF l_step_b = abap_true.
    l_step_b = abap_false.
    PERFORM html_links_node_end CHANGING ct_html.
  ENDIF.
ENDFORM.                    "links_ddic_ttyp


*-----------------------------------------------------------------------
* links - DDIC - TYPE
*-----------------------------------------------------------------------
FORM links_ddic_type
  CHANGING
    ct_html TYPE it_string
    c_step_a TYPE flag.

  DATA:
  l_step_b TYPE flag.

  FIELD-SYMBOLS:
  <ls_ztadir> TYPE st_ztadir.

  LOOP AT gt_ztadir ASSIGNING <ls_ztadir>
      WHERE pgmid = 'R3TR'
      AND object = 'TYPE'.
    IF l_step_b = abap_false.
      l_step_b = abap_true.
      IF c_step_a = abap_false.
        c_step_a = abap_true.
        PERFORM html_links_node_start
          USING
            'tabllib'
            txt_dict_objs
            space
            space
          CHANGING
            ct_html.
      ENDIF.
      PERFORM html_links_node_start
        USING
          'R3TR_TYPE'
          txt_type_grps
          space
          space
        CHANGING
          ct_html.
    ENDIF.
    PERFORM html_links_leaf
      USING
        'R3TR_TYPE'
        ''
        <ls_ztadir>-obj_name
        <ls_ztadir>-descript
      CHANGING
        ct_html.
  ENDLOOP.
  IF l_step_b = abap_true.
    l_step_b = abap_false.
    PERFORM html_links_node_end CHANGING ct_html.
  ENDIF.
ENDFORM.                    "links_ddic_type


*-----------------------------------------------------------------------
* links - DDIC - View
*-----------------------------------------------------------------------
FORM links_ddic_view
  CHANGING
    ct_html TYPE it_string
    c_step_a TYPE flag.

  DATA:
  l_step_b TYPE flag.

  FIELD-SYMBOLS:
  <ls_ztadir> TYPE st_ztadir.

  LOOP AT gt_ztadir ASSIGNING <ls_ztadir>
      WHERE pgmid = 'R3TR'
      AND object = 'VIEW'.
    IF l_step_b = abap_false.
      l_step_b = abap_true.
      IF c_step_a = abap_false.
        c_step_a = abap_true.
        PERFORM html_links_node_start
          USING
            'tabllib'
            txt_dict_objs
            space
            space
          CHANGING
            ct_html.
      ENDIF.
      PERFORM html_links_node_start
        USING
          'R3TR_VIEW_VIEW'
          txt_views
          space
          space
        CHANGING
          ct_html.
    ENDIF.
    PERFORM html_links_leaf
      USING
        'R3TR_VIEW'
        ''
        <ls_ztadir>-obj_name
        <ls_ztadir>-descript
      CHANGING
        ct_html.
  ENDLOOP.
  IF l_step_b = abap_true.
    l_step_b = abap_false.
    PERFORM html_links_node_end CHANGING ct_html.
  ENDIF.
ENDFORM.                    "links_ddic_view


*-----------------------------------------------------------------------
* links - FUGR
*-----------------------------------------------------------------------
FORM links_fugr
  CHANGING
    ct_html TYPE it_string.

  DATA:
  l_step_a TYPE flag,
  l_step_b TYPE flag,
  ls_ztadir TYPE st_ztadir,
  l_id TYPE string,
  l_progname TYPE progname.

  LOOP AT gt_ztadir INTO ls_ztadir
      WHERE pgmid = 'R3TR'
      AND object = 'FUGR'
      AND futype = gc_futype_group.
    IF l_step_a = abap_false.
      l_step_a = abap_true.
      PERFORM html_links_node_start
        USING
          'R3TR_FUGR'
          txt_function_groups
          space
          space
        CHANGING
          ct_html.
    ENDIF.
    PERFORM get_id
      USING 'R3TR_FUGR__' ls_ztadir-obj_name
      CHANGING l_id.
    CALL FUNCTION 'RS_TADIR_TO_PROGNAME'
      EXPORTING
        object   = ls_ztadir-object
        obj_name = ls_ztadir-obj_name
      IMPORTING
        progname = l_progname.
    PERFORM html_links_node_start
      USING
        l_id
        ls_ztadir-obj_name
        l_progname
        ls_ztadir-descript
      CHANGING
        ct_html.
***
    PERFORM links_fugr_modules
      USING ls_ztadir-obj_name
      CHANGING ct_html.
    PERFORM links_fugr_screens
      USING ls_ztadir-obj_name
      CHANGING ct_html.
    PERFORM links_fugr_includes
      USING ls_ztadir-obj_name
      CHANGING ct_html.
***
    PERFORM html_links_node_end CHANGING ct_html.
  ENDLOOP.

  IF l_step_a = abap_true.
    PERFORM html_links_node_end CHANGING ct_html.
    l_step_a = abap_false.
  ENDIF.
ENDFORM.                    "links_fugr


*-----------------------------------------------------------------------
* links - FUGR - Includes
*-----------------------------------------------------------------------
FORM links_fugr_includes
  USING
    value(i_obj_name)
  CHANGING
    ct_html TYPE it_string.

  DATA:
  l_id TYPE string,
  l_step_b TYPE flag.

  FIELD-SYMBOLS:
  <ls_ztadir> TYPE st_ztadir.

  PERFORM get_id
    USING 'fugr_incl_' i_obj_name
    CHANGING l_id.
  LOOP AT gt_ztadir ASSIGNING <ls_ztadir>
      WHERE pgmid = 'R3TR'
      AND object = 'FUGR'
      AND obj_name = i_obj_name
      AND futype = gc_futype_include.
    IF l_step_b = abap_false.
      l_step_b = abap_true.
      PERFORM html_links_node_start
        USING
          l_id
          txt_includes
          space
          space
        CHANGING
          ct_html.
    ENDIF.
    PERFORM html_links_leaf
      USING
        'R3TR_FUGR'
        'INCL'
        <ls_ztadir>-progname
        <ls_ztadir>-descript
      CHANGING
        ct_html.
  ENDLOOP.
  IF l_step_b = abap_true.
    PERFORM html_links_node_end CHANGING ct_html.
    l_step_b = abap_false.
  ENDIF.
ENDFORM.                    "links_fugr_includes


*-----------------------------------------------------------------------
* links - FUGR - Modules
*-----------------------------------------------------------------------
FORM links_fugr_modules
  USING
    value(i_obj_name)
  CHANGING
    ct_html TYPE it_string.

  DATA:
  l_id TYPE string,
  l_step_b TYPE flag.

  FIELD-SYMBOLS:
  <ls_ztadir> TYPE st_ztadir.

  PERFORM get_id
    USING 'fugr_fuba_' i_obj_name
    CHANGING l_id.
  LOOP AT gt_ztadir ASSIGNING <ls_ztadir>
      WHERE pgmid = 'R3TR'
      AND object = 'FUGR'
      AND obj_name = i_obj_name
      AND futype = gc_futype_module.
    IF l_step_b = abap_false.
      l_step_b = abap_true.

      PERFORM html_links_node_start
        USING
          l_id
          txt_function_modules
          space
          space
        CHANGING
          ct_html.
    ENDIF.
    PERFORM html_links_leaf_filename
      USING
        'R3TR_FUGR'
        'FUBA'
        <ls_ztadir>-funcname
        <ls_ztadir>-progname
        <ls_ztadir>-descript
      CHANGING
        ct_html.
  ENDLOOP.
  IF l_step_b = abap_true.
    PERFORM html_links_node_end CHANGING ct_html.
    l_step_b = abap_false.
  ENDIF.
ENDFORM.                    "links_fugr_modules


*-----------------------------------------------------------------------
* links - FUGR - Screens
*-----------------------------------------------------------------------
FORM links_fugr_screens
  USING
    value(i_obj_name)
  CHANGING
    ct_html TYPE it_string.

  DATA:
  l_filename TYPE string,
  l_id TYPE string,
  l_step_b TYPE flag.

  FIELD-SYMBOLS:
  <ls_ztadir> TYPE st_ztadir.

  PERFORM get_id
    USING 'fugr_scr_' i_obj_name
    CHANGING l_id.
  LOOP AT gt_ztadir ASSIGNING <ls_ztadir>
      WHERE pgmid = 'R3TR'
      AND object = 'FUGR'
      AND obj_name = i_obj_name
      AND futype = gc_futype_screen.
    IF l_step_b = abap_false.
      l_step_b = abap_true.
      PERFORM html_links_node_start
        USING
          l_id
          txt_screens
          space
          space
        CHANGING
          ct_html.
    ENDIF.
    CONCATENATE <ls_ztadir>-progname '-' <ls_ztadir>-dynpronr
        INTO l_filename.
    PERFORM html_links_leaf_filename
      USING
        'R3TR_FUGR'
        'SCR'
        <ls_ztadir>-dynpronr
        l_filename
        <ls_ztadir>-descript
      CHANGING
        ct_html.
  ENDLOOP.
  IF l_step_b = abap_true.
    PERFORM html_links_node_end CHANGING ct_html.
    l_step_b = abap_false.
  ENDIF.
ENDFORM.                    "links_fugr_screens


*-----------------------------------------------------------------------
* links - INCL
*-----------------------------------------------------------------------
FORM links_incl
  CHANGING
    ct_html TYPE it_string.

  DATA:
  l_step_a TYPE flag,
  l_step_b TYPE flag.

  FIELD-SYMBOLS:
  <ls_ztadir> TYPE st_ztadir.

******includes
  LOOP AT gt_ztadir ASSIGNING <ls_ztadir>
      WHERE pgmid = 'R3TR'
      AND object = 'PROG'
      AND subc = 'I'.
    IF l_step_a = abap_false.
      l_step_a = abap_true.
      PERFORM html_links_node_start
        USING
          'prog_I'
          txt_includes
          space
          space
        CHANGING
          ct_html.
    ENDIF.
    PERFORM html_links_leaf
      USING
        'R3TR_PROG'
        'INCL'
        <ls_ztadir>-obj_name
        <ls_ztadir>-descript
      CHANGING
        ct_html.
  ENDLOOP.
******
  IF l_step_a = abap_true.
    PERFORM html_links_node_end CHANGING ct_html.
    l_step_a = abap_false.
  ENDIF.
ENDFORM.                    "links_incl


*-----------------------------------------------------------------------
* links - MSAG
*-----------------------------------------------------------------------
FORM links_msag
  CHANGING
    ct_html TYPE it_string.

  DATA:
  l_step_a TYPE flag,
  l_step_b TYPE flag.

  FIELD-SYMBOLS:
  <ls_ztadir> TYPE st_ztadir.

******message classes
  LOOP AT gt_ztadir ASSIGNING <ls_ztadir>
      WHERE pgmid = 'R3TR'
      AND object = 'MSAG'.
    IF l_step_a = abap_false.
      l_step_a = abap_true.
      PERFORM html_links_node_start
        USING
          'msag'
          txt_message_classes
          space
          space
        CHANGING
          ct_html.
    ENDIF.
    PERFORM html_links_leaf
      USING
        'R3TR_MSAG'
        ''
        <ls_ztadir>-obj_name
        <ls_ztadir>-descript
      CHANGING
        ct_html.
  ENDLOOP.
******
  IF l_step_a = abap_true.
    PERFORM html_links_node_end CHANGING ct_html.
    l_step_a = abap_false.
  ENDIF.
ENDFORM.                    "links_msag


*-----------------------------------------------------------------------
* links - PARA
*-----------------------------------------------------------------------
FORM links_para
  CHANGING
    ct_html TYPE it_string.

  DATA:
  l_step_a TYPE flag,
  l_step_b TYPE flag,
  l_filename TYPE string.

  FIELD-SYMBOLS:
  <ls_ztadir> TYPE st_ztadir.

******set/get parameters
  LOOP AT gt_ztadir ASSIGNING <ls_ztadir>
      WHERE pgmid = 'R3TR'
      AND object = 'PARA'.
    IF l_step_a = abap_false.
      l_step_a = abap_true.
      PERFORM html_links_node_start
        USING
          'para'
          txt_set_get_parameters
          space
          space
        CHANGING
          ct_html.
    ENDIF.
    CONCATENATE <ls_ztadir>-obj_name '.' gc_extension_htm
      INTO l_filename.
    PERFORM encode_uri_link CHANGING l_filename.
    PERFORM replace_all
      USING '%' 'x'
      CHANGING l_filename.
    PERFORM html_links_leaf_popup
      USING
        'R3TR_PARA'
        <ls_ztadir>-obj_name
        l_filename
        <ls_ztadir>-descript
        tpt_para
      CHANGING
        ct_html.
  ENDLOOP.
******
  IF l_step_a = abap_true.
    PERFORM html_links_node_end CHANGING ct_html.
    l_step_a = abap_false.
  ENDIF.
ENDFORM.                    "links_para


*-----------------------------------------------------------------------
* links - PROG
*-----------------------------------------------------------------------
FORM links_prog
  CHANGING
    ct_html TYPE it_string.

  DATA:
  l_step_a TYPE flag,
  l_step_b TYPE flag.

  FIELD-SYMBOLS:
  <ls_ztadir> TYPE st_ztadir.

******programs
  LOOP AT gt_ztadir ASSIGNING <ls_ztadir>
      WHERE pgmid = 'R3TR'
      AND object = 'PROG'
      AND subc = '1'.
    IF l_step_a = abap_false.
      l_step_a = abap_true.
      PERFORM html_links_node_start
        USING
          'prog_1'
          txt_programs
          space
          space
        CHANGING
          ct_html.
    ENDIF.
    PERFORM html_links_leaf
      USING
        'R3TR_PROG'
        'REPO'
        <ls_ztadir>-obj_name
        <ls_ztadir>-descript
      CHANGING
        ct_html.
  ENDLOOP.
******
  IF l_step_a = abap_true.
    PERFORM html_links_node_end CHANGING ct_html.
    l_step_a = abap_false.
  ENDIF.
ENDFORM.                    "links_prog


*-----------------------------------------------------------------------
* links - SEO
*-----------------------------------------------------------------------
FORM links_seo
  CHANGING
    ct_html TYPE it_string.

  DATA:
  l_step_a TYPE flag.

  PERFORM links_seo_clas  CHANGING ct_html l_step_a.
  PERFORM links_seo_intf  CHANGING ct_html l_step_a.

  IF l_step_a = abap_true.
    PERFORM html_links_node_end CHANGING ct_html.
    l_step_a = abap_false.
  ENDIF.

ENDFORM.                    "links_seo


*-----------------------------------------------------------------------
* links - SEO - CLAS
*-----------------------------------------------------------------------
FORM links_seo_clas
  CHANGING
    ct_html TYPE it_string
    c_step_a TYPE flag.

  DATA:
  l_step_b TYPE flag.

  FIELD-SYMBOLS:
  <ls_ztadir> TYPE st_ztadir.

******classes
  LOOP AT gt_ztadir ASSIGNING <ls_ztadir>
      WHERE pgmid = 'R3TR'
      AND object = 'CLAS'.
    IF l_step_b = abap_false.
      l_step_b = abap_true.
      IF c_step_a = abap_false.
        c_step_a = abap_true.
        PERFORM html_links_node_start
          USING
            'claslib'
            txt_class_library
            space
            space
          CHANGING
            ct_html.
      ENDIF.
      PERFORM html_links_node_start
        USING
          'R3TR_CLAS'
          txt_classes
          space
          space
        CHANGING
          ct_html.
    ENDIF.
    PERFORM html_links_leaf
      USING
        'R3TR_CLAS'
        ''
        <ls_ztadir>-obj_name
        <ls_ztadir>-descript
      CHANGING
        ct_html.
  ENDLOOP.
  IF l_step_b = abap_true.
    l_step_b = abap_false.
    PERFORM html_links_node_end
      CHANGING
        ct_html.
  ENDIF.
ENDFORM.                    "links_seo_clas


*-----------------------------------------------------------------------
* links - SEO - INTF
*-----------------------------------------------------------------------
FORM links_seo_intf
  CHANGING
    ct_html TYPE it_string
    c_step_a TYPE flag.

  DATA:
  l_step_b TYPE flag.

  FIELD-SYMBOLS:
  <ls_ztadir> TYPE st_ztadir.

  LOOP AT gt_ztadir ASSIGNING <ls_ztadir>
      WHERE pgmid = 'R3TR'
      AND object = 'INTF'.
    IF l_step_b = abap_false.
      l_step_b = abap_true.
      IF c_step_a = abap_false.
        c_step_a = abap_true.
        PERFORM html_links_node_start
          USING
            'claslib'
            txt_class_library
            space
            space
          CHANGING
            ct_html.
      ENDIF.
      PERFORM html_links_node_start
        USING
          'R3TR_INTF'
          txt_interfaces
          space
          space
        CHANGING
          ct_html.
    ENDIF.
    PERFORM html_links_leaf
      USING
        'R3TR_INTF'
        ''
        <ls_ztadir>-obj_name
        <ls_ztadir>-descript
      CHANGING
        ct_html.
  ENDLOOP.
  IF l_step_b = abap_true.
    l_step_b = abap_false.
    PERFORM html_links_node_end CHANGING ct_html.
  ENDIF.
ENDFORM.                    "links_seo


*-----------------------------------------------------------------------
* links - TOBJ
*-----------------------------------------------------------------------
FORM links_tobj
  CHANGING
    ct_html TYPE it_string.

  DATA:
  l_step_a TYPE flag,
  l_step_b TYPE flag.

  FIELD-SYMBOLS:
  <ls_ztadir> TYPE st_ztadir.

******authorization objects
  LOOP AT gt_ztadir ASSIGNING <ls_ztadir>
      WHERE pgmid = 'R3TR'
      AND object = 'SUSO'.
    IF l_step_a = abap_false.
      l_step_a = abap_true.
      PERFORM html_links_node_start
        USING
          'suso'
          txt_authorization_object___2
          space
          space
        CHANGING
          ct_html.
    ENDIF.
    PERFORM html_links_leaf
      USING
        'R3TR_SUSO'
        ''
        <ls_ztadir>-obj_name
        <ls_ztadir>-descript
      CHANGING
        ct_html.
  ENDLOOP.
******
  IF l_step_a = abap_true.
    PERFORM html_links_node_end CHANGING ct_html.
    l_step_a = abap_false.
  ENDIF.
ENDFORM.                    "links_tobj


*-----------------------------------------------------------------------
* links - TRAN
*-----------------------------------------------------------------------
FORM links_tran
  CHANGING
    ct_html TYPE it_string.

  DATA:
  l_cinfo TYPE syhex01,
  l_def_call_tcode TYPE tcode,
  l_length TYPE i,
  l_off TYPE i,
  l_param TYPE tcdparam,
  l_step_a TYPE flag,
  l_step_b TYPE flag,
  l_tcode TYPE tcode,
  l_ttype TYPE c.

  CONSTANTS:
  lc_hex_tra TYPE x VALUE '00',               " Transaktion         T
  lc_hex_men TYPE x VALUE '01',               " Bereichsmenue       M
  lc_hex_par TYPE x VALUE '02',               " Parametertrans.     P
  lc_hex_rep TYPE x VALUE '80',               " Report              R
  lc_hex_rpv TYPE x VALUE '10',               " Report  mit Variante
  lc_hex_obj TYPE x VALUE '08',               " Objekttransaktionen
  lc_hex_chk TYPE x VALUE '04',               " mit Pruefobjekt
  lc_oo_tcode LIKE tstc-tcode VALUE 'OS_APPLICATION'.

  FIELD-SYMBOLS:
  <ls_ztadir> TYPE st_ztadir.

******transactions
  LOOP AT gt_ztadir ASSIGNING <ls_ztadir>
      WHERE pgmid = 'R3TR'
      AND object = 'TRAN'.

    l_tcode = <ls_ztadir>-obj_name.
    SELECT SINGLE cinfo FROM tstc INTO l_cinfo
        WHERE tcode = l_tcode.
    SELECT SINGLE param FROM tstcp INTO l_param
        WHERE tcode = l_tcode.

    CASE l_param(1).
      WHEN '@'.
        l_off = 1.
        IF l_param(2) = '@@'.
          l_off = 2.
        ENDIF.
        IF l_param CA space. ENDIF.
        l_length = sy-fdpos - l_off.
        l_def_call_tcode = l_param+l_off(l_length).
      WHEN '/'.
        IF l_param CA space. ENDIF.
        l_length = sy-fdpos.
        IF l_length > 2.
          SUBTRACT 2 FROM l_length.
          l_def_call_tcode = l_param+2(l_length).
        ENDIF.
    ENDCASE.

    IF l_cinfo O lc_hex_rep.                 "report transaction
      l_ttype = gc_tcode_report.
    ELSEIF l_cinfo O lc_hex_obj.             "object transaction
      l_ttype = gc_tcode_object.
    ELSEIF l_cinfo O lc_hex_par.             "parameter transaction
      l_ttype = gc_tcode_parameter.
      IF NOT l_param IS INITIAL
      AND l_param(1) = '@'.                  "variant transaction
        l_ttype = gc_tcode_variant.
      ELSEIF l_def_call_tcode = lc_oo_tcode. "object transaction
        l_ttype = gc_tcode_object.
      ENDIF.
    ELSEIF l_cinfo O lc_hex_men.             "menue
    ELSE.                                    "dialog transaction
      l_ttype = gc_tcode_dialog.
    ENDIF.

    IF l_step_a = abap_false.
      l_step_a = abap_true.
      PERFORM html_links_node_start
        USING
          'tran'
          txt_transactions
          space
          space
        CHANGING
          ct_html.
    ENDIF.
    PERFORM html_links_leaf
      USING
        'R3TR_TRAN'
        l_ttype
        <ls_ztadir>-obj_name
        <ls_ztadir>-descript
      CHANGING
        ct_html.
  ENDLOOP.
******
  IF l_step_a = abap_true.
    PERFORM html_links_node_end CHANGING ct_html.
    l_step_a = abap_false.
  ENDIF.
ENDFORM.                    "links_tran


*-----------------------------------------------------------------------
* links - XSLT
*-----------------------------------------------------------------------
FORM links_xslt
  CHANGING
    ct_html TYPE it_string.

  DATA:
  l_step_a TYPE flag,
  l_step_b TYPE flag.

  FIELD-SYMBOLS:
  <ls_ztadir> TYPE st_ztadir.
******transformations
  LOOP AT gt_ztadir ASSIGNING <ls_ztadir>
      WHERE pgmid = 'R3TR'
      AND object = 'XSLT'.
    IF l_step_a = abap_false.
      l_step_a = abap_true.
      PERFORM html_links_node_start
        USING
          'xslt'
          txt_transformations
          space
          space
        CHANGING
          ct_html.
    ENDIF.
    PERFORM html_links_leaf
      USING
        'R3TR_XSLT'
        ''
        <ls_ztadir>-obj_name
        <ls_ztadir>-descript
      CHANGING
        ct_html.
  ENDLOOP.
******
  IF l_step_a = abap_true.
    PERFORM html_links_node_end CHANGING ct_html.
    l_step_a = abap_false.
  ENDIF.
ENDFORM.                    "links_xslt
