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


*-----------------------------------------------------------------------
*  Selection screen declaration
*-----------------------------------------------------------------------
SELECTION-SCREEN FUNCTION KEY 1.
SELECTION-SCREEN FUNCTION KEY 2.
SELECTION-SCREEN FUNCTION KEY 3.

*-----------------------------------------------------------------------
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE t_choice.
* Package
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(22) t_pack.
SELECT-OPTIONS p_devcl FOR tdevc-devclass.
SELECTION-SCREEN END OF LINE.
* Folder
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(25) t_path.
PARAMETERS p_folder TYPE rlgrap-filename MEMORY ID mfolder.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK b1.

*-----------------------------------------------------------------------
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE t_opts.
* Add SourceCode
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(25) t_add_sc.
PARAMETERS p_add_sc AS CHECKBOX DEFAULT abap_true.
SELECTION-SCREEN END OF LINE.
* Empty Tab: display|disabled|hidden
SELECTION-SCREEN ULINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(25) t_etab.
PARAMETERS p_etab_n RADIOBUTTON GROUP etab.
SELECTION-SCREEN COMMENT 34(10) t_etab_n FOR FIELD p_etab_n.
PARAMETERS p_etab_d RADIOBUTTON GROUP etab DEFAULT 'X'.
SELECTION-SCREEN COMMENT 49(10) t_etab_d FOR FIELD p_etab_d.
PARAMETERS p_etab_h RADIOBUTTON GROUP etab.
SELECTION-SCREEN COMMENT 64(10) t_etab_h FOR FIELD p_etab_h.
SELECTION-SCREEN END OF LINE.
* database content
SELECTION-SCREEN ULINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(25) t_dbcont.
PARAMETERS p_dbcont AS CHECKBOX DEFAULT abap_true
  MODIF ID dis
  USER-COMMAND u_dbcont.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 6(20) t_dbform.
PARAMETERS p_db_csv AS CHECKBOX DEFAULT abap_true.
SELECTION-SCREEN COMMENT 29(15) t_db_csv.
PARAMETERS p_db_xml AS CHECKBOX DEFAULT abap_false.
SELECTION-SCREEN COMMENT 47(15) t_db_xml.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 6(20) t_dbmax.
PARAMETERS p_dbmax TYPE i DEFAULT 2000.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 6(17) t_dblim.
SELECT-OPTIONS p_dblim FOR dd02l-tabname.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 6(20) t_dbcls.
PARAMETERS p_dbclsa AS CHECKBOX DEFAULT abap_true.
SELECTION-SCREEN COMMENT 29(4) t_dbclsa.
PARAMETERS p_dbclsc AS CHECKBOX DEFAULT abap_true.
SELECTION-SCREEN COMMENT 36(4) t_dbclsc.
PARAMETERS p_dbclse AS CHECKBOX DEFAULT abap_true.
SELECTION-SCREEN COMMENT 43(4) t_dbclse.
PARAMETERS p_dbclsg AS CHECKBOX DEFAULT abap_true.
SELECTION-SCREEN COMMENT 50(4) t_dbclsg.
PARAMETERS p_dbclsl AS CHECKBOX DEFAULT abap_true.
SELECTION-SCREEN COMMENT 57(4) t_dbclsl.
PARAMETERS p_dbclss AS CHECKBOX DEFAULT abap_true.
SELECTION-SCREEN COMMENT 64(4) t_dbclss.
PARAMETERS p_dbclsw AS CHECKBOX DEFAULT abap_true.
SELECTION-SCREEN COMMENT 71(4) t_dbclsw.
SELECTION-SCREEN PUSHBUTTON 78(4) b_dbcls USER-COMMAND b_dbcls.
SELECTION-SCREEN END OF LINE.
* variants of reports
SELECTION-SCREEN ULINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(25) t_add_rv.
PARAMETERS p_add_rv AS CHECKBOX DEFAULT abap_true.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK b2.

*-----------------------------------------------------------------------
SELECTION-SCREEN: BEGIN OF BLOCK b3 WITH FRAME TITLE t_elems.
SELECTION-SCREEN BEGIN OF LINE.
* Dictionary Objects
PARAMETERS p_ddic AS CHECKBOX DEFAULT abap_true
  MODIF ID dis
  USER-COMMAND u_ddic.
