*&---------------------------------------------------------------------*
*&  Include           ZSOFTCOPY_SELECT                                 *
*&                                                                     *
*&---------------------------------------------------------------------*
*&                                                                     *
*& 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       *
*&                                                                     *
*&---------------------------------------------------------------------*


*-----------------------------------------------------------------------
* select
*-----------------------------------------------------------------------
FORM select.

  DATA:
  lt_tadir TYPE STANDARD TABLE OF tadir.

  SELECT * FROM tadir INTO TABLE lt_tadir
      WHERE devclass = g_pack.

  PERFORM select_obj TABLES lt_tadir.

  DESCRIBE TABLE gt_ztadir LINES g_cnt_elems.

ENDFORM.                    "select


*-----------------------------------------------------------------------
* select_obj
*-----------------------------------------------------------------------
FORM select_obj
  TABLES
    tt_tadir STRUCTURE tadir.

  DATA:
  l_where TYPE string,
  ls_ztadir TYPE st_ztadir,
  l_last_pgmid TYPE pgmid,
  l_last_object TYPE trobjtype.

  FIELD-SYMBOLS:
  <ls_tadir> TYPE tadir.


  SORT tt_tadir BY pgmid object.

  LOOP AT tt_tadir ASSIGNING <ls_tadir>.
    CLEAR ls_ztadir.
    MOVE-CORRESPONDING <ls_tadir> TO ls_ztadir.

    CASE <ls_tadir>-pgmid.
      WHEN 'R3TR'.
        CASE <ls_tadir>-object.
          WHEN 'CLAS'.  PERFORM select_seoclass   CHANGING ls_ztadir.
          WHEN 'DOMA'.  PERFORM select_dd01       CHANGING ls_ztadir.
          WHEN 'DTEL'.  PERFORM select_dd04       CHANGING ls_ztadir.
          WHEN 'ENQU'.  PERFORM select_dd25       CHANGING ls_ztadir.
          WHEN 'FUGR'.  PERFORM select_fdir       CHANGING ls_ztadir.
          WHEN 'INTF'.  PERFORM select_seoclass   CHANGING ls_ztadir.
          WHEN 'MSAG'.  PERFORM select_t100       CHANGING ls_ztadir.
          WHEN 'PARA'.  PERFORM select_tpara      CHANGING ls_ztadir.
          WHEN 'PROG'.  PERFORM select_trdir      CHANGING ls_ztadir.
          WHEN 'SHLP'.  PERFORM select_dd30       CHANGING ls_ztadir.
          WHEN 'SUSO'.  PERFORM select_tobj       CHANGING ls_ztadir.
          WHEN 'TABL'.  PERFORM select_dd02       CHANGING ls_ztadir.
          WHEN 'TRAN'.  PERFORM select_tstc       CHANGING ls_ztadir.
          WHEN 'TTYP'.  PERFORM select_dd40       CHANGING ls_ztadir.
          WHEN 'TYPE'.  PERFORM select_ddtypet    CHANGING ls_ztadir.
          WHEN 'VIEW'.  PERFORM select_dd25       CHANGING ls_ztadir.
          WHEN 'WAPA'.  PERFORM select_o2_appl    CHANGING ls_ztadir.
          WHEN 'WTAG'.  PERFORM select_o2_taglib  CHANGING ls_ztadir.
          WHEN 'XSLT'.  PERFORM select_o2_xslt    CHANGING ls_ztadir.
          WHEN OTHERS.  ls_ztadir-subrc = gc_subrc_not_found.
        ENDCASE.
      WHEN OTHERS.
        ls_ztadir-subrc = gc_subrc_not_found.
    ENDCASE.

    IF ls_ztadir-subrc = 0.
      APPEND ls_ztadir TO gt_ztadir.
    ENDIF.
  ENDLOOP.

  SORT gt_ztadir BY obj_name.

ENDFORM.                    "selectObj


