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


*-----------------------------------------------------------------------
* ddic
*-----------------------------------------------------------------------
FORM ddic.
*DOMA
  PERFORM ddic_r3tr_doma.
*DTEL
  PERFORM ddic_r3tr_dtel.
*ENQU: AGGTYPE = E
  PERFORM ddic_r3tr_enqu.
*SHLP
  PERFORM ddic_r3tr_shlp.
*TABL: TABCLASS = APPEND, INTTAB, VIEW
  PERFORM ddic_r3tr_tabl_1.
*TABL: TABCLASS = CLUSTER, POOL, TRANSP
  PERFORM ddic_r3tr_tabl_2.
*TTYP
  PERFORM ddic_r3tr_ttyp.
*TYPE
  PERFORM ddic_r3tr_type.
*VIEW
  PERFORM ddic_r3tr_view.

ENDFORM.                    "ddic


*-----------------------------------------------------------------------
* ddic_r3tr_doma                                 DomÃÂ¤nen
*-----------------------------------------------------------------------
FORM ddic_r3tr_doma.

  DATA:
  lt_html TYPE it_string,
  lt_tabstrip TYPE it_tabstrip,
  l_domname TYPE domname,
  ls_attributes TYPE st_attributes,
  ls_definition TYPE st_definition_1,
  ls_value_range TYPE st_value_range,
  lt_value_range TYPE it_value_range,
  ls_dd01v TYPE dd01v,
  ls_dd01v_n TYPE dd01v,
  lt_dd07v TYPE STANDARD TABLE OF dd07v,
  lt_dd07v_n TYPE STANDARD TABLE OF dd07v,
  l_state TYPE dcdomaget,
  lt_doc TYPE it_string.

  FIELD-SYMBOLS:
  <ls_ztadir> TYPE st_ztadir,
  <ls_dd07v> TYPE dd07v,
  <ls_tabstrip> TYPE st_tabstrip.

  PERFORM get_tabstrip
    USING 'DDIC_R3TR_DOMA' space
    CHANGING lt_tabstrip.

  LOOP AT gt_ztadir ASSIGNING <ls_ztadir>
      WHERE pgmid = 'R3TR'
      AND object = 'DOMA'
      AND downloaded = abap_false.
    <ls_ztadir>-downloaded = abap_true.

    CLEAR:
    ls_attributes.

    REFRESH:
    lt_html,
    lt_value_range,
    lt_dd07v,
    lt_dd07v_n,
    lt_doc.

    l_domname = <ls_ztadir>-obj_name.
    CALL FUNCTION 'DD_DOMA_GET'
      EXPORTING
        domain_name = l_domname
        langu       = sy-langu
        withtext    = abap_true
      IMPORTING
        dd01v_wa_a  = ls_dd01v
        dd01v_wa_n  = ls_dd01v_n
        got_state   = l_state
      TABLES
        dd07v_tab_a = lt_dd07v
        dd07v_tab_n = lt_dd07v_n
      EXCEPTIONS
        OTHERS      = 1.
    IF sy-subrc <> 0.
      <ls_ztadir>-subrc = sy-subrc.
      CONTINUE.
    ENDIF.
    ls_attributes-bname = ls_dd01v-as4user.
    PERFORM get_date
      USING
        ls_dd01v-as4date
      CHANGING
        ls_attributes-date_last_changed.
    ls_attributes-devclass = <ls_ztadir>-devclass.
    PERFORM get_devclass
      USING
        <ls_ztadir>-devclass
      CHANGING
        ls_attributes-devclass_descr.
    IF ls_dd01v-dommaster IS INITIAL.
      SELECT SINGLE masterlang FROM tadir INTO ls_dd01v-dommaster
          WHERE pgmid = 'R3TR'
          AND object = 'DOMA'
          AND obj_name = l_domname.
    ENDIF.
    PERFORM get_spras
      USING
        ls_dd01v-dommaster
      CHANGING
        ls_attributes-laiso
        ls_attributes-sptxt.
    PERFORM get_user
      USING
        ls_dd01v-as4user
      CHANGING
        ls_attributes-name_text.

    ls_definition-datatype = ls_dd01v-datatype.
    PERFORM get_dom_value_text
      USING
        'DATATYPE'
        ls_dd01v-datatype
      CHANGING
        ls_definition-datadescr.
    ls_definition-dataleng = ls_dd01v-leng.
    ls_definition-datadeci = ls_dd01v-decimals.
    ls_definition-outputlen = ls_dd01v-outputlen.
    ls_definition-convexit = ls_dd01v-convexit.
    ls_definition-signflag = ls_dd01v-signflag.
    ls_definition-lowercase = ls_dd01v-lowercase.

    SORT lt_dd07v BY valpos.
    LOOP AT lt_dd07v ASSIGNING <ls_dd07v>.
      ls_value_range-ddtext = <ls_dd07v>-ddtext.
      IF <ls_dd07v>-domval_ld IS INITIAL.
        ls_value_range-domvalue_l = <ls_dd07v>-domvalue_l.
      ELSE.
        ls_value_range-domvalue_l = <ls_dd07v>-domval_ld.
      ENDIF.
      IF <ls_dd07v>-domval_hd IS INITIAL.
        ls_value_range-domvalue_h = <ls_dd07v>-domval_hd.
      ELSE.
        ls_value_range-domvalue_h = <ls_dd07v>-domvalue_h.
      ENDIF.
      APPEND ls_value_range TO lt_value_range.
    ENDLOOP.
*doma documentation
    PERFORM get_docu
      USING
        'DO'
        <ls_ztadir>-obj_name
        'T'
      CHANGING
        lt_doc.
***
    LOOP AT lt_tabstrip ASSIGNING <ls_tabstrip>.
      <ls_tabstrip>-empty = abap_false.
      CASE <ls_tabstrip>-id.
        WHEN 'DOC'.
          IF lt_doc IS INITIAL.
            <ls_tabstrip>-empty = abap_true.
          ENDIF.
      ENDCASE.
    ENDLOOP.
*HTML header
    PERFORM html_main_header
      USING
        tpt_ddic_doma
        txt_domain
        <ls_ztadir>-obj_name
        txt_active___1
        txt_short_text___2
        <ls_ztadir>-descript
        space
        lt_tabstrip
        gt_link
      CHANGING
        lt_html.
*HTML documentation
    IF NOT lt_doc IS INITIAL
    OR g_empty_tab = gc_empty_tab_display.
      PERFORM html_add_doc
        USING
          lt_doc
          'DOC'
          abap_false
        CHANGING
          lt_html.
    ENDIF.
*HTML attributes
    PERFORM html_add_attributes_1
      USING
        ls_attributes
        'ATTRIBUTES'
        abap_false
      CHANGING
        lt_html.
*HTML definition
    PERFORM html_add_definition_1
      USING
        ls_definition
        'DEFINITION'
        abap_true
      CHANGING
        lt_html.
*HTML value range
    PERFORM html_add_value_range
      USING
        lt_value_range
        'VALUERANGE'
        abap_false
      CHANGING
        lt_html.
*HTML footer
    PERFORM html_main_footer
      USING
        lt_html.
*
    PERFORM download
      USING
        lt_html
        <ls_ztadir>-pgmid
        <ls_ztadir>-object
        <ls_ztadir>-obj_name
        gc_extension_htm
        abap_true.
  ENDLOOP.
ENDFORM.                                                    "r3tr_doma


*-----------------------------------------------------------------------
* ddic_r3tr_dtel                                 Datenelemente
*-----------------------------------------------------------------------
FORM ddic_r3tr_dtel.

  DATA:
  lt_html TYPE it_string,
  lt_tabstrip TYPE it_tabstrip,
  ls_tabstrip TYPE st_tabstrip,
  l_rollname TYPE rollname,
  ls_attributes TYPE st_attributes,
  ls_data_type TYPE st_data_type,
  ls_further_char TYPE st_further_char,
  ls_field_label TYPE st_field_label,
  lt_para TYPE tpara,
  ls_dd01l TYPE dd01l,
  lt_dd03p TYPE STANDARD TABLE OF dd03p,
  ls_dd04l TYPE dd04l,
  ls_dd04l_n TYPE dd04l,
  lt_dd04t TYPE STANDARD TABLE OF dd04t,
  ls_dd04t TYPE dd04t,
  lt_dd04t_n TYPE STANDARD TABLE OF dd04t,
  l_state TYPE ddrefstruc-state,
  lt_doc TYPE it_string,
  lt_docdz TYPE STANDARD TABLE OF docdz,
  l_tab_nr TYPE i,
  l_tab_id TYPE string,
  l_doc_obj TYPE doku_obj,
  l_active TYPE flag.

  FIELD-SYMBOLS:
  <l_dataleng> TYPE ANY,
  <l_datatype> TYPE ANY,
  <l_decimals> TYPE ANY,
  <l_refkind> TYPE ANY,
  <l_reftype> TYPE ANY,
  <ls_ztadir> TYPE st_ztadir,
  <ls_dd03p> TYPE dd03p,
  <ls_tabstrip> TYPE st_tabstrip,
  <ls_docdz> TYPE docdz.

  LOOP AT gt_ztadir ASSIGNING <ls_ztadir>
      WHERE pgmid = 'R3TR'
      AND object = 'DTEL'
      AND downloaded = abap_false.
    <ls_ztadir>-downloaded = abap_true.

    CLEAR:
    ls_attributes.

    REFRESH:
    lt_html,
    lt_tabstrip,
    lt_dd04t,
    lt_dd04t_n,
    lt_doc,
    lt_docdz.

    l_rollname = <ls_ztadir>-obj_name.
    CALL FUNCTION 'DD_DTEL_GET'
      EXPORTING
        roll_name   = l_rollname
        langu       = sy-langu
        withtext    = abap_true
      IMPORTING
        got_state   = l_state
        dd04l_wa_a  = ls_dd04l
        dd04l_wa_n  = ls_dd04l_n
        dd01l_wa    = ls_dd01l
        tpara_wa    = lt_para
      TABLES
        dd04t_tab_a = lt_dd04t
        dd04t_tab_n = lt_dd04t_n
      EXCEPTIONS
        OTHERS      = 1.
    IF sy-subrc <> 0.
      <ls_ztadir>-subrc = sy-subrc.
      CONTINUE.
    ENDIF.
    READ TABLE lt_dd04t INTO ls_dd04t INDEX 1.
*attributes
    ls_attributes-bname = ls_dd04l-as4user.
    PERFORM get_date
      USING
        ls_dd04l-as4date
      CHANGING
        ls_attributes-date_last_changed.
    ls_attributes-devclass = <ls_ztadir>-devclass.
    PERFORM get_devclass
      USING
        <ls_ztadir>-devclass
      CHANGING
        ls_attributes-devclass_descr.
    IF ls_dd04l-dtelmaster IS INITIAL.
      SELECT SINGLE masterlang FROM tadir INTO ls_dd04l-dtelmaster
          WHERE pgmid = 'R3TR'
          AND object = 'DTEL'
          AND obj_name = l_rollname.
    ENDIF.
    PERFORM get_spras
      USING
        ls_dd04l-dtelmaster
      CHANGING
        ls_attributes-laiso
        ls_attributes-sptxt.
    PERFORM get_user
      USING
        ls_dd04l-as4user
      CHANGING
        ls_attributes-name_text.