SELECTION-SCREEN COMMENT 5(39) t_ddic.
* Transactions
PARAMETERS p_tran AS CHECKBOX DEFAULT abap_true.
SELECTION-SCREEN COMMENT 49(39) t_tran.
* ---
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
* Dictionary Objects - Database Tables
SELECTION-SCREEN POSITION 6.
PARAMETERS p_tabl AS CHECKBOX DEFAULT abap_true.
SELECTION-SCREEN COMMENT 10(34) t_tabl.
* Message Classes
PARAMETERS p_msag AS CHECKBOX DEFAULT abap_true.
SELECTION-SCREEN COMMENT 49(39) t_msag.
* ---
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
* Dictionary Objects - Views
SELECTION-SCREEN POSITION 6.
PARAMETERS p_view AS CHECKBOX DEFAULT abap_true.
SELECTION-SCREEN COMMENT 10(34) t_view.
* SET/GET Parameters
PARAMETERS p_para AS CHECKBOX DEFAULT abap_true.
SELECTION-SCREEN COMMENT 49(39) t_para.
* ---
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
* Dictionary Objects - Table Types
SELECTION-SCREEN POSITION 6.
PARAMETERS p_ttyp AS CHECKBOX DEFAULT abap_true.
SELECTION-SCREEN COMMENT 10(34) t_ttyp.
* Authorization Object
PARAMETERS p_tobj AS CHECKBOX DEFAULT abap_true.
SELECTION-SCREEN COMMENT 49(39) t_tobj.
* ---
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
* Dictionary Objects - Structures
SELECTION-SCREEN POSITION 6.
PARAMETERS p_struc AS CHECKBOX DEFAULT abap_true.
SELECTION-SCREEN COMMENT 10(34) t_struc.
* Transformations
PARAMETERS p_xslt AS CHECKBOX DEFAULT abap_true.
SELECTION-SCREEN COMMENT 49(39) t_xslt.
* ---
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
* Dictionary Objects - Data Elements
SELECTION-SCREEN POSITION 6.
PARAMETERS p_dtel AS CHECKBOX DEFAULT abap_true.
SELECTION-SCREEN COMMENT 10(34) t_dtel.
* BSP Library
PARAMETERS p_bsplib AS CHECKBOX DEFAULT abap_true
  MODIF ID dis
  USER-COMMAND u_bsplib.
SELECTION-SCREEN COMMENT 49(39) t_bsplib.
* ---
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
* Dictionary Objects - Domains
SELECTION-SCREEN POSITION 6.
PARAMETERS p_doma AS CHECKBOX DEFAULT abap_true.
SELECTION-SCREEN COMMENT 10(34) t_doma.
* BSP Library - BSP Applications
SELECTION-SCREEN POSITION 50.
PARAMETERS p_bspapp AS CHECKBOX DEFAULT abap_true
  MODIF ID dis
  USER-COMMAND u_bspapp.
SELECTION-SCREEN COMMENT 54(34) t_bspapp.
* ---
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
* Dictionary Objects - Search Helps
SELECTION-SCREEN POSITION 6.
PARAMETERS p_shlp AS CHECKBOX DEFAULT abap_true.
SELECTION-SCREEN COMMENT 10(34) t_shlp.
* BSP Library - BSP Applications - Controller
SELECTION-SCREEN POSITION 55.
PARAMETERS p_wctrl AS CHECKBOX DEFAULT abap_true.
SELECTION-SCREEN COMMENT 59(29) t_wctrl.
* ---
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
* Dictionary Objects - Lock Objects
SELECTION-SCREEN POSITION 6.
PARAMETERS p_enqu AS CHECKBOX DEFAULT abap_true.
SELECTION-SCREEN COMMENT 10(34) t_enqu.
* BSP Library - BSP Applications - Views
SELECTION-SCREEN POSITION 55.
PARAMETERS p_wview AS CHECKBOX DEFAULT abap_true.
SELECTION-SCREEN COMMENT 59(29) t_wview.
* ---
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
* Dictionary Objects - Type Groups
SELECTION-SCREEN POSITION 6.
PARAMETERS p_type AS CHECKBOX DEFAULT abap_true.
SELECTION-SCREEN COMMENT 10(34) t_type.
* BSP Library - BSP Applications - Pages with Flow Logic
SELECTION-SCREEN POSITION 55.
PARAMETERS p_wbsp AS CHECKBOX DEFAULT abap_true.
SELECTION-SCREEN COMMENT 59(29) t_wbsp.
* ---
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
* Class Library
PARAMETERS p_clslib AS CHECKBOX DEFAULT abap_true
  MODIF ID dis
  USER-COMMAND u_clslib.
SELECTION-SCREEN COMMENT 5(39) t_clslib.
* BSP Library - BSP Applications - Page Fragments
SELECTION-SCREEN POSITION 55.
PARAMETERS p_wincl AS CHECKBOX DEFAULT abap_true.
SELECTION-SCREEN COMMENT 59(29) t_wincl.

* ---
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
* Class Library - Classes
SELECTION-SCREEN POSITION 6.
PARAMETERS p_clas AS CHECKBOX DEFAULT abap_true.
SELECTION-SCREEN COMMENT 10(34) t_clas.
* BSP Library - BSP Applications - MIMEs
SELECTION-SCREEN POSITION 55.
PARAMETERS p_wmime AS CHECKBOX DEFAULT abap_true.
SELECTION-SCREEN COMMENT 59(29) t_wmime.

