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


*-----------------------------------------------------------------------
* t
*-----------------------------------------------------------------------
FORM t.
*Message Classes
  PERFORM t_r3tr_msag.
*Authorization Oject
  PERFORM t_r3tr_tobj.
*SET/GET Parameters
  PERFORM t_r3tr_para.
*Transactions
  PERFORM t_r3tr_tran.
ENDFORM.                    "t


*-----------------------------------------------------------------------
* t_r3tr_msag                                   Message Classes
*-----------------------------------------------------------------------
FORM t_r3tr_msag.

  DATA:
  ls_ti TYPE st_textinput,
  lt_attr TYPE it_textinput,
  lt_box TYPE it_textinput,
  l_arbgb TYPE arbgb,
  l_bname TYPE xubname,
  l_name_text TYPE ad_namtext,
  ls_t100a TYPE t100a,
  l_laiso TYPE laiso,
  l_sptxt TYPE sptxt,
  lt_html TYPE it_string,
  ls_tabstrip TYPE st_tabstrip,
  lt_tabstrip TYPE it_tabstrip,
  lt_t100 TYPE STANDARD TABLE OF t100,
  ls_t100ext TYPE st_t100ext,
  lt_t100ext TYPE it_t100ext,
  lt_doc TYPE it_string.

  FIELD-SYMBOLS:
  <ls_ztadir> TYPE st_ztadir,
  <ls_t100> TYPE t100,
  <ls_t100ext> TYPE st_t100ext.

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

    CLEAR:
    ls_ti,
    ls_t100a.

    REFRESH:
    lt_attr,
    lt_box,
    lt_html,
    lt_t100,
    lt_t100ext,
    lt_tabstrip,
    lt_doc.

    l_arbgb = <ls_ztadir>-obj_name.

    SELECT SINGLE * FROM t100a INTO ls_t100a
        WHERE arbgb = l_arbgb.
*TabStrip
    PERFORM get_tabstrip
      USING 'T_R3TR_MSAG' space
      CHANGING lt_tabstrip.
*Attributes
*   Package
    CLEAR ls_ti.
    ls_ti-name = txt_package.
    ls_ti-value = <ls_ztadir>-devclass.
    ls_ti-input = abap_true.
    APPEND ls_ti TO lt_attr.
*   Last changed by
    CLEAR ls_ti.
    ls_ti-name = txt_last_changed_by___3.
    ls_ti-value = ls_t100a-lastuser.
    l_bname = ls_t100a-lastuser.
    PERFORM get_user
      USING l_bname
      CHANGING l_name_text.
    ls_ti-value_text = l_name_text.
    ls_ti-value_ext_space = abap_true.
    ls_ti-input = abap_true.
    ls_ti-has_value_ext = abap_true.
    APPEND ls_ti TO lt_attr.
*   Changed on
    CLEAR ls_ti.
    ls_ti-name = txt_changed_on.
    PERFORM get_date
      USING
        ls_t100a-ldate
      CHANGING
        ls_ti-value.
    ls_ti-value_ext_space = abap_true.
    ls_ti-input = abap_true.
    ls_ti-has_value_ext = abap_true.
    APPEND ls_ti TO lt_attr.
*   Last changed at
    CLEAR ls_ti.
    ls_ti-name = txt_last_changed_at.
    PERFORM get_time
      USING
        ls_t100a-ltime
      CHANGING
        ls_ti-value.
    ls_ti-value_ext_space = abap_true.
    ls_ti-input = abap_true.
    ls_ti-has_value_ext = abap_true.
    APPEND ls_ti TO lt_attr.
*Attributes - Box
*   Original lang.
    CLEAR ls_ti.
    ls_ti-name = txt_original_lang.
    PERFORM get_spras
      USING ls_t100a-masterlang
      CHANGING l_laiso l_sptxt.
    ls_ti-value = l_laiso.
    ls_ti-value_text = l_sptxt.
    ls_ti-value_ext_space = abap_true.
    ls_ti-input = abap_true.
    ls_ti-has_value_ext = abap_true.
    APPEND ls_ti TO lt_box.