*data type
    ls_data_type-domname = ls_dd04l-domname.
    PERFORM get_dom
      USING
        ls_data_type-domname
      CHANGING
        ls_data_type-domdescr.
    ASSIGN COMPONENT 'DATATYPE' OF STRUCTURE ls_dd04l TO <l_datatype>.
    IF <l_datatype> IS ASSIGNED.
      ls_data_type-datatype = <l_datatype>.
      UNASSIGN <l_datatype>.
    ENDIF.
    PERFORM get_dom_value_text
      USING
        'DATATYPE'
        ls_dd04l-domname
      CHANGING
        ls_data_type-datadescr.
    ASSIGN COMPONENT 'LENG' OF STRUCTURE ls_dd04l TO <l_dataleng>.
    IF <l_dataleng> IS ASSIGNED.
      ls_data_type-dataleng = <l_dataleng>.
      UNASSIGN <l_dataleng>.
    ENDIF.
    ASSIGN COMPONENT 'DECIMALS' OF STRUCTURE ls_dd04l TO <l_decimals>.
    IF <l_decimals> IS ASSIGNED.
      ls_data_type-datadeci = <l_decimals>.
      UNASSIGN <l_decimals>.
    ENDIF.
    ASSIGN COMPONENT 'REFKIND' OF STRUCTURE ls_dd04l TO <l_refkind>.
    IF <l_refkind> IS ASSIGNED.
      ls_data_type-refkind = <l_refkind>.
      UNASSIGN <l_refkind>.
    ENDIF.
    ASSIGN COMPONENT 'REFTYPE' OF STRUCTURE ls_dd04l TO <l_reftype>.
    IF <l_reftype> IS ASSIGNED.
      ls_data_type-reftype = <l_reftype>.
      UNASSIGN <l_reftype>.
    ELSE.
      ls_data_type-reftype = '#'.  "R/3 4.6 does not know ref type
    ENDIF.
*further char
    ls_further_char-shlpname = ls_dd04l-shlpname.
    ls_further_char-shlpfield = ls_dd04l-shlpfield.
    ls_further_char-memoryid = ls_dd04l-memoryid.
    ls_further_char-deffdname = ls_dd04l-deffdname.
    ls_further_char-logflag = ls_dd04l-logflag.
*field label
    ls_field_label-scrlen_s = ls_dd04l-scrlen1.
    ls_field_label-scrtext_s = ls_dd04t-scrtext_s.
    ls_field_label-scrlen_m = ls_dd04l-scrlen2.
    ls_field_label-scrtext_m = ls_dd04t-scrtext_m.
    ls_field_label-scrlen_l = ls_dd04l-scrlen3.
    ls_field_label-scrtext_l = ls_dd04t-scrtext_l.
    ls_field_label-headlen = ls_dd04l-headlen.
    ls_field_label-reptext = ls_dd04t-reptext.
*dtel documentation
    PERFORM get_docu
      USING
        'DE'
        <ls_ztadir>-obj_name
        'E'
      CHANGING
        lt_doc.
*supplementary documentation
    CALL FUNCTION 'DOCU_GET_DZ'
      EXPORTING
        langu    = sy-langu
        rollname = l_rollname
      TABLES
        dz_list  = lt_docdz
      EXCEPTIONS
        OTHERS   = 1.
    SORT lt_docdz BY addition.
***
    PERFORM get_tabstrip
      USING 'DDIC_R3TR_DTEL' space
      CHANGING lt_tabstrip.
    SORT lt_tabstrip BY tab_nr DESCENDING.
    READ TABLE lt_tabstrip ASSIGNING <ls_tabstrip> INDEX 1.
    l_tab_nr = <ls_tabstrip>-tab_nr.
    SORT lt_tabstrip BY tab_nr.
    CLEAR ls_tabstrip.
    ls_tabstrip-active_order = 1.
    LOOP AT lt_docdz ASSIGNING <ls_docdz>.
      l_tab_nr = l_tab_nr + 1.
      ls_tabstrip-form = 'DDIC_R3TR_DTEL'.
      CONCATENATE 'DOCDZ_' <ls_docdz>-addition INTO ls_tabstrip-id.
      ls_tabstrip-parent_id = 'DOCDZ'.
      ls_tabstrip-tab_nr = l_tab_nr.
      ls_tabstrip-text = <ls_docdz>-addition.
      APPEND ls_tabstrip TO lt_tabstrip.
      CLEAR ls_tabstrip.
    ENDLOOP.
    LOOP AT lt_tabstrip ASSIGNING <ls_tabstrip>.
      <ls_tabstrip>-empty = abap_false.
      CASE <ls_tabstrip>-id.
        WHEN 'DOC'.
          IF lt_doc IS INITIAL.
            <ls_tabstrip>-empty = abap_true.
          ENDIF.
        WHEN 'DOCDZ'.
          IF lt_docdz IS INITIAL.
            <ls_tabstrip>-empty = abap_true.
          ENDIF.
      ENDCASE.
    ENDLOOP.
*HTML header
    PERFORM html_main_header
      USING
        tpt_ddic_dtel
        txt_data_element___1
        <ls_ztadir>-obj_name
        txt_active___1
        txt_short_text___2
        <ls_ztadir>-descript
        space
        lt_tabstrip
        gt_link
      CHANGING
        lt_html.
*HTML documentation
    IF NOT lt_doc IS INITIAL
    OR g_empty_tab = gc_empty_tab_display.
      PERFORM html_add_doc
        USING
          lt_doc
          'DOC'
          abap_false
        CHANGING
          lt_html.
    ENDIF.
*HTML supplementary documentation
    IF NOT lt_docdz IS INITIAL
    OR g_empty_tab = gc_empty_tab_display.
      PERFORM html_add_container_begin
        USING
          lt_tabstrip
          'DOCDZ'
          abap_false
        CHANGING
          lt_html.
      l_active = abap_true.
      LOOP AT lt_docdz ASSIGNING <ls_docdz>.
        CLEAR: l_tab_id, l_doc_obj.
        REFRESH lt_doc.
        CONCATENATE 'DOCDZ_' <ls_docdz>-addition INTO l_tab_id.
        CALL FUNCTION 'DOCU_OBJECT_NAME_CONCATENATE'
          EXPORTING
            docu_id  = 'DZ'
            element  = <ls_docdz>-rollname
            addition = <ls_docdz>-addition
          IMPORTING
            object   = l_doc_obj.
        PERFORM get_docu
          USING
            'DZ'
            l_doc_obj
            'E'
          CHANGING
            lt_doc.
        PERFORM html_add_doc
          USING
            lt_doc
            l_tab_id
            l_active
          CHANGING
            lt_html.
        l_active = abap_false.
      ENDLOOP.
      PERFORM html_add_container_end
        CHANGING
          lt_html.
    ENDIF.
*HTML attributes
    PERFORM html_add_attributes_1
      USING
        ls_attributes
        'ATTRIBUTES'
        abap_false
      CHANGING
        lt_html.
*HTML data type
    PERFORM html_add_data_type
      USING
        ls_data_type
        'DATATYPE'
        abap_true
      CHANGING
        lt_html.
*HTML further char
    PERFORM html_add_further_char
      USING
        ls_further_char
        'FURTHERCHAR'
        abap_false
      CHANGING
        lt_html.
*HTML field label
    PERFORM html_add_field_label
      USING
        ls_field_label
        'FIELDLABEL'
        abap_false
      CHANGING
        lt_html.
*HTML footer
    PERFORM html_main_footer
      USING
        lt_html.

*download
    PERFORM download
      USING
        lt_html
        <ls_ztadir>-pgmid
        <ls_ztadir>-object
        <ls_ztadir>-obj_name
        gc_extension_htm
        abap_true.
  ENDLOOP.
ENDFORM.                                                    "r3tr_dtel


*-----------------------------------------------------------------------
* ddic_r3tr_enqu                                 Aggregat-Header
*                                                         (Sperrobjekte)
*-----------------------------------------------------------------------
FORM ddic_r3tr_enqu.

  DATA:
  lt_html TYPE it_string,
  lt_tabstrip TYPE it_tabstrip,
  l_viewname TYPE viewname,
  ls_attributes TYPE st_attributes,
  lt_tables TYPE it_tables,
  ls_tables TYPE st_tables,
  ls_dd25v TYPE dd25v,
  ls_dd25v_n TYPE dd25v,
  lt_dd26v TYPE STANDARD TABLE OF dd26v,
  lt_dd26v_n TYPE STANDARD TABLE OF dd26v,
  lt_dd27p TYPE STANDARD TABLE OF dd27p,
  lt_dd27p_n TYPE STANDARD TABLE OF dd27p,
  l_state TYPE dcenquget.

  FIELD-SYMBOLS:
  <ls_ztadir> TYPE st_ztadir,
  <ls_dd27p> TYPE dd27p.

  PERFORM get_tabstrip
    USING 'DDIC_R3TR_ENQU' space
    CHANGING lt_tabstrip.

  LOOP AT gt_ztadir ASSIGNING <ls_ztadir>
      WHERE pgmid = 'R3TR'
      AND object = 'ENQU'
      AND aggtype = 'E'
      AND downloaded = abap_false.
    <ls_ztadir>-downloaded = abap_true.

    CLEAR:
    ls_attributes.

    REFRESH:
    lt_html,
    lt_dd26v,
    lt_dd26v_n,
    lt_dd27p,
    lt_dd27p_n.

    l_viewname = <ls_ztadir>-obj_name.
    CALL FUNCTION 'DD_ENQU_GET'
      EXPORTING
        enqu_name   = l_viewname
        langu       = sy-langu
        withtext    = abap_true
      IMPORTING
        dd25v_wa_a  = ls_dd25v
        dd25v_wa_n  = ls_dd25v_n
        got_state   = l_state
      TABLES
        dd26v_tab_a = lt_dd26v
        dd26v_tab_n = lt_dd26v_n
        dd27p_tab_a = lt_dd27p
        dd27p_tab_n = lt_dd27p_n
      EXCEPTIONS
        OTHERS      = 1.
    IF sy-subrc <> 0.
      <ls_ztadir>-subrc = sy-subrc.
      CONTINUE.
    ENDIF.