* ---
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
* Class Library - Interfaces
SELECTION-SCREEN POSITION 6.
PARAMETERS p_intf AS CHECKBOX DEFAULT abap_true.
SELECTION-SCREEN COMMENT 10(34) t_intf.
* BSP Library - BSP Extensions
SELECTION-SCREEN POSITION 50.
PARAMETERS p_bsptag AS CHECKBOX DEFAULT abap_true.
SELECTION-SCREEN COMMENT 54(34) t_bsptag.
* ---
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
* Programs
PARAMETERS p_prog AS CHECKBOX DEFAULT abap_true.
SELECTION-SCREEN COMMENT 5(39) t_prog.
* ---
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
* Function Groups
PARAMETERS p_fugr AS CHECKBOX DEFAULT abap_true
  MODIF ID dis
  USER-COMMAND u_fugr.
SELECTION-SCREEN COMMENT 5(39) t_fugr.
* ---
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
* Function Groups - Function Modules
SELECTION-SCREEN POSITION 6.
PARAMETERS p_fuba AS CHECKBOX DEFAULT abap_true.
SELECTION-SCREEN COMMENT 10(34) t_fuba.
* ---
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
* Function Groups - Screens
SELECTION-SCREEN POSITION 6.
PARAMETERS p_scr AS CHECKBOX DEFAULT abap_true.
SELECTION-SCREEN COMMENT 10(34) t_scr.
* ---
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
* Function Groups - Includes
SELECTION-SCREEN POSITION 6.
PARAMETERS p_fuincl AS CHECKBOX DEFAULT abap_true.
SELECTION-SCREEN COMMENT 10(34) t_fuincl.
* ---
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
* Includes
PARAMETERS p_incl AS CHECKBOX DEFAULT abap_true.
SELECTION-SCREEN COMMENT 5(39) t_incl.
* ---
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK b3.


*-----------------------------------------------------------------------
* Display a directory picker window
*-----------------------------------------------------------------------
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_folder.

  DATA:
  l_obj_file TYPE REF TO cl_gui_frontend_services,
  l_selected_folder TYPE string,
  l_initial_folder TYPE string,
  l_message TYPE string,
  l_txt TYPE string,
  l_subrc TYPE sysubrc.

  IF sy-batch IS INITIAL.
    PERFORM cl_gui_get_folder
      CHANGING
        l_selected_folder
        l_subrc.

    IF l_subrc = 0.
      p_folder = l_selected_folder.
    ELSE.
      PERFORM get_message_text USING 'EA' '334'
                                   p_folder space space space
                             CHANGING l_message.
      PERFORM decode_html_io
        USING txt_please_enter_a_root_dir
        CHANGING l_txt.
      WRITE: / l_message, / l_txt.
    ENDIF.
  ENDIF.


*-----------------------------------------------------------------------
* at selection-screen
*-----------------------------------------------------------------------
AT SELECTION-SCREEN.

  CASE sscrfields-ucomm.
    WHEN 'FC01'.
      p_bsplib = abap_true.
      p_bspapp = abap_true.
      p_wbsp = abap_true.
      p_wctrl = abap_true.
      p_wincl = abap_true.
      p_wmime = abap_true.
      p_wview = abap_true.
      p_bsptag = abap_true.
*
      p_clslib = abap_true.
      p_clas = abap_true.
      p_intf = abap_true.
*
      p_ddic = abap_true.
      p_doma = abap_true.
      p_dtel = abap_true.
      p_enqu = abap_true.
      p_shlp = abap_true.
      p_struc = abap_true.
      p_tabl = abap_true.
      p_ttyp = abap_true.
      p_type = abap_true.
      p_view = abap_true.
*
      p_fugr = abap_true.
      p_fuba = abap_true.
      p_fuincl = abap_true.
      p_scr = abap_true.
*
      p_incl = abap_true.
*
      p_msag = abap_true.
*
      p_para = abap_true.
*
      p_prog = abap_true.
*
      p_tobj = abap_true.
*
      p_tran = abap_true.
*
      p_xslt = abap_true.
    WHEN 'FC02'.
      p_bsplib = abap_false.
      p_bspapp = abap_false.
      p_wbsp = abap_false.
      p_wctrl = abap_false.
      p_wincl = abap_false.
      p_wmime = abap_false.
      p_wview = abap_false.
      p_bsptag = abap_false.
*
      p_clslib = abap_false.
      p_clas = abap_false.
      p_intf = abap_false.

      p_ddic = abap_false.
      p_doma = abap_false.
      p_dtel = abap_false.
      p_enqu = abap_false.
      p_shlp = abap_false.
      p_struc = abap_false.
      p_tabl = abap_false.
      p_ttyp = abap_false.
      p_type = abap_false.
      p_view = abap_false.
*
      p_fugr = abap_false.
      p_fuba = abap_false.
      p_fuincl = abap_false.
      p_scr = abap_false.
*
      p_incl = abap_false.
*
      p_msag = abap_false.
*
      p_para = abap_false.
*
      p_prog = abap_false.
*
      p_tobj = abap_false.
*
      p_tran = abap_false.