*   Person respons.
    CLEAR ls_ti.
    ls_ti-name = txt_person_respons.
    ls_ti-value = ls_t100a-respuser.
    l_bname = ls_t100a-respuser.
    PERFORM get_user
      USING l_bname
      CHANGING l_name_text.
    ls_ti-value_text = l_name_text.
    ls_ti-value_ext_space = abap_true.
    ls_ti-input = abap_true.
    ls_ti-has_value_ext = abap_true.
    APPEND ls_ti TO lt_box.
*   Short text
    CLEAR ls_ti.
    ls_ti-name = txt_short_text___1.
    ls_ti-value = <ls_ztadir>-descript.
    ls_ti-input = abap_true.
    APPEND ls_ti TO lt_box.
*Messages
    SELECT * FROM t100 INTO TABLE lt_t100
        WHERE arbgb = l_arbgb
        AND sprsl = sy-langu.
    LOOP AT lt_t100 ASSIGNING <ls_t100>.
      CLEAR ls_t100ext.
*     T100U
      SELECT SINGLE name datum FROM t100u
          INTO (ls_t100ext-name,ls_t100ext-datum)
          WHERE arbgb = <ls_t100>-arbgb
          AND msgnr = <ls_t100>-msgnr.
      l_bname = ls_t100ext-name.
      IF NOT l_bname IS INITIAL.
        PERFORM get_user
          USING l_bname
          CHANGING ls_t100ext-name_text.
        PERFORM get_date
          USING ls_t100ext-datum
          CHANGING ls_t100ext-datum_text.
      ENDIF.