*attributes
    ls_attributes-bname = ls_dd25v-as4user.
    PERFORM get_date
      USING
        ls_dd25v-as4date
      CHANGING
        ls_attributes-date_last_changed.
    ls_attributes-devclass = <ls_ztadir>-devclass.
    PERFORM get_devclass
      USING
        <ls_ztadir>-devclass
      CHANGING
        ls_attributes-devclass_descr.
    IF ls_dd25v-masterlang IS INITIAL.
      SELECT SINGLE masterlang FROM tadir INTO ls_dd25v-masterlang
          WHERE pgmid = 'R3TR'
          AND object = 'ENQU'
          AND obj_name = l_viewname.
    ENDIF.
    PERFORM get_spras
      USING
        ls_dd25v-masterlang
      CHANGING
        ls_attributes-laiso
        ls_attributes-sptxt.
    PERFORM get_user
      USING
        ls_dd25v-as4user
      CHANGING
        ls_attributes-name_text.
    ls_attributes-display_rfcenable = abap_true.
    ls_attributes-rfcenable = ls_dd25v-globalflag.

    SORT lt_dd27p BY viewname objpos.
    LOOP AT lt_dd27p ASSIGNING <ls_dd27p>
        WHERE fieldname = '*'.
      CLEAR ls_tables.
      IF <ls_dd27p>-tabname = ls_dd25v-roottab.
        ls_tables-primary = abap_true.
      ENDIF.
      ls_tables-tabname = <ls_dd27p>-tabname.
      PERFORM get_dom_value_text
        USING
          'ENQMODE'
          <ls_dd27p>-enqmode
        CHANGING
          ls_tables-enqmode.
      APPEND ls_tables TO lt_tables.
    ENDLOOP.


    PERFORM html_main_header
      USING
        tpt_ddic_enqu
        txt_lock_object___1
        <ls_ztadir>-obj_name
        txt_active___1
        txt_short_text___2
        <ls_ztadir>-descript
        space
        lt_tabstrip
        gt_link
      CHANGING
        lt_html.
    PERFORM html_add_attributes_1
      USING
        ls_attributes
        'ATTRIBUTES'
        abap_false
      CHANGING
        lt_html.
    PERFORM html_add_tables
      USING
        lt_tables
        'TABLES'
        abap_true
      CHANGING
        lt_html.

    DELETE lt_dd27p WHERE fieldname = '*'.
    PERFORM html_add_table
      USING
        'ENQU_PARAM'
        lt_dd27p
        lt_dd27p
        'LOCKPARAMETER'
        abap_false
      CHANGING
        lt_html.
    PERFORM html_main_footer
      USING
        lt_html.

    PERFORM download
      USING
        lt_html
        <ls_ztadir>-pgmid
        <ls_ztadir>-object
        <ls_ztadir>-obj_name
        gc_extension_htm
        abap_true.
  ENDLOOP.
ENDFORM.                    "r3tr_enqu_e


*-----------------------------------------------------------------------
* ddic_r3tr_shlp                                 Suchhilfen
*-----------------------------------------------------------------------
FORM ddic_r3tr_shlp.

  DATA:
  lt_html TYPE it_string,
  l_shlpname TYPE shlpname,
  ls_dd30v TYPE dd30v,
  ls_dd30v_n TYPE dd30v,
  lt_dd31v TYPE STANDARD TABLE OF dd31v,
  lt_dd31v_n TYPE STANDARD TABLE OF dd31v,
  lt_dd32p TYPE STANDARD TABLE OF dd32p,
  lt_dd32p_n TYPE STANDARD TABLE OF dd32p,
  lt_dd33v TYPE STANDARD TABLE OF dd33v,
  lt_dd33v_n TYPE STANDARD TABLE OF dd33v,
  ls_attributes TYPE st_attributes,
  lt_tabstrip TYPE it_tabstrip,
  ls_definition TYPE st_definition_2,
  l_state TYPE dcshlpget.

  FIELD-SYMBOLS:
  <ls_ztadir> TYPE st_ztadir,
  <ls_dd07v> TYPE dd07v.

  PERFORM get_tabstrip
    USING 'DDIC_R3TR_SHLP' space
    CHANGING lt_tabstrip.

  LOOP AT gt_ztadir ASSIGNING <ls_ztadir>
      WHERE pgmid = 'R3TR'
      AND object = 'SHLP'
      AND downloaded = abap_false.
    <ls_ztadir>-downloaded = abap_true.

    CLEAR:
    ls_attributes,
    ls_definition.

    REFRESH:
    lt_html,
    lt_dd31v,
    lt_dd31v_n,
    lt_dd32p,
    lt_dd32p_n,
    lt_dd33v,
    lt_dd33v_n.


    l_shlpname = <ls_ztadir>-obj_name.
    CALL FUNCTION 'DD_SHLP_GET'
      EXPORTING
        shlp_name    = l_shlpname
        langu        = sy-langu
        withtext     = abap_true
        add_typeinfo = abap_true
      IMPORTING
        dd30v_wa_a   = ls_dd30v
        dd30v_wa_n   = ls_dd30v_n
        got_state    = l_state
      TABLES
        dd31v_tab_a  = lt_dd31v
        dd31v_tab_n  = lt_dd31v_n
        dd32p_tab_a  = lt_dd32p
        dd32p_tab_n  = lt_dd32p_n
        dd33v_tab_a  = lt_dd33v
        dd33v_tab_n  = lt_dd33v_n
      EXCEPTIONS
        OTHERS       = 1.
    IF sy-subrc <> 0.
      <ls_ztadir>-subrc = sy-subrc.
      CONTINUE.
    ENDIF.
    ls_attributes-bname = ls_dd30v-as4user.
    PERFORM get_date
      USING
        ls_dd30v-as4date
      CHANGING
        ls_attributes-date_last_changed.
    ls_attributes-devclass = <ls_ztadir>-devclass.
    PERFORM get_devclass
      USING
        <ls_ztadir>-devclass
      CHANGING
        ls_attributes-devclass_descr.
    IF ls_dd30v-ddlanguage IS INITIAL.
      SELECT SINGLE masterlang FROM tadir INTO ls_dd30v-ddlanguage
          WHERE pgmid = 'R3TR'
          AND object = 'SHLP'
          AND obj_name = l_shlpname.
    ENDIF.
    PERFORM get_spras
      USING
        ls_dd30v-ddlanguage
      CHANGING
        ls_attributes-laiso
        ls_attributes-sptxt.
    PERFORM get_user
      USING
        ls_dd30v-as4user
      CHANGING
        ls_attributes-name_text.

    ls_definition-selmethod = ls_dd30v-selmethod.
    ls_definition-texttab = ls_dd30v-texttab.
    ls_definition-dialogtype = ls_dd30v-dialogtype.
    ls_definition-hotkey = ls_dd30v-hotkey.
    ls_definition-selmexit = ls_dd30v-selmexit.

    PERFORM html_main_header
      USING
        tpt_ddic_shlp
        txt_elementary_srch_hlp
        <ls_ztadir>-obj_name
        txt_active___1
        txt_short_text___2
        <ls_ztadir>-descript
        space
        lt_tabstrip
        gt_link
      CHANGING
        lt_html.
    PERFORM html_add_attributes_1
      USING
        ls_attributes
        'ATTRIBUTES'
        abap_false
      CHANGING
        lt_html.
    PERFORM html_add_definition_2
      USING
        ls_definition
        'SHLP_PARAM'
        lt_dd32p
        'DEFINITION'
        abap_true
      CHANGING
        lt_html.
    PERFORM html_main_footer
      USING
        lt_html.

    PERFORM download
      USING
        lt_html
        <ls_ztadir>-pgmid
        <ls_ztadir>-object
        <ls_ztadir>-obj_name
        gc_extension_htm
        abap_true.
  ENDLOOP.
ENDFORM.                                                    "r3tr_shlp


*-----------------------------------------------------------------------
* ddic_r3tr_tabl_1                               SAP-Tabellen
*                                                           (Strukturen)
*-----------------------------------------------------------------------
FORM ddic_r3tr_tabl_1.

  DATA:
  lt_html TYPE it_string,
  lt_tabstrip TYPE it_tabstrip,
  ls_attributes TYPE st_attributes,
  ls_deliv_maint TYPE st_deliv_maint,
  ls_dd02v TYPE dd02v,
  lt_dd03p TYPE STANDARD TABLE OF dd03p,
  ls_dd09l TYPE dd09l,
  lt_zdd03p_ext TYPE it_zdd03p_ext,
  l_state TYPE dctablget,
  lt_doc TYPE it_string,
  lt_ddranking TYPE it_dom_value,
  lt_exclass TYPE it_access,
  ls_exclass TYPE st_access.

  FIELD-SYMBOLS:
  <ls_ztadir> TYPE st_ztadir,
  <ls_ddranking> TYPE st_dom_value,
  <ls_tabstrip> TYPE st_tabstrip,
  <l_exclass> TYPE ANY.

  PERFORM get_tabstrip
    USING 'DDIC_R3TR_TABL_1' space
    CHANGING lt_tabstrip.
  PERFORM get_dom_value_texts
    USING 'DDRANKING'
    CHANGING lt_ddranking.
  SORT lt_ddranking BY value DESCENDING.

  LOOP AT gt_ztadir ASSIGNING <ls_ztadir>
      WHERE pgmid = 'R3TR'
      AND object = 'TABL'
      AND ( tabclass = 'INTTAB'
        OR tabclass = 'VIEW'
        OR tabclass = 'APPEND' )
      AND downloaded = abap_false.
    <ls_ztadir>-downloaded = abap_true.

    CLEAR:
    ls_attributes.

    REFRESH:
    lt_html,
    lt_dd03p,
    lt_doc,
    lt_exclass.

    PERFORM ddic_r3tr_tabl_get
      CHANGING
        <ls_ztadir>
        ls_dd02v
        lt_dd03p
        lt_zdd03p_ext
        ls_dd09l.

    ls_attributes-bname = ls_dd02v-as4user.
    PERFORM get_date
      USING
        ls_dd02v-as4date
      CHANGING
        ls_attributes-date_last_changed.
    ls_attributes-devclass = <ls_ztadir>-devclass.
    PERFORM get_devclass
      USING
        <ls_ztadir>-devclass
      CHANGING
        ls_attributes-devclass_descr.
    PERFORM get_spras
      USING
        ls_dd02v-masterlang
      CHANGING
        ls_attributes-laiso
        ls_attributes-sptxt.
    PERFORM get_user
      USING
        ls_dd02v-as4user
      CHANGING
        ls_attributes-name_text.

    ls_deliv_maint-contflag = ls_dd02v-contflag.
    PERFORM get_dom_value_text
      USING
        'CONTFLAG'
        ls_dd02v-contflag
      CHANGING
        ls_deliv_maint-contflag_text.
    PERFORM get_dom_value_text
      USING
        'MAINTFLAG'
        ls_dd02v-mainflag
      CHANGING
        ls_deliv_maint-mainflag_text.
*enhancement category
    ASSIGN COMPONENT 'EXCLASS' OF STRUCTURE ls_dd02v TO <l_exclass>.
    IF <l_exclass> IS ASSIGNED.
      LOOP AT lt_ddranking ASSIGNING <ls_ddranking>.
        ls_exclass-ddtext = <ls_ddranking>-text.
        ls_exclass-checked = abap_false.
        IF <ls_ddranking>-value = <l_exclass>.
          ls_exclass-checked = abap_true.
        ENDIF.
        APPEND ls_exclass TO lt_exclass.
      ENDLOOP.
    ENDIF.
*documentation
    PERFORM get_docu
      USING
        'TB'
        <ls_ztadir>-obj_name
        'E'
      CHANGING
        lt_doc.
***
    LOOP AT lt_tabstrip ASSIGNING <ls_tabstrip>.
      <ls_tabstrip>-empty = abap_false.
      CASE <ls_tabstrip>-id.
        WHEN 'DOC'.
          IF lt_doc IS INITIAL.
            <ls_tabstrip>-empty = abap_true.
          ENDIF.
        WHEN 'EXCLASS'.
          IF lt_exclass IS INITIAL.
            <ls_tabstrip>-hidden = abap_true.
          ENDIF.
      ENDCASE.
    ENDLOOP.