*
      p_xslt = abap_false.
    WHEN 'FC03'.
      PERFORM gui_info_page.
  ENDCASE.
*---------------------------
  CASE sy-ucomm.
    WHEN 'B_DBCLS'.
      PERFORM gui_info_dbcls.
    WHEN 'U_BSPAPP'.
      IF p_bspapp = abap_false.
        p_wbsp = abap_false.
        p_wctrl = abap_false.
        p_wincl = abap_false.
        p_wmime = abap_false.
        p_wview = abap_false.
      ELSE.
        p_wbsp = abap_true.
        p_wctrl = abap_true.
        p_wincl = abap_true.
        p_wmime = abap_true.
        p_wview = abap_true.
      ENDIF.
    WHEN 'U_BSPLIB'.
      IF p_bsplib = abap_false.
        p_bspapp = abap_false.
        p_bsptag = abap_false.
        p_wbsp = abap_false.
        p_wctrl = abap_false.
        p_wincl = abap_false.
        p_wmime = abap_false.
        p_wview = abap_false.
      ELSE.
        p_bspapp = abap_true.
        p_bsptag = abap_true.
        p_wbsp = abap_true.
        p_wctrl = abap_true.
        p_wincl = abap_true.
        p_wmime = abap_true.
        p_wview = abap_true.
      ENDIF.
    WHEN 'U_CLSLIB'.
      IF p_clslib = abap_false.
        p_clas = abap_false.
        p_intf = abap_false.
      ELSE.
        p_clas = abap_true.
        p_intf = abap_true.
      ENDIF.
    WHEN 'U_DBCONT'.
      IF p_dbcont = abap_false.
        p_db_csv = abap_false.
        p_db_xml = abap_false.
        p_dbclsa = abap_false.
        p_dbclsc = abap_false.
        p_dbclsl = abap_false.
        p_dbclsg = abap_false.
        p_dbclse = abap_false.
        p_dbclss = abap_false.
        p_dbclsw = abap_false.
      ELSE.
        p_db_csv = abap_true.
        p_db_xml = abap_true.
        p_dbclsa = abap_true.
        p_dbclsc = abap_true.
        p_dbclsl = abap_true.
        p_dbclsg = abap_true.
        p_dbclse = abap_true.
        p_dbclss = abap_true.
        p_dbclsw = abap_true.
      ENDIF.
    WHEN 'U_DDIC'.
      IF p_ddic = abap_false.
        p_doma = abap_false.
        p_dtel = abap_false.
        p_enqu = abap_false.
        p_shlp = abap_false.
        p_struc = abap_false.
        p_tabl = abap_false.
        p_ttyp = abap_false.
        p_type = abap_false.
        p_view = abap_false.
      ELSE.
        p_doma = abap_true.
        p_dtel = abap_true.
        p_enqu = abap_true.
        p_shlp = abap_true.
        p_struc = abap_true.
        p_tabl = abap_true.
        p_ttyp = abap_true.
        p_type = abap_true.
        p_view = abap_true.
      ENDIF.
    WHEN 'U_FUGR'.
      IF p_fugr = abap_false.
        p_fuba = abap_false.
        p_fuincl = abap_false.
        p_scr = abap_false.
      ELSE.
        p_fuba = abap_true.
        p_fuincl = abap_true.
        p_scr = abap_true.
      ENDIF.
  ENDCASE.


*-----------------------------------------------------------------------
*  at selection-screen OUTPUT
*-----------------------------------------------------------------------
AT SELECTION-SCREEN OUTPUT.
  LOOP AT SCREEN.
* BSP Library
    IF screen-name = 'P_BSPAPP'
    OR screen-name = 'P_BSPTAG'.
      IF p_bsplib = abap_false.
        screen-input = 0.
      ELSE.
        screen-input = 1.
      ENDIF.
      MODIFY SCREEN.
    ENDIF.
    IF screen-name = 'P_WBSP'
    OR screen-name = 'P_WCTRL'
    OR screen-name = 'P_WINCL'
    OR screen-name = 'P_WMIME'
    OR screen-name = 'P_WVIEW'.
      IF p_bspapp = abap_false.
        screen-input = 0.
      ELSE.
        screen-input = 1.
      ENDIF.
      MODIFY SCREEN.
    ENDIF.
* Class Library
    IF screen-name = 'P_CLAS'
    OR screen-name = 'P_INTF'.
      IF p_clslib = abap_false.
        screen-input = 0.
      ELSE.
        screen-input = 1.
      ENDIF.
      MODIFY SCREEN.
    ENDIF.
* Dictionary Objects
    IF screen-name = 'P_DOMA'
    OR screen-name = 'P_DTEL'
    OR screen-name = 'P_ENQU'
    OR screen-name = 'P_SHLP'
    OR screen-name = 'P_STRUC'
    OR screen-name = 'P_TABL'
    OR screen-name = 'P_TTYP'
    OR screen-name = 'P_TYPE'
    OR screen-name = 'P_VIEW'.
      IF p_ddic = abap_false.
        screen-input = 0.
      ELSE.
        screen-input = 1.
      ENDIF.
      MODIFY SCREEN.
    ENDIF.