*-----------------------------------------------------------------------
* select_dd01                                    Domaenen
*-----------------------------------------------------------------------
FORM select_dd01
  CHANGING
    cs_ztadir TYPE st_ztadir.

  DATA:
  l_ddtext TYPE as4text,
  l_domname TYPE domname.

  IF g_add_elem_doma = abap_false.
    cs_ztadir-subrc = gc_subrc_deselected.
  ELSE.
    SELECT SINGLE ddtext FROM dd01t INTO l_ddtext
        WHERE domname = cs_ztadir-obj_name
        AND ddlanguage = sy-langu
        AND as4local = 'A'.
    IF sy-subrc = 0.
      cs_ztadir-descript = l_ddtext.
    ELSE.
      SELECT SINGLE domname FROM dd01l INTO l_domname
          WHERE domname = cs_ztadir-obj_name
          AND as4local = 'A'.
      IF sy-subrc = 0.
        cs_ztadir-obj_name = l_domname.
      ELSE.
        cs_ztadir-subrc = gc_subrc_not_found.
      ENDIF.
    ENDIF.
  ENDIF.
ENDFORM.                    "select_dd01


*-----------------------------------------------------------------------
* select_dd02                                    SAP-Tabellen
*-----------------------------------------------------------------------
FORM select_dd02
  CHANGING
    cs_ztadir TYPE st_ztadir.

  DATA:
  l_ddtext TYPE as4text,
  l_tabname TYPE tabname.


  l_tabname = cs_ztadir-obj_name.
  SELECT SINGLE tabclass FROM dd02l INTO cs_ztadir-tabclass
      WHERE tabname = l_tabname
      AND as4local = 'A'.
  IF sy-subrc = 0.
    IF ( cs_ztadir-tabclass = 'INTTAB'
      OR cs_ztadir-tabclass = 'VIEW'
      OR cs_ztadir-tabclass = 'APPEND' )
    AND g_add_elem_struc = abap_false.
      cs_ztadir-subrc = gc_subrc_deselected.
    ELSEIF ( cs_ztadir-tabclass = 'CLUSTER'
      OR cs_ztadir-tabclass = 'POOL'
      OR cs_ztadir-tabclass = 'TRANSP' )
    AND g_add_elem_tabl = abap_false.
      cs_ztadir-subrc = gc_subrc_deselected.
    ELSE.
      SELECT SINGLE ddtext FROM dd02t INTO l_ddtext
          WHERE tabname = l_tabname
          AND ddlanguage = sy-langu
          AND as4local = 'A'.
      IF sy-subrc = 0.
        cs_ztadir-descript = l_ddtext.
      ENDIF.
    ENDIF.
  ELSE.
    cs_ztadir-subrc = gc_subrc_not_found.
  ENDIF.
ENDFORM.                    "select_dd02


*-----------------------------------------------------------------------
* select_dd04                                    Datenelemente
*-----------------------------------------------------------------------
FORM select_dd04
  CHANGING
    cs_ztadir TYPE st_ztadir.

  DATA:
  l_ddtext TYPE as4text,
  l_rollname TYPE rollname.

  IF g_add_elem_dtel = abap_false.
    cs_ztadir-subrc = gc_subrc_deselected.
  ELSE.
    l_rollname = cs_ztadir-obj_name.
    SELECT SINGLE ddtext FROM dd04t INTO l_ddtext
        WHERE rollname = l_rollname
        AND ddlanguage = sy-langu
        AND as4local = 'A'.
    IF sy-subrc = 0.
      cs_ztadir-descript = l_ddtext.
    ELSE.
      SELECT SINGLE rollname FROM dd04l INTO l_rollname
          WHERE rollname = l_rollname
          AND as4local = 'A'.
      IF sy-subrc <> 0.
        cs_ztadir-subrc = gc_subrc_not_found.
      ENDIF.
    ENDIF.
  ENDIF.
ENDFORM.                    "select_dd04