*HTML header
    PERFORM html_main_header
      USING
        tpt_ddic_stru
        txt_structure
        <ls_ztadir>-obj_name
        txt_active___1
        txt_short_text___2
        <ls_ztadir>-descript
        space
        lt_tabstrip
        gt_link
      CHANGING
        lt_html.
*HTML enhancement category
    IF NOT lt_exclass IS INITIAL.
      PERFORM html_add_box_radiobuttons
        USING
          txt_enhancement_category_for_s
          'EXCLASS'
          lt_exclass
          'EXCLASS'
          abap_false
        CHANGING
          lt_html.
    ENDIF.
*HTML documentation
    IF NOT lt_doc IS INITIAL
    OR g_empty_tab = gc_empty_tab_display.
      PERFORM html_add_doc
        USING
          lt_doc
          'DOC'
          abap_false
        CHANGING
          lt_html.
    ENDIF.
*HTML attributes
    PERFORM html_add_attributes_1
      USING
        ls_attributes
        'ATTRIBUTES'
        abap_false
      CHANGING
        lt_html.
*HTML components
    PERFORM html_add_table
      USING
        'TABL1COMPO'
        lt_dd03p
        lt_zdd03p_ext
        'COMPONENTS'
        abap_true
      CHANGING
        lt_html.
*HTML entry help check
    PERFORM html_add_table
      USING
        'TABL1ENTRY'
        lt_dd03p
        lt_zdd03p_ext
        'ENTRY_HELP_CHECK'
        abap_false
      CHANGING
        lt_html.
*HTML curr quant fields
    PERFORM html_add_table
      USING
        'TABL1CURRQ'
        lt_dd03p
        lt_zdd03p_ext
        'CURR_QUANT_FIELDS'
        abap_false
      CHANGING
        lt_html.
*HTML footer
    PERFORM html_main_footer
      USING
        lt_html.
*
    PERFORM download
      USING
        lt_html
        <ls_ztadir>-pgmid
        <ls_ztadir>-object
        <ls_ztadir>-obj_name
        gc_extension_htm
        abap_true.
  ENDLOOP.
ENDFORM.                    "r3tr_tabl_1


*-----------------------------------------------------------------------
* ddic_r3tr_tabl_2                               SAP-Tabellen
*                                                    (Datenbanktabellen)
*-----------------------------------------------------------------------
FORM ddic_r3tr_tabl_2.

  DATA:
  lt_html TYPE it_string,
  lt_tabstrip TYPE it_tabstrip,
  l_name_value TYPE string,
  ls_attributes TYPE st_attributes,
  ls_deliv_maint TYPE st_deliv_maint,
  lt_access TYPE it_access,
  ls_dd02v TYPE dd02v,
  lt_dd03p TYPE STANDARD TABLE OF dd03p,
  ls_dd09l TYPE dd09l,
  lt_zdd03p_ext TYPE it_zdd03p_ext,
  l_state TYPE dctablget,
  lt_doc TYPE it_string,
  lt_ddranking TYPE it_dom_value,
  lt_exclass TYPE it_access,
  ls_exclass TYPE st_access,
  l_texttabname TYPE tabname,
  l_text_obj_name TYPE sobj_name,
  l_text_devclass TYPE devclass,
  lt_link TYPE it_link,
  ls_link TYPE st_link,
  lt_csv TYPE it_string,
  lt_xml TYPE it_string,
  lt_ts_params TYPE it_textinput,
  lt_ts_buffer TYPE it_access,
  lt_ts_buffer_type_l TYPE it_textinput,
  lt_ts_buffer_type_r TYPE it_textinput,
  lt_ts_bottom TYPE it_textinput,
  ls_textinput TYPE st_textinput,
  ls_access TYPE st_access,
  l_ddtext TYPE ddtext,
  lt_dom_value TYPE it_dom_value,
  lt_tmg_tech_details TYPE it_textinput,
  ls_tddat TYPE tddat,
  ls_tbrgt TYPE tbrgt,
  ls_tvdir TYPE tvdir,
  ls_objh TYPE objh,
  l_compare_flag TYPE string,
  lt_str TYPE it_string.


  FIELD-SYMBOLS:
  <ls_ztadir> TYPE st_ztadir,
  <ls_ddranking> TYPE st_dom_value,
  <ls_tabstrip> TYPE st_tabstrip,
  <l_exclass> TYPE ANY,
  <ls_dom_value> TYPE st_dom_value.

  PERFORM get_tabstrip
    USING 'DDIC_R3TR_TABL_2' space
    CHANGING lt_tabstrip.
  PERFORM get_dom_value_texts
    USING 'DDRANKING'
    CHANGING lt_ddranking.
  SORT lt_ddranking BY value DESCENDING.

  LOOP AT gt_ztadir ASSIGNING <ls_ztadir>
      WHERE pgmid = 'R3TR'
      AND object = 'TABL'
      AND ( tabclass = 'CLUSTER'
        OR tabclass = 'POOL'
        OR tabclass = 'TRANSP' )
      AND downloaded = abap_false.
    <ls_ztadir>-downloaded = abap_true.

    CLEAR:
    ls_attributes,
    l_state,
    l_texttabname,
    l_text_obj_name,
    l_text_devclass,
    ls_textinput,
    l_ddtext,
    ls_tddat,
    ls_tbrgt,
    ls_tvdir,
    ls_objh,
    l_compare_flag.

    REFRESH:
    lt_html,
    lt_doc,
    lt_exclass,
    lt_link,
    lt_csv,
    lt_xml,
    lt_ts_params,
    lt_ts_buffer,
    lt_ts_buffer_type_l,
    lt_ts_buffer_type_r,
    lt_ts_bottom,
    lt_tmg_tech_details.

    PERFORM ddic_r3tr_tabl_get
      CHANGING
        <ls_ztadir>
        ls_dd02v
        lt_dd03p
        lt_zdd03p_ext
        ls_dd09l.

    l_tabname = <ls_ztadir>-obj_name.

*attributes
    ls_attributes-bname = ls_dd02v-as4user.
    PERFORM get_date
      USING
        ls_dd02v-as4date
      CHANGING
        ls_attributes-date_last_changed.
    ls_attributes-devclass = <ls_ztadir>-devclass.
    PERFORM get_devclass
      USING
        <ls_ztadir>-devclass
      CHANGING
        ls_attributes-devclass_descr.
    PERFORM get_spras
      USING
        ls_dd02v-masterlang
      CHANGING
        ls_attributes-laiso
        ls_attributes-sptxt.
    PERFORM get_user
      USING
        ls_dd02v-as4user
      CHANGING
        ls_attributes-name_text.
*deliv maint
    ls_deliv_maint-sqltab = ls_dd02v-sqltab.
    ls_deliv_maint-display_cont = abap_true.
    ls_deliv_maint-contflag = ls_dd02v-contflag.
    PERFORM get_dom_value_text
      USING
        'CONTFLAG'
        ls_dd02v-contflag
      CHANGING
        ls_deliv_maint-contflag_text.
    ls_deliv_maint-display_main = abap_true.
    PERFORM get_dom_value_text
      USING
        'MAINTFLAG'
        ls_dd02v-mainflag
      CHANGING
        ls_deliv_maint-mainflag_text.
*technical settings
*   logical storage parameters
    CLEAR ls_textinput.
    ls_textinput-name = txt_data_class.
    ls_textinput-value = ls_dd09l-tabart.
    SELECT SINGLE darttext FROM dartt INTO l_ddtext
      WHERE tabart = ls_dd09l-tabart
      AND ddlangu = sy-langu.
    ls_textinput-description = l_ddtext.
    ls_textinput-input = abap_true.
    APPEND ls_textinput TO lt_ts_params.
    CLEAR ls_textinput.
    ls_textinput-name = txt_size_category.
    ls_textinput-value = ls_dd09l-tabkat.
    ls_textinput-input = abap_true.
    APPEND ls_textinput TO lt_ts_params.
*   buffering
    PERFORM get_dom_value_texts
      USING 'BUFALLOW'
      CHANGING lt_dom_value.
    LOOP AT lt_dom_value ASSIGNING <ls_dom_value>.
      CLEAR ls_access.
      ls_access-ddtext = <ls_dom_value>-text.
      IF <ls_dom_value>-value = ls_dd09l-bufallow.
        ls_access-checked = abap_true.
      ENDIF.
      APPEND ls_access TO lt_ts_buffer.
    ENDLOOP.
*   buffering type
    CLEAR ls_textinput.
    ls_textinput-name = txt_single_records_buff.
    IF ls_dd09l-pufferung = 'P'.
      ls_textinput-value = abap_true.
    ENDIF.
    ls_textinput-flag = abap_true.
    APPEND ls_textinput TO lt_ts_buffer_type_l.
    CLEAR ls_textinput.
    ls_textinput-name = txt_generic_area_buffered.
    IF ls_dd09l-pufferung = 'G'.
      ls_textinput-value = abap_true.
    ENDIF.
    ls_textinput-flag = abap_true.
    APPEND ls_textinput TO lt_ts_buffer_type_l.
    CLEAR ls_textinput.
    ls_textinput-name = txt_fully_buffered.
    IF ls_dd09l-pufferung = 'X'.
      ls_textinput-value = abap_true.
    ENDIF.
    ls_textinput-flag = abap_true.
    APPEND ls_textinput TO lt_ts_buffer_type_l.
    CLEAR ls_textinput.
    ls_textinput-space = abap_true.
    APPEND ls_textinput TO lt_ts_buffer_type_r.
    CLEAR ls_textinput.
    ls_textinput-name = txt_no_of_key_fields.
    PERFORM get_unpacked
      USING ls_dd09l-schfeldanz
      CHANGING ls_textinput-value.
    ls_textinput-input = abap_true.
    APPEND ls_textinput TO lt_ts_buffer_type_r.
    CLEAR ls_textinput.
    ls_textinput-space = abap_true.
    APPEND ls_textinput TO lt_ts_buffer_type_r.
*   bottom
    CLEAR ls_textinput.
    ls_textinput-name = txt_log_data_changes.
    ls_textinput-value = ls_dd09l-protokoll.
    ls_textinput-flag = abap_true.
    APPEND ls_textinput TO lt_ts_bottom.
*enhancement category
    ASSIGN COMPONENT 'EXCLASS' OF STRUCTURE ls_dd02v TO <l_exclass>.
    IF <l_exclass> IS ASSIGNED.
      LOOP AT lt_ddranking ASSIGNING <ls_ddranking>.
        ls_exclass-ddtext = <ls_ddranking>-text.
        ls_exclass-checked = abap_false.
        IF <ls_ddranking>-value = <l_exclass>.
          ls_exclass-checked = abap_true.
        ENDIF.
        APPEND ls_exclass TO lt_exclass.
      ENDLOOP.
    ENDIF.
*Table Maintenance Generator
    SELECT SINGLE * FROM tvdir INTO ls_tvdir
        WHERE tabname = l_tabname.
    SELECT SINGLE * FROM objh INTO ls_objh
        WHERE objectname = l_tabname
        AND objecttype = 'S'.