* Function Group
    IF screen-name = 'P_FUBA'
    OR screen-name = 'P_FUINCL'
    OR screen-name = 'P_SCR'.
      IF p_fugr = abap_false.
        screen-input = 0.
      ELSE.
        screen-input = 1.
      ENDIF.
      MODIFY SCREEN.
    ENDIF.
* database content
    IF screen-name = 'P_DB_CSV'
    OR screen-name = 'P_DB_XML'
    OR screen-name = 'P_DBCLSA'
    OR screen-name = 'P_DBCLSC'
    OR screen-name = 'P_DBCLSL'
    OR screen-name = 'P_DBCLSG'
    OR screen-name = 'P_DBCLSE'
    OR screen-name = 'P_DBCLSS'
    OR screen-name = 'P_DBCLSW'
    OR screen-name = 'P_DBMAX'
    OR screen-name = 'P_DBLIM-HIGH'
    OR screen-name = 'P_DBLIM-LOW'
    OR screen-name = '%_P_DBLIM_%_APP_%-VALU_PUSH'.
      IF p_dbcont = abap_false.
        screen-input = 0.
      ELSE.
        screen-input = 1.
      ENDIF.
      MODIFY SCREEN.
    ENDIF.
  ENDLOOP.


*-----------------------------------------------------------------------
*  Initialization
*-----------------------------------------------------------------------
INITIALIZATION.
* load...
  PERFORM csv_tools.

  DATA:
  lt_exclude TYPE TABLE OF sy-ucomm,
  ls_dyntxt TYPE smp_dyntxt,
  ls_fupararef TYPE fupararef,
  l_text TYPE string.

* Remove buttons
  APPEND 'DOCU' TO lt_exclude.
  CALL FUNCTION 'RS_SET_SELSCREEN_STATUS'
    EXPORTING
      p_status  = sy-pfkey
    TABLES
      p_exclude = lt_exclude
    EXCEPTIONS
      OTHERS    = 1.

* button "Select All"
  ls_dyntxt-icon_id = '@4B@'.
  ls_dyntxt-quickinfo = txt_select_all.
  sscrfields-functxt_01 = ls_dyntxt.
* button "Deselect All"
  ls_dyntxt-icon_id = '@4D@'.
  ls_dyntxt-quickinfo = txt_deselect_all.
  sscrfields-functxt_02 = ls_dyntxt.