*-----------------------------------------------------------------------
* links_dd25                                     Aggregat-Header
*                               (Views, Matchcode-Objekte, Sperrobjekte)
*-----------------------------------------------------------------------
FORM select_dd25
  CHANGING
    cs_ztadir TYPE st_ztadir.

  DATA:
  l_ddtext TYPE ddtext,
  l_viewname TYPE viewname.

  IF ( cs_ztadir-object = 'ENQU' AND g_add_elem_enqu = abap_false )
  OR ( cs_ztadir-object = 'VIEW' AND g_add_elem_view = abap_false ).
    cs_ztadir-subrc = gc_subrc_deselected.
  ELSE.
    l_viewname = cs_ztadir-obj_name.
    SELECT SINGLE aggtype FROM dd25l INTO cs_ztadir-aggtype
        WHERE viewname = l_viewname
        AND as4local = 'A'.
    IF sy-subrc = 0.
      SELECT SINGLE ddtext FROM dd25t INTO l_ddtext
          WHERE viewname = l_viewname
          AND ddlanguage = sy-langu
          AND as4local = 'A'.
      IF sy-subrc = 0.
        cs_ztadir-descript = l_ddtext.
      ENDIF.
    ELSE.
      cs_ztadir-subrc = gc_subrc_not_found.
    ENDIF.
  ENDIF.
ENDFORM.                    "select_dd25


*-----------------------------------------------------------------------
* select_dd30                                    Suchhilfen
*-----------------------------------------------------------------------
FORM select_dd30
  CHANGING
    cs_ztadir TYPE st_ztadir.

  DATA:
  l_ddtext TYPE ddtext,
  l_shlpname TYPE shlpname.

  IF g_add_elem_shlp = abap_false.
    cs_ztadir-subrc = gc_subrc_deselected.
  ELSE.
    l_shlpname = cs_ztadir-obj_name.
    SELECT SINGLE ddtext FROM dd30t INTO l_ddtext
        WHERE shlpname = l_shlpname
        AND ddlanguage = sy-langu
        AND as4local = 'A'.
    IF sy-subrc = 0.
      cs_ztadir-descript = l_ddtext.
    ELSE.
      SELECT SINGLE shlpname FROM dd30l INTO l_shlpname
          WHERE shlpname = l_shlpname
          AND as4local = 'A'.
      IF sy-subrc <> 0.
        cs_ztadir-subrc = gc_subrc_not_found.
      ENDIF.
    ENDIF.
  ENDIF.
ENDFORM.                    "select_dd30


*-----------------------------------------------------------------------
* links_dd40                                     Tabellentypen
*                                    (im DD definierte interne Tabellen)
*-----------------------------------------------------------------------
FORM select_dd40
  CHANGING
    cs_ztadir TYPE st_ztadir.

  DATA:
  l_ddtext TYPE ddtext,
  l_typename TYPE typename.

  IF g_add_elem_ttyp = abap_false.
    cs_ztadir-subrc = gc_subrc_deselected.
  ELSE.
    l_typename = cs_ztadir-obj_name.
    SELECT SINGLE ddtext FROM dd40t INTO l_ddtext
        WHERE typename = l_typename
        AND ddlanguage = sy-langu
        AND as4local = 'A'.
    IF sy-subrc = 0.
      cs_ztadir-descript = l_ddtext.
    ELSE.
      SELECT SINGLE typename FROM dd40l INTO l_typename
          WHERE typename = l_typename
          AND as4local = 'A'.
      IF sy-subrc <> 0.
        cs_ztadir-subrc = gc_subrc_not_found.
      ENDIF.
    ENDIF.
  ENDIF.
ENDFORM.                    "select_dd40


*-----------------------------------------------------------------------
* select_ddtypet                                 Texte zu Typgruppen
*-----------------------------------------------------------------------
FORM select_ddtypet
  CHANGING
    cs_ztadir TYPE st_ztadir.

  DATA:
  l_ddtext TYPE ddtext,
  l_typegroup TYPE typegroup.

  IF g_add_elem_type = abap_false.
    cs_ztadir-subrc = gc_subrc_deselected.
  ELSE.
    l_typegroup = cs_ztadir-obj_name.
    SELECT SINGLE ddtext FROM ddtypet INTO l_ddtext
        WHERE typegroup = l_typegroup
        AND ddlanguage = sy-langu.
    IF sy-subrc = 0.
      cs_ztadir-descript = l_ddtext.
    ELSE.
      cs_ztadir-subrc = gc_subrc_not_found.
    ENDIF.
  ENDIF.