*     Documentation
      CALL FUNCTION 'DOCU_OBJECT_NAME_CONCATENATE'
        EXPORTING
          docu_id  = 'NA'
          element  = <ls_t100>-arbgb
          addition = <ls_t100>-msgnr
        IMPORTING
          object   = ls_t100ext-object_name
        EXCEPTIONS
          OTHERS   = 0.
      CALL FUNCTION 'DOCU_SELFDEF_READ'
        EXPORTING
          object_id   = 'NA'
          object_name = ls_t100ext-object_name
        IMPORTING
          selfdef     = ls_t100ext-selfdef
        EXCEPTIONS
          OTHERS      = 0.
      IF NOT ls_t100ext-selfdef IS INITIAL.
        ls_t100ext-no_docu = abap_true.
      ELSE.
        ls_t100ext-ltext = '-->'.
        CONCATENATE 'switchContent(''' ls_t100ext-object_name ''')'
            INTO ls_t100ext-ltext_onclick.
        CLEAR ls_tabstrip.
        ls_tabstrip-id = ls_t100ext-object_name.
        ls_tabstrip-hidden = abap_true.
        APPEND ls_tabstrip TO lt_tabstrip.
      ENDIF.
      APPEND ls_t100ext TO lt_t100ext.
    ENDLOOP.
*HTML
    PERFORM html_main_header
      USING
        tpt_msag
        txt_message_class
        <ls_ztadir>-obj_name
        txt_active___1
        space
        space
        space
        lt_tabstrip
        gt_link
      CHANGING
        lt_html.
*   Attributes
    PERFORM html_add_textinput_subbox
      USING
        lt_attr
        txt_attributes___2
        lt_box
        'ATTRIBUTES'
        abap_true
      CHANGING
        lt_html.
*   Messages
    PERFORM html_add_table
      USING
        'MSAG_MESS'
        lt_t100
        lt_t100ext
        'MESSAGES'
        abap_false
      CHANGING
        lt_html.
*   Documentation
    LOOP AT lt_t100ext ASSIGNING <ls_t100ext>
        WHERE no_docu = abap_false.
      PERFORM get_docu
        USING
          'NA'
          <ls_t100ext>-object_name
          'E'
        CHANGING
          lt_doc.
      PERFORM html_add_doc
        USING
          lt_doc
          <ls_t100ext>-object_name
          abap_false
        CHANGING
          lt_html.
    ENDLOOP.
*
    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.
    <ls_ztadir>-downloaded = abap_true.
  ENDLOOP.

ENDFORM.                                                    "r3tr_msag


*-----------------------------------------------------------------------
* t_r3tr_tobj                                   Authorization Object
*-----------------------------------------------------------------------
FORM t_r3tr_tobj.

  DATA:
  l_objct TYPE xuobject,
  ls_tobj TYPE tobj,
  ls_ti TYPE st_textinput,
  lt_attr TYPE it_textinput,
  lt_box TYPE it_textinput,
  lt_actvt_attr TYPE it_textinput,
  lt_actvt TYPE it_textinput,
  lt_tactz TYPE STANDARD TABLE OF tactz,
  l_xutxt TYPE xutxt30,
  lt_html TYPE it_string,
  l_ctext TYPE xutext,
  l_bname TYPE xubname,
  l_name_text TYPE ad_namtext,
  l_field TYPE tobj-fiel1,
  l_text TYPE as4text,
  l_has_actvt TYPE flag,
  lt_doc TYPE it_string,
  lt_tabstrip TYPE it_tabstrip,
  l_javascript TYPE string.

  FIELD-SYMBOLS:
  <ls_ztadir> TYPE st_ztadir,
  <ls_tactz> TYPE tactz,
  <ls_tabstrip> TYPE st_tabstrip.

*TabStrip
  PERFORM get_tabstrip
    USING 'T_R3TR_TOBJ' space
    CHANGING lt_tabstrip.

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

    CLEAR:
    l_objct,
    ls_tobj,
    ls_ti,
    l_ctext,
    l_bname,
    l_name_text,
    l_has_actvt,
    l_javascript.

    REFRESH:
    lt_attr,
    lt_box,
    lt_actvt_attr,
    lt_actvt,
    lt_tactz,
    lt_doc,
    lt_html.

    l_objct = <ls_ztadir>-obj_name.

    SELECT SINGLE * FROM tobj INTO ls_tobj
        WHERE objct = l_objct.

    SELECT SINGLE ctext FROM tobct INTO l_ctext
        WHERE oclss = ls_tobj-oclss
        AND langu = sy-langu.

*Attributes
*   Class
    CLEAR ls_ti.
    ls_ti-name = txt_class.
    ls_ti-value = ls_tobj-oclss.
    ls_ti-value_ext = l_ctext.
    ls_ti-input = abap_true.
    ls_ti-has_value_ext = abap_true.
    APPEND ls_ti TO lt_attr.
*   Author
    CLEAR ls_ti.
    ls_ti-name = txt_autor.
    ls_ti-value = ls_tobj-bname.
    l_bname = ls_tobj-bname.
    PERFORM get_user
      USING l_bname
      CHANGING l_name_text.
    ls_ti-value_text = l_name_text.
    ls_ti-input = abap_true.
    APPEND ls_ti TO lt_attr.
*Attributes - Box
    DO 10 TIMES VARYING l_field
        FROM ls_tobj-fiel1 NEXT ls_tobj-fiel2.
      CLEAR:
      l_text,
      ls_ti.
      IF NOT l_field IS INITIAL.
        IF l_field = 'ACTVT'.
          l_has_actvt = abap_true.
        ENDIF.
        CALL FUNCTION 'AUTH_FIELD_GET_INFO'
          EXPORTING
            fieldname = l_field
          IMPORTING
            text      = l_text.
      ENDIF.
      ls_ti-value = l_field.
      ls_ti-value_ext = l_text.
      ls_ti-has_value_ext = abap_true.
      ls_ti-no_name = abap_true.
      ls_ti-input = abap_true.
      APPEND ls_ti TO lt_box.
    ENDDO.
*Documentation
    PERFORM get_docu
      USING
        'UO'
        l_objct
        'E'
      CHANGING
        lt_doc.
*Activities
    SELECT * FROM tactz INTO TABLE lt_tactz
        WHERE brobj = l_objct.
    SORT lt_tactz BY actvt.
    LOOP AT lt_tactz ASSIGNING <ls_tactz>.
      SELECT SINGLE ltext FROM tactt INTO l_xutxt
          WHERE actvt = <ls_tactz>-actvt
          AND spras = sy-langu.
      CLEAR ls_ti.
      ls_ti-name = <ls_tactz>-actvt.
      ls_ti-value = abap_true.
      ls_ti-flag = abap_true.
      ls_ti-description = l_xutxt.
      APPEND ls_ti TO lt_actvt.
    ENDLOOP.
*Activities - Attributes
    CLEAR ls_ti.
    ls_ti-name = txt_conversion_for_authorizati.
    ls_ti-value = ls_tobj-conversion.
    ls_ti-flag = abap_true.
    APPEND ls_ti TO lt_actvt_attr.
    CLEAR ls_ti.
    ls_ti-name = txt_activity.
    IF l_has_actvt = abap_true.
      ls_ti-value = 'ACTVT'.
    ENDIF.
    ls_ti-input = abap_true.
    APPEND ls_ti TO lt_actvt_attr.
*Tabstrip
    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
    IF NOT lt_doc IS INITIAL.
      l_javascript = 'makeDivSize(''DOC'');'.
    ENDIF.
    PERFORM html_main_header
      USING
        tpt_tobj
        txt_object
        <ls_ztadir>-obj_name
        space
        txt_text
        <ls_ztadir>-descript
        l_javascript
        lt_tabstrip
        gt_link
      CHANGING
        lt_html.
*Attributes
    PERFORM html_add_textinput_subbox
      USING
        lt_attr
        txt_authorization_fields
        lt_box
        'ATTRIBUTES'
        abap_true
      CHANGING
        lt_html.
*Activities
    PERFORM html_add_textinput_subbox
      USING
        lt_actvt_attr
        txt_values
        lt_actvt
        'ACTVT'
        abap_false
      CHANGING
        lt_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.
*
    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.
    <ls_ztadir>-downloaded = abap_true.
  ENDLOOP.

ENDFORM.                                                    "r3tr_tobj


*-----------------------------------------------------------------------
* t_r3tr_para                                   SET/GET Parameters
*-----------------------------------------------------------------------
FORM t_r3tr_para.

  DATA:
  ls_ti TYPE st_textinput,
  lt_ti TYPE it_textinput,
  l_filename TYPE string,
  lt_html TYPE it_string.

  FIELD-SYMBOLS:
  <ls_ztadir> TYPE st_ztadir.

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

    REFRESH:
    lt_html,
    lt_ti.

    CLEAR ls_ti.
    ls_ti-name = txt_parameter_id.
    ls_ti-value = <ls_ztadir>-obj_name.
    ls_ti-input = abap_true.
    APPEND ls_ti TO lt_ti.

    CLEAR ls_ti.
    ls_ti-name = txt_text.
    ls_ti-value = <ls_ztadir>-descript.
    ls_ti-input = abap_true.
    APPEND ls_ti TO lt_ti.

    l_filename = <ls_ztadir>-obj_name.
    PERFORM encode_uri_link CHANGING l_filename.
    PERFORM replace_all
      USING '%' 'x'
      CHANGING l_filename.

    PERFORM replace_all
      USING '<' '-'
      CHANGING l_filename.
    PERFORM replace_all
      USING '>' '-'
      CHANGING l_filename.
    PERFORM encode_uri
      CHANGING l_filename.

*** HTML
    PERFORM html_main_popupheader
      USING
        txt_component_information
      CHANGING
        lt_html.
*   Content
    PERFORM html_add_textinputnodiv
      USING
        lt_ti
      CHANGING
        lt_html.
*   Footer
    PERFORM html_main_popupfooter
      CHANGING lt_html.
*   Download
    PERFORM download
      USING
        lt_html
        <ls_ztadir>-pgmid
        <ls_ztadir>-object
        l_filename
        gc_extension_htm
        abap_true.

  ENDLOOP.

ENDFORM.                                                    "r3tr_para


*-----------------------------------------------------------------------
* t_r3tr_tran                                   Transactions
*-----------------------------------------------------------------------
FORM t_r3tr_tran.

  DATA:
  ls_tran TYPE st_transaction,
  ls_tstc TYPE tstc,
  ls_tstc_tmp TYPE tstc,
  lt_tstca TYPE STANDARD TABLE OF tstca,
  ls_tstcc TYPE tstcc,
  l_param TYPE tcdparam,
  l_tcode TYPE tcode,
  l_gui_title TYPE string,
  ls_ti TYPE st_textinput,
  lt_defval TYPE it_textinput,
  lt_gui_support TYPE it_textinput,
  lt_para TYPE it_transaction_para,
  ls_para TYPE st_transaction_para,
  lt_html TYPE it_string,
  l_off TYPE i,
  l_length TYPE i,
  l_str TYPE string,
  lt_str TYPE it_string,
  lt_tabstrip TYPE it_tabstrip.

  CONSTANTS:
  lc_hex_tra TYPE x VALUE '00',               " Transaktion         T
  lc_hex_men TYPE x VALUE '01',               " Bereichsmenue       M
  lc_hex_par TYPE x VALUE '02',               " Parametertrans.     P
  lc_hex_rep TYPE x VALUE '80',               " Report              R
  lc_hex_rpv TYPE x VALUE '10',               " Report  mit Variante
  lc_hex_obj TYPE x VALUE '08',               " Objekttransaktionen
  lc_hex_chk TYPE x VALUE '04',               " mit Pruefobjekt
  lc_oo_program(9)            VALUE '\PROGRAM=',
  lc_oo_class(7)              VALUE '\CLASS=',
  lc_oo_method(8)             VALUE '\METHOD=',
  lc_oo_tcode LIKE tstc-tcode VALUE 'OS_APPLICATION'.

  FIELD-SYMBOLS:
  <ls_ztadir> TYPE st_ztadir,
  <ls_tstca> TYPE tstca,
  <l_pervas> TYPE ANY.

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

    CLEAR:
    ls_para,
    ls_tran,
    ls_ti,
    ls_tstc,
    ls_tstc_tmp,
    ls_tstcc,
    l_param,
    l_tcode,
    l_gui_title,
    l_off,
    l_length,
    l_str.

    REFRESH:
    lt_tstca,
    lt_defval,
    lt_gui_support,
    lt_para,
    lt_html,
    lt_str,
    lt_tabstrip.


    l_tcode = <ls_ztadir>-obj_name.

    SELECT SINGLE * FROM tstc INTO ls_tstc
        WHERE tcode = l_tcode.
    ls_tran-pgmna = ls_tstc-pgmna.
    ls_tran-dypno = ls_tstc-dypno.
    IF ls_tstc-arbgb <> '&&'.
      ls_tran-trans_var = abap_true.
    ENDIF.

    SELECT * FROM tstca INTO TABLE lt_tstca
        WHERE tcode = l_tcode.
    LOOP AT lt_tstca ASSIGNING <ls_tstca>.
      ls_tran-objct = <ls_tstca>-objct.
      EXIT.
    ENDLOOP.

    SELECT SINGLE * FROM tstcc INTO ls_tstcc
        WHERE tcode = l_tcode.
    IF ls_tstcc-s_webgui = '2'.
      ls_tran-clf_ewt = abap_true.
      ls_tran-clf_profi = abap_false.
    ELSE.
      ls_tran-clf_ewt = abap_false.
      ls_tran-clf_profi = abap_true.
    ENDIF.
    ASSIGN COMPONENT 'S_PERVAS' OF STRUCTURE ls_tstcc TO <l_pervas>.
    IF <l_pervas> IS ASSIGNED.
      ls_tran-clf_pervas = <l_pervas>.
      UNASSIGN <l_pervas>.
    ENDIF.
    ls_tran-clf_service = ls_tstcc-s_service.
*Parameter
    SELECT SINGLE param FROM tstcp INTO l_param
        WHERE tcode = l_tcode.

    CASE l_param(1).
      WHEN '\'.
        IF l_param CS lc_oo_program.
          l_off = sy-fdpos + 9.
          l_length = strlen( l_param ) - l_off.
          l_str = l_param+l_off(l_length).
          IF l_str CA '\'.
            ls_tran-pgmna = l_str+0(sy-fdpos).
          ELSE.
            ls_tran-pgmna = l_str.
          ENDIF.
        ENDIF.
        IF l_param CS lc_oo_class.
          l_off = sy-fdpos + 7.
          l_length = strlen( l_param ) - l_off.
          l_str = l_param+l_off(l_length).
          IF l_str CA '\'.
            ls_tran-classname = l_str+0(sy-fdpos).
          ELSE.
            ls_tran-classname = l_str.
          ENDIF.
        ENDIF.
        IF l_param CS lc_oo_method.
          l_off = sy-fdpos + 8.
          l_length = strlen( l_param ) - l_off.
          l_str = l_param+l_off(l_length).
          IF l_str CA '\'.
            ls_tran-method = l_str+0(sy-fdpos).
          ELSE.
            ls_tran-method = l_str.
          ENDIF.
        ENDIF.
        IF NOT ls_tstc-pgmna IS INITIAL.
          ls_tran-local = abap_true.
        ENDIF.
      WHEN '@'.
        l_off = 1.
        IF l_param(2) = '@@'.
          l_off = 2.
          ls_tran-ind_vari = abap_true.
        ENDIF.
        IF l_param CA space. ENDIF.
        l_length = sy-fdpos - l_off.
        ls_tran-def_call_tcode = l_param+l_off(l_length).

        l_off = l_off + l_length + 1.
        l_length = strlen( l_param ).
        SUBTRACT l_off FROM l_length.
        ls_tran-variant = l_param+l_off(l_length).
      WHEN '/'.
        IF l_param+1(1) = '*'.
          ls_tran-def_skip_1 = abap_true.
        ENDIF.

        IF l_param CA space. ENDIF.
        l_length = sy-fdpos.
        IF l_length > 2.
          SUBTRACT 2 FROM l_length.
          ls_tran-def_call_tcode = l_param+2(l_length).
          SELECT SINGLE * FROM tstc INTO ls_tstc_tmp
              WHERE tcode = ls_tran-def_call_tcode.
          IF sy-subrc = 0.
            "...
          ENDIF.

          IF l_param CA '='.
            l_off = 3 + l_length.
            l_length = strlen( l_param ).
            SUBTRACT l_off FROM l_length.
            l_str = l_param+l_off(l_length).

            SPLIT l_str AT ';' INTO TABLE lt_str.
            LOOP AT lt_str INTO l_str.
              IF l_str CA '='.
                CLEAR ls_para.
                SPLIT l_str AT '=' INTO
                    ls_para-para_field ls_para-para_value.
                APPEND ls_para TO lt_para.
              ENDIF.
            ENDLOOP.
          ENDIF.
        ENDIF.
      WHEN OTHERS.
        IF l_param CA '='.
          SPLIT l_param AT ';' INTO TABLE lt_str.
          LOOP AT lt_str INTO l_str.
            IF l_str CA '='.
              CLEAR ls_para.
              SPLIT l_str AT '=' INTO
                  ls_para-para_field ls_para-para_value.
              APPEND ls_para TO lt_para.
            ENDIF.
          ENDLOOP.
        ENDIF.
    ENDCASE.
***
    SELECT SINGLE ttext FROM tstct INTO ls_tran-ttext
        WHERE sprsl = sy-langu
        AND tcode = l_tcode.
***
    IF ls_tstc-cinfo O lc_hex_rep.       "report transaction
      ls_tran-ttype = gc_tcode_report.
      l_gui_title = tpt_tran_repo.
      IF ls_tran-dypno IS INITIAL.
        ls_tran-dypno = '1000'.
      ENDIF.
      IF ls_tstc-cinfo O lc_hex_rpv AND NOT l_param IS INITIAL.
        ls_tran-repo_vari = l_param.
      ENDIF.
    ELSEIF ls_tstc-cinfo O lc_hex_obj.   "object transaction
      ls_tran-ttype = gc_tcode_object.
      l_gui_title = tpt_tran_obj.
      IF ls_tran-def_call_tcode = lc_oo_tcode.
        ls_tran-trframe = abap_true.
      ENDIF.
    ELSEIF ls_tstc-cinfo O lc_hex_par.   "parameter transaction
      ls_tran-ttype = gc_tcode_parameter.
      l_gui_title = tpt_tran_param.
      IF NOT l_param IS INITIAL
      AND l_param(1) = '@'.                 "variant transaction
        ls_tran-ttype = gc_tcode_variant.
        l_gui_title = tpt_tran_vari.
      ELSEIF ls_tran-def_call_tcode = lc_oo_tcode.
        "object transaction
        ls_tran-ttype = gc_tcode_object.
        l_gui_title = tpt_tran_obj.
        ls_tran-trframe = abap_true.
      ENDIF.
    ELSEIF ls_tstc-cinfo O lc_hex_men.   "menue
    ELSE.                                   "dialog transaction
      ls_tran-ttype = gc_tcode_dialog.
      l_gui_title = tpt_tran_dialog.
    ENDIF.

    IF NOT ls_tran-def_call_tcode IS INITIAL
    AND ( ls_tstcc IS INITIAL OR ls_tstcc = l_tcode )
    AND ls_tran-ttype <> gc_tcode_object.
      ls_tran-clf_inhe = abap_true.
      SELECT SINGLE * FROM tstcc INTO ls_tstcc
          WHERE tcode = ls_tran-def_call_tcode.
      IF ls_tstcc-s_webgui = '2'.
        ls_tran-clf_ewt = abap_true.
        ls_tran-clf_profi = abap_false.
      ELSE.
        ls_tran-clf_ewt = abap_false.
        ls_tran-clf_profi = abap_true.
      ENDIF.
      ASSIGN COMPONENT 'S_PERVAS' OF STRUCTURE ls_tstcc TO <l_pervas>.
      IF <l_pervas> IS ASSIGNED.
        ls_tran-clf_pervas = <l_pervas>.
        UNASSIGN <l_pervas>.
      ENDIF.
      ls_tran-clf_service = ls_tstcc-s_service.
    ENDIF.

*Default values for
    CLEAR ls_ti.
    ls_ti-name = txt_transaction.
    ls_ti-value = ls_tran-def_call_tcode.
    ls_ti-input = abap_true.
    APPEND ls_ti TO lt_defval.
    CLEAR ls_ti.
    ls_ti-name = txt_skip_initial_screen.
    ls_ti-value = ls_tran-def_skip_1.
    ls_ti-flag = abap_true.
    APPEND ls_ti TO lt_defval.
    CLEAR ls_ti.
    ls_ti-name = txt_screen.
    ls_ti-value = ls_tran-dypno.
    ls_ti-input = abap_true.
    ls_ti-has_value_ext = abap_true.
    ls_ti-value_ext_space = abap_true.
    APPEND ls_ti TO lt_defval.
    CLEAR ls_ti.
    ls_ti-name = txt_from_module_pool.
    ls_ti-value = ls_tran-pgmna.
    ls_ti-input = abap_true.
    APPEND ls_ti TO lt_defval.
*GUI support
    CLEAR ls_ti.
    ls_ti-name = txt_sapgui_for_html.
    ls_ti-flag = abap_true.
    IF NOT ls_tstcc-s_webgui IS INITIAL.
      ls_ti-value = abap_true.
    ENDIF.
    APPEND ls_ti TO lt_gui_support.
    CLEAR ls_ti.
    ls_ti-name = txt_sapgui_for_java.
    ls_ti-flag = abap_true.
    ls_ti-value = ls_tstcc-s_platin.
    APPEND ls_ti TO lt_gui_support.
    CLEAR ls_ti.
    ls_ti-name = txt_sapgui_for_windows.
    ls_ti-flag = abap_true.
    ls_ti-value = ls_tstcc-s_win32.
    APPEND ls_ti TO lt_gui_support.

*** HTML
    PERFORM html_main_header
      USING
        l_gui_title
        txt_transaction_code
        <ls_ztadir>-obj_name
        space
        txt_package
        <ls_ztadir>-devclass
        'makeDivSize(''TRANSACTION'');'
        lt_tabstrip
        gt_link
      CHANGING
        lt_html.
*Transaction
    PERFORM html_add_transaction
      USING
        ls_tran
        lt_tstca
        lt_defval
        lt_gui_support
        lt_para
        'TRANSACTION'
        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.
    <ls_ztadir>-downloaded = abap_true.
  ENDLOOP.
ENDFORM.                                                    "r3tr_tran