*   technical dialog details
    SELECT SINGLE * FROM tddat INTO ls_tddat
        WHERE tabname = l_tabname.
    SELECT SINGLE * FROM tbrgt INTO ls_tbrgt
        WHERE brgru = ls_tddat-cclass
        AND spras = sy-langu.
*
    CLEAR ls_textinput.
    ls_textinput-name = txt_authorization_group.
    ls_textinput-value = ls_tddat-cclass.
    PERFORM encode_html CHANGING ls_textinput-value.
    ls_textinput-input = abap_true.
    ls_textinput-description = ls_tbrgt-bezei.
    PERFORM encode_html CHANGING ls_textinput-description.
    APPEND ls_textinput TO lt_tmg_tech_details.
*
    CLEAR ls_textinput.
    ls_textinput-name = txt_authorization_object___1.
    ls_textinput-value = ls_tbrgt-brobj.
    APPEND ls_textinput TO lt_tmg_tech_details.
*
    CLEAR ls_textinput.
    ls_textinput-name = txt_function_group.
    ls_textinput-value = ls_tvdir-area.
    ls_textinput-input = abap_true.
    APPEND ls_textinput TO lt_tmg_tech_details.
*
    CLEAR ls_textinput.
    ls_textinput-name = txt_package.
    ls_textinput-value = ls_tvdir-devclass.
    ls_textinput-input = abap_true.
    APPEND ls_textinput TO lt_tmg_tech_details.
*   dialog data transport details
    PERFORM get_dom_value_text
      USING 'OBJIMP' ls_objh-importable
      CHANGING l_compare_flag.
*Table Documentation
    PERFORM get_docu
      USING
        'TB'
        <ls_ztadir>-obj_name
        'E'
      CHANGING
        lt_doc.
*Text table
    CLEAR ls_link.
    CALL FUNCTION 'TABLE_GET_TEXTTABLE'
      EXPORTING
        checktable = l_tabname
      IMPORTING
        tabname    = l_texttabname
      EXCEPTIONS
        OTHERS     = 1.
    IF sy-subrc = 0.
      l_text_obj_name = l_texttabname.
      SELECT SINGLE devclass FROM tadir INTO l_text_devclass
          WHERE pgmid = <ls_ztadir>-pgmid
          AND object = <ls_ztadir>-object
          AND obj_name = l_text_obj_name.
      IF l_text_devclass = g_pack.
        CONCATENATE l_texttabname '.' gc_extension_htm
            INTO ls_link-href.
        ls_link-onclick = 'window.location=this.href'.
      ENDIF.
      ls_link-descript = txt_text_table.
      ls_link-title = l_texttabname.
      APPEND ls_link TO lt_link.
    ENDIF.
*Content
    CLEAR ls_link.
    READ TABLE gt_tadir TRANSPORTING NO FIELDS
      WITH KEY obj_name = <ls_ztadir>-obj_name.
    IF sy-subrc = 0.
*  csv
      IF g_add_db_format_csv = abap_true.
        PERFORM data2csv
          USING l_tabname
          CHANGING lt_csv.
        PERFORM download
          USING
            lt_csv
            <ls_ztadir>-pgmid
            <ls_ztadir>-object
            <ls_ztadir>-obj_name
            gc_extension_csv
            abap_false.
        ls_link-href = <ls_ztadir>-obj_name.
        SPLIT ls_link-href AT '/' INTO TABLE lt_str.
        LOOP AT lt_str INTO ls_link-href.
        ENDLOOP.
        CONCATENATE ls_link-href '.' gc_extension_csv
          INTO ls_link-href.
        ls_link-onclick = 'window.open(this.href)'.
        ls_link-descript = gc_extension_csv.
        APPEND ls_link TO lt_link.
      ENDIF.
*  xml
      IF g_add_db_format_xml = abap_true.
        PERFORM data2xml
          USING l_tabname
          CHANGING lt_xml.
        PERFORM download
          USING
            lt_xml
            <ls_ztadir>-pgmid
            <ls_ztadir>-object
            <ls_ztadir>-obj_name
            gc_extension_xml
            abap_false.
        ls_link-href = <ls_ztadir>-obj_name.
        SPLIT ls_link-href AT '/' INTO TABLE lt_str.
        LOOP AT lt_str INTO ls_link-href.
        ENDLOOP.
        CONCATENATE ls_link-href '.' gc_extension_xml
          INTO ls_link-href.
        ls_link-onclick = 'window.open(this.href)'.
        ls_link-descript = gc_extension_xml.
        APPEND ls_link TO lt_link.
      ENDIF.
    ENDIF.
***
    LOOP AT lt_tabstrip ASSIGNING <ls_tabstrip>.
      <ls_tabstrip>-empty = abap_false.
      CASE <ls_tabstrip>-id.
        WHEN 'DOC'.
          IF lt_doc IS INITIAL.
            <ls_tabstrip>-empty = abap_true.
          ENDIF.
        WHEN 'EXCLASS'.
          IF lt_exclass IS INITIAL.
            <ls_tabstrip>-hidden = abap_true.
          ENDIF.
      ENDCASE.
    ENDLOOP.
    CASE <ls_ztadir>-tabclass.
      WHEN 'CLUSTER'.
        l_name_value = txt_cluster_table.
      WHEN 'POOL'.
        l_name_value = txt_pooled_table.
      WHEN 'TRANSP'.
        l_name_value = txt_transp_table.
      WHEN OTHERS.
        l_name_value = txt_table.
    ENDCASE.
*HTML header
    PERFORM html_main_header
      USING
        tpt_ddic_tabl
        l_name_value
        <ls_ztadir>-obj_name
        txt_active___1
        txt_short_text___2
        <ls_ztadir>-descript
        space
        lt_tabstrip
        lt_link
      CHANGING
        lt_html.
*HTML technical settings
    PERFORM html_add_tech_settings
      USING
        txt_logical_storage_parameters
        lt_ts_params
        txt_buffering
        lt_ts_buffer
        txt_buffering_type
        lt_ts_buffer_type_l
        lt_ts_buffer_type_r
        lt_ts_bottom
        'TECH_SETTINGS'
        abap_false
      CHANGING
        lt_html.
*HTML enhancement category
    IF NOT lt_exclass IS INITIAL.
      PERFORM html_add_box_radiobuttons
        USING
          txt_enhancement_category_for_s
          'EXCLASS'
          lt_exclass
          'EXCLASS'
          abap_false
        CHANGING
          lt_html.
    ENDIF.
*HTML table maintenance generator
    PERFORM html_add_tablemaintgenerator
      USING
        txt_technical_dialog_details
        lt_tmg_tech_details
        txt_maintenance_screens
        ls_tvdir-type
        ls_tvdir-liste
        ls_tvdir-detail
        txt_dialog_data_transport_deta
        ls_tvdir-flag
        l_compare_flag
        'TABLE_MAINT_GEN'
        abap_false
      CHANGING
        lt_html.
*HTML documentation
    IF NOT lt_doc IS INITIAL
    OR g_empty_tab = gc_empty_tab_display.
      PERFORM html_add_doc
        USING
          lt_doc
          'DOC'
          abap_false
        CHANGING
          lt_html.
    ENDIF.
*HTML attributes
    PERFORM html_add_attributes_1
      USING
        ls_attributes
        'ATTRIBUTES'
        abap_false
      CHANGING
        lt_html.
    PERFORM html_add_deliv_maint
      USING
        ls_deliv_maint
        lt_access
        'DELIVMAINT'
        abap_false
      CHANGING
        lt_html.
*HTML fields
    PERFORM html_add_table
      USING
        'TABL2FIELD'
        lt_dd03p
        lt_zdd03p_ext
        'FIELDS'
        abap_true
      CHANGING
        lt_html.
*HTML entry help check
    PERFORM html_add_table
      USING
        'TABL2ENTRY'
        lt_dd03p
        lt_zdd03p_ext
        'ENTRY_HELP_CHECK'
        abap_false
      CHANGING
        lt_html.
*HTML curr quant fields
    PERFORM html_add_table
      USING
        'TABL2CURRQ'
        lt_dd03p
        lt_zdd03p_ext
        'CURR_QUANT_FIELDS'
        abap_false
      CHANGING
        lt_html.
*HTML footer
    PERFORM html_main_footer
      USING
        lt_html.
    PERFORM download
      USING
        lt_html
        <ls_ztadir>-pgmid
        <ls_ztadir>-object
        <ls_ztadir>-obj_name
        gc_extension_htm
        abap_true.
  ENDLOOP.
ENDFORM.                    "r3tr_tabl_2


*-----------------------------------------------------------------------
* ddic_r3tr_tabl_get                             SAP-Tabellen
*-----------------------------------------------------------------------
FORM ddic_r3tr_tabl_get
  CHANGING
    cs_ztadir TYPE st_ztadir
    cs_dd02v TYPE dd02v
    ct_dd03p TYPE dd03ttyp
    ct_zdd03p_ext TYPE it_zdd03p_ext
    cs_dd09l TYPE dd09l.


  CLEAR:
  cs_dd02v,
  cs_dd09l.

  REFRESH:
  ct_dd03p,
  ct_zdd03p_ext.

  DATA:
  l_strukname TYPE strukname,
  ls_dd02v_n TYPE dd02v,
  lt_dd03p_n TYPE STANDARD TABLE OF dd03p,
  lt_dd05m TYPE STANDARD TABLE OF dd05m,
  lt_dd05m_n TYPE STANDARD TABLE OF dd05m,
  lt_dd08v TYPE STANDARD TABLE OF dd08v,
  lt_dd08v_n TYPE STANDARD TABLE OF dd08v,
  ls_dd09v_n TYPE dd09v,
  lt_dd12v TYPE STANDARD TABLE OF dd12v,
  lt_dd12v_n TYPE STANDARD TABLE OF dd12v,
  lt_dd17v TYPE STANDARD TABLE OF dd17v,
  lt_dd17v_n TYPE STANDARD TABLE OF dd17v,
  lt_dd35v TYPE STANDARD TABLE OF dd35v,
  lt_dd35v_n TYPE STANDARD TABLE OF dd35v,
  lt_dd36m TYPE STANDARD TABLE OF dd36m,
  lt_dd36m_n TYPE STANDARD TABLE OF dd36m,
  ls_zdd03p_ext TYPE st_zdd03p_ext,
  l_state TYPE dctablget.

  FIELD-SYMBOLS:
  <ls_dd03p> TYPE dd03p.


  l_strukname = cs_ztadir-obj_name.
  CALL FUNCTION 'DD_TABL_GET'
    EXPORTING
      tabl_name    = l_strukname
      withtext     = abap_true
      add_typeinfo = abap_true
    IMPORTING
      dd02v_wa_a   = cs_dd02v
      dd02v_wa_n   = ls_dd02v_n
      dd09l_wa_a   = cs_dd09l
      dd09l_wa_n   = ls_dd09v_n
      got_state    = l_state
    TABLES
      dd03p_tab_a  = ct_dd03p
      dd03p_tab_n  = lt_dd03p_n
      dd05m_tab_a  = lt_dd05m
      dd05m_tab_n  = lt_dd05m_n
      dd08v_tab_a  = lt_dd08v
      dd08v_tab_n  = lt_dd08v_n
      dd12v_tab_a  = lt_dd12v
      dd12v_tab_n  = lt_dd12v_n
      dd17v_tab_a  = lt_dd17v
      dd17v_tab_n  = lt_dd17v_n
      dd35v_tab_a  = lt_dd35v
      dd35v_tab_n  = lt_dd35v_n
      dd36m_tab_a  = lt_dd36m
      dd36m_tab_n  = lt_dd36m_n
    EXCEPTIONS
      OTHERS       = 1.
  IF sy-subrc <> 0.
    cs_ztadir-subrc = sy-subrc.
    RETURN.
  ENDIF.

  IF cs_dd02v-masterlang IS INITIAL.
    SELECT SINGLE masterlang FROM tadir INTO cs_dd02v-masterlang
        WHERE pgmid = 'R3TR'
        AND object = 'TABL'
        AND obj_name = l_strukname.
  ENDIF.

  LOOP AT ct_dd03p ASSIGNING <ls_dd03p>.
    IF <ls_dd03p>-fieldname = '.INCLU--AP'.
      <ls_dd03p>-fieldname = '.APPEND'.
    ENDIF.
    IF <ls_dd03p>-rollname IS INITIAL
    AND NOT <ls_dd03p>-precfield IS INITIAL.
      SELECT SINGLE tabname FROM dd02l INTO <ls_dd03p>-rollname
        WHERE tabname = <ls_dd03p>-precfield
        AND as4local = 'A'.
      IF sy-subrc = 0.
        <ls_dd03p>-datatype = 'STRU'.
      ELSE.
        SELECT SINGLE typename FROM dd40l INTO <ls_dd03p>-rollname
          WHERE typename = <ls_dd03p>-precfield
          AND as4local = 'A'.
        IF sy-subrc = 0.
          <ls_dd03p>-datatype = 'TTYP'.
        ENDIF.
      ENDIF.
    ENDIF.

    CLEAR ls_zdd03p_ext.
    CASE <ls_dd03p>-shlporigin.
      WHEN 'F'.
        ls_zdd03p_ext-shlporigin_f = abap_true.
      WHEN 'P'.
        ls_zdd03p_ext-shlporigin_p = abap_true.
    ENDCASE.
    IF NOT <ls_dd03p>-shlporigin IS INITIAL.
      PERFORM get_dom_value_text
        USING
          'SHLPORIGIN'
          <ls_dd03p>-shlporigin
        CHANGING
          ls_zdd03p_ext-shlporigin_ddtext.
    ENDIF.
    APPEND ls_zdd03p_ext TO ct_zdd03p_ext.
  ENDLOOP.
