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


*-----------------------------------------------------------------------
* get_class_attribute_value
*-----------------------------------------------------------------------
FORM get_class_attribute_value
  USING
    value(i_clsname) TYPE seoclsname
    value(i_cmpname) TYPE seocmpname
  CHANGING
    c_attvalue TYPE seovalue.

  DATA:
  l_len TYPE i.

  CLEAR c_attvalue.
  SELECT SINGLE attvalue FROM seocompodf INTO c_attvalue
      WHERE clsname = i_clsname
      AND cmpname = i_cmpname
      AND version = 1.
  IF sy-subrc = 0.
    IF c_attvalue+0(1) = ''''.
      l_len = strlen( c_attvalue ) - 2.
      c_attvalue = c_attvalue+1(l_len).
    ENDIF.
  ENDIF.

ENDFORM.                    "get_class_attvalue


*-----------------------------------------------------------------------
* get_class_exists
*-----------------------------------------------------------------------
FORM get_class_exists
  USING
    value(i_clsname) TYPE seoclsname
  CHANGING
    c_class_exists TYPE flag.

  DATA:
  l_clsname TYPE seoclsname.

  c_class_exists = abap_false.
  SELECT SINGLE clsname FROM seoclass INTO l_clsname
    WHERE clsname = i_clsname.
  IF sy-subrc = 0.
    c_class_exists = abap_true.
  ENDIF.

ENDFORM.                    "get_class_exists


*-----------------------------------------------------------------------
* get_date
*-----------------------------------------------------------------------
FORM get_date
  USING
    value(i_date) TYPE sydatum
  CHANGING
    c_date TYPE string.

  CALL FUNCTION 'CONVERT_DATE_TO_EXTERNAL'
    EXPORTING
      date_internal = i_date
    IMPORTING
      date_external = c_date.
ENDFORM.                    "get_date


*-----------------------------------------------------------------------
* get_devClass
*-----------------------------------------------------------------------
FORM get_devclass
  USING
    value(i_devclass) TYPE devclass
  CHANGING
    c_text TYPE as4text.

  CLEAR c_text.
  SELECT SINGLE ctext FROM tdevct INTO c_text
      WHERE devclass = i_devclass
      AND spras = sy-langu.
ENDFORM.                    "get_devClass


*-----------------------------------------------------------------------
* get_docu
*-----------------------------------------------------------------------
FORM get_docu
  USING
    value(i_id) TYPE doku_id
    value(i_object) TYPE any
    value(i_typ) TYPE doku_typ
  CHANGING
    ct_str TYPE it_string.

  DATA:
  lt_html TYPE STANDARD TABLE OF htmlline,
  l_object TYPE doku_obj,
  lt_line TYPE STANDARD TABLE OF tline,
  ls_entry TYPE glos_entry,
  l_pos TYPE i.

  FIELD-SYMBOLS:
  <ls_html> TYPE htmlline.

  REFRESH ct_str.
  l_object = i_object.

  CALL FUNCTION 'DOCU_GET'
    EXPORTING
      id     = i_id
      langu  = sy-langu
      object = l_object
      typ    = i_typ
    TABLES
      line   = lt_line
    EXCEPTIONS
      OTHERS = 1.
  CHECK sy-subrc = 0.

  ls_entry-langu = sy-langu.
  CALL FUNCTION 'DOC_SAPSCRIPT_TO_HTML_FORMAT'
    EXPORTING
      entry          = ls_entry
    TABLES
      sapscript_text = lt_line
      html_text      = lt_html.

  CLEAR l_pos.
  LOOP AT lt_html ASSIGNING <ls_html>.
    IF <ls_html>+0(5) = '<BODY'.
      l_pos = sy-tabix.
    ENDIF.
    PERFORM replace_all
      USING '</BODY>' space
      CHANGING <ls_html>.
    PERFORM replace_all
      USING '</HTML>' space
      CHANGING <ls_html>.
  ENDLOOP.
  DO l_pos TIMES.
    DELETE lt_html INDEX 1.
  ENDDO.

  LOOP AT lt_html ASSIGNING <ls_html>.
    APPEND <ls_html>-tdline TO ct_str.
  ENDLOOP.
ENDFORM.                    "get_docu


*-----------------------------------------------------------------------
* get_dom
*-----------------------------------------------------------------------
FORM get_dom
  USING
    value(i_domname) TYPE domname
  CHANGING
    c_text TYPE as4text.

  CLEAR c_text.
  SELECT SINGLE ddtext FROM dd01t INTO c_text
      WHERE domname = i_domname
      AND ddlanguage = sy-langu
      AND as4local = 'A'.
ENDFORM.                    "get_dom


*-----------------------------------------------------------------------
* get_dom_value_text
*-----------------------------------------------------------------------
FORM get_dom_value_text
  USING
    value(i_domname) TYPE domname
    value(i_domvalue) TYPE any
  CHANGING
    c_text TYPE any.

  DATA:
  l_domvalue TYPE domvalue_l,
  l_text TYPE val_text.

  CLEAR c_text.
  l_domvalue = i_domvalue.

  SELECT SINGLE ddtext FROM dd07t INTO l_text
      WHERE domname = i_domname
      AND ddlanguage = sy-langu
      AND as4local = 'A'
      AND domvalue_l = l_domvalue.
  IF sy-subrc = 0.
    c_text = l_text.
  ENDIF.
ENDFORM.                    "getDomValueText


*-----------------------------------------------------------------------
* get_dom_value_texts
*-----------------------------------------------------------------------
FORM get_dom_value_texts
  USING
    value(i_domname) TYPE domname
  CHANGING
    ct_dom_value TYPE it_dom_value.

  DATA:
  lt_dd07t TYPE STANDARD TABLE OF dd07t,
  ls_dom_value TYPE st_dom_value.

  FIELD-SYMBOLS:
  <ls_dd07t> TYPE dd07t.

  REFRESH ct_dom_value.
  SELECT * FROM dd07t INTO TABLE lt_dd07t
      WHERE domname = i_domname
      AND ddlanguage = sy-langu
      AND as4local = 'A'
      ORDER BY domvalue_l DESCENDING.
  LOOP AT lt_dd07t ASSIGNING <ls_dd07t>.
    ls_dom_value-text = <ls_dd07t>-ddtext.
    ls_dom_value-value = <ls_dd07t>-domvalue_l.
    APPEND ls_dom_value TO ct_dom_value.
  ENDLOOP.
ENDFORM.                    "get_dom_value_texts


*-----------------------------------------------------------------------
* get_dtel_text
*-----------------------------------------------------------------------
FORM get_dtel_text
  USING
    value(i_rollname) TYPE rollname
    value(i_field) TYPE c
  CHANGING
    c_text TYPE any.

  DATA:
  ls_dd04t TYPE dd04t,
  l_field TYPE fieldname.

  FIELD-SYMBOLS:
  <l_text> TYPE ANY.

  CLEAR c_text.
  CASE i_field.
    WHEN 'D'.
      l_field = 'DDTEXT'.
    WHEN 'T'.
      l_field = 'REPTEXT'.
    WHEN 'S'.
      l_field = 'SCRTEXT_S'.
    WHEN 'M'.
      l_field = 'SCRTEXT_M'.
    WHEN 'L'.
      l_field = 'SCRTEXT_L'.
    WHEN OTHERS.
      l_field = 'SCRTEXT_M'.
  ENDCASE.
  SELECT SINGLE * FROM dd04t INTO ls_dd04t
      WHERE rollname = i_rollname
      AND ddlanguage = sy-langu
      AND as4local = 'A'.
  IF sy-subrc = 0.
    ASSIGN COMPONENT l_field OF STRUCTURE ls_dd04t TO <l_text>.
    IF <l_text> IS ASSIGNED.
      c_text = <l_text>.
    ENDIF.
  ENDIF.
ENDFORM.                    "get_dtel_text


*-----------------------------------------------------------------------
* get_fuba_exists
*-----------------------------------------------------------------------
FORM get_fuba_exists
  USING
    value(i_funcname) TYPE rs38l_fnam
  CHANGING
    c_fuba_exists TYPE flag.

  DATA:
  l_funcname TYPE rs38l_fnam.

  c_fuba_exists = abap_false.
  SELECT SINGLE funcname FROM tfdir INTO l_funcname
    WHERE funcname = i_funcname.
  IF sy-subrc = 0.
    c_fuba_exists = abap_true.
  ENDIF.

ENDFORM.                    "get_class_exists


*-----------------------------------------------------------------------
* get_GUI_kind
*-----------------------------------------------------------------------
FORM get_gui_kind
  USING
    value(i_kind) TYPE c
  CHANGING
    c_gui_kind TYPE string.

  DATA l_kind.
  CLEAR c_gui_kind.
  l_kind = i_kind.
  TRANSLATE l_kind TO UPPER CASE.
  CASE l_kind.
    WHEN 'P'.
      c_gui_kind = txt_parameters.
    WHEN 'S'.
      c_gui_kind = txt_selection_criteria.
    WHEN OTHERS.
      c_gui_kind = l_kind.
  ENDCASE.
ENDFORM.                    "get_GUI_kind


*-----------------------------------------------------------------------
* get_GUI_operator
*-----------------------------------------------------------------------
FORM get_gui_operator
  USING
    value(i_operator) TYPE char2
  CHANGING
    c_gui_operator TYPE string.

  DATA l_operator(2) TYPE c.
  CLEAR c_gui_operator.
  l_operator = i_operator.
  TRANSLATE l_operator TO UPPER CASE.
  CASE l_operator.
    WHEN 'BT'.
      c_gui_operator = '[]'.
    WHEN 'CP'.
      c_gui_operator = '[*]'.
    WHEN 'EQ'.
      c_gui_operator = '='.
    WHEN 'GE'.
      c_gui_operator = '>='.
    WHEN 'GT'.
      c_gui_operator = '>'.
    WHEN 'LE'.
      c_gui_operator = '<='.
    WHEN 'LK'.
      c_gui_operator = 'like'.
    WHEN 'LT'.
      c_gui_operator = '<'.
    WHEN 'NB'.
      c_gui_operator = ']['.
    WHEN 'NE'.
      c_gui_operator = '<>'.
    WHEN 'NP'.
      c_gui_operator = ']*['.
    WHEN OTHERS.
      c_gui_operator = l_operator.
  ENDCASE.
ENDFORM.                    "get_GUI_operator


*-----------------------------------------------------------------------
* get_GUI_sign
*-----------------------------------------------------------------------
FORM get_gui_sign
  USING
    value(i_sign) TYPE c
  CHANGING
    c_gui_sign TYPE string.

  DATA l_sign.
  CLEAR c_gui_sign.
  l_sign = i_sign.
  TRANSLATE l_sign TO UPPER CASE.
  CASE l_sign.
    WHEN 'E'.
      c_gui_sign = txt_exclusive.
    WHEN 'I'.
      c_gui_sign = txt_inclusive.
    WHEN OTHERS.
      c_gui_sign = l_sign.
  ENDCASE.
ENDFORM.                    "get_GUI_sign


*-----------------------------------------------------------------------
* get_hardwarekey
*-----------------------------------------------------------------------
FORM get_hardwarekey
  CHANGING
    c_hwkey TYPE custkey_t.

  DATA:
  l_rc TYPE sysubrc.

  CALL FUNCTION 'SLIC_LOCAL_HWKEY'
    EXPORTING
      no_raise = 1
    IMPORTING
      hwkey    = c_hwkey
      rc       = l_rc.
ENDFORM.                    "get_hardwarekey


*-----------------------------------------------------------------------
* get_icon_text
*-----------------------------------------------------------------------
FORM get_icon_text
  USING
    value(i_icon_id) TYPE icon_d
    value(i_field) TYPE c
  CHANGING
    c_text TYPE any.

  DATA:
  ls_icont TYPE icont,
  l_field TYPE fieldname.

  FIELD-SYMBOLS:
  <l_text> TYPE ANY.

  CLEAR c_text.
  CASE i_field.
    WHEN 'S'.
      l_field = 'SHORTTEXT'.
    WHEN 'Q'.
      l_field = 'QUICKINFO'.
    WHEN OTHERS.
      l_field = 'SHORTTEXT'.
  ENDCASE.
  SELECT SINGLE * FROM icont INTO ls_icont
      WHERE id = i_icon_id
      AND langu = sy-langu.
  IF sy-subrc = 0.
    ASSIGN COMPONENT l_field OF STRUCTURE ls_icont TO <l_text>.
    IF <l_text> IS ASSIGNED.
      c_text = <l_text>.
    ENDIF.
  ENDIF.
ENDFORM.                    "get_icon_text


*-----------------------------------------------------------------------
* get_id
*-----------------------------------------------------------------------
FORM get_id
  USING
    value(i_param_1)
    value(i_param_2)
  CHANGING
    c_id.

  CONCATENATE i_param_1 i_param_2 INTO c_id.

  PERFORM replace_all
    USING '/' '_'
    CHANGING c_id.
ENDFORM.                    "get_id


*-----------------------------------------------------------------------
* get_message_text
*-----------------------------------------------------------------------
FORM get_message_text
  USING
    value(i_arbgb) TYPE any
    value(i_msgnr) TYPE any
    value(i_v1) TYPE any
    value(i_v2) TYPE any
    value(i_v3) TYPE any
    value(i_v4) TYPE any
  CHANGING
    c_text TYPE string.

  DATA:
  l_id TYPE bapiret2-id,
  l_number TYPE bapiret2-number,
  l_v1 TYPE bapiret2-message_v1,
  l_v2 TYPE bapiret2-message_v2,
  l_v3 TYPE bapiret2-message_v3,
  l_v4 TYPE bapiret2-message_v4,
  l_message TYPE bapiret2-message,
  lt_return TYPE bapiret2,
  lt_text TYPE STANDARD TABLE OF bapitgb.

  l_id = i_arbgb.
  l_number = i_msgnr.
  l_v1 = i_v1.
  l_v2 = i_v2.
  l_v3 = i_v3.
  l_v4 = i_v4.

  CALL FUNCTION 'BAPI_MESSAGE_GETDETAIL'
    EXPORTING
      id         = l_id
      number     = l_number
      language   = sy-langu
      textformat = 'ASC'
      message_v1 = l_v1
      message_v2 = l_v2
      message_v3 = l_v3
      message_v4 = l_v4
    IMPORTING
      message    = l_message
      return     = lt_return
    TABLES
      text       = lt_text.

  c_text = l_message.

ENDFORM.                    "get_message_text


*-----------------------------------------------------------------------
* get_page_title
*-----------------------------------------------------------------------
FORM get_page_title
  USING
    value(i_prefix) TYPE any
    value(i_arbgb) TYPE any
    value(i_msgnr) TYPE any
    value(i_obj_name) TYPE any
  CHANGING
    c_page_title TYPE char255.

  DATA:
  l_text TYPE string,
  l_prefix TYPE string.

  PERFORM get_message_text
    USING
      i_arbgb
      i_msgnr
      i_obj_name
      space
      space
      space
    CHANGING
      l_text.

  IF NOT i_prefix IS INITIAL.
    CONCATENATE i_prefix ':' INTO l_prefix.
    CONCATENATE l_prefix l_text INTO c_page_title SEPARATED BY space.
  ELSE.
    c_page_title = l_text.
  ENDIF.

ENDFORM.                    "get_page_title


*-----------------------------------------------------------------------
* get_props
*-----------------------------------------------------------------------
FORM get_props
  CHANGING
    ct_prop TYPE it_prop.

  DATA:
  ls_prop TYPE st_prop,
  l_hwkey TYPE custkey_t,
  l_str TYPE string,
  l_stext TYPE text40,
  l_laiso TYPE laiso,
  l_sptxt TYPE sptxt.

  REFRESH ct_prop.

* version
  ls_prop-name = 'scver'.
  ls_prop-value = gc_version.
  APPEND ls_prop TO ct_prop.
* hardwarekey
  ls_prop-name = 'hwkey'.
  PERFORM get_hardwarekey
    CHANGING l_hwkey.
  ls_prop-value = l_hwkey.
  APPEND ls_prop TO ct_prop.
* component version
  ls_prop-name = 'compo'.
  SELECT SINGLE stext FROM cvers_txt INTO l_stext
    WHERE langu = 'EN'.
  IF sy-subrc <> 0.
    SELECT SINGLE stext FROM cvers_txt INTO l_stext.
  ENDIF.
  ls_prop-value = l_stext.
  APPEND ls_prop TO ct_prop.
* kernel release
  ls_prop-name = 'krel'.
  PERFORM get_version_info
    USING 'kernel release'
    CHANGING l_str.
  ls_prop-value = l_str.
  APPEND ls_prop TO ct_prop.
* patch level
  ls_prop-name = 'patch'.
  PERFORM get_version_info
    USING 'kernel patch level'
    CHANGING l_str.
  ls_prop-value = l_str.
  APPEND ls_prop TO ct_prop.
* username
  ls_prop-name = 'uname'.
  ls_prop-value = sy-uname.
  APPEND ls_prop TO ct_prop.
* language
  ls_prop-name = 'langu'.
  PERFORM get_spras USING sy-langu l_laiso l_sptxt.
  ls_prop-value = l_laiso.
  APPEND ls_prop TO ct_prop.
* date
  ls_prop-name = 'datum'.
  ls_prop-value = sy-datum.
  APPEND ls_prop TO ct_prop.
* time
  ls_prop-name = 'uzeit'.
  ls_prop-value = sy-uzeit.
  APPEND ls_prop TO ct_prop.

ENDFORM.                    "get_props


*-----------------------------------------------------------------------
* get_spras
*-----------------------------------------------------------------------
FORM get_spras
  USING
    value(i_spras) TYPE any
  CHANGING
    c_laiso TYPE laiso
    c_sptxt TYPE sptxt.

  DATA:
  l_spras TYPE spras,
  l_spraslen TYPE i.

  CLEAR:
  c_laiso,
  c_sptxt.

  l_spraslen = strlen( i_spras ).
  IF l_spraslen = 2.
    c_laiso = i_spras.
    SELECT SINGLE spras FROM t002 INTO l_spras
        WHERE spras = i_spras.
  ELSE.
    l_spras = i_spras.
    SELECT SINGLE laiso FROM t002 INTO c_laiso
        WHERE spras = i_spras.
  ENDIF.

  SELECT SINGLE sptxt FROM t002t INTO c_sptxt
      WHERE spras = l_spras
      AND sprsl = sy-langu.
ENDFORM.                    "get_spras


*-----------------------------------------------------------------------
* get_tabstrip
*-----------------------------------------------------------------------
FORM get_tabstrip
  USING
    value(i_form) TYPE fieldname
    value(i_comp_value) TYPE any
  CHANGING
    ct_tabstrip TYPE it_tabstrip.

  FIELD-SYMBOLS:
  <ls_tabstrip> TYPE st_tabstrip.

  REFRESH ct_tabstrip.

  LOOP AT gt_tabstrip ASSIGNING <ls_tabstrip>
      WHERE form = i_form.
    IF NOT <ls_tabstrip>-comparator IS INITIAL.
      CASE <ls_tabstrip>-comparator.
        WHEN 'CO'.
          IF NOT i_comp_value CO <ls_tabstrip>-comp_value.
            CONTINUE.
          ENDIF.
      ENDCASE.
    ENDIF.
    APPEND <ls_tabstrip> TO ct_tabstrip.
  ENDLOOP.
  SORT ct_tabstrip BY tab_nr.

ENDFORM.                    "get_tabstrip


*-----------------------------------------------------------------------
* get_tabstrip_defined
*-----------------------------------------------------------------------
FORM get_tabstrip_defined
  USING
    it_tabstrip TYPE it_tabstrip
  CHANGING
    ct_tabstrip TYPE it_tabstrip.

  DATA:
  ls_tabstrip TYPE st_tabstrip,
  l_parent_id(100) TYPE c VALUE '#'.

  FIELD-SYMBOLS:
  <ls_tabstrip> TYPE st_tabstrip.

*opening status
  LOOP AT it_tabstrip INTO ls_tabstrip.
    IF ls_tabstrip-empty = abap_true.
      CASE g_empty_tab.
        WHEN gc_empty_tab_disable.
          ls_tabstrip-disabled = abap_true.
          APPEND ls_tabstrip TO ct_tabstrip.
        WHEN gc_empty_tab_display.
          APPEND ls_tabstrip TO ct_tabstrip.
        WHEN gc_empty_tab_hide.
          " do nothing
      ENDCASE.
    ELSE.
      APPEND ls_tabstrip TO ct_tabstrip.
    ENDIF.
  ENDLOOP.
*active tabs
  SORT ct_tabstrip BY parent_id active_order.
  LOOP AT ct_tabstrip ASSIGNING <ls_tabstrip>
      WHERE active_order > 0
      AND disabled = abap_false
      AND hidden = abap_false
      AND empty = abap_false.
    IF l_parent_id = <ls_tabstrip>-parent_id.
      CONTINUE.
    ENDIF.
    l_parent_id = <ls_tabstrip>-parent_id.
    <ls_tabstrip>-active = abap_true.
  ENDLOOP.
  SORT ct_tabstrip BY tab_nr.

ENDFORM.                    "get_tabstrip_defined


*-----------------------------------------------------------------------
* get_time
*-----------------------------------------------------------------------
FORM get_time
  USING
    value(i_time) TYPE sytime
  CHANGING
    c_time TYPE string.

  CONCATENATE i_time+0(2) ':' i_time+2(2) ':' i_time+4(2)
  INTO c_time.
ENDFORM.                    "get_time


*-----------------------------------------------------------------------
* get_trdir_name
*-----------------------------------------------------------------------
FORM get_trdir_name
  USING
    value(i_name) TYPE any
    value(i_type) TYPE char10
  CHANGING
    c_programm TYPE programm.

  DATA:
  l_len TYPE i,
  l_diff TYPE i.

  CONSTANTS:
  lc_eqlen TYPE i VALUE 30.

  c_programm = i_name.
  l_len = strlen( c_programm ).
  l_diff = lc_eqlen - l_len.
  DO l_diff TIMES.
    CONCATENATE c_programm '=' INTO c_programm.
  ENDDO.
  CONCATENATE c_programm i_type INTO c_programm.

ENDFORM.                    "get_trdir_name


*-----------------------------------------------------------------------
* get_trdir_name_method_include
*-----------------------------------------------------------------------
FORM get_trdir_name_method_include
  USING
    value(i_mtdkey) TYPE seocpdkey
  CHANGING
    c_programm TYPE program.

  DATA:
  l_index TYPE seomtdindx,
  l_num TYPE i,
  l_hex TYPE string,
  l_hex_index(3) TYPE c,
  l_type TYPE char10,
  l_len TYPE i.

  CLEAR c_programm.
  SELECT SINGLE methodindx FROM tmdir INTO l_index
    WHERE classname = i_mtdkey-clsname
    AND methodname = i_mtdkey-cpdname.
  IF sy-subrc = 0.
    l_num = l_index.
    PERFORM number_to_x_string
      USING l_num 36
      CHANGING l_hex.
    l_hex_index = l_hex.
    DO.
      l_len = strlen( l_hex_index ).
      IF l_len < 3.
        CONCATENATE '0' l_hex_index INTO l_hex_index.
      ELSE.
        EXIT.
      ENDIF.
    ENDDO.
    CONCATENATE 'CM' l_hex_index INTO l_type.
    PERFORM get_trdir_name
      USING i_mtdkey-clsname l_type
      CHANGING c_programm.
  ENDIF.
ENDFORM.                    "get_trdir_name_method_include


*-----------------------------------------------------------------------
* get_unpacked
*-----------------------------------------------------------------------
FORM get_unpacked
  USING
    value(i_number) TYPE any
  CHANGING
    c_str TYPE string.

  DATA:
  l_strlen TYPE i.

  c_str = i_number.
  CONDENSE c_str NO-GAPS.
  SHIFT c_str LEFT DELETING LEADING '0'.
  l_strlen = strlen( i_number ).
  IF c_str IS INITIAL AND l_strlen > 0.
    c_str = '0'.
  ENDIF.
ENDFORM.                    "get_unpacked


*-----------------------------------------------------------------------
* get_user
*-----------------------------------------------------------------------
FORM get_user
  USING
    value(i_bname) TYPE xubname
  CHANGING
    c_name_text TYPE ad_namtext.

  DATA:
  lt_adrp TYPE STANDARD TABLE OF adrp,
  l_persnumber TYPE ad_persnum.

  FIELD-SYMBOLS:
  <ls_adrp> TYPE adrp.

  CLEAR c_name_text.
  SELECT SINGLE persnumber FROM usr21 INTO l_persnumber
      WHERE bname = i_bname.
  SELECT * FROM adrp INTO TABLE lt_adrp
      WHERE persnumber = l_persnumber
      ORDER BY date_from DESCENDING.
  LOOP AT lt_adrp ASSIGNING <ls_adrp>.
    c_name_text = <ls_adrp>-name_text.
    IF NOT c_name_text IS INITIAL.
      EXIT.
    ENDIF.
  ENDLOOP.
ENDFORM.                    "get_user


*-----------------------------------------------------------------------
* get_version_info
*-----------------------------------------------------------------------
FORM get_version_info
  USING
    value(i_type) TYPE any
  CHANGING
    c_value TYPE string.

  DATA:
  l_index TYPE i,
  lt_version_info TYPE it_version_info.

  FIELD-SYMBOLS:
  <ls_version_info> TYPE st_version_info.

  CLEAR c_value.

  CASE i_type.
    WHEN 'SAP version'.           l_index =  1.
    WHEN 'operating system'.      l_index =  2.
    WHEN 'machine type'.          l_index =  3.
    WHEN 'node name'.             l_index =  4.
    WHEN 'SAP system id'.         l_index =  5.
    WHEN 'database system'.       l_index =  6.
    WHEN 'database name'.         l_index =  7.
    WHEN 'database host'.         l_index =  8.
    WHEN 'database owner'.        l_index =  9.
    WHEN 'rsyn'.                  l_index = 10.
    WHEN 'IP address'.            l_index = 11.
    WHEN 'kernel release'.        l_index = 12.
    WHEN 'database library'.      l_index = 13.
    WHEN 'kernel compiled'.       l_index = 14.
    WHEN 'kernel patch level'.    l_index = 15.
    WHEN 'supported SAP vers.'.   l_index = 16.
    WHEN 'supported database'.    l_index = 17.
    WHEN 'valid OP system'.       l_index = 18.
    WHEN 'OP system release'.     l_index = 19.
    WHEN 'ABAP load version'.     l_index = 20.
    WHEN 'CUA load version'.      l_index = 21.
    WHEN 'kernel kind'.           l_index = 22.
  ENDCASE.

  CALL 'SAPCORE' ID 'ID' FIELD 'VERSION'
                 ID 'TABLE' FIELD lt_version_info.
  READ TABLE lt_version_info ASSIGNING <ls_version_info>
    WITH KEY type = i_type.
  IF sy-subrc <> 0 AND l_index > 0.
    READ TABLE lt_version_info ASSIGNING <ls_version_info>
      INDEX l_index.
  ENDIF.
  IF sy-subrc = 0 AND <ls_version_info> IS ASSIGNED.
    c_value = <ls_version_info>-value.

    CASE i_type.
      WHEN 'database system'.
        IF c_value(3) = 'ADA'.
          c_value = 'SAP DB'.
        ENDIF.
    ENDCASE.
  ENDIF.
ENDFORM.                    "get_version_info