* button "Information"
  ls_dyntxt-icon_id = '@0S@'.
  ls_dyntxt-quickinfo = txt_information.
  sscrfields-functxt_03 = ls_dyntxt.

  b_dbcls = '@0S@'.

  PERFORM decode_html_io USING txt_source_code      CHANGING t_add_sc.
  PERFORM decode_html_io USING txt_variants_of_reports
      CHANGING t_add_rv.
  PERFORM decode_html_io USING txt_bsp_applications CHANGING t_bspapp.
  PERFORM decode_html_io USING txt_bsp_library      CHANGING t_bsplib.
  PERFORM decode_html_io USING txt_bsp_extensions   CHANGING t_bsptag.
  PERFORM decode_html_io USING txt_selection        CHANGING t_choice.
  PERFORM decode_html_io USING txt_classes          CHANGING t_clas.
  PERFORM decode_html_io USING txt_class_library    CHANGING t_clslib.
  t_db_csv = gc_extension_csv.
  t_db_xml = gc_extension_xml.
  PERFORM decode_html_io USING txt_database_content CHANGING t_dbcont.
  PERFORM decode_html_io USING txt_format           CHANGING t_dbform.
  PERFORM decode_html_io USING txt_restrict         CHANGING t_dblim.
  PERFORM decode_html_io USING txt_max_no_of_lines  CHANGING t_dbmax.
  PERFORM decode_html_io USING txt_delivery_class   CHANGING t_dbcls.
  t_dbclsa = 'A'.
  t_dbclsc = 'C'.
  t_dbclsl = 'L'.
  t_dbclsg = 'G'.
  t_dbclse = 'E'.
  t_dbclss = 'S'.
  t_dbclsw = 'W'.
  PERFORM decode_html_io USING txt_dict_objs        CHANGING t_ddic.
  PERFORM decode_html_io USING txt_domains          CHANGING t_doma.
  PERFORM decode_html_io USING txt_data_elements    CHANGING t_dtel.
  PERFORM decode_html_io USING txt_objects          CHANGING t_elems.
  PERFORM decode_html_io USING txt_lock_objects     CHANGING t_enqu.
  PERFORM decode_html_io USING txt_empty_tab        CHANGING t_etab.
  PERFORM decode_html_io USING txt_disabled         CHANGING t_etab_d.
  PERFORM decode_html_io USING txt_hidden           CHANGING t_etab_h.
  PERFORM decode_html_io USING txt_display          CHANGING t_etab_n.
  PERFORM decode_html_io USING txt_function_modules CHANGING t_fuba.
  PERFORM decode_html_io USING txt_function_groups  CHANGING t_fugr.
  PERFORM decode_html_io USING txt_includes         CHANGING t_fuincl.
  PERFORM decode_html_io USING txt_includes         CHANGING t_incl.
  PERFORM decode_html_io USING txt_interfaces       CHANGING t_intf.
  PERFORM decode_html_io USING txt_message_classes  CHANGING t_msag.
  PERFORM decode_html_io USING txt_options          CHANGING t_opts.
  PERFORM decode_html_io USING txt_package          CHANGING t_pack.
  PERFORM decode_html_io USING txt_set_get_parameters
      CHANGING t_para.
  PERFORM decode_html_io USING txt_directory        CHANGING t_path.
  PERFORM decode_html_io USING txt_programs         CHANGING t_prog.
  PERFORM decode_html_io USING txt_screens          CHANGING t_scr.
  PERFORM decode_html_io USING txt_srch_helps       CHANGING t_shlp.
  PERFORM decode_html_io USING txt_structures       CHANGING t_struc.
  PERFORM decode_html_io USING txt_database_tables  CHANGING t_tabl.
  PERFORM decode_html_io USING txt_authorization_object___2
      CHANGING t_tobj.
  PERFORM decode_html_io USING txt_transactions     CHANGING t_tran.
  PERFORM decode_html_io USING txt_table_types      CHANGING t_ttyp.
  PERFORM decode_html_io USING txt_type_grps        CHANGING t_type.
  PERFORM decode_html_io USING txt_views            CHANGING t_view.
  PERFORM decode_html_io USING txt_pages_with_flow_logic
      CHANGING t_wbsp.
  PERFORM decode_html_io USING txt_controller       CHANGING t_wctrl.
  PERFORM decode_html_io USING txt_page_fragments   CHANGING t_wincl.
  PERFORM decode_html_io USING txt_mimes            CHANGING t_wmime.
  PERFORM decode_html_io USING txt_views            CHANGING t_wview.
  PERFORM decode_html_io USING txt_transformations  CHANGING t_xslt.

  SELECT SINGLE * FROM fupararef INTO ls_fupararef
    WHERE funcname = 'GUI_DOWNLOAD'
    AND r3state = 'A'
    AND parameter = 'SHOW_TRANSFER_STATUS'.
  IF sy-subrc = 0.
    g_has_download_status = abap_true.
  ENDIF.


*-----------------------------------------------------------------------
* start-of-selection
*-----------------------------------------------------------------------
START-OF-SELECTION.
  DATA:
  l_dir TYPE string,
  l_dir_check TYPE flag,
  l_dir_rc TYPE i,
  l_message TYPE string,
  l_txt TYPE string,
  lt_tadir TYPE STANDARD TABLE OF tadir,
  l_tabname TYPE tabname,
  ls_contflag TYPE st_contflag_range,
  lt_contflag TYPE it_contflag_range.

  FIELD-SYMBOLS:
  <ls_tadir> TYPE tadir.

  CLEAR:
  g_folder,
  g_pack.

  REFRESH:
  gt_tadir.


  IF p_devcl IS INITIAL.
    PERFORM decode_html_io
      USING txt_enter_a_package
      CHANGING l_txt.
    WRITE / l_txt.
  ELSEIF p_folder IS INITIAL.
    PERFORM decode_html_io
      USING txt_please_enter_a_root_dir
      CHANGING l_txt.
    WRITE / l_txt.
  ELSE.
*   block3
    g_add_elem_ddic       = p_ddic.
    g_add_elem_tabl       = p_tabl.
    g_add_elem_view       = p_view.
    g_add_elem_ttyp       = p_ttyp.
    g_add_elem_struc      = p_struc.
    g_add_elem_dtel       = p_dtel.
    g_add_elem_doma       = p_doma.
    g_add_elem_shlp       = p_shlp.
    g_add_elem_enqu       = p_enqu.
    g_add_elem_type       = p_type.
    g_add_elem_clslib     = p_clslib.
    g_add_elem_clas       = p_clas.
    g_add_elem_intf       = p_intf.
    g_add_elem_prog       = p_prog.
    g_add_elem_fugr       = p_fugr.
    g_add_elem_fuba       = p_fuba.
    g_add_elem_msag       = p_msag.
    g_add_elem_scr        = p_scr.
    g_add_elem_fuincl     = p_fuincl.
    g_add_elem_incl       = p_incl.
    g_add_elem_o2appl     = p_bspapp.
    g_add_elem_o2applbsp  = p_wbsp.
    g_add_elem_o2applctrl = p_wctrl.
    g_add_elem_o2applincl = p_wincl.
    g_add_elem_o2applmime = p_wmime.
    g_add_elem_o2applview = p_wview.
    g_add_elem_o2taglib   = p_bsptag.
    g_add_elem_para       = p_para.
    g_add_elem_tobj       = p_tobj.
    g_add_elem_tran       = p_tran.
    g_add_elem_xslt       = p_xslt.