ENDFORM.                    "r3tr_tabl_get


*-----------------------------------------------------------------------
* ddic_r3tr_ttyp                                 Tabellentypen
*-----------------------------------------------------------------------
FORM ddic_r3tr_ttyp.

  DATA:
  lt_html TYPE it_string,
  lt_tabstrip TYPE it_tabstrip,
  l_typename TYPE typename,
  lt_dom_value_accessmode TYPE it_dom_value,
  lt_dom_value_keydef TYPE it_dom_value,
  lt_dom_value_keykind TYPE it_dom_value,
  ls_access TYPE st_access,
  ls_attributes TYPE st_attributes,
  ls_line_type TYPE st_line_type,
  ls_init_access TYPE st_init_access,
  ls_key TYPE st_key,
  lt_accessmode TYPE it_access,
  lt_keykind TYPE it_access,
  lt_keydef TYPE it_access,
  ls_dd40v TYPE dd40v,
  ls_dd40v_n TYPE dd40v,
  ls_dd42v TYPE dd42v,
  lt_dd42v TYPE STANDARD TABLE OF dd42v,
  lt_dd42v_n TYPE STANDARD TABLE OF dd42v,
  l_state TYPE dcttypget,
  l_ttypkind TYPE c.

  FIELD-SYMBOLS:
  <l_datatype> TYPE ANY,
  <l_dataleng> TYPE ANY,
  <l_decimals> TYPE ANY,
  <l_reftype> TYPE ANY,
  <l_rowkind> TYPE ANY,
  <l_rowtype> TYPE ANY,
  <l_occurs> TYPE ANY,
  <l_range_ctyp> TYPE ANY,
  <l_ttypkind> TYPE ANY,
  <ls_ztadir> TYPE st_ztadir,
  <ls_dom_value> TYPE st_dom_value.

  PERFORM get_tabstrip
    USING 'DDIC_R3TR_TTYP' space
    CHANGING lt_tabstrip.

  PERFORM get_dom_value_texts
    USING
      'ACCESSMODE'
    CHANGING
      lt_dom_value_accessmode.
  PERFORM get_dom_value_texts
    USING
      'TTYPKEYDEF'
    CHANGING
      lt_dom_value_keydef.
  PERFORM get_dom_value_texts
    USING
      'KEYKIND'
    CHANGING
      lt_dom_value_keykind.


  LOOP AT gt_ztadir ASSIGNING <ls_ztadir>
      WHERE pgmid = 'R3TR'
      AND object = 'TTYP'
      AND downloaded = abap_false.
    <ls_ztadir>-downloaded = abap_true.

    CLEAR:
    ls_attributes,
    ls_line_type,
    ls_init_access,
    ls_key,
    l_ttypkind.

    REFRESH:
    lt_html,
    lt_dd42v,
    lt_dd42v_n.

    l_typename = <ls_ztadir>-obj_name.
    CALL FUNCTION 'DD_TTYP_GET'
      EXPORTING
        ttyp_name   = l_typename
        langu       = sy-langu
        withtext    = abap_true
      IMPORTING
        got_state   = l_state
        dd40v_wa_a  = ls_dd40v
        dd40v_wa_n  = ls_dd40v_n
      TABLES
        dd42v_tab_a = lt_dd42v
        dd42v_tab_n = lt_dd42v_n
      EXCEPTIONS
        OTHERS      = 1.
    IF sy-subrc <> 0.
      <ls_ztadir>-subrc = sy-subrc.
      CONTINUE.
    ENDIF.
    ASSIGN COMPONENT 'TTYPKIND' OF STRUCTURE ls_dd40v TO <l_ttypkind>.
    IF <l_ttypkind> IS ASSIGNED.
      l_ttypkind = <l_ttypkind>.
      UNASSIGN <l_ttypkind>.
    ENDIF.
*attributes
    ls_attributes-bname = ls_dd40v-as4user.
    PERFORM get_date
      USING
        ls_dd40v-as4date
      CHANGING
        ls_attributes-date_last_changed.
    ls_attributes-devclass = <ls_ztadir>-devclass.
    PERFORM get_devclass
      USING
        <ls_ztadir>-devclass
      CHANGING
        ls_attributes-devclass_descr.
    IF ls_dd40v-ddlanguage IS INITIAL.
      SELECT SINGLE masterlang FROM tadir INTO ls_dd40v-ddlanguage
          WHERE pgmid = 'R3TR'
          AND object = 'TTYP'
          AND obj_name = l_typename.
    ENDIF.
    PERFORM get_spras
      USING
        ls_dd40v-ddlanguage
      CHANGING
        ls_attributes-laiso
        ls_attributes-sptxt.
    PERFORM get_user
      USING
        ls_dd40v-as4user
      CHANGING
        ls_attributes-name_text.
*linetype
    ls_line_type-rowkind = ls_dd40v-rowkind.
    ASSIGN COMPONENT 'ROWKIND' OF STRUCTURE ls_dd40v TO <l_rowkind>.
    IF <l_rowkind> IS ASSIGNED.
      ls_line_type-rowkind = <l_rowkind>.
      UNASSIGN <l_rowkind>.
    ENDIF.
    ASSIGN COMPONENT 'ROWTYPE' OF STRUCTURE ls_dd40v TO <l_rowtype>.
    IF <l_rowtype> IS ASSIGNED.
      ls_line_type-rowtype = <l_rowtype>.
      UNASSIGN <l_rowtype>.
    ENDIF.
    PERFORM get_dom_value_text
      USING
        'TYPEKIND'
        ls_dd40v-rowtype
      CHANGING
        ls_line_type-rowdescr.
    ASSIGN COMPONENT 'DATATYPE' OF STRUCTURE ls_dd40v TO <l_datatype>.
    IF <l_datatype> IS ASSIGNED.
      ls_line_type-datatype = <l_datatype>.
      UNASSIGN <l_datatype>.
    ENDIF.
    ASSIGN COMPONENT 'LENG' OF STRUCTURE ls_dd40v TO <l_dataleng>.
    IF <l_dataleng> IS ASSIGNED.
      ls_line_type-dataleng = <l_dataleng>.
      UNASSIGN <l_dataleng>.
    ENDIF.
    ASSIGN COMPONENT 'DECIMALS' OF STRUCTURE ls_dd40v TO <l_decimals>.
    IF <l_decimals> IS ASSIGNED.
      ls_line_type-datadeci = <l_decimals>.
      UNASSIGN <l_decimals>.
    ENDIF.
    ls_line_type-datadeci = ls_dd40v-decimals.
    ASSIGN COMPONENT 'REFTYPE' OF STRUCTURE ls_dd40v TO <l_reftype>.
    IF <l_reftype> IS ASSIGNED.
      ls_line_type-reftype = <l_reftype>.
      PERFORM get_dom_value_text
        USING
          'DDREFTYPE'
          <l_reftype>
        CHANGING
          ls_line_type-refdescr.
      UNASSIGN <l_reftype>.
    ELSE.
      ls_line_type-reftype = '#'.  " R/3 4.6 does not know ref type
    ENDIF.
    ASSIGN COMPONENT 'RANGE_CTYP' OF STRUCTURE ls_dd40v
      TO <l_range_ctyp>.
    IF <l_range_ctyp> IS ASSIGNED.
      ls_line_type-range_ctyp = <l_range_ctyp>.
      UNASSIGN <l_range_ctyp>.
    ENDIF.
    ASSIGN COMPONENT 'CTDATATYPE' OF STRUCTURE ls_dd40v
      TO <l_datatype>.
    IF <l_datatype> IS ASSIGNED.
      ls_line_type-ctdatatype = <l_datatype>.
      UNASSIGN <l_datatype>.
    ENDIF.
    ASSIGN COMPONENT 'CTLENG' OF STRUCTURE ls_dd40v TO <l_dataleng>.
    IF <l_dataleng> IS ASSIGNED.
      ls_line_type-ctleng = <l_dataleng>.
      UNASSIGN <l_dataleng>.
    ENDIF.
    ASSIGN COMPONENT 'CTDECIMALS' OF STRUCTURE ls_dd40v
      TO <l_decimals>.
    IF <l_decimals> IS ASSIGNED.
      ls_line_type-ctdecimals = <l_decimals>.
      UNASSIGN <l_decimals>.
    ENDIF.
*initaccess
    ASSIGN COMPONENT 'OCCURS' OF STRUCTURE ls_dd40v TO <l_occurs>.
    IF <l_occurs> IS ASSIGNED.
      ls_init_access-occurs = <l_occurs>.
      UNASSIGN <l_occurs>.
    ELSE.
      ls_init_access-unknown = abap_true.
    ENDIF.

    REFRESH lt_accessmode.
    LOOP AT lt_dom_value_accessmode ASSIGNING <ls_dom_value>.
      CLEAR ls_access.
      ls_access-ddtext = <ls_dom_value>-text.
      IF ls_dd40v-accessmode = <ls_dom_value>-value.
        ls_access-checked = abap_true.
      ENDIF.
      APPEND ls_access TO lt_accessmode.
    ENDLOOP.