ENDFORM.                    "select_ddtypet


*-----------------------------------------------------------------------
* select_fdir                                    Funktionsgruppen
*-----------------------------------------------------------------------
FORM select_fdir
  CHANGING
    cs_ztadir TYPE st_ztadir.

  DATA:
  ls_ztadir TYPE st_ztadir,
  lt_ztadir TYPE it_ztadir,
  lt_fdir TYPE STANDARD TABLE OF v_fdir,
  l_progname TYPE progname,
  lt_incl TYPE STANDARD TABLE OF progname,
  l_incl TYPE progname,
  l_group TYPE area,
  l_include_number TYPE includenr,
  lt_d020s TYPE STANDARD TABLE OF d020s,
  l_area TYPE rs38l_area,
  l_areat TYPE areat,
  l_stext TYPE rs38l_ftxt,
  l_dtxt TYPE as4text,
  l_text TYPE repti.

  FIELD-SYMBOLS:
  <ls_fdir> TYPE v_fdir,
  <ls_d020s> TYPE d020s.

  l_area = cs_ztadir-obj_name.

* Function Group
  IF g_add_elem_fugr = abap_false.
    cs_ztadir-subrc = gc_subrc_deselected.
  ELSE.
    cs_ztadir-futype = gc_futype_group.
    SELECT SINGLE areat FROM tlibt INTO l_areat
      WHERE area = l_area
      AND spras = sy-langu.
    IF sy-subrc = 0.
      cs_ztadir-descript = l_areat.
    ELSE.
      SELECT SINGLE area FROM tlibg INTO l_area
        WHERE area = l_area.
      IF sy-subrc <> 0.
        cs_ztadir-subrc = gc_subrc_not_found.
        CHECK sy-subrc = 0.
      ENDIF.
    ENDIF.
    CALL FUNCTION 'RS_TADIR_TO_PROGNAME'
      EXPORTING
        object   = cs_ztadir-object
        obj_name = cs_ztadir-obj_name
      IMPORTING
        progname = l_progname.
  ENDIF.

* Function Modules
  IF g_add_elem_fuba = abap_true
  OR g_add_elem_fuincl = abap_true.
    SELECT * FROM v_fdir INTO TABLE lt_fdir
        WHERE area = l_area
        AND active = abap_true.
    LOOP AT lt_fdir ASSIGNING <ls_fdir>.
      CLEAR ls_ztadir.
      MOVE-CORRESPONDING cs_ztadir TO ls_ztadir.
      CLEAR ls_ztadir-descript.
      ls_ztadir-futype = gc_futype_module.
      ls_ztadir-funcname = <ls_fdir>-funcname.
      IF NOT <ls_fdir>-masterlang IS INITIAL.
        ls_ztadir-masterlang = <ls_fdir>-masterlang.
      ENDIF.
      SELECT SINGLE stext FROM tftit INTO l_stext
        WHERE funcname = <ls_fdir>-funcname
        AND spras = sy-langu.
      IF sy-subrc = 0.
        ls_ztadir-descript = l_stext.
      ENDIF.
      CALL FUNCTION 'FUNCTION_INCLUDE_CONCATENATE'
        EXPORTING
          include_number = <ls_fdir>-include
        IMPORTING
          include        = ls_ztadir-progname
        CHANGING
          group          = <ls_fdir>-area.
      APPEND ls_ztadir TO lt_ztadir.
      IF g_add_elem_fuba = abap_true.
        APPEND ls_ztadir TO gt_ztadir.
      ENDIF.
    ENDLOOP.
  ENDIF.