*   block2
    g_add_sourcecode = p_add_sc.
    CASE abap_true.
      WHEN p_etab_n.
        g_empty_tab = gc_empty_tab_display.
      WHEN p_etab_d.
        g_empty_tab = gc_empty_tab_disable.
      WHEN p_etab_h.
        g_empty_tab = gc_empty_tab_hide.
    ENDCASE.
    g_add_db_content = p_dbcont.
    g_add_db_format_csv = p_db_csv.
    g_add_db_format_xml = p_db_xml.
    g_add_db_max_lines = p_dbmax.
    ls_contflag-sign = 'I'.
    ls_contflag-option = 'EQ'.
    IF p_dbclsa = abap_true.
      ls_contflag-low = 'A'.
      APPEND ls_contflag TO lt_contflag.
    ENDIF.
    IF p_dbclsc = abap_true.
      ls_contflag-low = 'C'.
      APPEND ls_contflag TO lt_contflag.
    ENDIF.
    IF p_dbclse = abap_true.
      ls_contflag-low = 'E'.
      APPEND ls_contflag TO lt_contflag.
    ENDIF.
    IF p_dbclsg = abap_true.
      ls_contflag-low = 'G'.
      APPEND ls_contflag TO lt_contflag.
    ENDIF.
    IF p_dbclsl = abap_true.
      ls_contflag-low = 'L'.
      APPEND ls_contflag TO lt_contflag.
    ENDIF.
    IF p_dbclss = abap_true.
      ls_contflag-low = 'S'.
      APPEND ls_contflag TO lt_contflag.
    ENDIF.
    IF p_dbclsw = abap_true.
      ls_contflag-low = 'W'.
      APPEND ls_contflag TO lt_contflag.
    ENDIF.
    IF g_add_db_content = abap_true
    AND NOT lt_contflag IS INITIAL.
      IF NOT p_dblim IS INITIAL.
        SELECT * FROM tadir INTO TABLE lt_tadir
            WHERE pgmid = 'R3TR'
            AND object = 'TABL'
            AND obj_name IN p_dblim
            AND devclass IN p_devcl.
      ELSE.
        SELECT * FROM tadir INTO TABLE lt_tadir
            WHERE pgmid = 'R3TR'
            AND object = 'TABL'
            AND devclass IN p_devcl.
      ENDIF.
      LOOP AT lt_tadir ASSIGNING <ls_tadir>.
        l_tabname = <ls_tadir>-obj_name.
        SELECT SINGLE tabname FROM dd02l INTO l_tabname
            WHERE as4local = 'A'
            AND tabclass = 'TRANSP'
            AND tabname = l_tabname
            AND contflag IN lt_contflag.
        IF sy-subrc = 0.
          APPEND <ls_tadir> TO gt_tadir.
        ENDIF.
      ENDLOOP.
      REFRESH lt_tadir.
      REFRESH lt_contflag.
    ENDIF.
    g_add_report_variants = p_add_rv.
*   block 1
    l_dir = p_folder.
    CALL METHOD cl_gui_frontend_services=>directory_exist
      EXPORTING
        directory = l_dir
      RECEIVING
        result    = l_dir_check
      EXCEPTIONS
        OTHERS    = 1.
    IF sy-subrc = 0 AND l_dir_check = abap_false.
      CALL METHOD cl_gui_frontend_services=>directory_create
        EXPORTING
          directory = l_dir
        CHANGING
          rc        = l_dir_rc
        EXCEPTIONS
          OTHERS    = 1.
      IF sy-subrc = 0 AND l_dir_rc = 0.
        g_folder = p_folder.
      ENDIF.
    ELSEIF sy-subrc = 0.
      g_folder = p_folder.
    ENDIF.
    IF g_folder IS INITIAL.
      CLEAR l_message.
      PERFORM get_message_text
        USING 'EA' '334' p_folder space space space
        CHANGING l_message.
      PERFORM decode_html_io
        USING txt_please_enter_a_valid_path
        CHANGING l_txt.
      WRITE: / l_message, / l_txt.
    ELSE.
      SELECT * FROM tdevc INTO TABLE gt_tdevc
          WHERE devclass IN p_devcl.
      IF sy-subrc <> 0.
        CLEAR l_message.
        DO.
          IF p_devcl-low NA '%'.
            EXIT.
          ENDIF.
          PERFORM replace_all
            USING '%' '*'
            CHANGING p_devcl-low.
        ENDDO.
        PERFORM get_message_text
          USING 'PACKAGE_BUILDER01' '411' p_devcl-low
            space space space
          CHANGING l_message.
        PERFORM decode_html_io
          USING txt_please_enter_a_root_dir
          CHANGING l_txt.
        WRITE: / l_message, / l_txt.
      ENDIF.
    ENDIF.
  ENDIF.