*key
    REFRESH lt_keydef.
    LOOP AT lt_dom_value_keydef ASSIGNING <ls_dom_value>.
      CLEAR ls_access.
      ls_access-ddtext = <ls_dom_value>-text.
      IF ls_dd40v-keydef = <ls_dom_value>-value.
        ls_access-checked = abap_true.
      ENDIF.
      APPEND ls_access TO lt_keydef.
    ENDLOOP.

    REFRESH lt_keykind.
    LOOP AT lt_dom_value_keykind ASSIGNING <ls_dom_value>.
      CLEAR ls_access.
      ls_access-ddtext = <ls_dom_value>-text.
      IF ls_dd40v-keykind = <ls_dom_value>-value.
        ls_access-checked = abap_true.
      ENDIF.
      APPEND ls_access TO lt_keykind.
    ENDLOOP.
***
    IF ls_dd40v-generic = abap_true.
      ls_line_type-info = txt_type_is_generic.
      ls_init_access-info1 = txt_type_is_generic.
      ls_key-info = txt_type_is_generic.
    ENDIF.
    IF l_ttypkind = 'R'.
      ls_init_access-info2 = txt_access_type_is_given_for_a.
      CONCATENATE
        txt_key_attribute_defined_for1
        txt_key_attribute_defined_for2
        INTO ls_key-info SEPARATED BY space.
    ENDIF.

**************
    PERFORM html_main_header
      USING
        tpt_ddic_ttyp
        txt_table_type
        <ls_ztadir>-obj_name
        txt_active___1
        txt_short_text___2
        <ls_ztadir>-descript
        space
        lt_tabstrip
        gt_link
      CHANGING
        lt_html.
*HTML attributes
    PERFORM html_add_attributes_1
      USING
        ls_attributes
        'ATTRIBUTES'
        abap_false
      CHANGING
        lt_html.
*HTML line type
    IF l_ttypkind = 'R'.
      PERFORM html_add_line_type_2
        USING
          ls_line_type
          'LINETYPE'
          abap_true
        CHANGING
          lt_html.
    ELSE.
      PERFORM html_add_line_type_1
        USING
          ls_line_type
          'LINETYPE'
          abap_true
        CHANGING
          lt_html.
    ENDIF.
*HTML init access
    PERFORM html_add_init_access
      USING
        ls_init_access
        lt_accessmode
        'INITACCESS'
        abap_false
      CHANGING
        lt_html.
*HTML key
    PERFORM html_add_key
      USING
        ls_key
        lt_keydef
        lt_keykind
        'TTYP_DD42V'
        lt_dd42v
        'KEY'
        abap_false
      CHANGING
        lt_html.
*
    PERFORM html_main_footer
      USING
        lt_html.

    PERFORM download
      USING
        lt_html
        <ls_ztadir>-pgmid
        <ls_ztadir>-object
        <ls_ztadir>-obj_name
        gc_extension_htm
        abap_true.
  ENDLOOP.
ENDFORM.                                                    "r3tr_ttyp


*-----------------------------------------------------------------------
* ddic_r3tr_type                                 Suchhilfen
*-----------------------------------------------------------------------
FORM ddic_r3tr_type.

  DATA:
  lt_html TYPE it_string,
  l_progname TYPE progname,
  ls_trdir TYPE trdir,
  lt_source TYPE it_string,
  ls_attributes TYPE st_attributes,
  lt_tabstrip TYPE it_tabstrip.

  FIELD-SYMBOLS:
  <ls_ztadir> TYPE st_ztadir.

  PERFORM get_tabstrip
    USING 'DDIC_R3TR_TYPE' space
    CHANGING lt_tabstrip.

  LOOP AT gt_ztadir ASSIGNING <ls_ztadir>
      WHERE pgmid = 'R3TR'
      AND object = 'TYPE'
      AND downloaded = abap_false.
    <ls_ztadir>-downloaded = abap_true.

    CLEAR:
    ls_attributes.

    REFRESH:
    lt_html.

    CALL FUNCTION 'RS_TADIR_TO_PROGNAME'
      EXPORTING
        object   = 'TYPE'
        obj_name = <ls_ztadir>-obj_name
      IMPORTING
        progname = l_progname.
    SELECT SINGLE * FROM trdir
        INTO ls_trdir
        WHERE name = l_progname.
    IF sy-subrc <> 0.
      <ls_ztadir>-subrc = sy-subrc.
      CONTINUE.
    ENDIF.
    ls_attributes-bname = ls_trdir-unam.
    PERFORM get_date
      USING
        ls_trdir-udat
      CHANGING
        ls_attributes-date_last_changed.
    ls_attributes-devclass = <ls_ztadir>-devclass.
    PERFORM get_devclass
      USING
        <ls_ztadir>-devclass
      CHANGING
        ls_attributes-devclass_descr.
    IF ls_trdir-rload IS INITIAL.
      SELECT SINGLE masterlang FROM tadir INTO ls_trdir-rload
          WHERE pgmid = 'R3TR'
          AND object = 'TYPE'
          AND obj_name = <ls_ztadir>-obj_name.
    ENDIF.
    PERFORM get_spras
      USING
        ls_trdir-rload
      CHANGING
        ls_attributes-laiso
        ls_attributes-sptxt.
    PERFORM get_user
      USING
        ls_trdir-unam
      CHANGING
        ls_attributes-name_text.
    PERFORM try_read_report
      USING l_progname
      CHANGING lt_source.
*HTML
    PERFORM html_main_header
      USING
        tpt_ddic_type
        txt_type_group
        <ls_ztadir>-obj_name
        txt_active___1
        txt_short_text___2
        <ls_ztadir>-descript
        'makeDivSize(''SOURCECODE'')'
        lt_tabstrip
        gt_link
      CHANGING
        lt_html.
    PERFORM html_add_attributes_1
      USING
        ls_attributes
        'ATTRIBUTES'
        abap_false
      CHANGING
        lt_html.
    PERFORM html_add_sourcecode
      USING
        lt_source
        <ls_ztadir>-obj_name
        space
        space
        gc_extension_txt
        'SOURCECODE'
        abap_true
      CHANGING
        lt_html.
    PERFORM html_main_footer
      USING
        lt_html.

    PERFORM download
      USING
        lt_html
        <ls_ztadir>-pgmid
        <ls_ztadir>-object
        <ls_ztadir>-obj_name
        gc_extension_htm
        abap_true.
    IF g_add_sourcecode = abap_true.
      PERFORM download
        USING
          lt_source
          <ls_ztadir>-pgmid
          <ls_ztadir>-object
          <ls_ztadir>-obj_name
          gc_extension_txt
          abap_false.
    ENDIF.
  ENDLOOP.
ENDFORM.                                                    "r3tr_type


*-----------------------------------------------------------------------
* ddic_r3tr_view                                 Aggregat-Header
*                               (Views, Matchcode-Objekte, Sperrobjekte)
*-----------------------------------------------------------------------
FORM ddic_r3tr_view.

  DATA:
  lt_html TYPE it_string,
  lt_tabstrip TYPE it_tabstrip,
  l_viewname TYPE viewname,
  ls_attributes TYPE st_attributes,
  ls_tabname TYPE st_tabname,
  lt_tabname TYPE it_tabname,
  ls_join_conditions TYPE st_join_conditions,
  lt_join_conditions TYPE it_join_conditions,
  lt_tables TYPE it_tables,
  ls_table TYPE st_table_structure,
  ls_deliv_maint TYPE st_deliv_maint,
  lt_dom_value_viewgrant TYPE it_dom_value,
  lt_access TYPE it_access,
  ls_access TYPE st_access,
  ls_dd09v TYPE dd09v,
  ls_dd09v_n TYPE dd09v,
  ls_dd25v TYPE dd25v,
  ls_dd25v_n TYPE dd25v,
  lt_dd26v TYPE STANDARD TABLE OF dd26v,
  lt_dd26v_n TYPE STANDARD TABLE OF dd26v,
  lt_dd27p TYPE STANDARD TABLE OF dd27p,
  lt_dd27p_n TYPE STANDARD TABLE OF dd27p,
  lt_dd28v TYPE STANDARD TABLE OF dd28v,
  lt_dd28v_n TYPE STANDARD TABLE OF dd28v,
  l_state TYPE dcviewget,
  l_id TYPE string,
  l_txt_viewclass TYPE as4text,
  lt_ts_buffer TYPE it_access,
  lt_ts_buffer_type_l TYPE it_textinput,
  lt_ts_buffer_type_r TYPE it_textinput,
  ls_textinput TYPE st_textinput,
  l_ddtext TYPE ddtext,
  lt_dom_value TYPE it_dom_value,
  lt_create TYPE it_string,
  l_filename TYPE string.

  FIELD-SYMBOLS:
  <ls_ztadir> TYPE st_ztadir,
  <ls_dom_value> TYPE st_dom_value,
  <ls_dd26v> TYPE dd26v,
  <ls_dd27p> TYPE dd27p,
  <ls_dd28v> TYPE dd28v,
  <ls_tabstrip> TYPE st_tabstrip.

  PERFORM get_dom_value_texts
    USING
      'VIEWGRANT'
    CHANGING
      lt_dom_value_viewgrant.

  LOOP AT gt_ztadir ASSIGNING <ls_ztadir>
      WHERE pgmid = 'R3TR'
      AND object = 'VIEW'
      AND downloaded = abap_false.
    <ls_ztadir>-downloaded = abap_true.

    CLEAR:
    ls_attributes,
    l_txt_viewclass,
    ls_textinput,
    l_ddtext,
    l_filename.

    REFRESH:
    lt_html,
    lt_dd26v,
    lt_dd26v_n,
    lt_dd27p,
    lt_dd27p_n,
    lt_dd28v,
    lt_dd28v_n,
    lt_ts_buffer,
    lt_ts_buffer_type_l,
    lt_ts_buffer_type_r,
    lt_create.

    l_viewname = <ls_ztadir>-obj_name.
    CALL FUNCTION 'DD_VIEW_GET'
      EXPORTING
        view_name   = l_viewname
        langu       = sy-langu
        withtext    = abap_true
      IMPORTING
        dd25v_wa_a  = ls_dd25v
        dd25v_wa_n  = ls_dd25v_n
        dd09l_wa_a  = ls_dd09v
        dd09l_wa_n  = ls_dd09v_n
        got_state   = l_state
      TABLES
        dd26v_tab_a = lt_dd26v
        dd26v_tab_n = lt_dd26v_n
        dd27p_tab_a = lt_dd27p
        dd27p_tab_n = lt_dd27p_n
        dd28v_tab_a = lt_dd28v
        dd28v_tab_n = lt_dd28v_n
      EXCEPTIONS
        OTHERS      = 1.
    IF sy-subrc <> 0.
      <ls_ztadir>-subrc = sy-subrc.
      CONTINUE.
    ENDIF.