* Screens
  IF g_add_elem_scr = abap_true.
    SELECT * FROM d020s INTO TABLE lt_d020s
      WHERE prog = l_progname.
    LOOP AT lt_d020s ASSIGNING <ls_d020s>.
      CLEAR ls_ztadir.
      MOVE-CORRESPONDING cs_ztadir TO ls_ztadir.
      CLEAR ls_ztadir-descript.
      SELECT SINGLE dtxt FROM d020t INTO l_dtxt
        WHERE prog = l_progname
        AND dynr = <ls_d020s>-dnum
        AND lang = sy-langu.
      IF sy-subrc = 0.
        ls_ztadir-descript = l_dtxt.
      ENDIF.
      ls_ztadir-futype = gc_futype_screen.
      ls_ztadir-progname = l_progname.
      ls_ztadir-dynpronr = <ls_d020s>-dnum.
      ls_ztadir-masterlang = <ls_d020s>-spra.
      APPEND ls_ztadir TO gt_ztadir.
    ENDLOOP.
  ENDIF.

* Includes
  IF g_add_elem_fuincl = abap_true.
    CALL FUNCTION 'GET_INCLUDETAB'
      EXPORTING
        progname = l_progname
      TABLES
        incltab  = lt_incl.
    SORT lt_incl.
    LOOP AT lt_incl INTO l_incl.
      l_progname = l_incl.
      CALL FUNCTION 'FUNCTION_INCLUDE_SPLIT'
        IMPORTING
          group          = l_group
          include_number = l_include_number
        CHANGING
          include        = l_progname.
*     check if include is a function module
      READ TABLE lt_ztadir TRANSPORTING NO FIELDS
        WITH KEY progname = l_progname.
      IF sy-subrc = 0.
        CONTINUE.      "include is a function module
      ENDIF.
      IF l_group = cs_ztadir-obj_name
      AND NOT l_include_number IS INITIAL.
        CONTINUE.
      ENDIF.
      CLEAR ls_ztadir.
      MOVE-CORRESPONDING cs_ztadir TO ls_ztadir.
      CLEAR ls_ztadir-descript.
      SELECT SINGLE text FROM trdirt INTO l_text
          WHERE name = l_incl
          AND sprsl = sy-langu.
      IF sy-subrc = 0.
        ls_ztadir-descript = l_text.
      ENDIF.
      ls_ztadir-futype = gc_futype_include.
      ls_ztadir-funcname = l_incl.
      ls_ztadir-progname = l_incl.
      CALL FUNCTION 'RS_PROGRAM_GET_DEVCLASS'
        EXPORTING
          progname = ls_ztadir-progname
        IMPORTING
          devclass = ls_ztadir-devclass.
      APPEND ls_ztadir TO gt_ztadir.
    ENDLOOP.
  ENDIF.
ENDFORM.                    "select_fdir


*-----------------------------------------------------------------------
* select_O2_appl                                 BSP Applications
*-----------------------------------------------------------------------
FORM select_o2_appl
  CHANGING
    cs_ztadir TYPE st_ztadir.

  DATA:
  l_text TYPE as4text,
  l_applname(30) TYPE c,
  l_applext(30) TYPE c,
  l_descript(60) TYPE c,
  ls_ztadir TYPE st_ztadir,
  l_pagekey(70) TYPE c,
  l_pagename(70) TYPE c,
  l_pagetype TYPE c,
  lt_mime TYPE it_mime.

  FIELD-SYMBOLS:
  <ls_mime> TYPE st_mime.

  IF g_add_elem_o2appl = abap_false.
    cs_ztadir-subrc = gc_subrc_deselected.
  ELSE.
    l_applname = cs_ztadir-obj_name.
    SELECT SINGLE applname applext FROM ('O2APPL')
        INTO (l_applname, l_applext)
        WHERE applname = l_applname
        AND version = 'A'.
    IF sy-subrc = 0.
      cs_ztadir-o2name = l_applext.
      SELECT SINGLE text FROM ('O2APPLT') INTO l_text
          WHERE applname = l_applname
          AND langu = sy-langu.
      IF sy-subrc = 0.
        cs_ztadir-descript = l_text.
      ENDIF.