END-OF-SELECTION.


*-----------------------------------------------------------------------
  IF NOT gt_tdevc IS INITIAL AND NOT g_folder IS INITIAL.
    LOOP AT gt_tdevc INTO gs_tdevc.
      g_pack = gs_tdevc-devclass.
      PERFORM init.

      PERFORM select.
      PERFORM html_base.

      PERFORM optionals.
      PERFORM system.
    ENDLOOP.

    PERFORM decode_html_io
      USING txt_completed
      CHANGING l_txt.
    WRITE l_txt.
  ENDIF.


*-----------------------------------------------------------------------
* gui_info_dbcls
*-----------------------------------------------------------------------
FORM gui_info_dbcls.

  DATA:
  lt_type TYPE it_dom_value,
  ls_hinfo TYPE help_info,
*  ls_oheader type thead,
  ls_exclfun TYPE hlpfcode,
  lt_exclfun TYPE STANDARD TABLE OF hlpfcode,
  ls_hline TYPE tline,
  lt_hline TYPE STANDARD TABLE OF tline.

  FIELD-SYMBOLS:
  <ls_type> TYPE st_dom_value.

  PERFORM get_dom_value_texts
    USING 'CONTFLAG'
    CHANGING lt_type.

  ls_hline-tdformat = 'U1'.
  ls_hline-tdline = txt_delivery_class.
  APPEND ls_hline TO lt_hline.

  SORT lt_type BY value.
  LOOP AT lt_type ASSIGNING <ls_type>.
    ls_hline-tdformat = 'B1'.
    CONCATENATE '<ZK>' <ls_type>-value '</>:'
        INTO ls_hline-tdline.
    CONCATENATE ls_hline-tdline <ls_type>-text
        INTO ls_hline-tdline SEPARATED BY space.
    APPEND ls_hline TO lt_hline.
  ENDLOOP.

  CALL FUNCTION 'HELP_DOCULINES_SHOW'
    EXPORTING
*      cucol = 10
*      curow = 3
      help_infos = ls_hinfo
*      linenr = 1
*      not_help = abap_false
*      overlay_header = ls_oheader
*      suppress_viewer = abap_false
*      classic_sapscript = abap_false
*    importing
*      help_popup_cancel =
    TABLES
      excludefun = lt_exclfun
      helplines = lt_hline.

ENDFORM.                    "gui_info_dbcls


*-----------------------------------------------------------------------
* gui_info_page
*-----------------------------------------------------------------------
FORM gui_info_page.

  DATA:
  lt_type TYPE it_dom_value,
  ls_hinfo TYPE help_info,
*  ls_oheader type thead,
  ls_exclfun TYPE hlpfcode,
  lt_exclfun TYPE STANDARD TABLE OF hlpfcode,
  ls_hline TYPE tline,
  lt_hline TYPE STANDARD TABLE OF tline.

  ls_hline-tdformat = 'U1'.
  ls_hline-tdline =
      '&#x53;&#x6F;&#x66;&#x74;&#x43;&#x6F;&#x70;&#x79;'.
  PERFORM decode_html CHANGING ls_hline-tdline.
  APPEND ls_hline TO lt_hline.

  ls_hline-tdformat = 'AS'.
  CONCATENATE '<ZK>' txt_version '</>:' INTO ls_hline-tdline.
  CONCATENATE ls_hline-tdline gc_version
      INTO ls_hline-tdline SEPARATED BY space.
  PERFORM decode_html CHANGING ls_hline-tdline.
  APPEND ls_hline TO lt_hline.

  ls_hline-tdformat = '*'.
  CONCATENATE '&#xA9; 2008-' gc_version+0(4) ' globalBIT, LLC.'
      INTO ls_hline-tdline.
  PERFORM decode_html CHANGING ls_hline-tdline.
  APPEND ls_hline TO lt_hline.

  ls_hline-tdformat = '/'.
  ls_hline-tdline = txt_all_rights_reserved.
  PERFORM decode_html CHANGING ls_hline-tdline.
  APPEND ls_hline TO lt_hline.

  ls_hline-tdformat = 'AS'.
  ls_hline-tdline = txt_product_under_gpl.
  PERFORM replace_single
    USING '#GPL#' 'GNU General Public License'
    CHANGING ls_hline-tdline.
  PERFORM decode_html CHANGING ls_hline-tdline.
  APPEND ls_hline TO lt_hline.

  CALL FUNCTION 'HELP_DOCULINES_SHOW'
    EXPORTING
*      cucol = 10
*      curow = 3
      help_infos = ls_hinfo
*      linenr = 1
*      not_help = abap_false
*      overlay_header = ls_oheader
*      suppress_viewer = abap_false
*      classic_sapscript = abap_false
*    importing
*      help_popup_cancel =
    TABLES
      excludefun = lt_exclfun
      helplines = lt_hline.

ENDFORM.                    "gui_info_page