*attributes
    ls_attributes-bname = ls_dd25v-as4user.
    PERFORM get_date
      USING
        ls_dd25v-as4date
      CHANGING
        ls_attributes-date_last_changed.
    ls_attributes-devclass = <ls_ztadir>-devclass.
    PERFORM get_devclass
      USING
        <ls_ztadir>-devclass
      CHANGING
        ls_attributes-devclass_descr.
    IF ls_dd25v-masterlang IS INITIAL.
      SELECT SINGLE masterlang FROM tadir INTO ls_dd25v-masterlang
          WHERE pgmid = 'R3TR'
          AND object = 'VIEW'
          AND obj_name = l_viewname.
    ENDIF.
    PERFORM get_spras
      USING
        ls_dd25v-masterlang
      CHANGING
        ls_attributes-laiso
        ls_attributes-sptxt.
    PERFORM get_user
      USING
        ls_dd25v-as4user
      CHANGING
        ls_attributes-name_text.
    IF ls_dd25v-viewclass CO 'A'.
      ls_attributes-display_appview = abap_true.
      ls_attributes-appview = ls_dd25v-roottab.
    ENDIF.
*technical settings
    IF NOT ls_dd09v-tabname IS INITIAL.
*     buffering
      PERFORM get_dom_value_texts
        USING 'BUFALLOW'
        CHANGING lt_dom_value.
      LOOP AT lt_dom_value ASSIGNING <ls_dom_value>.
        CLEAR ls_access.
        ls_access-ddtext = <ls_dom_value>-text.
        IF <ls_dom_value>-value = ls_dd09v-bufallow.
          ls_access-checked = abap_true.
        ENDIF.
        APPEND ls_access TO lt_ts_buffer.
      ENDLOOP.
*     buffering type
      CLEAR ls_textinput.
      ls_textinput-name = txt_single_records_buff.
      IF ls_dd09v-pufferung = 'P'.
        ls_textinput-value = abap_true.
      ENDIF.
      ls_textinput-flag = abap_true.
      APPEND ls_textinput TO lt_ts_buffer_type_l.
      CLEAR ls_textinput.
      ls_textinput-name = txt_generic_area_buffered.
      IF ls_dd09v-pufferung = 'G'.
        ls_textinput-value = abap_true.
      ENDIF.
      ls_textinput-flag = abap_true.
      APPEND ls_textinput TO lt_ts_buffer_type_l.
      CLEAR ls_textinput.
      ls_textinput-name = txt_fully_buffered.
      IF ls_dd09v-pufferung = 'X'.
        ls_textinput-value = abap_true.
      ENDIF.
      ls_textinput-flag = abap_true.
      APPEND ls_textinput TO lt_ts_buffer_type_l.
      CLEAR ls_textinput.
      ls_textinput-space = abap_true.
      APPEND ls_textinput TO lt_ts_buffer_type_r.
      CLEAR ls_textinput.
      ls_textinput-name = txt_no_of_key_fields.
      PERFORM get_unpacked
        USING ls_dd09v-schfeldanz
        CHANGING ls_textinput-value.
      ls_textinput-input = abap_true.
      APPEND ls_textinput TO lt_ts_buffer_type_r.
      CLEAR ls_textinput.
      ls_textinput-space = abap_true.
      APPEND ls_textinput TO lt_ts_buffer_type_r.
    ENDIF.
*CREATE Statement
    CALL FUNCTION 'DB_GET_VIEW_DEFINITION_RAW'
      EXPORTING
        viewname = l_viewname
      TABLES
        text_tab = lt_create
      EXCEPTIONS
        OTHERS   = 1.
*tables for joining
    REFRESH lt_tabname.
*  data
    LOOP AT lt_dd26v ASSIGNING <ls_dd26v>.
      ls_tabname-tabname = <ls_dd26v>-tabname.
      APPEND ls_tabname TO lt_tabname.
    ENDLOOP.
    SORT lt_tabname BY tabname.
    DELETE ADJACENT DUPLICATES FROM lt_tabname.

*join conditions - data
    REFRESH lt_join_conditions.
    IF ls_dd25v-viewclass CO 'HDCV'.
*  data
      REFRESH lt_join_conditions.
      SORT lt_dd28v BY position.
      LOOP AT lt_dd28v ASSIGNING <ls_dd28v>.
        IF <ls_dd28v>-negation = 'JL'.
          ls_join_conditions-tabname_l = <ls_dd28v>-tabname.
          ls_join_conditions-fieldname_l = <ls_dd28v>-fieldname.
          PERFORM get_gui_operator
            USING
              <ls_dd28v>-operator
            CHANGING
              ls_join_conditions-operator.
        ELSE.
          ls_join_conditions-tabname_r = <ls_dd28v>-tabname.
          ls_join_conditions-fieldname_r = <ls_dd28v>-fieldname.
          APPEND ls_join_conditions TO lt_join_conditions.
        ENDIF.
      ENDLOOP.
    ENDIF.

*selection condition
    IF ls_dd25v-viewclass CO 'HDCV'.
      DELETE lt_dd28v WHERE constants = space.
    ENDIF.
*maint status - access
    REFRESH lt_access.
    LOOP AT lt_dom_value_viewgrant ASSIGNING <ls_dom_value>.
      CLEAR ls_access.
      IF ls_dd25v-viewclass CO 'HCV'
      OR <ls_dom_value>-value NA 'MU'.
        ls_access-ddtext = <ls_dom_value>-text.
        IF ls_dd25v-viewgrant = <ls_dom_value>-value.
          ls_access-checked = abap_true.
        ENDIF.
        APPEND ls_access TO lt_access.
      ENDIF.
    ENDLOOP.
*maint status - others
    CLEAR ls_deliv_maint.
    ls_deliv_maint-display_cont = abap_false.
    ls_deliv_maint-display_main = abap_false.
    IF ls_dd25v-viewclass CO 'CV'.
      ls_deliv_maint-display_cont = abap_true.
      ls_deliv_maint-contflag = ls_dd25v-customauth.
      PERFORM get_dom_value_text
        USING
          'CONTFLAG'
          ls_dd25v-customauth
        CHANGING
          ls_deliv_maint-contflag_text.
    ENDIF.
    IF ls_dd25v-viewclass CO 'DPCV'.
      ls_deliv_maint-display_main = abap_true.
      PERFORM get_dom_value_text
        USING
          'MAINTFLAG'
          ls_dd25v-globalflag
        CHANGING
          ls_deliv_maint-mainflag_text.
    ENDIF.
***Tabstrip
    PERFORM get_tabstrip
      USING 'DDIC_R3TR_VIEW' ls_dd25v-viewclass
      CHANGING lt_tabstrip.
    LOOP AT lt_tabstrip ASSIGNING <ls_tabstrip>.
      <ls_tabstrip>-empty = abap_false.
      CASE <ls_tabstrip>-id.
        WHEN 'CREATE'.
          IF lt_create IS INITIAL.
            <ls_tabstrip>-empty = abap_true.
          ENDIF.
        WHEN 'SELECTIONCONDITIONS'.
          IF lt_dd28v IS INITIAL.
            <ls_tabstrip>-empty = abap_true.
          ENDIF.
      ENDCASE.
    ENDLOOP.

*HTML header
    PERFORM get_dom_value_text
      USING
        'VIEWCLASS'
        ls_dd25v-viewclass
      CHANGING
        l_txt_viewclass.
    PERFORM html_main_header
      USING
        tpt_ddic_view
        l_txt_viewclass
        <ls_ztadir>-obj_name
        txt_active___1
        txt_short_text___2
        <ls_ztadir>-descript
        space
        lt_tabstrip
        gt_link
      CHANGING
        lt_html.
*HTML technical settings
    IF ls_dd25v-viewclass CO 'HDPSCV'.
      PERFORM html_add_box1rb_subbox2ti
        USING
          txt_buffering
          lt_ts_buffer
          txt_buffering_type
          lt_ts_buffer_type_l
          lt_ts_buffer_type_r
          'TECH_SETTINGS'
          abap_false
        CHANGING
          lt_html.
    ENDIF.
*HTML CREATE Statement
    IF ls_dd25v-viewclass CO 'HDPSCV'.
      IF NOT lt_create IS INITIAL
      OR g_empty_tab = gc_empty_tab_display.
        CONCATENATE l_viewname '_CREATE' INTO l_filename.
        PERFORM html_add_sourcecode
          USING
            lt_create
            l_filename
            space
            space
            gc_extension_txt
            'CREATE'
            abap_false
          CHANGING
            lt_html.
        IF NOT lt_create IS INITIAL
        AND g_add_sourcecode = abap_true.
          PERFORM download
            USING
              lt_create
              <ls_ztadir>-pgmid
              <ls_ztadir>-object
              l_filename
              gc_extension_txt
              abap_false.
        ENDIF.
      ENDIF.
    ENDIF.
*HTML attributes
    PERFORM html_add_attributes_1
      USING
        ls_attributes
        'ATTRIBUTES'
        abap_false
      CHANGING
        lt_html.
*HTML table/join conditions
    IF ls_dd25v-viewclass CO 'HDCV'.
      PERFORM html_add_table2hor
        USING
          'VIEW_JOINT'
          lt_tabname
          lt_tabname
          'VIEW_JOINC'
          lt_join_conditions
          lt_join_conditions
          'TABJOINCONDITIONS'
          abap_false
        CHANGING
          lt_html.
    ENDIF.
*HTML view fields
    PERFORM get_id
      USING 'VIEW_FIELD|' ls_dd25v-viewclass
      CHANGING l_id.
    IF ls_dd25v-viewclass CO 'HDPCV'.
      PERFORM html_add_table
        USING
          l_id
          lt_dd27p
          lt_dd27p
          'VIEWFIELDS'
          abap_true
        CHANGING
          lt_html.
    ELSEIF ls_dd25v-viewclass CO 'AS'.
      PERFORM html_add_table2hor
        USING
          'VIEW_JOINT'
          lt_tabname
          lt_tabname
          l_id
          lt_dd27p
          lt_dd27p
          'VIEWFIELDS'
          abap_true
        CHANGING
          lt_html.
    ENDIF.
*HTML selection conditions
    IF ls_dd25v-viewclass CO 'HDCV'.
      IF NOT lt_dd28v IS INITIAL
      OR g_empty_tab = gc_empty_tab_display.
        PERFORM html_add_table
          USING
            'VIEW_SELEC'
            lt_dd28v
            lt_dd28v
            'SELECTIONCONDITIONS'
            abap_false
          CHANGING
            lt_html.
      ENDIF.
    ENDIF.
*HTML maint status
    IF ls_dd25v-viewclass CO 'HDCV'.
      PERFORM html_add_deliv_maint
        USING
          ls_deliv_maint
          lt_access
          'DELIVMAINT'
          abap_false
        CHANGING
          lt_html.
    ENDIF.
*HTML footer
    PERFORM html_main_footer
      USING
        lt_html.
*download
    PERFORM download
      USING
        lt_html
        <ls_ztadir>-pgmid
        <ls_ztadir>-object
        <ls_ztadir>-obj_name
        gc_extension_htm
        abap_true.
  ENDLOOP.
ENDFORM.                                                    "r3tr_view