* Controller, Views, Pages with Flow Logik, Page Fragments
      SELECT pagekey pagename pagetype FROM ('O2PAGDIR')
          INTO (l_pagekey, l_pagename, l_pagetype)
          WHERE applname = l_applname
          ORDER BY pagekey.
        IF ( l_pagetype = gc_o2type_bsp
             AND g_add_elem_o2applbsp  = abap_true )
        OR ( l_pagetype = gc_o2type_ctrl
             AND g_add_elem_o2applctrl = abap_true )
        OR ( l_pagetype = gc_o2type_incl
             AND g_add_elem_o2applincl = abap_true )
        OR ( l_pagetype = gc_o2type_view
             AND g_add_elem_o2applview = abap_true ).
          CLEAR: ls_ztadir.
          MOVE-CORRESPONDING cs_ztadir TO ls_ztadir.
          CLEAR l_descript.
          SELECT SINGLE descript FROM ('O2PAGDIRT')
              INTO l_descript
              WHERE applname = l_applname
              AND pagekey = l_pagekey
              AND langu = sy-langu.
          ls_ztadir-descript = l_descript.
          ls_ztadir-o2pagekey = l_pagekey.
          ls_ztadir-o2pagename = l_pagename.
          ls_ztadir-o2type = l_pagetype.
          APPEND ls_ztadir TO gt_ztadir.
        ENDIF.
      ENDSELECT.
*MIMEs
      IF g_add_elem_o2applmime  = abap_true.
        PERFORM o2_get_mimes
          USING l_applname
          CHANGING lt_mime.
        LOOP AT lt_mime ASSIGNING <ls_mime>.
          CLEAR: ls_ztadir.
          MOVE-CORRESPONDING cs_ztadir TO ls_ztadir.
          CLEAR ls_ztadir-descript.
          ls_ztadir-o2pagekey = <ls_mime>-key.
          ls_ztadir-o2pagename = <ls_mime>-name.
          ls_ztadir-o2type = gc_o2type_mime.
          ls_ztadir-mime_objtype = <ls_mime>-objtype.
          ls_ztadir-mime_class = <ls_mime>-class.
          ls_ztadir-mime_objid = <ls_mime>-objid.
          ls_ztadir-descript = <ls_mime>-mimetype_descript.
          APPEND ls_ztadir TO gt_ztadir.
        ENDLOOP.
      ENDIF.
***
    ELSE.
      cs_ztadir-subrc = gc_subrc_not_found.
    ENDIF.
  ENDIF.
ENDFORM.                    "select_O2_appl


*-----------------------------------------------------------------------
* select_O2_taglib                               BSP Extensions
*-----------------------------------------------------------------------
FORM select_o2_taglib
  CHANGING
    cs_ztadir TYPE st_ztadir.

  DATA:
  l_descript TYPE as4text,
  l_tlibid(30) TYPE c,
  l_tagid(30) TYPE c,
  ls_ztadir TYPE st_ztadir.

  IF g_add_elem_o2taglib = abap_false.
    cs_ztadir-subrc = gc_subrc_deselected.
  ELSE.
    l_tlibid = cs_ztadir-obj_name.
    SELECT SINGLE tlibid FROM ('O2TAGLIB') INTO l_tlibid
        WHERE tlibid = l_tlibid
        AND state = 'A'.
    IF sy-subrc = 0.
      SELECT SINGLE descript FROM ('TAGLIBT') INTO l_descript
          WHERE tlibid = l_tlibid
          AND state = 'A'
          AND langu = sy-langu.
      IF sy-subrc = 0.
        cs_ztadir-descript = l_descript.
      ENDIF.
* TAGs
      SELECT tagid FROM ('O2TAG') INTO l_tagid
          WHERE tlibid = l_tlibid
          AND state = 'A'.
        CLEAR: ls_ztadir.
        MOVE-CORRESPONDING cs_ztadir TO ls_ztadir.
        CLEAR ls_ztadir-descript.
        SELECT SINGLE descript FROM ('TAGT') INTO l_descript
            WHERE tlibid = l_tlibid
            AND state = 'A'
            AND langu = sy-langu
            AND tagid = l_tagid.
        IF sy-subrc = 0.
          ls_ztadir-descript = l_descript.
        ENDIF.
        ls_ztadir-o2type = gc_o2type_tag.
        ls_ztadir-o2name = l_tagid.
        ls_ztadir-o2pagekey = l_tagid.
        TRANSLATE ls_ztadir-o2pagekey TO UPPER CASE.
        APPEND ls_ztadir TO gt_ztadir.
      ENDSELECT.
***
    ELSE.
      cs_ztadir-subrc = gc_subrc_not_found.
    ENDIF.
  ENDIF.
ENDFORM.                    "select_O2_taglib


*-----------------------------------------------------------------------
* select_O2_xslt                                 Transformation
*-----------------------------------------------------------------------
FORM select_o2_xslt
  CHANGING
    cs_ztadir TYPE st_ztadir.

  DATA:
  l_descript TYPE as4text,
  l_xsltdesc(40) TYPE c.

  IF g_add_elem_xslt = abap_false.
    cs_ztadir-subrc = gc_subrc_deselected.
  ELSE.
    l_xsltdesc = cs_ztadir-obj_name.
    SELECT SINGLE descript FROM ('O2XSLTTEXT') INTO l_descript
        WHERE xsltdesc = l_xsltdesc
        AND langu = sy-langu
        AND state = 'A'.
    IF sy-subrc = 0.
      cs_ztadir-descript = l_descript.
    ELSE.
      cs_ztadir-subrc = gc_subrc_not_found.
    ENDIF.
  ENDIF.
ENDFORM.                    "select_O2_xslt


*-----------------------------------------------------------------------
* select_seoclass                                Klasse/Interface
*-----------------------------------------------------------------------
FORM select_seoclass
  CHANGING
    cs_ztadir TYPE st_ztadir.

  DATA:
  l_descript TYPE seodescr,
  l_clsname TYPE seoclsname,
  l_type TYPE seoclstype.

  l_clsname = cs_ztadir-obj_name.
  CASE cs_ztadir-object.
    WHEN 'CLAS'.
      l_type = 0.
      IF g_add_elem_clas = abap_false.
        cs_ztadir-subrc = gc_subrc_deselected.
      ENDIF.
    WHEN 'INTF'.
      l_type = 1.
      IF g_add_elem_intf = abap_false.
        cs_ztadir-subrc = gc_subrc_deselected.
      ENDIF.
    WHEN OTHERS.
      l_type = 2.
  ENDCASE.
  IF cs_ztadir-subrc = 0.
    SELECT SINGLE clsname FROM seoclass INTO l_clsname
        WHERE clsname = l_clsname
        AND clstype = l_type.
    IF sy-subrc <> 0.
      cs_ztadir-subrc = gc_subrc_not_found.
    ELSE.
      SELECT SINGLE descript FROM seoclasstx INTO l_descript
          WHERE clsname = l_clsname
          AND langu = sy-langu.
      IF sy-subrc = 0.
        cs_ztadir-descript = l_descript.
      ENDIF.
    ENDIF.
  ENDIF.
ENDFORM.                    "select_seoclass


*-----------------------------------------------------------------------
* select_t100                                    Message Class
*-----------------------------------------------------------------------
FORM select_t100
  CHANGING
    cs_ztadir TYPE st_ztadir.

  DATA:
  l_arbgb TYPE arbgb,
  l_stext TYPE as4text.

  l_arbgb = cs_ztadir-obj_name.
  IF g_add_elem_msag = abap_false.
    cs_ztadir-subrc = gc_subrc_deselected.
  ELSE.
    SELECT SINGLE stext FROM t100a INTO l_stext
        WHERE arbgb = l_arbgb.
    IF sy-subrc <> 0.
      cs_ztadir-subrc = gc_subrc_not_found.
    ELSE.
      SELECT SINGLE stext FROM t100t INTO l_stext
          WHERE arbgb = l_arbgb
          AND sprsl = sy-langu.
      cs_ztadir-descript = l_stext.
    ENDIF.
  ENDIF.
ENDFORM.                    "select_t100


*-----------------------------------------------------------------------
* select_tobj                                    Authorization Object
*-----------------------------------------------------------------------
FORM select_tobj
  CHANGING
    cs_ztadir TYPE st_ztadir.

  DATA:
  l_objct TYPE xuobject,
  l_ttext TYPE xutext.

  l_objct = cs_ztadir-obj_name.
  IF g_add_elem_tobj = abap_false.
    cs_ztadir-subrc = gc_subrc_deselected.
  ELSE.
    SELECT SINGLE objct FROM tobj INTO l_objct
        WHERE objct = l_objct.
    IF sy-subrc <> 0.
      cs_ztadir-subrc = gc_subrc_not_found.
    ELSE.
      SELECT SINGLE ttext FROM tobjt INTO l_ttext
          WHERE object = l_objct
          AND langu = sy-langu.
      IF sy-subrc = 0.
        cs_ztadir-descript = l_ttext.
      ENDIF.
    ENDIF.
  ENDIF.
ENDFORM.                    "select_tobj


*-----------------------------------------------------------------------
* select_tpara                                   SET/GET Parameter
*-----------------------------------------------------------------------
FORM select_tpara
  CHANGING
    cs_ztadir TYPE st_ztadir.

  DATA:
  l_paramid TYPE memoryid,
  l_partext TYPE as4text.

  l_paramid = cs_ztadir-obj_name.
  IF g_add_elem_para = abap_false.
    cs_ztadir-subrc = gc_subrc_deselected.
  ELSE.
    SELECT SINGLE partext FROM tpara INTO l_partext
        WHERE paramid = l_paramid.
    IF sy-subrc <> 0.
      cs_ztadir-subrc = gc_subrc_not_found.
    ELSE.
      cs_ztadir-descript = l_partext.
      SELECT SINGLE partext FROM tparat INTO l_partext
          WHERE paramid = l_paramid
          AND sprache = sy-langu.
      IF sy-subrc = 0.
        cs_ztadir-descript = l_partext.
      ENDIF.
    ENDIF.
  ENDIF.
ENDFORM.                    "select_tpara


*-----------------------------------------------------------------------
* select_tstc                                    Transaction
*-----------------------------------------------------------------------
FORM select_tstc
  CHANGING
    cs_ztadir TYPE st_ztadir.

  DATA:
  l_tcode TYPE tcode,
  l_ttext TYPE ttext_stct.

  l_tcode = cs_ztadir-obj_name.
  IF g_add_elem_tran = abap_false.
    cs_ztadir-subrc = gc_subrc_deselected.
  ELSE.
    SELECT SINGLE tcode FROM tstc INTO l_tcode
        WHERE tcode = l_tcode.
    IF sy-subrc <> 0.
      cs_ztadir-subrc = gc_subrc_not_found.
    ELSE.
      SELECT SINGLE ttext FROM tstct INTO l_ttext
          WHERE tcode = l_tcode
          AND sprsl = sy-langu.
      IF sy-subrc = 0.
        cs_ztadir-descript = l_ttext.
      ENDIF.
    ENDIF.
  ENDIF.
ENDFORM.                    "select_tstc


*-----------------------------------------------------------------------
* select_trdir                                   Program/Include
*-----------------------------------------------------------------------
FORM select_trdir
  CHANGING
    cs_ztadir TYPE st_ztadir.

  DATA:
  l_program TYPE sy-repid,
  l_title TYPE rs38m-repti.

  l_program = cs_ztadir-obj_name.
  CALL FUNCTION 'PROGRAM_TITLE'
    EXPORTING
      program  = l_program
      language = sy-langu
    IMPORTING
      title    = l_title.
  cs_ztadir-descript = l_title.
  cs_ztadir-progname = cs_ztadir-obj_name.
  SELECT SINGLE subc FROM trdir INTO cs_ztadir-subc
    WHERE name = cs_ztadir-progname.
  IF sy-subrc <> 0
  OR cs_ztadir-subc NA '1I'.
    cs_ztadir-subrc = gc_subrc_not_found.
  ELSEIF ( cs_ztadir-subc = 'I' AND g_add_elem_incl = abap_false )
  OR ( cs_ztadir-subc = '1' AND g_add_elem_prog = abap_false ).
    cs_ztadir-subrc = gc_subrc_deselected.
  ENDIF.
ENDFORM.                    "select_trdir
