TYPES EXPORT_LINE_TYPE(512) TYPE C.
TYPES EXPORT_TABLE_TYPE TYPE STANDARD TABLE OF TAB512.

FUNCTION Z_MITI_BW_DOWNLOAD.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     VALUE(P_AREA) TYPE  DD02L-TABNAME OPTIONAL
*"     VALUE(P_LOCAL_PATH) TYPE  STRING OPTIONAL
*"     VALUE(P_LANGUAGE) TYPE  L001TAB-DATA DEFAULT 'E'
*"     VALUE(ROWSKIPS) TYPE  SO_INT DEFAULT 0
*"     VALUE(ROWCOUNT) TYPE  SO_INT DEFAULT 0
*"  TABLES
*"      EXPORT_TABLE STRUCTURE  TAB512
*"  EXCEPTIONS
*"      E_EXP_GUI_DOWNLOADFAILED
*"----------------------------------------------------------------------

* ----------------------------------------------------------------------
* Copyright © 1997-2023 Meta Integration Technology, Inc.
* ----------------------------------------------------------------------
*"     P_AREA = metadata to query
*"     P_LOCAL_PATH = local directory to save to
*"     P_LANGUAGE = language to use
*"     ROWSKIPS = number of rows to skip, for pagination of large datasets
*"     ROWCOUNT = number of rows to retrieve, for pagination of large datasets
* ----------------------------------------------------------------------

*  CLASS CL_ABAP_CHAR_UTILITIES DEFINITION LOAD.
DATA: FILE_NAME TYPE STRING.
DATA: FILE_SEP TYPE C.
DATA: FUNCTION_VERSION TYPE STRING.

* This RFC function module current version
FUNCTION_VERSION = '13'.

* File separator is backslash on Microsoft Windows
FILE_SEP = '\'.

*  DATA: t1 TYPE timestamp,
*        t2 TYPE timestamp,
*        runtime TYPE timestamp.
*  GET TIME STAMP FIELD t1.
*  GET TIME STAMP FIELD t2.
*  runtime = t2 - t1.

*SystemInformation
  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'SYSTEMINFO'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_SYSTEMINFO
    USING FUNCTION_VERSION
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'SYSTEMINFO.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.
*SoftwareComponents
  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'SWCOMPS'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_SWCOMPS
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'SWCOMPS.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.
*Source system
  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'SOURCE_SYSTEM'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_SOURCE_SYSTEM
    USING P_LANGUAGE
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'SOURCE_SYSTEM.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

   IF STRLEN( P_AREA ) = 0 OR P_AREA = 'SOURCE_SYSTEM_ATTRIBUTE'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_SOURCE_SYSTEM_ATTR
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'SOURCE_SYSTEM_ATTRIBUTE.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

   IF STRLEN( P_AREA ) = 0 OR P_AREA = 'SOURCE_SYSTEM_ATTRIBUTE2'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_SOURCE_SYSTEM_ATTR2
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'SOURCE_SYSTEM_ATTRIBUTE2.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'APPLICATION_DS'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_APPLICATION_DS
    USING P_LANGUAGE
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'APPLICATION_DS.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'DATA_SOURCE'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_DATA_SOURCE
    USING P_LANGUAGE
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'DATA_SOURCE.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'DATA_SOURCE_FIELDS'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_DATA_SOURCE_FIELDS
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'DATA_SOURCE_FIELDS.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'DATA_SOURCE3X'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_DATA_SOURCE3X
    USING P_LANGUAGE
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'DATA_SOURCE3X.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'DATA_SOURCE3X_FIELDS'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_DATA_SOURCE3X_FIELDS
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'DATA_SOURCE3X_FIELDS.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'INFO_AREA'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_INFO_AREA
    USING P_LANGUAGE
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'INFO_AREA.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'INFO_OBJECT_CATALOG'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_INFO_OBJECT_CATALOG
    USING P_LANGUAGE
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'INFO_OBJECT_CATALOG.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'OBJECT_CATALOG_DEP'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_OBJECT_CATALOG_DEP
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'OBJECT_CATALOG_DEP.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'INFO_CUBE'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_INFO_CUBE
    USING P_LANGUAGE
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'INFO_CUBE.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'INFO_CUBE_DETAIL'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_INFO_CUBE_DETAIL
    USING P_LANGUAGE
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'INFO_CUBE_DETAIL.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'INFO_CUBE_INFO_OBJ'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_INFO_CUBE_INFO_OBJ
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'INFO_CUBE_INFO_OBJ.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'INFO_CUBE_DIM'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_INFO_CUBE_DIM
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'INFO_CUBE_DIM.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

 IF STRLEN( P_AREA ) = 0 OR P_AREA = 'INFO_OBJECT'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_INFO_OBJ
    USING P_LANGUAGE
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'INFO_OBJECT.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

   IF STRLEN( P_AREA ) = 0 OR P_AREA = 'INFO_OBJECT_REF'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_INFO_OBJ_REF
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'INFO_OBJECT_REF.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.


  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'INFO_OBJECT_CHAR_REF'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_INFO_OBJ_CHAR_REF
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'INFO_OBJECT_CHAR_REF.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'INFO_OBJ_TRAN_ROUTINE'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_INFO_OBJ_TRAN_ROUTINE
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'INFO_OBJ_TRAN_ROUTINE.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'NAVIGATION_ATTRIBUTE'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_INFO_OBJ_NAV_ATTR
    USING P_LANGUAGE
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'NAVIGATION_ATTRIBUTE.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'INFOOBJECT_ATTRIBUTE'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_INFO_OBJ_ATTR
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'INFOOBJECT_ATTRIBUTE.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'INFOOBJECT_COMPOUND'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_INFO_OBJ_COMP
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'INFOOBJECT_COMPOUND.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'INFOOBJECT_CHAR_DETAIL'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_INFO_OBJ_CHAR_DETAIL
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'INFOOBJECT_CHAR_DETAIL.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'INFOOBJECT_PACK_CHAR_DETAIL'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_INFO_OBJ_PACK_DETAIL
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'INFOOBJECT_PACK_CHAR_DETAIL.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'INFOOBJECT_PACK_KEY'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_INFO_OBJ_KEY
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'INFOOBJECT_PACK_KEY.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'INFOSETS'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_INFO_SETS
    USING P_LANGUAGE
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'INFOSETS.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'INFOSETS_TABLE'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_INFO_SETS_TABLE
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'INFOSETS_TABLE.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'INFOSETS_SOURCE_OBJECT'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_INFO_SETS_OBJ
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'INFOSETS_SOURCE_OBJECT.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'INFOSOURCE'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_INFOSOURCE
    USING P_LANGUAGE
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'INFOSOURCE.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'INFOSOURCE_FIELDS'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_INFOSOURCE_FIELDS
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'INFOSOURCE_FIELDS.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

   IF STRLEN( P_AREA ) = 0 OR P_AREA = 'INFOSOURCE3X'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_INFOSOURCE3X
    USING P_LANGUAGE
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'INFOSOURCE3X.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'INFOSOURCE3X_FIELDS'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_INFOSOURCE3X_FIELDS
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'INFOSOURCE3X_FIELDS.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

    IF STRLEN( P_AREA ) = 0 OR P_AREA = 'INFOSPOKE'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_INFOSPOKE
    USING P_LANGUAGE
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'INFOSPOKE.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'INFOSPOKE_FIELDS'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_INFOSPOKE_FIELDS
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'INFOSPOKE_FIELDS.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'INFOSPOKE_SELECTION'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_INFOSPOKE_SELECTION
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'INFOSPOKE_SELECTION.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'HYBRIDPROVIDER'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_PROVIDER
    USING P_LANGUAGE 'H'
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'HYBRIDPROVIDER.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'HYBRIDPROVIDER_DETAIL'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_HYBRID_PROVIDER_DETAIL
    USING P_LANGUAGE 'H'
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'HYBRIDPROVIDER_DETAIL.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'HYBRIDPROVIDER_INFO_OBJ'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_PROVIDER_INFO_OBJ
    USING 'H'
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'HYBRIDPROVIDER_INFO_OBJ.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'HYBRIDPROVIDER_DIM'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_HYBRID_PROVIDER_DIM
    USING 'H'
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'HYBRIDPROVIDER_DIM.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'HYBRIDPROVIDER_INFO'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_PROVIDER_INFO
    USING 'H'
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'HYBRIDPROVIDER_INFO.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'APPLICATION'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_APPLICATION
    USING P_LANGUAGE
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'APPLICATION.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'MULTIPROVIDER_INFO'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_PROVIDER_INFO
    USING 'M'
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'MULTIPROVIDER_INFO.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

   IF STRLEN( P_AREA ) = 0 OR P_AREA = 'MULTIPROVIDER'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_PROVIDER
    USING P_LANGUAGE 'M'
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'MULTIPROVIDER.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'MULTIPROVIDER_DETAIL'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_PROVIDER_DETAIL
    USING P_LANGUAGE 'M'
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'MULTIPROVIDER_DETAIL.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'MULTIPROVIDER_INFO_OBJ'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_PROVIDER_INFO_OBJ
    USING 'M'
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'MULTIPROVIDER_INFO_OBJ.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'MULTIPROVIDER_DIM'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_PROVIDER_DIM
    USING 'M'
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'MULTIPROVIDER_DIM.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'AGGREGATION_LEVEL'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_AGGREGATION_LEVEL
    USING P_LANGUAGE
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'AGGREGATION_LEVEL.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'AGGREGATION_LEVEL_ATTR'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_AGGREGATION_LEVEL_ATTR
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'AGGREGATION_LEVEL_ATTR.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'DATASTORE_OBJ'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_DATASTORE_OBJ
    USING P_LANGUAGE
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'DATASTORE_OBJ.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'DATASTORE_OBJ_FIELD'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_DATASTORE_OBJ_FIELD
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'DATASTORE_OBJ_FIELD.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

   IF STRLEN( P_AREA ) = 0 OR P_AREA = 'DATASTORE_OBJ_ATTR'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_DATASTORE_OBJ_ATTR
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'DATASTORE_OBJ_ATTR.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'ADV_DATASTORE_FDESC'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_ADV_DATASTORE_FDESC
    USING P_LANGUAGE
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'ADV_DATASTORE_FDESC.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'ADV_DATASTORE_OBJ'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_ADV_DATASTORE_OBJ
    USING P_LANGUAGE
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'ADV_DATASTORE_OBJ.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'COMPOSITE_PROVIDER'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_COMPOSITE_PROVIDER
    USING P_LANGUAGE
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'COMPOSITE_PROVIDER.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'COMPOSITE_PROVIDER_XML'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_COMPOSITE_PROVIDER_XML
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'COMPOSITE_PROVIDER_XML.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'COMPOSITE_PROVIDER_DETAIL'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_COMPOSITE_PROVIDER_DET
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'COMPOSITE_PROVIDER_DETAIL.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'ADV_DATASTORE_XML'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_ADV_DATASTORE_XML
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'ADV_DATASTORE_XML.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'ADV_DATASTORE_OBJ_FIELDS'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_ADV_DATASTORE_FIELDS
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'ADV_DATASTORE_OBJ_FIELDS.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

 IF STRLEN( P_AREA ) = 0 OR P_AREA = 'AGGREGATE'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_AGGREGATE
    USING P_LANGUAGE
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'AGGREGATE.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

   IF STRLEN( P_AREA ) = 0 OR P_AREA = 'AGGREGATE_REF'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_AGGREGATE_REF
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'AGGREGATE_REF.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

   IF STRLEN( P_AREA ) = 0 OR P_AREA = 'AGGREGATE_ATTR'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_AGGREGATE_ATTR
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'AGGREGATE_ATTR.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

   IF STRLEN( P_AREA ) = 0 OR P_AREA = 'AGGREGATE_DIM'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_AGGREGATE_DIM
    USING P_LANGUAGE
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'AGGREGATE_DIM.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'AGGREGATE_DIM_INFO_OBJ'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_AGGREGATE_DIM_INFO_OBJ
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'AGGREGATE_DIM_INFO_OBJ.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'OPEN_HUBS'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_OPEN_HUBS
    USING P_LANGUAGE
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'OPEN_HUBS.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'OPEN_HUBS_INFO_SPOKE'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_OPEN_HUBS_INFO_SPOKE
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'OPEN_HUBS_INFO_SPOKE.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'OPEN_HUBS_FIELDS'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_OPEN_HUBS_FIELDS
    USING P_LANGUAGE
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'OPEN_HUBS_FIELDS.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'OPEN_HUBS_DEST_FILE'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_OPEN_HUBS_DEST_FILE
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'OPEN_HUBS_DEST_FILE.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'UPDATE_RULES'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_UPDATE_RULES
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'UPDATE_RULES.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'UPDATE_RULES_KEY'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_UPDATE_RULES_KEY
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'UPDATE_RULES_KEY.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'UPDATE_RULES_CHAR'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_UPDATE_RULES_CHAR
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'UPDATE_RULES_CHAR.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'UPDATE_RULES_ROUTINE'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_UPDATE_RULES_ROUTINE
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'UPDATE_RULES_ROUTINE.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'UPDATE_RULES_ABAP'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_UPDATE_RULES_ABAP
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'UPDATE_RULES_ABAP.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'TRAN'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_TRAN
    USING P_LANGUAGE
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'TRAN.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'TRAN_RULE'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_TRAN_RULE
    USING P_LANGUAGE
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'TRAN_RULE.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'TRAN_ABAP'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_TRAN_ABAP
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'TRAN_ABAP.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'TRAN_ABAP_INV'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_TRAN_ABAP_INV
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'TRAN_ABAP_INV.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'TRAN_FIELDS'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_TRAN_FIELDS
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'TRAN_FIELDS.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'TRANSFER_RULE'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_TRANSFER_RULE
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'TRANSFER_RULE.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'TRAN_RULE_ROUTINE_ID'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_TRAN_RULE_ROUTINE_ID
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'TRAN_RULE_ROUTINE_ID.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'TRANSFER_FIELDS'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_TRANSFER_FIELDS
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'TRANSFER_FIELDS.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

   IF STRLEN( P_AREA ) = 0 OR P_AREA = 'TRANSFER_FIELDS_DS'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_TRANSFER_FIELDS_DS
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'TRANSFER_FIELDS_DS.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'TRANSFER_RULE_ABAP'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_TRANSFER_RULE_ABAP
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'TRANSFER_RULE_ABAP.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'TRAN_ROUTINE_SETTING'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_TRAN_ROUTINE_SETTING
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'TRAN_ROUTINE_SETTING.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'TRAN_ROUTINE_FIELDS'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_TRAN_ROUTINE_FIELDS
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'TRAN_ROUTINE_FIELDS.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'QUERY'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_QUERY
    USING P_LANGUAGE
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'QUERY.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'QUERY_REF'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_QUERY_REF
    USING P_LANGUAGE
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'QUERY_REF.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'QUERY_CHAR'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_QUERY_CHAR
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'QUERY_CHAR.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_LOCAL_PATH ) > 0 .
    FREE EXPORT_TABLE.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'QUERY_COLUMNS'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_QUERY_COLUMNS
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'QUERY_COLUMNS.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

   IF STRLEN( P_AREA ) = 0 OR P_AREA = 'QUERY_FORMULA_DEF'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_QUERY_FORMULA_DEF
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'QUERY_FORMULA_DEF.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'QUERY_CELLS'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_QUERY_CELLS
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'QUERY_CELLS.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

*	Open ODS only for version 740 and later
  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'OPEN_ODS'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_OPEN_ODS
    USING P_LANGUAGE
    CHANGING EXPORT_TABLE[].
   IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'OPEN_ODS.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'OPEN_ODS_FIELDS'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_OPEN_ODS_FIELDS
    USING P_LANGUAGE
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'OPEN_ODS_FIELDS.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'QUERY_VIEWS'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_QUERY_VIEWS
    USING P_LANGUAGE
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'QUERY_VIEWS.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'WORKBOOKS'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_WORKBOOKS
    USING P_LANGUAGE
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'WORKBOOKS.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'WORKBOOKS_DETAIL'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_WORKBOOKS_DETAIL
    USING P_LANGUAGE
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'WORKBOOKS_DETAIL.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'ROLES'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_ROLES
    USING P_LANGUAGE
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'ROLES.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'ROLES_TEXTS'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_ROLES_TEXTS
    USING P_LANGUAGE
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'ROLES_TEXTS.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'ROLES_INDEXES'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_ROLES_INDEXES
    USING P_LANGUAGE
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'ROLES_INDEXES.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'WEB_TEMPLATES'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_WEB_TEMPLATES
    USING P_LANGUAGE
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'WEB_TEMPLATES.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'BEX_WEB_TEMPLATES'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_BEX_WEB_TEMPLATES
    USING P_LANGUAGE
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'BEX_WEB_TEMPLATES.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'ENTERPRISE_REPORTS'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_ENTERPRISE_REPORTS
    USING P_LANGUAGE
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'ENTERPRISE_REPORTS.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

   IF STRLEN( P_AREA ) = 0 OR P_AREA = 'CRYSTAL_REPORTS'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_CRYSTAL_REPORTS
    USING P_LANGUAGE
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'CRYSTAL_REPORTS.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'CRYSTAL_REPORTS_DETAIL'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_CRYSTAL_REPORTS_DETAIL
    USING P_LANGUAGE
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'CRYSTAL_REPORTS_DETAIL.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'INFOSETCLASSIC'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_INFOSETCLASSIC
    USING P_LANGUAGE
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'INFOSETCLASSIC.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'INFOSETCLASSIC_FIELDS'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_INFOSETCLASSIC_FIELDS
    USING P_LANGUAGE
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'INFOSETCLASSIC_FIELDS.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'INFOSET_QUERIES'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_INFOSET_QUERIES
    USING P_LANGUAGE
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'INFOSET_QUERIES.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_AREA ) = 0 OR P_AREA = 'INFOSET_COND'.
    CLEAR EXPORT_TABLE[].
    PERFORM Z_QUERY_INFOSET_COND
    USING P_LANGUAGE
    CHANGING EXPORT_TABLE[].
    IF STRLEN( P_LOCAL_PATH ) > 0 .
      CONCATENATE P_LOCAL_PATH 'INFOSET_COND.txt' INTO FILE_NAME SEPARATED BY FILE_SEP.
      PERFORM Z_FORM_DOWNLOAD
      TABLES EXPORT_TABLE
      USING FILE_NAME.
    ENDIF.
    COMMIT WORK.
  ENDIF.

  IF STRLEN( P_LOCAL_PATH ) > 0 .
    FREE EXPORT_TABLE.
  ENDIF.

ENDFUNCTION.

* ------------------------------------------------------------------- *
FORM Z_FORM_CLEANSTRING
CHANGING P_LINE TYPE STRING.

  DATA: cPat1(2) TYPE X VALUE '0D47'.
  FIELD-SYMBOLS: <ic> TYPE X,
                 <tc> TYPE C.
  ASSIGN cPat1 TO <ic> CASTING.
  ASSIGN <ic> TO <tc> CASTING.

  REPLACE ALL OCCURRENCES OF cl_abap_char_utilities=>CR_LF IN P_LINE WITH '/'.
  REPLACE ALL OCCURRENCES OF cl_abap_char_utilities=>NEWLINE IN P_LINE WITH '/'.
  REPLACE ALL OCCURRENCES OF cl_abap_char_utilities=>FORM_FEED IN P_LINE WITH '/'.
  TRANSLATE P_LINE USING <tc>.

ENDFORM.

FORM Z_FORM_DOWNLOAD
TABLES P_TABLE TYPE EXPORT_TABLE_TYPE
USING P_FILENAME TYPE STRING.

*  DATA: INOROWS LIKE SY-TABIX.

*  DESCRIBE TABLE P_TABLE LINES INOROWS.

  CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
      FILENAME                = P_FILENAME
      FILETYPE                = 'ASC'
*UTF-8: 4310. Taken from the table TCP00A (or TCP00)
*https://wiki.scn.sap.com/wiki/display/ABAP/Character+encoding+conversion
*Perhaps use 4110 instead?
      CODEPAGE                = '4310'
      WRITE_FIELD_SEPARATOR   = 'X'
      TRUNC_TRAILING_BLANKS   = 'X'
      APPEND                  = ' '
    TABLES
      DATA_TAB                = P_TABLE
    EXCEPTIONS
      " declare specific exceptions here ?
      OTHERS                  = 99.

  IF SY-SUBRC <> 0.
      raise E_EXP_GUI_DOWNLOADFAILED.
  ENDIF.

ENDFORM.

FORM Z_QUERY_SYSTEMINFO
USING FUNCTION_VERSION TYPE STRING
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  DATA: RFCSI TYPE RFCSI.

    CALL FUNCTION 'RFC_SYSTEM_INFO'
       IMPORTING rfcsi_export = rfcsi.

    CONCATENATE
      RFCSI-RFCHOST RFCSI-RFCSYSID RFCSI-RFCSAPRL FUNCTION_VERSION RFCSI-RFCDEST
*      RFCSI-RFCPROTO RFCSI-RFCCHARTYP RFCSI-RFCINTTYP
*      RFCSI-RFCFLOTYP RFCSI-RFCDEST RFCSI-RFCHOST
*      RFCSI-RFCSYSID RFCSI-RFCDATABS RFCSI-RFCDBHOST
*      RFCSI-RFCDBSYS RFCSI-RFCSAPRL RFCSI-RFCMACH
*      RFCSI-RFCOPSYS RFCSI-RFCTZONE RFCSI-RFCDAYST
*      RFCSI-RFCIPADDR RFCSI-RFCKERNRL RFCSI-RFCHOST2
*      RFCSI-RFCSI_RESV RFCSI-RFCIPV6ADDR
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
ENDFORM.

FORM Z_FORM_VALUE_FROM_XML
USING XML_STRING TYPE XSTRING NAME TYPE STRING
CHANGING VALUE2 TYPE STRING.

DATA: gt_xml_data   TYPE TABLE OF smum_xmltb.
DATA: gt_return     TYPE TABLE OF bapiret2.
DATA: gwa_xml_data  TYPE smum_xmltb.

CALL FUNCTION 'SMUM_XML_PARSE'
        EXPORTING
          xml_input = XML_STRING
        TABLES
          xml_table = gt_xml_data
          return    = gt_return.

LOOP AT gt_xml_data INTO gwa_xml_data.
 IF  gwa_xml_data-cname EQ NAME.
    VALUE2 = gwa_xml_data-cvalue.
  ENDIF.
    CLEAR gwa_xml_data.
ENDLOOP.

ENDFORM.

* ------------------------------------------------------------------- *
FORM Z_QUERY_SWCOMPS
CHANGING P_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: it_tt_comptab    TYPE STANDARD TABLE OF SPAM_CVERS.
  DATA: it_et_components TYPE STANDARD TABLE OF COMP_PROPS.
  DATA: it_et_complayer	 TYPE STANDARD TABLE OF SPAM_CLAYR.
  DATA: it_et_cvers_sub	 TYPE STANDARD TABLE OF CVERS_SUB.
*  FIELD-SYMBOLS: <wa_tt_comptab> TYPE SPAM_CVERS.
  FIELD-SYMBOLS: <wa_et_components> TYPE COMP_PROPS.
*  FIELD-SYMBOLS: <wa_et_complayer> TYPE SPAM_CLAYR.
*  FIELD-SYMBOLS: <wa_et_cvers_sub> TYPE CVERS_SUB.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.

  CALL FUNCTION 'OCS_GET_INSTALLED_COMPS'
    EXPORTING
      iv_patchable_only       = ' '
      iv_active_only          = ' '
      iv_buffered             = ' '
  TABLES
    tt_comptab              = it_tt_comptab
    et_components           = it_et_components
    et_complayer            = it_et_complayer
    et_cvers_sub            = it_et_cvers_sub
  EXCEPTIONS
      NO_RELEASE_FOUND =           1
      WRONG_RELEASE =              2
    .

  IF SY-SUBRC EQ 0.
    "Success
    LOOP AT it_et_components ASSIGNING <wa_et_components>.
      CONCATENATE
      <wa_et_components>-COMPONENT <wa_et_components>-RELEASE
      INTO EXPORT_LINE
      SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
      APPEND EXPORT_LINE TO P_TABLE.
    ENDLOOP.
  ELSEIF SY-SUBRC EQ 1.
    "Add code for exception here
  ELSEIF SY-SUBRC EQ 2. "Exception
    "Add code for exception here
  ENDIF.

  FREE it_et_components.
  FREE it_tt_comptab.
  FREE it_et_complayer.
  FREE it_et_cvers_sub.

ENDFORM.

FORM Z_QUERY_QUERY_CELLS
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSZCEL,
    ELTUID TYPE RSZCEL-ELTUID,
    MEMUID1 TYPE RSZCEL-MEMUID1,
    MEMUID2 TYPE RSZCEL-MEMUID2,
  END OF TY_RSZCEL.
  FIELD-SYMBOLS: <WA> TYPE TY_RSZCEL.
  DATA: RSZCEL_TMP TYPE TABLE OF TY_RSZCEL.

  SELECT ELTUID MEMUID1 MEMUID1
  FROM RSZCEL AS ra
  INTO TABLE RSZCEL_TMP
  WHERE ra~OBJVERS EQ 'A'
  ORDER BY ELTUID.

  LOOP AT RSZCEL_TMP ASSIGNING <WA>.
    CONCATENATE
    <WA>-ELTUID <WA>-MEMUID1 <WA>-MEMUID1
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSZCEL_TMP.
ENDFORM.

FORM Z_QUERY_QUERY_FORMULA_DEF
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSZCALC,
    ELTUID TYPE RSZCALC-ELTUID,
    STEPNR TYPE RSZCALC-STEPNR,
    OPERA TYPE RSZCALC-OPERA,
    OPER1 TYPE RSZCALC-OPER1,
    OPER2 TYPE RSZCALC-OPER2,
    O1FLG TYPE RSZCALC-O1FLG,
    O2FLG TYPE RSZCALC-O2FLG,
  END OF TY_RSZCALC.
  FIELD-SYMBOLS: <WA> TYPE TY_RSZCALC.
  DATA: RSZCALC_TMP TYPE TABLE OF TY_RSZCALC.

  SELECT ELTUID STEPNR OPERA OPER1 OPER2 O1FLG O2FLG
  FROM RSZCALC AS ra
  INTO TABLE RSZCALC_TMP
  WHERE ra~OBJVERS EQ 'A'
  ORDER BY ELTUID.

  LOOP AT RSZCALC_TMP ASSIGNING <WA>.
    CONCATENATE
    <WA>-ELTUID <WA>-STEPNR <WA>-OPERA <WA>-OPER1 <WA>-OPER2 <WA>-O1FLG <WA>-O2FLG
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSZCALC_TMP.
ENDFORM.

FORM Z_QUERY_QUERY_COLUMNS
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSZRANGE,
    ELTUID TYPE RSZSELECT-ELTUID,
    IOBJNM TYPE RSZSELECT-IOBJNM,
    ENUM(4) TYPE n,
    OPT(2) TYPE c,
    SIGN(1) TYPE c,
    SELTP(1) TYPE n,
    TERM(4) TYPE n,
    FACTOR(4) TYPE n,
    LOWFLAG(1) TYPE n,
    HIGHFLAG(1) TYPE n,
    ALERTLEVEL(2) TYPE n,
    LOW TYPE STRING,
    HIGH TYPE STRING,
  END OF TY_RSZRANGE.
  FIELD-SYMBOLS: <WA> TYPE TY_RSZRANGE.
  DATA: RSZRANGE_TMP TYPE TABLE OF TY_RSZRANGE.

  SELECT ELTUID IOBJNM ENUM OPT SIGN SELTP TERM FACTOR LOWFLAG HIGHFLAG ALERTLEVEL
   LOW HIGH
  FROM RSZRANGE AS ra
  INTO TABLE RSZRANGE_TMP
  WHERE ra~OBJVERS EQ 'A'
  ORDER BY ELTUID.

  LOOP AT RSZRANGE_TMP ASSIGNING <WA>.
    CONCATENATE
    <WA>-ELTUID <WA>-IOBJNM <WA>-ENUM <WA>-OPT
    <WA>-SIGN <WA>-SELTP <WA>-TERM <WA>-FACTOR
    <WA>-LOWFLAG <WA>-HIGHFLAG <WA>-ALERTLEVEL
    <WA>-LOW <WA>-HIGH
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSZRANGE_TMP.
ENDFORM.

FORM Z_QUERY_QUERY_CHAR
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSZSELECT,
    ELTUID TYPE RSZSELECT-ELTUID,
    IOBJNM TYPE RSZSELECT-IOBJNM,
    CONTYPE TYPE RSZSELECT-CONTYPE,
    CONIOBJNM TYPE RSZSELECT-CONIOBJNM,
    SOTP TYPE RSZSELECT-SOTP,
  END OF TY_RSZSELECT.
  FIELD-SYMBOLS: <WA> TYPE TY_RSZSELECT.
  DATA: RSZSELECT_TMP TYPE TABLE OF TY_RSZSELECT.

  SELECT ELTUID IOBJNM CONTYPE CONIOBJNM SOTP
  FROM RSZSELECT AS ra
  INTO TABLE RSZSELECT_TMP
  WHERE ra~OBJVERS EQ 'A'
  ORDER BY ELTUID.

  LOOP AT RSZSELECT_TMP ASSIGNING <WA>.
    CONCATENATE
    <WA>-ELTUID <WA>-IOBJNM <WA>-CONTYPE <WA>-CONIOBJNM <WA>-SOTP
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSZSELECT_TMP.
ENDFORM.

FORM Z_QUERY_QUERY_REF
USING P_LANGUAGE TYPE L001TAB-DATA
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSZELTXREF,
    SELTUID TYPE RSZELTXREF-SELTUID,
    TELTUID TYPE RSZELTXREF-TELTUID,
    LAYTP TYPE RSZELTXREF-LAYTP,
    INFOCUBE TYPE RSZELTXREF-INFOCUBE,
    OPTIONAL TYPE RSZELTXREF-OPTIONAL,
    POSN TYPE RSZELTXREF-POSN,
    TXTLG TYPE RSZELTTXT-TXTLG,
    DEFAULTHINTFLAG TYPE RSZELTDIR-DEFAULTHINTFLAG,
    DEFAULTHINT TYPE RSZELTDIR-DEFAULTHINT,
    COMPID TYPE RSZCOMPDIR-COMPID,
  END OF TY_RSZELTXREF.
  FIELD-SYMBOLS: <WA> TYPE TY_RSZELTXREF.
  DATA: RSZELTXREF_TMP TYPE TABLE OF TY_RSZELTXREF.
  DATA: EXPORT_LINECLEANED TYPE STRING.

  SELECT SELTUID TELTUID LAYTP ref~INFOCUBE OPTIONAL POSN
  rat~TXTLG DEFAULTHINTFLAG DEFAULTHINT refz~COMPID
  FROM RSZELTXREF AS ref
  LEFT OUTER JOIN RSZELTTXT as rat
    ON ref~TELTUID EQ rat~ELTUID
    AND rat~LANGU EQ P_LANGUAGE
    AND rat~OBJVERS EQ 'A'
  LEFT JOIN RSZELTDIR AS refd
    ON ref~TELTUID EQ refd~ELTUID
    AND refd~OBJVERS EQ 'A'
   AND DEFAULTTEXT EQ 'X'
  LEFT JOIN RSZCOMPDIR AS refz
    ON ref~TELTUID EQ refz~COMPUID
    AND refz~OBJVERS EQ 'A'
    AND refz~COMPDIM EQ '0'
  INTO TABLE RSZELTXREF_TMP
  WHERE ref~OBJVERS EQ 'A'
  ORDER BY ref~TELTUID.

  LOOP AT RSZELTXREF_TMP ASSIGNING <WA>.
    EXPORT_LINECLEANED = <WA>-POSN.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED.
    CONCATENATE
    <WA>-SELTUID <WA>-TELTUID <WA>-LAYTP <WA>-INFOCUBE <WA>-OPTIONAL
    EXPORT_LINECLEANED <WA>-TXTLG <WA>-DEFAULTHINTFLAG <WA>-DEFAULTHINT
    <WA>-COMPID
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSZELTXREF_TMP.
ENDFORM.

FORM Z_QUERY_QUERY
USING P_LANGUAGE TYPE L001TAB-DATA
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_V_REP_JOIN,
    COMPUID TYPE V_REP_JOIN-COMPUID,
    COMPID TYPE V_REP_JOIN-COMPID,
    INFOCUBE TYPE V_REP_JOIN-INFOCUBE,
    TIMESTMP TYPE V_REP_JOIN-TIMESTMP,
    CREATED TYPE V_REP_JOIN-CREATED,
    TXTLG TYPE RSZELTTXT-TXTLG,
  END OF TY_V_REP_JOIN.
  FIELD-SYMBOLS: <WA> TYPE TY_V_REP_JOIN.
  DATA: V_REP_JOIN_TMP TYPE TABLE OF TY_V_REP_JOIN.
  DATA: EXPORT_LINECLEANED TYPE STRING.
  DATA: EXPORT_LINECLEANED1 TYPE STRING.

  SELECT COMPUID COMPID INFOCUBE TIMESTMP CREATED
  rat~TXTLG
  FROM V_REP_JOIN AS ra
  LEFT OUTER JOIN RSZELTTXT as rat
    ON ra~COMPUID EQ rat~ELTUID
    AND rat~LANGU EQ P_LANGUAGE
    AND rat~OBJVERS EQ 'A'
  INTO TABLE V_REP_JOIN_TMP
  WHERE ra~OBJVERS EQ 'A'
  ORDER BY ra~COMPUID.

  LOOP AT V_REP_JOIN_TMP ASSIGNING <WA>.
    EXPORT_LINECLEANED = <WA>-CREATED.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED.

    EXPORT_LINECLEANED1 = <WA>-TIMESTMP.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED1.

    CONCATENATE
    <WA>-COMPUID <WA>-COMPID <WA>-INFOCUBE EXPORT_LINECLEANED1 EXPORT_LINECLEANED
    <WA>-TXTLG
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE V_REP_JOIN_TMP.
ENDFORM.

FORM Z_QUERY_TRAN_ROUTINE_FIELDS
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSISOSMAP,
    OLTPSOURCE TYPE RSISOSMAP-OLTPSOURCE,
    LOGSYS TYPE RSISOSMAP-LOGSYS,
    IOBJNM TYPE RSTSRULES-IOBJNM,
    FIELDNM TYPE RSARFIELDS-FIELDNM,
    "ABAP_TYPE(1) TYPE c,
  END OF TY_RSISOSMAP.
  FIELD-SYMBOLS: <WA> TYPE TY_RSISOSMAP.
  DATA: RSISOSMAP_TMP TYPE TABLE OF TY_RSISOSMAP.

  SELECT OLTPSOURCE LOGSYS IOBJNM FIELDNM
  FROM RSISOSMAP AS rs
  INNER JOIN RSTSRULES AS rss
    ON rs~TRANSTRU EQ rss~TRANSTRU
    AND rss~OBJVERS EQ 'A'
  INNER JOIN RSARFIELDS AS rsa
    ON rss~CONVROUT_G EQ rsa~CODEID
    AND rsa~OBJVERS EQ 'A'
  INTO TABLE  RSISOSMAP_TMP
  BYPASSING BUFFER
  WHERE rs~OBJVERS EQ 'A'
  AND ISTYPE NE 'H'
  ORDER BY OLTPSOURCE LOGSYS.

  LOOP AT RSISOSMAP_TMP ASSIGNING <WA>.
    CONCATENATE
    <WA>-OLTPSOURCE <WA>-LOGSYS <WA>-IOBJNM <WA>-FIELDNM
    'G'
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSISOSMAP_TMP.

  SELECT OLTPSOURCE LOGSYS IOBJNM FIELDNM
  FROM RSISOSMAP AS rs
  INNER JOIN RSTSRULES AS rss
    ON rs~TRANSTRU EQ rss~TRANSTRU
    AND rss~OBJVERS EQ 'A'
  INNER JOIN RSARFIELDS AS rsa
    ON rss~CONVROUT_L EQ rsa~CODEID
    AND rsa~OBJVERS EQ 'A'
  INTO TABLE  RSISOSMAP_TMP
  BYPASSING BUFFER
  WHERE rs~OBJVERS EQ 'A'
  AND ISTYPE NE 'H'
  ORDER BY OLTPSOURCE LOGSYS.

  LOOP AT RSISOSMAP_TMP ASSIGNING <WA>.
    CONCATENATE
    <WA>-OLTPSOURCE <WA>-LOGSYS <WA>-IOBJNM <WA>-FIELDNM
    'L'
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSISOSMAP_TMP.
ENDFORM.

FORM Z_QUERY_TRAN_ROUTINE_SETTING
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSISOSMAP,
    OLTPSOURCE TYPE RSISOSMAP-OLTPSOURCE,
    LOGSYS TYPE RSISOSMAP-LOGSYS,
    IOBJNM TYPE RSTSRULES-IOBJNM,
    DEPENDENCY TYPE RSAROUT-DEPENDENCY,
    "ABAP_TYPE(1) TYPE c,
  END OF TY_RSISOSMAP.
  FIELD-SYMBOLS: <WA> TYPE TY_RSISOSMAP.
  DATA: RSISOSMAP_TMP TYPE TABLE OF TY_RSISOSMAP.

  SELECT OLTPSOURCE LOGSYS IOBJNM DEPENDENCY
  FROM RSISOSMAP AS rs
  INNER JOIN RSTSRULES AS rss
  ON rs~TRANSTRU EQ rss~TRANSTRU
  AND rss~OBJVERS EQ 'A'
  INNER JOIN RSAROUT AS rsa
  ON rss~CONVROUT_G EQ rsa~CODEID AND rsa~OBJVERS EQ 'A'
  INTO TABLE  RSISOSMAP_TMP
  BYPASSING BUFFER
  WHERE rs~OBJVERS EQ 'A' AND ISTYPE NE 'H'
  ORDER BY OLTPSOURCE LOGSYS.

  LOOP AT RSISOSMAP_TMP ASSIGNING <WA>.
    CONCATENATE
    <WA>-OLTPSOURCE <WA>-LOGSYS <WA>-IOBJNM <WA>-DEPENDENCY 'G'
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSISOSMAP_TMP.

  SELECT OLTPSOURCE LOGSYS IOBJNM DEPENDENCY
  FROM RSISOSMAP AS rs
  INNER JOIN RSTSRULES AS rss
  ON rs~TRANSTRU EQ rss~TRANSTRU
  AND rss~OBJVERS EQ 'A'
  INNER JOIN RSAROUT AS rsa
  ON rss~CONVROUT_L EQ rsa~CODEID AND rsa~OBJVERS EQ 'A'
  INTO TABLE RSISOSMAP_TMP
  BYPASSING BUFFER
  WHERE rs~OBJVERS EQ 'A' AND ISTYPE NE 'H'
  ORDER BY OLTPSOURCE LOGSYS.

  LOOP AT RSISOSMAP_TMP ASSIGNING <WA>.
    CONCATENATE
    <WA>-OLTPSOURCE <WA>-LOGSYS <WA>-IOBJNM <WA>-DEPENDENCY 'L'
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSISOSMAP_TMP.
ENDFORM.

FORM Z_QUERY_TRANSFER_RULE_ABAP
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSISOSMAP,
    OLTPSOURCE TYPE RSISOSMAP-OLTPSOURCE,
    LOGSYS TYPE RSISOSMAP-LOGSYS,
    LINE_NO TYPE RSAABAP-LINE_NO,
    LINE TYPE RSAABAP-LINE,
    IOBJNM TYPE RSTSRULES-IOBJNM,
    "ABAP_TYPE(1) TYPE c,
  END OF TY_RSISOSMAP.
  FIELD-SYMBOLS: <WA> TYPE TY_RSISOSMAP.
  DATA: RSISOSMAP_TMP TYPE TABLE OF TY_RSISOSMAP.

  SELECT rs~OLTPSOURCE rs~LOGSYS LINE_NO LINE ##TOO_MANY_ITAB_FIELDS
  FROM RSISOSMAP AS rs
  INNER JOIN RSTS AS rss
  ON rs~TRANSTRU EQ rss~TRANSTRU
  AND rss~OBJVERS EQ 'A'
  INNER JOIN RSAABAP AS rsa
  ON rss~STARTROUTINE EQ rsa~CODEID
  AND rsa~OBJVERS EQ 'A'
  INTO TABLE RSISOSMAP_TMP
  BYPASSING BUFFER
  WHERE rs~OBJVERS EQ 'A'
  AND ISTYPE NE 'H'
  ORDER BY rs~OLTPSOURCE rs~LOGSYS.

  LOOP AT RSISOSMAP_TMP ASSIGNING <WA>.
    CONCATENATE
    <WA>-OLTPSOURCE <WA>-LOGSYS '1' <WA>-LINE_NO
    <WA>-LINE 'S'
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSISOSMAP_TMP.

  SELECT OLTPSOURCE LOGSYS LINE_NO LINE IOBJNM
  FROM RSISOSMAP AS rs
  INNER JOIN RSTSRULES AS rss
  ON rs~TRANSTRU EQ rss~TRANSTRU
  AND rss~OBJVERS EQ 'A'
  INNER JOIN RSAABAP AS rsa
  ON rss~CONVROUT_G EQ rsa~CODEID
  AND rsa~OBJVERS EQ 'A'
  INTO TABLE RSISOSMAP_TMP
  BYPASSING BUFFER
  WHERE rs~OBJVERS EQ 'A'
  AND ISTYPE NE 'H'
  ORDER BY OLTPSOURCE LOGSYS.

  LOOP AT RSISOSMAP_TMP ASSIGNING <WA>.
    CONCATENATE
    <WA>-OLTPSOURCE <WA>-LOGSYS <WA>-IOBJNM <WA>-LINE_NO
    <WA>-LINE 'G'
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSISOSMAP_TMP.

  SELECT OLTPSOURCE LOGSYS LINE_NO LINE IOBJNM
  FROM RSISOSMAP AS rs
  INNER JOIN RSTSRULES AS rss
  ON rs~TRANSTRU EQ rss~TRANSTRU
  AND rss~OBJVERS EQ 'A'
  INNER JOIN RSAABAP AS rsa
  ON rss~CONVROUT_L EQ rsa~CODEID
  AND rsa~OBJVERS EQ 'A'
  INTO TABLE RSISOSMAP_TMP
  BYPASSING BUFFER
  WHERE rs~OBJVERS EQ 'A'
  AND ISTYPE NE 'H'
  ORDER BY OLTPSOURCE LOGSYS.

  LOOP AT RSISOSMAP_TMP ASSIGNING <WA>.
    CONCATENATE
    <WA>-OLTPSOURCE <WA>-LOGSYS <WA>-IOBJNM <WA>-LINE_NO
    <WA>-LINE 'L'
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSISOSMAP_TMP.
ENDFORM.

FORM Z_QUERY_TRANSFER_FIELDS_DS
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSISOSMAP,
    OLTPSOURCE TYPE RSISOSMAP-OLTPSOURCE,
    LOGSYS TYPE RSISOSMAP-LOGSYS,
    FIELDNM TYPE RSOSFIELDMAP-FIELDNM,
    IOBJNM TYPE RSOSFIELDMAP-IOBJNM,
  END OF TY_RSISOSMAP.
  FIELD-SYMBOLS: <WA> TYPE TY_RSISOSMAP.
  DATA: RSISOSMAP_TMP TYPE TABLE OF TY_RSISOSMAP.

  SELECT rs~OLTPSOURCE rs~LOGSYS
  FIELDNM rsm~IOBJNM
  FROM RSISOSMAP AS rs
  INNER JOIN RSOSFIELDMAP AS rsm
    ON rs~OLTPSOURCE EQ rsm~OLTPSOURCE
    AND rs~LOGSYS EQ rsm~LOGSYS
    AND rsm~OBJVERS EQ 'A'
  INTO TABLE RSISOSMAP_TMP
  BYPASSING BUFFER
  WHERE rs~OBJVERS EQ 'A' AND ISTYPE NE 'H'
  ORDER BY rs~OLTPSOURCE rs~LOGSYS.

  LOOP AT RSISOSMAP_TMP ASSIGNING <WA>.
    CONCATENATE
    <WA>-OLTPSOURCE <WA>-LOGSYS
    <WA>-FIELDNM <WA>-IOBJNM
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSISOSMAP_TMP.
ENDFORM.

FORM Z_QUERY_TRANSFER_FIELDS
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSISOSMAP,
    OLTPSOURCE TYPE RSISOSMAP-OLTPSOURCE,
    LOGSYS TYPE RSISOSMAP-LOGSYS,
    COMSTRU TYPE RSTSRULES-COMSTRU,
    IOBJNM TYPE RSTSRULES-IOBJNM,
    IOBJNM_TS TYPE RSTSRULES-IOBJNM_TS,
    FIXED_VALUE TYPE RSTSRULES-FIXED_VALUE,
    CONVROUT_G TYPE RSTSRULES-CONVROUT_G,
    CONVROUT_L TYPE RSTSRULES-CONVROUT_L,
    FORMULA_ID TYPE RSTSRULES-FORMULA_ID,
  END OF TY_RSISOSMAP.
  FIELD-SYMBOLS: <WA> TYPE TY_RSISOSMAP.
  DATA: RSISOSMAP_TMP TYPE TABLE OF TY_RSISOSMAP.

  SELECT rs~OLTPSOURCE rs~LOGSYS rss~COMSTRU rss~IOBJNM IOBJNM_TS FIXED_VALUE CONVROUT_G CONVROUT_L FORMULA_ID
  FROM RSISOSMAP AS rs
  INNER JOIN RSTSRULES AS rss
    ON rs~TRANSTRU EQ rss~TRANSTRU
    AND rss~OBJVERS EQ 'A'
  INTO TABLE RSISOSMAP_TMP
  BYPASSING BUFFER
  WHERE rs~OBJVERS EQ 'A' AND ISTYPE NE 'H'
  ORDER BY rs~OLTPSOURCE rs~LOGSYS.

  LOOP AT RSISOSMAP_TMP ASSIGNING <WA>.
    CONCATENATE
    <WA>-OLTPSOURCE <WA>-LOGSYS <WA>-COMSTRU <WA>-IOBJNM <WA>-IOBJNM_TS <WA>-FIXED_VALUE
    <WA>-CONVROUT_G <WA>-CONVROUT_L <WA>-FORMULA_ID
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSISOSMAP_TMP.
ENDFORM.

FORM Z_QUERY_TRAN_RULE_ROUTINE_ID
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSISOSMAP,
    OLTPSOURCE TYPE RSISOSMAP-OLTPSOURCE,
    LOGSYS TYPE RSISOSMAP-LOGSYS,
    STARTROUTINE TYPE RSTS-STARTROUTINE,
  END OF TY_RSISOSMAP.
  FIELD-SYMBOLS: <WA> TYPE TY_RSISOSMAP.
  DATA: RSISOSMAP_TMP TYPE TABLE OF TY_RSISOSMAP.

  SELECT OLTPSOURCE rs~LOGSYS STARTROUTINE
  FROM RSISOSMAP AS rs
  INNER JOIN RSTS AS rss
  ON rs~TRANSTRU EQ rss~TRANSTRU
  AND rss~OBJVERS EQ 'A'
  INTO TABLE RSISOSMAP_TMP
  BYPASSING BUFFER
  WHERE rs~OBJVERS EQ 'A' AND ISTYPE NE 'H'
  ORDER BY OLTPSOURCE rs~LOGSYS.

  LOOP AT RSISOSMAP_TMP ASSIGNING <WA>.
    CONCATENATE
    <WA>-OLTPSOURCE <WA>-LOGSYS <WA>-STARTROUTINE
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSISOSMAP_TMP.
ENDFORM.


FORM Z_QUERY_TRANSFER_RULE
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSISOSMAP,
    OLTPSOURCE TYPE RSISOSMAP-OLTPSOURCE,
    LOGSYS TYPE RSISOSMAP-LOGSYS,
    ISOURCE TYPE RSISOSMAP-ISOURCE,
    ISOSTYPE TYPE RSISOSMAP-ISOSTYPE,
    ISSRCTYPE TYPE RSISOSMAP-ISSRCTYPE,
    TIMESTMP TYPE RSISOSMAP-TIMESTMP,
    CONTTIMESTMP TYPE RSISOSMAP-CONTTIMESTMP,
    TRANSTRU TYPE RSISOSMAP-TRANSTRU,
  END OF TY_RSISOSMAP.
  FIELD-SYMBOLS: <WA> TYPE TY_RSISOSMAP.
  DATA: RSISOSMAP_TMP TYPE TABLE OF TY_RSISOSMAP.
  DATA: EXPORT_LINECLEANED TYPE STRING.
  DATA: EXPORT_LINECLEANED1 TYPE STRING.

  SELECT OLTPSOURCE LOGSYS ISOURCE ISOSTYPE ISSRCTYPE TIMESTMP CONTTIMESTMP TRANSTRU
  FROM RSISOSMAP
  INTO TABLE RSISOSMAP_TMP
  BYPASSING BUFFER
  WHERE OBJVERS EQ 'A' AND ISTYPE NE 'H'
  ORDER BY OLTPSOURCE LOGSYS.

  LOOP AT RSISOSMAP_TMP ASSIGNING <WA>.
    EXPORT_LINECLEANED = <WA>-CONTTIMESTMP.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED.

    EXPORT_LINECLEANED1 = <WA>-TIMESTMP.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED1.

    CONCATENATE
    <WA>-OLTPSOURCE <WA>-LOGSYS <WA>-ISOURCE <WA>-ISOSTYPE
    <WA>-ISSRCTYPE EXPORT_LINECLEANED1 EXPORT_LINECLEANED <WA>-TRANSTRU
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSISOSMAP_TMP.
ENDFORM.

FORM Z_QUERY_TRAN_FIELDS
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSTRANFIELD,
    TRANID TYPE RSTRANFIELD-TRANID,
    SEGID TYPE RSTRANFIELD-SEGID,
    RULEID TYPE RSTRANFIELD-RULEID,
    STEPID TYPE RSTRANFIELD-STEPID,
    PARAMTYPE TYPE RSTRANFIELD-PARAMTYPE,
    PARAMNM TYPE RSTRANFIELD-PARAMNM,
    FIELDNM TYPE RSTRANFIELD-FIELDNM,
    FIELDTYPE TYPE RSTRANFIELD-FIELDTYPE,
    KEYFLAG TYPE RSTRANFIELD-KEYFLAG,
    RULEPOSIT TYPE RSTRANFIELD-RULEPOSIT,
    AGGR TYPE RSTRANFIELD-AGGR,
  END OF TY_RSTRANFIELD.
  FIELD-SYMBOLS: <WA> TYPE TY_RSTRANFIELD.
  DATA: RSTRANFIELD_TMP TYPE TABLE OF TY_RSTRANFIELD.
  DATA: EXPORT_LINECLEANED TYPE STRING.
  DATA: EXPORT_LINECLEANED2 TYPE STRING.

  SELECT ra~TRANID SEGID RULEID STEPID PARAMTYPE PARAMNM FIELDNM FIELDTYPE KEYFLAG RULEPOSIT AGGR
  FROM RSTRAN AS ra
  INNER JOIN RSTRANFIELD as rat
    ON ra~TRANID EQ rat~TRANID
    AND rat~OBJVERS EQ 'A'
  INTO TABLE RSTRANFIELD_TMP
  BYPASSING BUFFER
  WHERE ra~OBJVERS EQ 'A'
  ORDER BY ra~TRANID.

  LOOP AT RSTRANFIELD_TMP ASSIGNING <WA>.
    EXPORT_LINECLEANED = <WA>-RULEID.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED.

    EXPORT_LINECLEANED2 = <WA>-STEPID.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED.

    CONCATENATE
    <WA>-TRANID <WA>-SEGID EXPORT_LINECLEANED EXPORT_LINECLEANED2 <WA>-PARAMTYPE
    <WA>-PARAMNM <WA>-FIELDNM <WA>-FIELDTYPE <WA>-KEYFLAG <WA>-RULEPOSIT <WA>-AGGR
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSTRANFIELD_TMP.
ENDFORM.

FORM Z_QUERY_TRAN_ABAP_INV
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSAABAP,
    TRANID TYPE RSTRAN-TRANID,
    LINE_NO TYPE RSAABAPINV-LINE_NO,
    LINE TYPE RSAABAPINV-LINE,
    RULEID TYPE RSTRANRULE-RULEID,
    "ABAP_TYPE(1) TYPE c,
  END OF TY_RSAABAP.
  FIELD-SYMBOLS: <WA> TYPE TY_RSAABAP.
  DATA: RSAABAP_TMP TYPE TABLE OF TY_RSAABAP.
  DATA: EXPORT_LINECLEANED TYPE STRING.

  SELECT ra~TRANID LINE_NO LINE rat~RULEID
  FROM RSTRAN AS ra
  INNER JOIN RSTRANRULE as rat
    ON ra~TRANID EQ rat~TRANID
    AND rat~OBJVERS EQ 'A'
  INNER JOIN RSTRANSTEPROUT as ratr
    ON rat~TRANID EQ ratr~TRANID
    AND rat~RULEID EQ ratr~RULEID
    AND ratr~OBJVERS EQ 'A'
  INNER JOIN RSAABAPINV as ratinv
    ON ratinv~CODEID EQ ratr~CODEID
    AND ratinv~OBJVERS EQ 'A'
  INTO TABLE RSAABAP_TMP
  BYPASSING BUFFER
  WHERE ra~OBJVERS EQ 'A'
  ORDER BY ra~TRANID.

  LOOP AT RSAABAP_TMP ASSIGNING <WA>.
    EXPORT_LINECLEANED = <WA>-RULEID.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED.
    CONCATENATE
    <WA>-TRANID EXPORT_LINECLEANED <WA>-LINE_NO <WA>-LINE 'R'
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSAABAP_TMP.

  SELECT ra~TRANID LINE_NO LINE ##TOO_MANY_ITAB_FIELDS
  FROM RSTRAN AS ra
  INNER JOIN RSAABAPINV as ratinv
    ON ratinv~CODEID EQ ra~EXPERT
    AND ratinv~OBJVERS EQ 'A'
  INTO TABLE RSAABAP_TMP
  BYPASSING BUFFER
  WHERE ra~OBJVERS EQ 'A'
  ORDER BY ra~TRANID.

  LOOP AT RSAABAP_TMP ASSIGNING <WA>.
    EXPORT_LINECLEANED = <WA>-RULEID.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED.
    CONCATENATE
    <WA>-TRANID EXPORT_LINECLEANED <WA>-LINE_NO <WA>-LINE 'X'
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSAABAP_TMP.

  SELECT ra~TRANID LINE_NO LINE ##TOO_MANY_ITAB_FIELDS
  FROM RSTRAN AS ra
  INNER JOIN RSAABAPINV as ratinv
    ON ratinv~CODEID EQ ra~STARTROUTINE
    AND ratinv~OBJVERS EQ 'A'
  INTO TABLE RSAABAP_TMP
  BYPASSING BUFFER
  WHERE ra~OBJVERS EQ 'A'
  ORDER BY ra~TRANID.

  LOOP AT RSAABAP_TMP ASSIGNING <WA>.
    EXPORT_LINECLEANED = <WA>-RULEID.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED.
    CONCATENATE
    <WA>-TRANID EXPORT_LINECLEANED <WA>-LINE_NO <WA>-LINE 'S'
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSAABAP_TMP.

  SELECT ra~TRANID LINE_NO LINE ##TOO_MANY_ITAB_FIELDS
  FROM RSTRAN AS ra
  INNER JOIN RSAABAPINV as ratinv
    ON ratinv~CODEID EQ ra~ENDROUTINE
    AND ratinv~OBJVERS EQ 'A'
  INTO TABLE RSAABAP_TMP
  BYPASSING BUFFER
  WHERE ra~OBJVERS EQ 'A'
  ORDER BY ra~TRANID.

  LOOP AT RSAABAP_TMP ASSIGNING <WA>.
    EXPORT_LINECLEANED = <WA>-RULEID.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED.
    CONCATENATE
    <WA>-TRANID EXPORT_LINECLEANED <WA>-LINE_NO <WA>-LINE 'E'
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSAABAP_TMP.
ENDFORM.

FORM Z_QUERY_TRAN_ABAP
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSAABAP,
    TRANID TYPE RSTRAN-TRANID,
    LINE_NO TYPE RSAABAP-LINE_NO,
    LINE TYPE RSAABAP-LINE,
    RULEID TYPE RSTRANRULE-RULEID,
    "ABAP_TYPE(1) TYPE c,
  END OF TY_RSAABAP.
  FIELD-SYMBOLS: <WA> TYPE TY_RSAABAP.
  DATA: RSAABAP_TMP TYPE TABLE OF TY_RSAABAP.
  DATA: EXPORT_LINECLEANED TYPE STRING.

  SELECT ra~TRANID LINE_NO LINE rat~RULEID
  FROM RSTRAN AS ra
  INNER JOIN RSTRANRULE as rat
    ON ra~TRANID EQ rat~TRANID
    AND rat~OBJVERS EQ 'A'
  INNER JOIN RSTRANSTEPROUT as ratr
    ON rat~TRANID EQ ratr~TRANID
    AND rat~RULEID EQ ratr~RULEID
    AND ratr~OBJVERS EQ 'A'
  INNER JOIN RSAABAP as ratabap
    ON ratabap~CODEID EQ ratr~CODEID
    AND ratabap~OBJVERS EQ 'A'
  INTO TABLE RSAABAP_TMP
  BYPASSING BUFFER
  WHERE ra~OBJVERS EQ 'A'
  ORDER BY ra~TRANID.

  LOOP AT RSAABAP_TMP ASSIGNING <WA>.
    EXPORT_LINECLEANED = <WA>-RULEID.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED.
    CONCATENATE
    <WA>-TRANID EXPORT_LINECLEANED <WA>-LINE_NO <WA>-LINE 'R'
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSAABAP_TMP.

  SELECT ra~TRANID LINE_NO LINE ##TOO_MANY_ITAB_FIELDS
  FROM RSTRAN AS ra
  INNER JOIN RSAABAP as ratinv
    ON ratinv~CODEID EQ ra~EXPERT
    AND ratinv~OBJVERS EQ 'A'
  INTO TABLE RSAABAP_TMP
  BYPASSING BUFFER
  WHERE ra~OBJVERS EQ 'A'
  ORDER BY ra~TRANID.

  LOOP AT RSAABAP_TMP ASSIGNING <WA>.
    EXPORT_LINECLEANED = <WA>-RULEID.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED.
    CONCATENATE
    <WA>-TRANID EXPORT_LINECLEANED <WA>-LINE_NO <WA>-LINE 'X'
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSAABAP_TMP.

  SELECT ra~TRANID LINE_NO LINE ##TOO_MANY_ITAB_FIELDS
  FROM RSTRAN AS ra
  INNER JOIN RSAABAP as ratinv
    ON ratinv~CODEID EQ ra~STARTROUTINE
    AND ratinv~OBJVERS EQ 'A'
  INTO TABLE RSAABAP_TMP
  BYPASSING BUFFER
  WHERE ra~OBJVERS EQ 'A'
  ORDER BY ra~TRANID.

  LOOP AT RSAABAP_TMP ASSIGNING <WA>.
    EXPORT_LINECLEANED = <WA>-RULEID.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED.
    CONCATENATE
    <WA>-TRANID EXPORT_LINECLEANED <WA>-LINE_NO <WA>-LINE 'S'
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSAABAP_TMP.

  SELECT ra~TRANID LINE_NO LINE ##TOO_MANY_ITAB_FIELDS
  FROM RSTRAN AS ra
  INNER JOIN RSAABAP as ratinv
    ON ratinv~CODEID EQ ra~ENDROUTINE
    AND ratinv~OBJVERS EQ 'A'
  INTO TABLE RSAABAP_TMP
  BYPASSING BUFFER
  WHERE ra~OBJVERS EQ 'A'
  ORDER BY ra~TRANID.

  LOOP AT RSAABAP_TMP ASSIGNING <WA>.
    EXPORT_LINECLEANED = <WA>-RULEID.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED.
    CONCATENATE
    <WA>-TRANID EXPORT_LINECLEANED <WA>-LINE_NO <WA>-LINE 'E'
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSAABAP_TMP.

  SELECT ra~TRANID LINE_NO LINE ##TOO_MANY_ITAB_FIELDS
  FROM RSTRAN AS ra
  INNER JOIN RSAABAP as ratinv
    ON ratinv~CODEID EQ ra~GLBCODE
    AND ratinv~OBJVERS EQ 'A'
  INTO TABLE RSAABAP_TMP
  BYPASSING BUFFER
  WHERE ra~OBJVERS EQ 'A'
  ORDER BY ra~TRANID.

  LOOP AT RSAABAP_TMP ASSIGNING <WA>.
    EXPORT_LINECLEANED = <WA>-RULEID.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED.
    CONCATENATE
    <WA>-TRANID EXPORT_LINECLEANED <WA>-LINE_NO <WA>-LINE 'G'
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSAABAP_TMP.

  SELECT ra~TRANID LINE_NO LINE ##TOO_MANY_ITAB_FIELDS
  FROM RSTRAN AS ra
  INNER JOIN RSAABAP as ratinv
    ON ratinv~CODEID EQ ra~GLBCODE2
    AND ratinv~OBJVERS EQ 'A'
  INTO TABLE RSAABAP_TMP
  BYPASSING BUFFER
  WHERE ra~OBJVERS EQ 'A'
  ORDER BY ra~TRANID.

  LOOP AT RSAABAP_TMP ASSIGNING <WA>.
    EXPORT_LINECLEANED = <WA>-RULEID.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED.
    CONCATENATE
    <WA>-TRANID EXPORT_LINECLEANED <WA>-LINE_NO <WA>-LINE '2'
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSAABAP_TMP.
ENDFORM.

FORM Z_QUERY_TRAN_RULE
USING P_LANGUAGE TYPE L001TAB-DATA
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSTRANRULE,
    TRANID TYPE RSTRANRULE-TRANID,
    RULEID TYPE RSTRANRULE-RULEID,
    SEQNR TYPE RSTRANRULE-SEQNR,
    GROUPID TYPE RSTRANRULE-GROUPID,
    GROUPTYPE TYPE RSTRANRULE-GROUPTYPE,
    FIELD_USAGE TYPE RSTRANRULE-FIELD_USAGE,
    RULETYPE TYPE RSTRANRULE-RULETYPE,
    REF_RULE TYPE RSTRANRULE-REF_RULE,
    AGGR TYPE RSTRANRULE-AGGR,
    TXTSH TYPE RSTRANRULET-TXTSH,
    CODEID TYPE RSTRANSTEPROUT-CODEID,
    KIND TYPE RSTRANSTEPROUT-KIND,
    VALUE TYPE RSTRANSTEPCNST-VALUE,
    TXT TYPE RSTRANGROUPT-TXT,
  END OF TY_RSTRANRULE.
  FIELD-SYMBOLS: <WA> TYPE TY_RSTRANRULE.
  DATA: RSTRANRULE_TMP TYPE TABLE OF TY_RSTRANRULE.
  DATA: EXPORT_LINECLEANED TYPE STRING.
  DATA: EXPORT_LINECLEANED2 TYPE STRING.

  SELECT ra~TRANID rat~RULEID SEQNR ratg~GROUPID GROUPTYPE FIELD_USAGE RULETYPE REF_RULE AGGR
  TXTSH CODEID KIND VALUE TXT
  FROM RSTRAN AS ra
  INNER JOIN RSTRANRULE as rat
    ON ra~TRANID EQ rat~TRANID
    AND rat~OBJVERS EQ 'A'
  LEFT OUTER JOIN RSTRANRULET as ratt
    ON rat~TRANID EQ ratt~TRANID
    AND rat~RULEID EQ ratt~RULEID
      AND ratt~LANGU EQ P_LANGUAGE
    AND ratt~OBJVERS EQ 'A'
  LEFT OUTER JOIN RSTRANSTEPROUT as ratr
    ON rat~TRANID EQ ratr~TRANID
    AND rat~RULEID EQ ratr~RULEID
    AND ratr~OBJVERS EQ 'A'
  LEFT OUTER JOIN RSTRANSTEPCNST as ratc
    ON rat~TRANID EQ ratc~TRANID
    AND rat~RULEID EQ ratc~RULEID
    AND ratc~OBJVERS EQ 'A'
 LEFT OUTER JOIN RSTRANGROUPT as ratg
    ON rat~TRANID EQ ratg~TRANID
    AND rat~GROUPID EQ ratg~GROUPID
    AND ratg~OBJVERS EQ 'A'
  INTO TABLE RSTRANRULE_TMP
  BYPASSING BUFFER
  WHERE ra~OBJVERS EQ 'A'
  ORDER BY ra~TRANID.

  LOOP AT RSTRANRULE_TMP ASSIGNING <WA>.
    EXPORT_LINECLEANED = <WA>-RULEID.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED.

    EXPORT_LINECLEANED2 = <WA>-REF_RULE.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED.

    CONCATENATE
    <WA>-TRANID EXPORT_LINECLEANED <WA>-SEQNR <WA>-GROUPID <WA>-GROUPTYPE
    <WA>-FIELD_USAGE <WA>-RULETYPE EXPORT_LINECLEANED2 <WA>-AGGR
    <WA>-TXTSH <WA>-CODEID <WA>-KIND <WA>-VALUE <WA>-TXT
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSTRANRULE_TMP.
ENDFORM.

FORM Z_QUERY_TRAN
USING P_LANGUAGE TYPE L001TAB-DATA
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSTRAN,
    TRANID TYPE RSTRAN-TRANID,
    SOURCETYPE TYPE RSTRAN-SOURCETYPE,
    SOURCENAME TYPE RSTRAN-SOURCENAME,
    TARGETTYPE TYPE RSTRAN-TARGETTYPE,
    TARGETNAME TYPE RSTRAN-TARGETNAME,
    TIMESTMP TYPE RSTRAN-TIMESTMP,
    CONTTIMESTMP TYPE RSTRAN-CONTTIMESTMP,
    EXPERT TYPE RSTRAN-EXPERT,
    TXTLG TYPE RSTRANT-TXTLG,
    GLBCODE TYPE RSTRAN-GLBCODE,
    GLBCODE2 TYPE RSTRAN-GLBCODE2,
    STARTROUTINE TYPE RSTRAN-STARTROUTINE,
    ENDROUTINE TYPE RSTRAN-ENDROUTINE,
  END OF TY_RSTRAN.
  FIELD-SYMBOLS: <WA> TYPE TY_RSTRAN.
  DATA: RSTRAN_TMP TYPE TABLE OF TY_RSTRAN.
  DATA: EXPORT_LINECLEANED TYPE STRING.
  DATA: EXPORT_LINECLEANED1 TYPE STRING.

  SELECT ra~TRANID SOURCETYPE SOURCENAME TARGETTYPE TARGETNAME TIMESTMP CONTTIMESTMP EXPERT
  rat~TXTLG GLBCODE GLBCODE2 STARTROUTINE ENDROUTINE
  FROM RSTRAN AS ra
  LEFT OUTER JOIN RSTRANT as rat
    ON ra~TRANID EQ rat~TRANID
      AND rat~LANGU EQ P_LANGUAGE
    AND rat~OBJVERS EQ 'A'
  INTO TABLE RSTRAN_TMP
  BYPASSING BUFFER
  WHERE ra~OBJVERS EQ 'A'
  ORDER BY ra~TRANID.

  LOOP AT RSTRAN_TMP ASSIGNING <WA>.
    EXPORT_LINECLEANED = <WA>-CONTTIMESTMP.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED.

    EXPORT_LINECLEANED1 = <WA>-TIMESTMP.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED1.

    CONCATENATE
    <WA>-TRANID <WA>-SOURCETYPE <WA>-SOURCENAME <WA>-TARGETTYPE <WA>-TARGETNAME EXPORT_LINECLEANED1 EXPORT_LINECLEANED
    <WA>-EXPERT <WA>-TXTLG <WA>-GLBCODE <WA>-GLBCODE2 <WA>-STARTROUTINE <WA>-ENDROUTINE
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSTRAN_TMP.
ENDFORM.

FORM Z_QUERY_UPDATE_RULES_ABAP
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSAABAP,
    UPDID TYPE RSUPDROUT-UPDID,
    CODEID TYPE RSAABAP-CODEID,
    LINE_NO TYPE RSAABAP-LINE_NO,
    LINE TYPE RSAABAP-LINE,
  END OF TY_RSAABAP.
  FIELD-SYMBOLS: <WA> TYPE TY_RSAABAP.
  DATA: RSAABAP_TMP TYPE TABLE OF TY_RSAABAP.

  SELECT ra~UPDID rsa~CODEID LINE_NO LINE
  FROM RSUPDINFO AS ra
  INNER JOIN RSUPDROUT AS rs
  ON ra~UPDID EQ rs~UPDID AND rs~OBJVERS EQ 'A'
  INNER JOIN RSAABAP AS rsa
  ON rs~CODEID EQ rsa~CODEID AND rsa~OBJVERS EQ 'A'
  INTO TABLE RSAABAP_TMP
  WHERE ra~OBJVERS EQ 'A'.

  LOOP AT RSAABAP_TMP ASSIGNING <WA>.
    CONCATENATE
    <WA>-UPDID <WA>-CODEID <WA>-LINE_NO <WA>-LINE
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSAABAP_TMP.
ENDFORM.

FORM Z_QUERY_UPDATE_RULES_ROUTINE
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSUPDROUT,
    UPDID TYPE RSUPDROUT-UPDID,
    ROUTINE TYPE RSUPDROUT-ROUTINE,
    ICIOBJNM TYPE RSUPDROUT-ICIOBJNM,
    CODEID TYPE RSUPDROUT-CODEID,
  END OF TY_RSUPDROUT.
  FIELD-SYMBOLS: <WA> TYPE TY_RSUPDROUT.
  DATA: RSUPDROUT_TMP TYPE TABLE OF TY_RSUPDROUT.

  SELECT rs~UPDID ROUTINE ICIOBJNM CODEID
  FROM RSUPDINFO AS ra
  INNER JOIN RSUPDROUT AS rs
  ON ra~UPDID EQ rs~UPDID AND rs~OBJVERS EQ 'A'
  INTO TABLE RSUPDROUT_TMP
  WHERE ra~OBJVERS EQ 'A'.

  LOOP AT RSUPDROUT_TMP ASSIGNING <WA>.
    CONCATENATE
    <WA>-UPDID <WA>-ROUTINE <WA>-ICIOBJNM <WA>-CODEID
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSUPDROUT_TMP.
ENDFORM.

FORM Z_QUERY_UPDATE_RULES_CHAR
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSUPDKEY,
    UPDID TYPE RSUPDKEY-UPDID,
    RULENO TYPE RSUPDKEY-RULENO,
    ICIOBJNM TYPE RSUPDKEY-ICIOBJNM,
    CSIOBJNM TYPE RSUPDKEY-CSIOBJNM,
  END OF TY_RSUPDKEY.
  FIELD-SYMBOLS: <WA> TYPE TY_RSUPDKEY.
  DATA: RSUPDKEY_TMP TYPE TABLE OF TY_RSUPDKEY.

  SELECT rs~UPDID RULENO ICIOBJNM CSIOBJNM
  FROM RSUPDINFO AS ra
  INNER JOIN RSUPDKEY AS rs
  ON ra~UPDID EQ rs~UPDID AND rs~OBJVERS EQ 'A'
  INTO TABLE RSUPDKEY_TMP
  WHERE ra~OBJVERS EQ 'A'.

  LOOP AT RSUPDKEY_TMP ASSIGNING <WA>.
    CONCATENATE
    <WA>-UPDID <WA>-RULENO <WA>-ICIOBJNM <WA>-CSIOBJNM
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSUPDKEY_TMP.
ENDFORM.

FORM Z_QUERY_UPDATE_RULES_KEY
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSUPDDAT,
    UPDID TYPE RSUPDDAT-UPDID,
    RULENO TYPE RSUPDDAT-RULENO,
    UPDTYPE TYPE RSUPDDAT-UPDTYPE,
    CALCTPDAT TYPE RSUPDDAT-CALCTPDAT,
    ICIOBJNM TYPE RSUPDDAT-ICIOBJNM,
    CSIOBJNM TYPE RSUPDDAT-CSIOBJNM,
    ROUTINE TYPE RSUPDDAT-ROUTINE,
    TAUNIIOBJNM TYPE RSUPDDAT-TAUNIIOBJNM,
    CONSTANT TYPE RSUPDDAT-CONSTANT,
    FORMULA_ID TYPE RSUPDDAT-FORMULA_ID,
  END OF TY_RSUPDDAT.
  FIELD-SYMBOLS: <WA> TYPE TY_RSUPDDAT.
  DATA: RSUPDDAT_TMP TYPE TABLE OF TY_RSUPDDAT.

  SELECT rs~UPDID RULENO UPDTYPE CALCTPDAT
            ICIOBJNM CSIOBJNM ROUTINE TAUNIIOBJNM CONSTANT FORMULA_ID
  FROM RSUPDINFO AS ra
  INNER JOIN RSUPDDAT AS rs
  ON ra~UPDID EQ rs~UPDID AND rs~OBJVERS EQ 'A'
  INTO TABLE RSUPDDAT_TMP
  WHERE ra~OBJVERS EQ 'A' AND rs~UPDTYPE NE 'NOP'.

  LOOP AT RSUPDDAT_TMP ASSIGNING <WA>.
    CONCATENATE
    <WA>-UPDID <WA>-RULENO <WA>-UPDTYPE <WA>-CALCTPDAT
    <WA>-ICIOBJNM <WA>-CSIOBJNM <WA>-ROUTINE <WA>-TAUNIIOBJNM <WA>-CONSTANT <WA>-FORMULA_ID
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSUPDDAT_TMP.
ENDFORM.

FORM Z_QUERY_UPDATE_RULES
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSUPDINFO,
    UPDID TYPE RSUPDINFO-UPDID,
    INFOCUBE TYPE RSUPDINFO-INFOCUBE,
    ISOURCE TYPE RSUPDINFO-ISOURCE,
    TIMESTMP TYPE RSUPDINFO-TIMESTMP,
    CONTTIMESTMP TYPE RSUPDINFO-CONTTIMESTMP,
  END OF TY_RSUPDINFO.
  FIELD-SYMBOLS: <WA> TYPE TY_RSUPDINFO.
  DATA: RSUPDINFO_TMP TYPE TABLE OF TY_RSUPDINFO.
  DATA: EXPORT_LINECLEANED TYPE STRING.
  DATA: EXPORT_LINECLEANED1 TYPE STRING.

  SELECT UPDID INFOCUBE ISOURCE TIMESTMP CONTTIMESTMP
  FROM RSUPDINFO
  INTO TABLE RSUPDINFO_TMP
  WHERE OBJVERS EQ 'A'.

  LOOP AT RSUPDINFO_TMP ASSIGNING <WA>.
    EXPORT_LINECLEANED = <WA>-CONTTIMESTMP.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED.

    EXPORT_LINECLEANED1 = <WA>-TIMESTMP.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED1.
    CONCATENATE
    <WA>-UPDID <WA>-INFOCUBE
    <WA>-ISOURCE EXPORT_LINECLEANED1 EXPORT_LINECLEANED
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSUPDINFO_TMP.
ENDFORM.

FORM Z_QUERY_OPEN_HUBS_DEST_FILE
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSBFILE,
    OHDEST TYPE RSBFILE-OHDEST,
    FILE TYPE RSBFILE-FILE,
    PATH TYPE RSBFILE-PATH,
    SEPARATOR TYPE RSBFILE-SEPARATOR,
  END OF TY_RSBFILE.
  FIELD-SYMBOLS: <WA> TYPE TY_RSBFILE.
  DATA: RSBFILE_TMP TYPE TABLE OF TY_RSBFILE.

  SELECT ra~OHDEST FILE PATH SEPARATOR
  FROM RSBOHDEST AS ra
  INNER JOIN RSBFILE as rat
    ON ra~OHDEST EQ rat~OHDEST
    AND rat~OBJVERS EQ 'A'
  INTO TABLE RSBFILE_TMP
  BYPASSING BUFFER
  WHERE ra~OBJVERS EQ 'A'.

  LOOP AT RSBFILE_TMP ASSIGNING <WA>.
    CONCATENATE
    <WA>-OHDEST <WA>-FILE
    <WA>-PATH <WA>-SEPARATOR
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSBFILE_TMP.
ENDFORM.

FORM Z_QUERY_OPEN_HUBS_FIELDS
USING P_LANGUAGE TYPE L001TAB-DATA
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSBOHFIELDS,
    OHDEST TYPE RSBOHFIELDS-OHDEST,
    FIELDNM TYPE RSBOHFIELDS-FIELDNM,
    TEMPIOBJNM TYPE RSBOHFIELDS-TEMPIOBJNM,
    KEYFLAG TYPE RSBOHFIELDS-KEYFLAG,
    POSIT TYPE RSBOHFIELDS-POSIT,
    DATATYPE TYPE RSBOHFIELDS-DATATYPE,
    LENG TYPE RSBOHFIELDS-LENG,
    DECIMALS TYPE RSBOHFIELDS-DECIMALS,
    TXTLG TYPE RSBOHFIELDST-TXTLG,
  END OF TY_RSBOHFIELDS.
  FIELD-SYMBOLS: <WA> TYPE TY_RSBOHFIELDS.
  DATA: RSBOHFIELDS_TMP TYPE TABLE OF TY_RSBOHFIELDS.

  SELECT ra~OHDEST rat~FIELDNM TEMPIOBJNM KEYFLAG POSIT DATATYPE LENG
  rat~DECIMALS TXTLG
  FROM RSBOHDEST AS ra
  INNER JOIN RSBOHFIELDS as rat
    ON ra~OHDEST EQ rat~OHDEST
    AND rat~OBJVERS EQ 'A'
  LEFT JOIN RSBOHFIELDST AS rs
    ON rat~OHDEST EQ rs~OHDEST
    AND rat~FIELDNM EQ rs~FIELDNM
    AND rs~LANGU EQ P_LANGUAGE
    AND rs~OBJVERS EQ 'A'
  INTO TABLE RSBOHFIELDS_TMP
  BYPASSING BUFFER
  WHERE ra~OBJVERS EQ 'A'.

  LOOP AT RSBOHFIELDS_TMP ASSIGNING <WA>.
    CONCATENATE
    <WA>-OHDEST <WA>-FIELDNM <WA>-TEMPIOBJNM
    <WA>-KEYFLAG <WA>-POSIT <WA>-DATATYPE
    <WA>-LENG <WA>-DECIMALS <WA>-TXTLG
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSBOHFIELDS_TMP.
ENDFORM.

FORM Z_QUERY_OPEN_HUBS_INFO_SPOKE
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSBSPOKE,
    OHDEST TYPE RSBSPOKE-OHDEST,
    INFOSPOKE TYPE RSBSPOKE-INFOSPOKE,
  END OF TY_RSBSPOKE.
  FIELD-SYMBOLS: <WA> TYPE TY_RSBSPOKE.
  DATA: RSBSPOKE_TMP TYPE TABLE OF TY_RSBSPOKE.

  SELECT ra~OHDEST INFOSPOKE
  FROM RSBOHDEST AS ra
  INNER JOIN RSBSPOKE as rat
    ON ra~OHDEST EQ rat~OHDEST
    AND rat~OBJVERS EQ 'A'
  INTO TABLE RSBSPOKE_TMP
  BYPASSING BUFFER
  WHERE ra~OBJVERS EQ 'A'.

  LOOP AT RSBSPOKE_TMP ASSIGNING <WA>.
    CONCATENATE
    <WA>-OHDEST <WA>-INFOSPOKE
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSBSPOKE_TMP.
ENDFORM.


FORM Z_QUERY_OPEN_HUBS
USING P_LANGUAGE TYPE L001TAB-DATA
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSBOHDEST,
    OHDEST TYPE RSBOHDEST-OHDEST,
    INFOAREA TYPE RSBOHDEST-INFOAREA,
    CONTTIMESTMP TYPE RSBOHDEST-CONTTIMESTMP,
    TIMESTMP TYPE RSBOHDEST-TIMESTMP,
    SOURCETLOGO TYPE RSBOHDEST-SOURCETLOGO,
    SOURCEOBJNM TYPE RSBOHDEST-SOURCEOBJNM,
    DESTTYPE TYPE RSBOHDEST-DESTTYPE,
    TXTLG TYPE RSDDAGGRT-TXTLG,
    DBTAB TYPE RSBDBTAB-DBTAB,
    WRITEMODE TYPE RSBDBTAB-WRITEMODE,
    GENKEY TYPE RSBDBTAB-GENKEY,
    POSIT TYPE RSBOHDESTVAR-POSIT,
    NAME TYPE RSBOHDESTVAR-NAME,
    VALUE TYPE RSBOHDESTVAR-VALUE,
  END OF TY_RSBOHDEST.
  FIELD-SYMBOLS: <WA> TYPE TY_RSBOHDEST.
  DATA: RSBOHDEST_TMP TYPE TABLE OF TY_RSBOHDEST.
  DATA: EXPORT_LINECLEANED TYPE STRING.
  DATA: EXPORT_LINECLEANED1 TYPE STRING.

  SELECT ra~OHDEST INFOAREA CONTTIMESTMP TIMESTMP
  SOURCETLOGO SOURCEOBJNM DESTTYPE rat~TXTLG
  DBTAB WRITEMODE GENKEY POSIT NAME VALUE
  FROM RSBOHDEST AS ra
  LEFT OUTER JOIN RSBOHDESTT as rat
    ON ra~OHDEST EQ rat~OHDEST
      AND rat~LANGU EQ P_LANGUAGE
    AND rat~OBJVERS EQ 'A'
  LEFT OUTER JOIN RSBDBTAB as rsd
    ON ra~OHDEST EQ rsd~OHDEST
    AND rsd~OBJVERS EQ 'A'
  LEFT OUTER JOIN RSBOHDESTVAR as rsv
    ON ra~OHDEST EQ rsv~OHDEST
    AND rsv~OBJVERS EQ 'A'
  INTO TABLE RSBOHDEST_TMP
  BYPASSING BUFFER
  WHERE ra~OBJVERS EQ 'A'
  ORDER BY ra~OHDEST.

  LOOP AT RSBOHDEST_TMP ASSIGNING <WA>.
    EXPORT_LINECLEANED = <WA>-CONTTIMESTMP.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED.

    EXPORT_LINECLEANED1 = <WA>-TIMESTMP.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED1.

    CONCATENATE
    <WA>-OHDEST <WA>-INFOAREA EXPORT_LINECLEANED
    EXPORT_LINECLEANED1 <WA>-SOURCETLOGO <WA>-SOURCEOBJNM <WA>-DESTTYPE <WA>-TXTLG
    <WA>-DBTAB <WA>-WRITEMODE <WA>-GENKEY <WA>-POSIT <WA>-NAME <WA>-VALUE
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSBOHDEST_TMP.
ENDFORM.

FORM Z_QUERY_AGGREGATE_DIM_INFO_OBJ
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSDDIMEIOBJ,
    AGGRUID TYPE RSDDAGGRDIR-AGGRUID,
    DIMENSION TYPE RSDDIMEIOBJ-DIMENSION,
    POSIT TYPE RSDDIMEIOBJ-POSIT,
    IOBJNM TYPE RSDDIMEIOBJ-IOBJNM,
  END OF TY_RSDDIMEIOBJ.
  FIELD-SYMBOLS: <WA> TYPE TY_RSDDIMEIOBJ.
  DATA: RSDDIMEIOBJ_TMP TYPE TABLE OF TY_RSDDIMEIOBJ.

  SELECT ra~AGGRUID DIMENSION POSIT IOBJNM
  FROM RSDDAGGRDIR AS ra
  INNER JOIN RSDDIMEIOBJ as rat
    ON ra~INFOCUBE EQ rat~INFOCUBE
    AND rat~OBJVERS EQ 'A'
  INTO TABLE RSDDIMEIOBJ_TMP
  BYPASSING BUFFER
  WHERE ra~OBJVERS EQ 'A'.

  LOOP AT RSDDIMEIOBJ_TMP ASSIGNING <WA>.
    CONCATENATE
    <WA>-AGGRUID <WA>-DIMENSION <WA>-POSIT
    <WA>-IOBJNM
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSDDIMEIOBJ_TMP.
ENDFORM.

FORM Z_QUERY_AGGREGATE_DIM
USING P_LANGUAGE TYPE L001TAB-DATA
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSDDIME,
    AGGRUID TYPE RSDDAGGRDIR-AGGRUID,
    DIMENSION TYPE RSDDIME-DIMENSION,
    POSIT TYPE RSDDIME-POSIT,
    IOBJTP TYPE RSDDIME-IOBJTP,
    TXTLG TYPE RSDDIMET-TXTLG,
  END OF TY_RSDDIME.
  FIELD-SYMBOLS: <WA> TYPE TY_RSDDIME.
  DATA: RSDDIME_TMP TYPE TABLE OF TY_RSDDIME.

  SELECT ra~AGGRUID rat~DIMENSION POSIT IOBJTP TXTLG
  FROM RSDDAGGRDIR AS ra
  INNER JOIN RSDDIME as rat
    ON ra~INFOCUBE EQ rat~INFOCUBE
    AND rat~OBJVERS EQ 'A'
  LEFT JOIN RSDDIMET AS rs
    ON rat~INFOCUBE EQ rs~INFOCUBE
    AND rat~DIMENSION EQ rs~DIMENSION
    AND rs~LANGU EQ P_LANGUAGE
    AND rs~OBJVERS EQ 'A'
  INTO TABLE RSDDIME_TMP
  BYPASSING BUFFER
  WHERE ra~OBJVERS EQ 'A' AND rat~IOBJTP IN ('CHA', 'KYF', 'TIM', 'DPA', 'UNI').

  LOOP AT RSDDIME_TMP ASSIGNING <WA>.
    CONCATENATE
    <WA>-AGGRUID <WA>-DIMENSION <WA>-POSIT
    <WA>-IOBJTP <WA>-TXTLG
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSDDIME_TMP.
ENDFORM.

FORM Z_QUERY_AGGREGATE_ATTR
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSDDAGGRCOMP,
    AGGRUID TYPE RSDDAGGRDIR-AGGRUID,
    IOBJNM TYPE RSDDIMEIOBJ-IOBJNM,
    AGGRST TYPE RSDDAGGRDIR-OBJVERS,
    HIEID TYPE RSDDAGGRDIR-AGGRUID,
    TLEVEL(2) TYPE n,
    VALUE TYPE STRING,
  END OF TY_RSDDAGGRCOMP.
  FIELD-SYMBOLS: <WA> TYPE TY_RSDDAGGRCOMP.
  DATA: RSDDAGGRCOMP_TMP TYPE TABLE OF TY_RSDDAGGRCOMP.

  SELECT ra~AGGRUID IOBJNM AGGRST HIEID TLEVEL VALUE
  FROM RSDDAGGRDIR AS ra
  INNER JOIN RSDDAGGRCOMP as rat
    ON ra~AGGRUID EQ rat~AGGRUID
    AND rat~OBJVERS EQ 'A'
  INTO TABLE RSDDAGGRCOMP_TMP
  WHERE ra~OBJVERS EQ 'A'.

  LOOP AT RSDDAGGRCOMP_TMP ASSIGNING <WA>.
    CONCATENATE
    <WA>-AGGRUID <WA>-IOBJNM <WA>-AGGRST
    <WA>-HIEID <WA>-TLEVEL <WA>-VALUE
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSDDAGGRCOMP_TMP.
ENDFORM.

FORM Z_QUERY_AGGREGATE_REF
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSDCUBE,
    AGGRUID TYPE RSDDAGGRDIR-AGGRUID,
    INFOAREA TYPE RSDCUBE-INFOAREA,
  END OF TY_RSDCUBE.
  FIELD-SYMBOLS: <WA> TYPE TY_RSDCUBE.
  DATA: RSDCUBE_TMP TYPE TABLE OF TY_RSDCUBE.

  SELECT ra~AGGRUID INFOAREA
  FROM RSDDAGGRDIR AS ra
  INNER JOIN RSDCUBE as rat
    ON ra~INFOCUBE EQ rat~INFOCUBE
    AND rat~OBJVERS EQ 'A'
  INTO TABLE RSDCUBE_TMP
  BYPASSING BUFFER
  WHERE ra~OBJVERS EQ 'A'.

  LOOP AT RSDCUBE_TMP ASSIGNING <WA>.
    CONCATENATE
    <WA>-AGGRUID <WA>-INFOAREA
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSDCUBE_TMP.
ENDFORM.

FORM Z_QUERY_AGGREGATE
USING P_LANGUAGE TYPE L001TAB-DATA
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSDDAGGRDIR,
    AGGRUID TYPE RSDDAGGRDIR-AGGRUID,
    AGGRCUBE TYPE RSDDAGGRDIR-AGGRCUBE,
    INFOCUBE TYPE RSDDAGGRDIR-INFOCUBE,
    CONTTIMESTMP TYPE RSDDAGGRDIR-CONTTIMESTMP,
    TIMESTMP TYPE RSDDAGGRDIR-TIMESTMP,
    TXTLG TYPE RSDDAGGRT-TXTLG,
  END OF TY_RSDDAGGRDIR.
  FIELD-SYMBOLS: <WA> TYPE TY_RSDDAGGRDIR.
  DATA: RSDDAGGRDIR_TMP TYPE TABLE OF TY_RSDDAGGRDIR.
  DATA: EXPORT_LINECLEANED TYPE STRING.
  DATA: EXPORT_LINECLEANED1 TYPE STRING.

  SELECT ra~AGGRUID AGGRCUBE INFOCUBE CONTTIMESTMP TIMESTMP rat~TXTLG
  FROM RSDDAGGRDIR AS ra
  LEFT OUTER JOIN RSDDAGGRT as rat
    ON ra~AGGRUID EQ rat~AGGRUID
    AND rat~LANGU EQ P_LANGUAGE
    AND rat~OBJVERS EQ 'A'
  INTO TABLE RSDDAGGRDIR_TMP
  BYPASSING BUFFER
  WHERE ra~OBJVERS EQ 'A'
  ORDER BY ra~AGGRUID.

  LOOP AT RSDDAGGRDIR_TMP ASSIGNING <WA>.
    EXPORT_LINECLEANED = <WA>-CONTTIMESTMP.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED.

    EXPORT_LINECLEANED1 = <WA>-TIMESTMP.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED1.

    CONCATENATE
    <WA>-AGGRUID <WA>-AGGRCUBE <WA>-INFOCUBE EXPORT_LINECLEANED
    EXPORT_LINECLEANED1 <WA>-TXTLG
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSDDAGGRDIR_TMP.
ENDFORM.

FORM Z_QUERY_DATASTORE_OBJ
USING P_LANGUAGE TYPE L001TAB-DATA
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSDODSO,
    ODSOBJECT TYPE RSDODSO-ODSOBJECT,
    INFOAREA TYPE RSDODSO-INFOAREA,
    CONTTIMESTMP TYPE RSDODSO-CONTTIMESTMP,
    TIMESTMP TYPE RSDODSO-TIMESTMP,
    TXTLG TYPE RSDODSOT-TXTLG,
  END OF TY_RSDODSO.
  FIELD-SYMBOLS: <WA> TYPE TY_RSDODSO.
  DATA: RSDODSO_TMP TYPE TABLE OF TY_RSDODSO.
  DATA: EXPORT_LINECLEANED TYPE STRING.
  DATA: EXPORT_LINECLEANED1 TYPE STRING.

  SELECT ra~ODSOBJECT INFOAREA CONTTIMESTMP TIMESTMP rat~TXTLG
  FROM RSDODSO AS ra
  LEFT OUTER JOIN RSDODSOT as rat
    ON ra~ODSOBJECT EQ rat~ODSOBJECT
    AND rat~LANGU EQ P_LANGUAGE
    AND rat~OBJVERS EQ 'A'
  INTO TABLE RSDODSO_TMP
  BYPASSING BUFFER
  WHERE ra~OBJVERS EQ 'A'
  ORDER BY ra~ODSOBJECT ra~INFOAREA.

  LOOP AT RSDODSO_TMP ASSIGNING <WA>.
    EXPORT_LINECLEANED = <WA>-CONTTIMESTMP.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED.

    EXPORT_LINECLEANED1 = <WA>-TIMESTMP.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED1.

    CONCATENATE
    <WA>-ODSOBJECT <WA>-INFOAREA EXPORT_LINECLEANED EXPORT_LINECLEANED1
    <WA>-TXTLG
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSDODSO_TMP.
ENDFORM.

FORM Z_QUERY_DATASTORE_OBJ_FIELD
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSDODSOIOBJ,
    ODSOBJECT TYPE RSDODSOIOBJ-ODSOBJECT,
    IOBJNM TYPE RSDODSOIOBJ-IOBJNM,
    POSIT TYPE RSDODSOIOBJ-POSIT,
    KEYFLAG TYPE RSDODSOIOBJ-KEYFLAG,
  END OF TY_RSDODSOIOBJ.
  FIELD-SYMBOLS: <WA> TYPE TY_RSDODSOIOBJ.
  DATA: RSDODSOIOBJ_TMP TYPE TABLE OF TY_RSDODSOIOBJ.

  SELECT ra~ODSOBJECT rs~IOBJNM rs~POSIT rs~KEYFLAG
  FROM RSDODSO AS ra
  INNER JOIN RSDODSOIOBJ AS rs
  ON ra~ODSOBJECT EQ rs~ODSOBJECT
  AND rs~OBJVERS EQ 'A'
  INTO TABLE RSDODSOIOBJ_TMP
  BYPASSING BUFFER
  WHERE ra~OBJVERS EQ 'A'
  ORDER BY rs~ODSOBJECT rs~IOBJNM.

   LOOP AT RSDODSOIOBJ_TMP ASSIGNING <WA>.
    CONCATENATE
    <WA>-ODSOBJECT <WA>-IOBJNM <WA>-POSIT <WA>-KEYFLAG
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSDODSOIOBJ_TMP.
ENDFORM.

FORM Z_QUERY_DATASTORE_OBJ_ATTR
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSDODSOATRNAV,
    ODSOBJECT TYPE RSDODSOATRNAV-ODSOBJECT,
    POSIT TYPE RSDODSOATRNAV-POSIT,
    ATRNAVNM TYPE RSDODSOATRNAV-ATRNAVNM,
  END OF TY_RSDODSOATRNAV.
  FIELD-SYMBOLS: <WA> TYPE TY_RSDODSOATRNAV.
  DATA: RSDODSOATRNAV_TMP TYPE TABLE OF TY_RSDODSOATRNAV.

  SELECT ra~ODSOBJECT rs~POSIT rs~ATRNAVNM
  FROM RSDODSO AS ra
  INNER JOIN RSDODSOATRNAV AS rs
    ON ra~ODSOBJECT EQ rs~ODSOBJECT
    AND rs~OBJVERS EQ 'A'
  INTO TABLE RSDODSOATRNAV_TMP
  BYPASSING BUFFER
  WHERE ra~OBJVERS EQ 'A'
  ORDER BY rs~ODSOBJECT rs~ATRNAVNM.

   LOOP AT RSDODSOATRNAV_TMP ASSIGNING <WA>.
    CONCATENATE
    <WA>-ODSOBJECT <WA>-POSIT <WA>-ATRNAVNM
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSDODSOATRNAV_TMP.
ENDFORM.


FORM Z_QUERY_ADV_DATASTORE_OBJ
USING P_LANGUAGE TYPE L001TAB-DATA
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSOADSO,
    ADSONM TYPE RSDODSO-ODSOBJECT,
    INFOAREA TYPE RSDODSO-INFOAREA,
    CONTTIMESTMP TYPE RSDODSO-CONTTIMESTMP,
    TIMESTMP TYPE RSDODSO-TIMESTMP,
    TXTLG TYPE RSDODSOT-TXTLG,
    CUBEDELTAONLY TYPE RSOADSO-CUBEDELTAONLY,
  END OF TY_RSOADSO.
  FIELD-SYMBOLS: <WA> TYPE TY_RSOADSO.
  DATA: RSOADSO_TMP TYPE TABLE OF TY_RSOADSO.
  DATA: EXPORT_LINECLEANED TYPE STRING.
  DATA: EXPORT_LINECLEANED1 TYPE STRING.

  SELECT ra~ADSONM INFOAREA CONTTIMESTMP TIMESTMP rat~DESCRIPTION CUBEDELTAONLY
  FROM RSOADSO AS ra
  LEFT OUTER JOIN RSOADSOT as rat
    ON ra~ADSONM EQ rat~ADSONM
    AND rat~LANGU EQ P_LANGUAGE
    AND rat~OBJVERS EQ 'A' AND rat~TTYP EQ 'EUSR'
  INTO TABLE RSOADSO_TMP
  BYPASSING BUFFER
  WHERE ra~OBJVERS EQ 'A'
  ORDER BY ra~ADSONM ra~INFOAREA.

  LOOP AT RSOADSO_TMP ASSIGNING <WA>.
    EXPORT_LINECLEANED = <WA>-CONTTIMESTMP.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED.

    EXPORT_LINECLEANED1 = <WA>-TIMESTMP.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED1.

    CONCATENATE
    <WA>-ADSONM <WA>-INFOAREA EXPORT_LINECLEANED EXPORT_LINECLEANED1
    <WA>-TXTLG <WA>-CUBEDELTAONLY
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSOADSO_TMP.
ENDFORM.

FORM Z_QUERY_ADV_DATASTORE_FDESC
USING P_LANGUAGE TYPE L001TAB-DATA
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSOADSO,
    ADSONM TYPE RSDODSO-ODSOBJECT,
    COLNAME TYPE RSDODSOT-TXTLG,
    TXTLG TYPE RSDODSOT-TXTLG,
  END OF TY_RSOADSO.
  FIELD-SYMBOLS: <WA> TYPE TY_RSOADSO.
  DATA: RSOADSO_TMP TYPE TABLE OF TY_RSOADSO.

  SELECT ra~ADSONM COLNAME rat~DESCRIPTION
  FROM RSOADSO AS ra
  LEFT OUTER JOIN RSOADSOT as rat
    ON ra~ADSONM EQ rat~ADSONM
    AND rat~LANGU EQ P_LANGUAGE
    AND rat~OBJVERS EQ 'A' AND rat~TTYP EQ 'ELEM'
  INTO TABLE RSOADSO_TMP
  BYPASSING BUFFER
  WHERE ra~OBJVERS EQ 'A'
  ORDER BY ra~ADSONM.

  LOOP AT RSOADSO_TMP ASSIGNING <WA>.
    CONCATENATE
    <WA>-ADSONM <WA>-COLNAME <WA>-TXTLG
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSOADSO_TMP.
ENDFORM.

FORM Z_CONVERT_TO_BASE64
USING XSTRING TYPE XSTRING
  CHANGING BASE_STRING TYPE STRING.

  CALL FUNCTION 'SCMS_BASE64_ENCODE_STR'
  EXPORTING
    input = XSTRING
  IMPORTING
    output =  BASE_STRING.

ENDFORM.

FORM Z_QUERY_ADV_DATASTORE_XML
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSOADSO,
    ADSONM TYPE RSDODSO-ODSOBJECT,
    XML_UI TYPE XSTRING,
  END OF TY_RSOADSO.
  FIELD-SYMBOLS: <WA_DDL> TYPE TY_RSOADSO.
  DATA: RSOADSO_TMP TYPE TABLE OF TY_RSOADSO.

  SELECT ra~ADSONM ra~XML_UI
  FROM RSOADSO AS ra
  INTO TABLE RSOADSO_TMP
  BYPASSING BUFFER
  WHERE ra~OBJVERS EQ 'A'
  ORDER BY ra~ADSONM ra~INFOAREA.

  DATA: LT_STRING_COMP LIKE SWASTRTAB OCCURS 0 WITH HEADER LINE.
  DATA: DDL_ROWS TYPE STRING.
  DATA: ROWINDEX TYPE SO_INT.
  DATA: ROWEND TYPE SO_INT.

** Implement pagination, because 42.877 View object can result in 3.122.204 lines
** Objects have on average ~73 lines
*  ROWINDEX = 0.
*  ROWEND = ROWSKIPS + ROWCOUNT.
  LOOP AT RSOADSO_TMP ASSIGNING <WA_DDL>.
    CLEAR DDL_ROWS.
    PERFORM Z_CONVERT_TO_BASE64 USING <WA_DDL>-XML_UI CHANGING DDL_ROWS.
    CALL FUNCTION 'SWA_STRING_SPLIT'
    EXPORTING
    INPUT_STRING         = DDL_ROWS
    MAX_COMPONENT_LENGTH = 255
    TABLES
    STRING_COMPONENTS    = LT_STRING_COMP.

  APPEND '|BEGIN_XML|' TO EXPORT_TABLE.

    LOOP AT LT_STRING_COMP.
*      IF ROWCOUNT = 0 OR ( ROWINDEX >= ROWSKIPS AND ROWINDEX < ROWEND ) .
        CONCATENATE <WA_DDL>-ADSONM lt_string_comp-str
            INTO EXPORT_LINE
            SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
            APPEND EXPORT_LINE TO EXPORT_TABLE.
*     ELSEIF ROWCOUNT > 0 AND ROWINDEX >= ROWEND.
*        EXIT.
*      ENDIF.
*      ROWINDEX = ROWINDEX + 1.
      ENDLOOP.
  APPEND '|END_XML|' TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSOADSO_TMP.
ENDFORM.

FORM Z_QUERY_ADV_DATASTORE_FIELDS
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSOADSO,
    ADSONM TYPE RSDODSO-ODSOBJECT,
    XML_UI TYPE XSTRING,
  END OF TY_RSOADSO.
  FIELD-SYMBOLS: <WA> TYPE TY_RSOADSO.
  DATA: RSOADSO_TMP TYPE TABLE OF TY_RSOADSO.

  SELECT ra~ADSONM ra~XML_UI
  FROM RSOADSO AS ra
  INTO TABLE RSOADSO_TMP
  BYPASSING BUFFER
  WHERE ra~OBJVERS EQ 'A'
  ORDER BY ra~ADSONM ra~INFOAREA.

  LOOP AT RSOADSO_TMP ASSIGNING <WA>.
    DATA:  g_t_xml_data TYPE TABLE OF smum_xmltb INITIAL SIZE 0.
    DATA:  g_s_xml_info LIKE LINE OF g_t_xml_data.
    DATA:  g_t_return TYPE STANDARD TABLE OF bapiret2.
    CALL FUNCTION 'SMUM_XML_PARSE'
    EXPORTING
     xml_input = <WA>-XML_UI
    TABLES
     xml_table = g_t_xml_data
     return    = g_t_return
    EXCEPTIONS
      OTHERS    = 0.

    DATA: el      TYPE STRING.
    DATA: FIELD_RESULT      TYPE STRING.

    IF NOT g_t_xml_data IS INITIAL.

      LOOP AT g_t_xml_data INTO g_s_xml_info WHERE hier EQ 2.
        if el eq 'element' and g_s_xml_info-type EQ ''.
          if FIELD_RESULT NE ''.
            CONCATENATE
            <WA>-ADSONM FIELD_RESULT
            INTO EXPORT_LINE
            SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
            APPEND EXPORT_LINE TO EXPORT_TABLE.
            CLEAR FIELD_RESULT.
          ENDIF.
          el = ''.
        endif.
        IF  g_s_xml_info-cname EQ 'element'.
          el = 'element'.
        ENDIF.

        if el EQ 'element' AND g_s_xml_info-type EQ 'A'.
         if g_s_xml_info-cname EQ 'infoObjectName' and g_s_xml_info-hier EQ 2.
            CONCATENATE
            FIELD_RESULT ';' g_s_xml_info-cvalue
            INTO FIELD_RESULT.
         elseif g_s_xml_info-cname EQ 'name' and g_s_xml_info-hier EQ 2.
            CONCATENATE
            FIELD_RESULT g_s_xml_info-cvalue
            INTO FIELD_RESULT.
         endif.
        ENDIF.

        CLEAR g_s_xml_info.
      ENDLOOP.
  FREE g_t_xml_data.
    ENDIF.


  ENDLOOP.

  FREE RSOADSO_TMP.
ENDFORM.

FORM Z_QUERY_COMPOSITE_PROVIDER
USING P_LANGUAGE TYPE L001TAB-DATA
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSOHCPR,
    CP_NAME TYPE RSDODSO-ODSOBJECT,
    INFOAREA TYPE RSDODSO-INFOAREA,
    CONTTIMESTMP TYPE RSDODSO-CONTTIMESTMP,
    TIMESTMP TYPE RSDODSO-TIMESTMP,
    TXTLG TYPE RSDODSOT-TXTLG,
  END OF TY_RSOHCPR.
  FIELD-SYMBOLS: <WA> TYPE TY_RSOHCPR.
  DATA: RSOHCPR_TMP TYPE TABLE OF TY_RSOHCPR.
  DATA: EXPORT_LINECLEANED TYPE STRING.
  DATA: EXPORT_LINECLEANED1 TYPE STRING.

  SELECT cp~HCPRNM cp~INFOAREA cp~CONTTIMESTMP cp~TIMESTMP cpt~DESCRIPTION
  FROM RSOHCPR AS cp
  left outer JOIN RSOHCPRT as cpt
    ON cp~HCPRNM EQ cpt~HCPRNM
    AND cpt~LANGU EQ P_LANGUAGE
    AND cpt~OBJVERS EQ 'A'
    AND cpt~COLNAME EQ ''
  INTO TABLE RSOHCPR_TMP
  BYPASSING BUFFER
  WHERE cp~OBJVERS EQ 'A'
  ORDER BY cp~HCPRNM cp~INFOAREA.

  LOOP AT RSOHCPR_TMP ASSIGNING <WA>.
    EXPORT_LINECLEANED = <WA>-CONTTIMESTMP.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED.

    EXPORT_LINECLEANED1 = <WA>-TIMESTMP.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED1.

    CONCATENATE
    <WA>-CP_NAME <WA>-INFOAREA EXPORT_LINECLEANED EXPORT_LINECLEANED1
    <WA>-TXTLG
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSOHCPR_TMP.
ENDFORM.

FORM Z_QUERY_COMPOSITE_PROVIDER_XML
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

*  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSOHCPR,
    CP_NAME TYPE RSDODSO-ODSOBJECT,
    XML_UI TYPE XSTRING,
  END OF TY_RSOHCPR.
  FIELD-SYMBOLS: <WA> TYPE TY_RSOHCPR.
  DATA: RSOHCPR_TMP TYPE TABLE OF TY_RSOHCPR.

  SELECT cp~HCPRNM cp~XML_UI
  FROM RSOHCPR AS cp
  INTO TABLE RSOHCPR_TMP
  BYPASSING BUFFER
  WHERE cp~OBJVERS EQ 'A'
  ORDER BY cp~HCPRNM cp~INFOAREA.

  DATA: lv_string TYPE string.

  DATA: it_text_tab TYPE STANDARD TABLE OF STRING.
  FIELD-SYMBOLS: <wa_text_tab> TYPE STRING.

  DATA: filesize TYPE i.
*  DATA: filename TYPE string.

  TYPES: BEGIN OF TY_ITAB,
    line TYPE x LENGTH 255,
  END OF TY_ITAB.
  DATA: itab TYPE TABLE OF TY_ITAB.

  LOOP AT RSOHCPR_TMP ASSIGNING <WA>.

    CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
    EXPORTING
      buffer        = <WA>-XML_UI
    IMPORTING
      output_length = filesize
    TABLES
      binary_tab    = itab.

    CALL FUNCTION 'SCMS_BINARY_TO_STRING'
    EXPORTING
      input_length = filesize
    IMPORTING
      text_buffer = lv_string
    TABLES
      binary_tab = itab.

    CALL FUNCTION 'SOTR_SERV_STRING_TO_TABLE' "
    EXPORTING
      text =                      lv_string
      line_length =               512
    TABLES
      text_tab =                  it_text_tab.

    APPEND <WA>-CP_NAME TO EXPORT_TABLE.
    APPEND '|BEGIN_XML|' TO EXPORT_TABLE.

    LOOP AT it_text_tab ASSIGNING <wa_text_tab>.
      APPEND <wa_text_tab> TO EXPORT_TABLE.
    ENDLOOP.
    FREE it_text_tab.

    APPEND '|END_XML|' TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSOHCPR_TMP.
ENDFORM.

FORM Z_QUERY_COMPOSITE_PROVIDER_DET
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSOHCPR,
    CP_NAME TYPE RSDODSO-ODSOBJECT,
    OBJECT_DEP TYPE RSDODSO-ODSOBJECT,
    OBJECT_DEP_TYPE TYPE RSDODSO-INFOAREA,
  END OF TY_RSOHCPR.
  FIELD-SYMBOLS: <WA> TYPE TY_RSOHCPR.
  DATA: RSOHCPR_TMP TYPE TABLE OF TY_RSOHCPR.

  SELECT cp~HCPRNM ref~OBJNM_DEP ref~TLOGO_DEP
  FROM RSOHCPR AS cp
  INNER JOIN RSOOBJXREF  as ref
  on cp~HCPRNM EQ ref~OBJNM
  AND ref~OBJVERS EQ 'A'
  AND ref~ASC_TYPE EQ 5
  INTO TABLE RSOHCPR_TMP
  BYPASSING BUFFER
  WHERE cp~OBJVERS EQ 'A'
  ORDER BY cp~HCPRNM cp~INFOAREA.

  LOOP AT RSOHCPR_TMP ASSIGNING <WA>.
  CONCATENATE
    <WA>-CP_NAME <WA>-OBJECT_DEP <WA>-OBJECT_DEP_TYPE
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSOHCPR_TMP.
ENDFORM.


FORM Z_QUERY_AGGREGATION_LEVEL
USING P_LANGUAGE TYPE L001TAB-DATA
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSPLS_ALVL,
    AGGRLEVEL TYPE RSPLS_ALVL-AGGRLEVEL,
    INFOPROV TYPE RSPLS_ALVL-INFOPROV,
    INFOAREA TYPE RSPLS_ALVL-INFOAREA,
    CONTTIMESTMP TYPE RSPLS_ALVL-CONTTIMESTMP,
    TIMESTMP TYPE RSPLS_ALVL-TIMESTMP,
    TXTLG TYPE RSPLS_ALVLT-TXTLG,
    ALVLTYPE TYPE RSPLS_ALVL-ALVLTYPE,
  END OF TY_RSPLS_ALVL.
  FIELD-SYMBOLS: <WA> TYPE TY_RSPLS_ALVL.
  DATA: RSPLS_ALVL_TMP TYPE TABLE OF TY_RSPLS_ALVL.
  DATA: EXPORT_LINECLEANED TYPE STRING.
  DATA: EXPORT_LINECLEANED1 TYPE STRING.

  SELECT ra~AGGRLEVEL INFOPROV INFOAREA CONTTIMESTMP TIMESTMP rat~TXTLG ALVLTYPE
  FROM RSPLS_ALVL AS ra
  LEFT OUTER JOIN RSPLS_ALVLT as rat
    ON ra~AGGRLEVEL EQ rat~AGGRLEVEL
      AND rat~LANGU EQ P_LANGUAGE
    AND rat~OBJVERS EQ 'A'
  INTO TABLE RSPLS_ALVL_TMP
  BYPASSING BUFFER
  WHERE ra~OBJVERS EQ 'A'
  ORDER BY ra~AGGRLEVEL ra~INFOAREA.

  LOOP AT RSPLS_ALVL_TMP ASSIGNING <WA>.
    EXPORT_LINECLEANED = <WA>-CONTTIMESTMP.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED.

    EXPORT_LINECLEANED1 = <WA>-TIMESTMP.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED1.

    CONCATENATE
    <WA>-AGGRLEVEL <WA>-INFOPROV <WA>-INFOAREA EXPORT_LINECLEANED EXPORT_LINECLEANED1
    <WA>-TXTLG <WA>-ALVLTYPE
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSPLS_ALVL_TMP.
ENDFORM.

FORM Z_QUERY_AGGREGATION_LEVEL_ATTR
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSPLS_ALVL_IOBJ,
    AGGRLEVEL TYPE RSPLS_ALVL_IOBJ-AGGRLEVEL,
    IOBJNM TYPE RSPLS_ALVL_IOBJ-IOBJNM,
    PARTIOBJ TYPE RSPLS_ALVL_IOBJ-PARTIOBJ,
  END OF TY_RSPLS_ALVL_IOBJ.
  FIELD-SYMBOLS: <WA> TYPE TY_RSPLS_ALVL_IOBJ.
  DATA: RSPLS_ALVL_IOBJ_TMP TYPE TABLE OF TY_RSPLS_ALVL_IOBJ.

  SELECT ra~AGGRLEVEL rs~IOBJNM rs~PARTIOBJ
  FROM RSPLS_ALVL AS ra
  INNER JOIN RSPLS_ALVL_IOBJ AS rs
    ON ra~AGGRLEVEL EQ rs~AGGRLEVEL
    AND rs~OBJVERS EQ 'A'
  INTO TABLE RSPLS_ALVL_IOBJ_TMP
  BYPASSING BUFFER
  WHERE ra~OBJVERS EQ 'A'
  ORDER BY rs~AGGRLEVEL rs~IOBJNM.

   LOOP AT RSPLS_ALVL_IOBJ_TMP ASSIGNING <WA>.
    CONCATENATE
    <WA>-AGGRLEVEL <WA>-IOBJNM <WA>-PARTIOBJ
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSPLS_ALVL_IOBJ_TMP.
ENDFORM.

FORM Z_QUERY_PROVIDER_INFO_OBJ
USING P_CUBETYPE TYPE c
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSDDIME,
    INFOCUBE TYPE RSDCUBEIOBJ-INFOCUBE,
    IOBJNM TYPE RSDCUBEIOBJ-IOBJNM,
    POSIT TYPE RSDCUBEIOBJ-POSIT,
  END OF TY_RSDDIME.
  FIELD-SYMBOLS: <WA> TYPE TY_RSDDIME.
  DATA: RSDDIME_TMP TYPE TABLE OF TY_RSDDIME.

  SELECT cube~INFOCUBE ra~IOBJNM ra~POSIT
  FROM RSDCUBE AS cube
  LEFT JOIN RSDCUBEIOBJ AS ra
    ON cube~INFOCUBE EQ ra~INFOCUBE
  INTO TABLE RSDDIME_TMP
  BYPASSING BUFFER
  WHERE cube~OBJVERS EQ 'A' AND CUBETYPE IN (P_CUBETYPE)
  ORDER BY ra~INFOCUBE ra~IOBJNM.

  LOOP AT RSDDIME_TMP ASSIGNING <WA>.
    CONCATENATE
    <WA>-INFOCUBE <WA>-IOBJNM <WA>-POSIT
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSDDIME_TMP.
ENDFORM.

FORM Z_QUERY_PROVIDER_DIM
USING P_CUBETYPE TYPE c
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSDDIMEIOBJ,
    INFOCUBE TYPE RSDDIMEIOBJ-INFOCUBE,
    DIMENSION TYPE RSDDIMEIOBJ-DIMENSION,
    POSIT TYPE RSDDIMEIOBJ-POSIT,
    IOBJNM TYPE RSDDIMEIOBJ-IOBJNM,
  END OF TY_RSDDIMEIOBJ.
  FIELD-SYMBOLS: <WA> TYPE TY_RSDDIMEIOBJ.
  DATA: RSDDIMEIOBJ_TMP TYPE TABLE OF TY_RSDDIMEIOBJ.

  SELECT ra~INFOCUBE ra~DIMENSION rs~POSIT IOBJNM
  FROM RSDCUBE AS cube
  INNER JOIN RSDDIME AS ra
    ON cube~INFOCUBE EQ ra~INFOCUBE
  INNER JOIN RSDDIMEIOBJ AS rs
    ON rs~INFOCUBE EQ ra~INFOCUBE
  AND rs~DIMENSION EQ ra~DIMENSION
  INTO TABLE RSDDIMEIOBJ_TMP
  BYPASSING BUFFER
  WHERE ra~OBJVERS EQ 'A' AND cube~OBJVERS EQ 'A' AND rs~OBJVERS EQ 'A' AND CUBETYPE IN (P_CUBETYPE)
  ORDER BY ra~INFOCUBE ra~DIMENSION.

  LOOP AT RSDDIMEIOBJ_TMP ASSIGNING <WA>.
    CONCATENATE
    <WA>-INFOCUBE <WA>-DIMENSION
    <WA>-POSIT <WA>-IOBJNM
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSDDIMEIOBJ_TMP.
ENDFORM.

FORM Z_QUERY_HYBRID_PROVIDER_DIM
USING P_CUBETYPE TYPE c
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSDDIMEIOBJ,
    INFOCUBE TYPE RSDDIMEIOBJ-INFOCUBE,
    DIMENSION TYPE RSDDIMEIOBJ-DIMENSION,
    POSIT TYPE RSDDIMEIOBJ-POSIT,
    IOBJNM TYPE RSDDIMEIOBJ-IOBJNM,
  END OF TY_RSDDIMEIOBJ.
  FIELD-SYMBOLS: <WA> TYPE TY_RSDDIMEIOBJ.
  DATA: RSDDIMEIOBJ_TMP TYPE TABLE OF TY_RSDDIMEIOBJ.

  SELECT cube~INFOCUBE ra~DIMENSION rs~POSIT IOBJNM
  FROM RSDCUBE AS cube
  INNER JOIN RSDCUBEMULTI AS rm
  ON cube~INFOCUBE EQ rm~INFOCUBE
  AND rm~OBJVERS EQ 'A'
  INNER JOIN RSDDIME AS ra
    ON rm~PARTCUBE EQ ra~INFOCUBE
  INNER JOIN RSDDIMEIOBJ AS rs
    ON rs~INFOCUBE EQ ra~INFOCUBE
  AND rs~DIMENSION EQ ra~DIMENSION
  INTO TABLE RSDDIMEIOBJ_TMP
  BYPASSING BUFFER
  WHERE ra~OBJVERS EQ 'A' AND cube~OBJVERS EQ 'A' AND rs~OBJVERS EQ 'A' AND CUBETYPE IN (P_CUBETYPE)
  ORDER BY ra~INFOCUBE ra~DIMENSION.

  LOOP AT RSDDIMEIOBJ_TMP ASSIGNING <WA>.
    CONCATENATE
    <WA>-INFOCUBE <WA>-DIMENSION
    <WA>-POSIT <WA>-IOBJNM
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSDDIMEIOBJ_TMP.
ENDFORM.

FORM Z_QUERY_PROVIDER_DETAIL
USING P_LANGUAGE TYPE L001TAB-DATA P_CUBETYPE TYPE c
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSDDIME,
    INFOCUBE TYPE RSDDIME-INFOCUBE,
    DIMENSION TYPE RSDDIME-DIMENSION,
    POSIT TYPE RSDDIME-POSIT,
    IOBJTP TYPE RSDDIME-IOBJTP,
    TXTLG TYPE RSDDIMET-TXTLG,
  END OF TY_RSDDIME.
  FIELD-SYMBOLS: <WA> TYPE TY_RSDDIME.
  DATA: RSDDIME_TMP TYPE TABLE OF TY_RSDDIME.

  SELECT ra~INFOCUBE ra~DIMENSION ra~POSIT IOBJTP rat~TXTLG
  FROM RSDCUBE AS cube
  INNER JOIN RSDDIME AS ra
    ON cube~INFOCUBE EQ ra~INFOCUBE
  LEFT OUTER JOIN RSDDIMET as rat
    ON ra~INFOCUBE EQ rat~INFOCUBE
    AND ra~DIMENSION EQ rat~DIMENSION
    AND rat~LANGU EQ P_LANGUAGE
    AND rat~OBJVERS EQ 'A'
  INTO TABLE RSDDIME_TMP
  BYPASSING BUFFER
  WHERE ra~OBJVERS EQ 'A' AND cube~OBJVERS EQ 'A' AND CUBETYPE IN (P_CUBETYPE)
  ORDER BY ra~INFOCUBE ra~DIMENSION.

  LOOP AT RSDDIME_TMP ASSIGNING <WA>.
    CONCATENATE
    <WA>-INFOCUBE <WA>-DIMENSION
    <WA>-POSIT <WA>-IOBJTP <WA>-TXTLG
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSDDIME_TMP.
ENDFORM.

FORM Z_QUERY_HYBRID_PROVIDER_DETAIL
USING P_LANGUAGE TYPE L001TAB-DATA P_CUBETYPE TYPE c
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSDDIME,
    INFOCUBE TYPE RSDDIME-INFOCUBE,
    DIMENSION TYPE RSDDIME-DIMENSION,
    POSIT TYPE RSDDIME-POSIT,
    IOBJTP TYPE RSDDIME-IOBJTP,
    TXTLG TYPE RSDDIMET-TXTLG,
  END OF TY_RSDDIME.
  FIELD-SYMBOLS: <WA> TYPE TY_RSDDIME.
  DATA: RSDDIME_TMP TYPE TABLE OF TY_RSDDIME.

  SELECT cube~INFOCUBE ra~DIMENSION ra~POSIT IOBJTP rat~TXTLG
  FROM RSDCUBE AS cube
  INNER JOIN RSDCUBEMULTI AS rm
    ON cube~INFOCUBE EQ rm~INFOCUBE
    AND rm~OBJVERS EQ 'A'
  INNER JOIN RSDDIME AS ra
    ON rm~PARTCUBE EQ ra~INFOCUBE
  LEFT OUTER JOIN RSDDIMET as rat
    ON ra~INFOCUBE EQ rat~INFOCUBE
    AND ra~DIMENSION EQ rat~DIMENSION
    AND rat~LANGU EQ P_LANGUAGE
    AND rat~OBJVERS EQ 'A'
  INTO TABLE RSDDIME_TMP
  BYPASSING BUFFER
  WHERE ra~OBJVERS EQ 'A' AND cube~OBJVERS EQ 'A' AND CUBETYPE IN (P_CUBETYPE)
  ORDER BY ra~INFOCUBE ra~DIMENSION.

  LOOP AT RSDDIME_TMP ASSIGNING <WA>.
    CONCATENATE
    <WA>-INFOCUBE <WA>-DIMENSION
    <WA>-POSIT <WA>-IOBJTP <WA>-TXTLG
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSDDIME_TMP.
ENDFORM.

FORM Z_QUERY_PROVIDER
USING P_LANGUAGE TYPE L001TAB-DATA P_CUBETYPE TYPE c
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSDCUBE,
    INFOCUBE TYPE RSDCUBE-INFOCUBE,
    INFOAREA TYPE RSDCUBE-INFOAREA,
    CONTTIMESTMP TYPE RSDCUBE-CONTTIMESTMP,
    TIMESTMP TYPE RSDCUBE-TIMESTMP,
    TXTLG TYPE RSDCUBET-TXTLG,
    CUBETYPE TYPE RSDCUBE-CUBETYPE,
    CUBESUBTYPE TYPE RSDCUBE-CUBESUBTYPE,
    FUNCNAME TYPE RSDCUBE-FUNCNAME,
    WRITECLASNM  TYPE RSDCUBE-WRITECLASNM,
  END OF TY_RSDCUBE.
  FIELD-SYMBOLS: <WA> TYPE TY_RSDCUBE.
  DATA: RSDCUBE_TMP TYPE TABLE OF TY_RSDCUBE.
  DATA: EXPORT_LINECLEANED TYPE STRING.
  DATA: EXPORT_LINECLEANED1 TYPE STRING.

  SELECT ra~INFOCUBE ra~INFOAREA CONTTIMESTMP TIMESTMP rat~TXTLG
  CUBETYPE CUBESUBTYPE FUNCNAME WRITECLASNM
  FROM RSDCUBE AS ra
  LEFT OUTER JOIN RSDCUBET as rat
    ON ra~INFOCUBE EQ rat~INFOCUBE
    AND rat~LANGU EQ P_LANGUAGE
    AND rat~OBJVERS EQ 'A'
  INTO TABLE RSDCUBE_TMP
  BYPASSING BUFFER
  WHERE ra~OBJVERS EQ 'A' AND CUBETYPE IN (P_CUBETYPE)
  ORDER BY ra~INFOCUBE.

  LOOP AT RSDCUBE_TMP ASSIGNING <WA>.
    EXPORT_LINECLEANED = <WA>-CONTTIMESTMP.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED.

    EXPORT_LINECLEANED1 = <WA>-TIMESTMP.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED1.

    CONCATENATE
    <WA>-INFOCUBE <WA>-INFOAREA
    EXPORT_LINECLEANED EXPORT_LINECLEANED1 <WA>-TXTLG
    <WA>-CUBETYPE <WA>-CUBESUBTYPE
    <WA>-FUNCNAME <WA>-WRITECLASNM
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSDCUBE_TMP.
ENDFORM.

FORM Z_QUERY_PROVIDER_INFO
USING P_CUBETYPE TYPE c
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSDCUBEMULTI,
    INFOCUBE TYPE RSDCUBEMULTI-INFOCUBE,
    PARTCUBE TYPE RSDCUBEMULTI-PARTCUBE,
    POSIT TYPE RSDCUBEMULTI-POSIT,
  END OF TY_RSDCUBEMULTI.
  FIELD-SYMBOLS: <WA> TYPE TY_RSDCUBEMULTI.
  DATA: RSDCUBEMULTI_TMP TYPE TABLE OF TY_RSDCUBEMULTI.

  SELECT ra~INFOCUBE rs~PARTCUBE rs~POSIT
  FROM RSDCUBE AS ra
  INNER JOIN RSDCUBEMULTI AS rs
    ON ra~INFOCUBE EQ rs~INFOCUBE
    AND rs~OBJVERS EQ 'A'
  INTO TABLE RSDCUBEMULTI_TMP
  BYPASSING BUFFER
  WHERE ra~OBJVERS EQ 'A' AND CUBETYPE IN (P_CUBETYPE)
  ORDER BY ra~INFOCUBE.

   LOOP AT RSDCUBEMULTI_TMP ASSIGNING <WA>.
    CONCATENATE
    <WA>-INFOCUBE <WA>-PARTCUBE
    <WA>-POSIT
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSDCUBEMULTI_TMP.
ENDFORM.

FORM Z_QUERY_INFOSPOKE_SELECTION
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSBSPOKESELSET,
    INFOSPOKE TYPE RSBSPOKESELSET-INFOSPOKE,
    IOBJNM TYPE RSBSPOKESELSET-IOBJNM,
    POSIT TYPE RSBSPOKESELSET-POSIT,
    OPT TYPE RSBSPOKESELSET-OPT,
    LOW TYPE RSBSPOKESELSET-LOW,
    HIGH TYPE RSBSPOKESELSET-HIGH,
  END OF TY_RSBSPOKESELSET.
  FIELD-SYMBOLS: <WA> TYPE TY_RSBSPOKESELSET.
  DATA: RSBSPOKESELSET_TMP TYPE TABLE OF TY_RSBSPOKESELSET.

  SELECT ra~INFOSPOKE rs~IOBJNM rs~POSIT rs~OPT rs~LOW rs~HIGH
  FROM RSBSPOKE AS ra
  INNER JOIN RSBSPOKESELSET AS rs
    ON ra~INFOSPOKE EQ rs~INFOSPOKE
    AND rs~OBJVERS EQ 'A'
  INTO TABLE RSBSPOKESELSET_TMP
  BYPASSING BUFFER
  WHERE ra~OBJVERS EQ 'A'
  ORDER BY ra~INFOSPOKE rs~IOBJNM.

   LOOP AT RSBSPOKESELSET_TMP ASSIGNING <WA>.
    CONCATENATE
    <WA>-INFOSPOKE <WA>-IOBJNM <WA>-POSIT
    <WA>-OPT <WA>-LOW <WA>-HIGH
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSBSPOKESELSET_TMP.
ENDFORM.

FORM Z_QUERY_INFOSPOKE_FIELDS
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSBSPOKEFIELDS,
    INFOSPOKE TYPE RSBSPOKEFIELDS-INFOSPOKE,
    IOBJNM TYPE RSBSPOKEFIELDS-IOBJNM,
    IOBJNM_INT TYPE RSBSPOKEFIELDS-IOBJNM_INT,
    POSIT TYPE RSBSPOKEFIELDS-POSIT,
    ATRNAVFL TYPE RSBSPOKEFIELDS-ATRNAVFL,
  END OF TY_RSBSPOKEFIELDS.
  FIELD-SYMBOLS: <WA> TYPE TY_RSBSPOKEFIELDS.
  DATA: RSBSPOKEFIELDS_TMP TYPE TABLE OF TY_RSBSPOKEFIELDS.

  SELECT ra~INFOSPOKE rs~IOBJNM rs~IOBJNM_INT rs~POSIT rs~ATRNAVFL
  FROM RSBSPOKE AS ra
  INNER JOIN RSBSPOKEFIELDS AS rs
    ON ra~INFOSPOKE EQ rs~INFOSPOKE
    AND rs~OBJVERS EQ 'A'
  INTO TABLE RSBSPOKEFIELDS_TMP
  BYPASSING BUFFER
  WHERE ra~OBJVERS EQ 'A'
  ORDER BY ra~INFOSPOKE rs~IOBJNM.

   LOOP AT RSBSPOKEFIELDS_TMP ASSIGNING <WA>.
    CONCATENATE
    <WA>-INFOSPOKE <WA>-IOBJNM <WA>-IOBJNM_INT
    <WA>-POSIT <WA>-ATRNAVFL
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSBSPOKEFIELDS_TMP.
ENDFORM.

FORM Z_QUERY_INFOSPOKE
USING P_LANGUAGE TYPE L001TAB-DATA
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSBSPOKE,
    INFOSPOKE TYPE RSBSPOKE-INFOSPOKE,
    APPLNM TYPE RSBSPOKE-APPLNM,
    CONTTIMESTMP TYPE RSBSPOKE-CONTTIMESTMP,
    TIMESTMP TYPE RSBSPOKE-TIMESTMP,
    OHDEST TYPE RSBSPOKE-OHDEST,
    OHSOURCE TYPE RSBSPOKE-OHSOURCE,
    OHSRCTYPE TYPE RSBSPOKE-OHSRCTYPE,
    TXTLG TYPE RSBSPOKET-TXTLG,
  END OF TY_RSBSPOKE.
  FIELD-SYMBOLS: <WA> TYPE TY_RSBSPOKE.
  DATA: RSBSPOKE_TMP TYPE TABLE OF TY_RSBSPOKE.
  DATA: EXPORT_LINECLEANED TYPE STRING.
  DATA: EXPORT_LINECLEANED1 TYPE STRING.

  SELECT ra~INFOSPOKE APPLNM CONTTIMESTMP TIMESTMP OHDEST
  OHSOURCE OHSRCTYPE rat~TXTLG
  FROM RSBSPOKE AS ra
  LEFT OUTER JOIN RSBSPOKET as rat
    ON ra~INFOSPOKE EQ rat~INFOSPOKE
    AND rat~LANGU EQ P_LANGUAGE
    AND rat~OBJVERS EQ 'A'
  INTO TABLE RSBSPOKE_TMP
  BYPASSING BUFFER
  WHERE ra~OBJVERS EQ 'A'
  ORDER BY ra~INFOSPOKE ra~APPLNM.

  LOOP AT RSBSPOKE_TMP ASSIGNING <WA>.
    EXPORT_LINECLEANED = <WA>-CONTTIMESTMP.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED.

    EXPORT_LINECLEANED1 = <WA>-TIMESTMP.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED1.

    CONCATENATE
    <WA>-INFOSPOKE <WA>-APPLNM EXPORT_LINECLEANED EXPORT_LINECLEANED1
    <WA>-OHDEST <WA>-OHSOURCE <WA>-OHSRCTYPE <WA>-TXTLG
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSBSPOKE_TMP.
ENDFORM.

FORM Z_QUERY_INFOSOURCE3X_FIELDS
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSKSFIELD,
    ISOURCE TYPE RSIS-ISOURCE,
    IOBJNM TYPE RSKSFIELD-IOBJNM,
    POSIT TYPE RSKSFIELD-POSIT,
    FIELDNM TYPE RSKSFIELD-FIELDNM,
    DATATYPE TYPE RSKSFIELD-DATATYPE,
    LENG TYPE RSKSFIELD-LENG,
    CONVEXIT TYPE RSKSFIELD-CONVEXIT,
    DECIMALS TYPE RSKSFIELD-DECIMALS,
  END OF TY_RSKSFIELD.
  FIELD-SYMBOLS: <WA> TYPE TY_RSKSFIELD.
  DATA: RSKSFIELD_TMP TYPE TABLE OF TY_RSKSFIELD.

  SELECT ra~ISOURCE rs~IOBJNM rs~POSIT rs~FIELDNM rs~DATATYPE rs~LENG
  rs~CONVEXIT rs~DECIMALS
  FROM RSIS AS ra
  INNER JOIN RSKSFIELD AS rs
    ON ra~COMSTRU EQ rs~COMSTRU
    AND rs~OBJVERS EQ 'A'
  INTO TABLE RSKSFIELD_TMP
  BYPASSING BUFFER
  WHERE ra~OBJVERS EQ 'A'
  ORDER BY rs~FIELDNM ra~ISOURCE rs~IOBJNM.

   LOOP AT RSKSFIELD_TMP ASSIGNING <WA>.
    CONCATENATE
    <WA>-ISOURCE <WA>-IOBJNM <WA>-POSIT
    <WA>-FIELDNM <WA>-DATATYPE <WA>-LENG
    <WA>-CONVEXIT <WA>-DECIMALS
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSKSFIELD_TMP.
ENDFORM.

FORM Z_QUERY_INFOSOURCE3X
USING P_LANGUAGE TYPE L001TAB-DATA
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSIS,
    ISOURCE TYPE RSIS-ISOURCE,
    APPLNM TYPE RSIS-APPLNM,
    CONTTIMESTMP TYPE RSIS-CONTTIMESTMP,
    TIMESTMP TYPE RSIS-TIMESTMP,
    ISSRCTYPE TYPE RSIS-ISSRCTYPE,
    TXTLG TYPE RSIST-TXTLG,
    COMSTRU TYPE RSIS-COMSTRU,
    INVISIBLE TYPE RSIS-INVISIBLE,
  END OF TY_RSIS.
  FIELD-SYMBOLS: <WA> TYPE TY_RSIS.
  DATA: RSIS_TMP TYPE TABLE OF TY_RSIS.
  DATA: EXPORT_LINECLEANED TYPE STRING.
  DATA: EXPORT_LINECLEANED1 TYPE STRING.

  SELECT ra~ISOURCE APPLNM CONTTIMESTMP TIMESTMP ISSRCTYPE rat~TXTLG
  COMSTRU INVISIBLE
  FROM RSIS AS ra
  LEFT OUTER JOIN RSIST as rat
    ON ra~ISOURCE EQ rat~ISOURCE
    AND rat~LANGU EQ P_LANGUAGE
    AND rat~OBJVERS EQ 'A'
  INTO TABLE RSIS_TMP
  BYPASSING BUFFER
  WHERE ra~OBJVERS EQ 'A'
  ORDER BY ra~ISOURCE ra~APPLNM.

  LOOP AT RSIS_TMP ASSIGNING <WA>.
    EXPORT_LINECLEANED = <WA>-TIMESTMP.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED.

    EXPORT_LINECLEANED1 = <WA>-CONTTIMESTMP.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED1.

    CONCATENATE
    <WA>-ISOURCE <WA>-APPLNM EXPORT_LINECLEANED EXPORT_LINECLEANED1
    <WA>-ISSRCTYPE <WA>-TXTLG <WA>-COMSTRU <WA>-INVISIBLE
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSIS_TMP.
ENDFORM.


FORM Z_QUERY_APPLICATION
USING P_LANGUAGE TYPE L001TAB-DATA
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSAPPL,
    APPLNM TYPE RSAPPL-APPLNM,
    APPLNM_P TYPE RSAPPL-APPLNM_P,
    TIMESTMP TYPE RSAPPL-TIMESTMP,
    CONTTIMESTMP TYPE RSAPPL-CONTTIMESTMP,
    TXTLG TYPE RSAPPLT-TXTLG,
  END OF TY_RSAPPL.
  FIELD-SYMBOLS: <WA> TYPE TY_RSAPPL.
  DATA: RSAPPL_TMP TYPE TABLE OF TY_RSAPPL.
  DATA: EXPORT_LINECLEANED TYPE STRING.
  DATA: EXPORT_LINECLEANED1 TYPE STRING.

  SELECT ra~APPLNM APPLNM_P TIMESTMP CONTTIMESTMP rat~TXTLG
  FROM RSAPPL AS ra
  LEFT OUTER JOIN RSAPPLT as rat
    ON ra~APPLNM EQ rat~APPLNM
    AND rat~LANGU EQ P_LANGUAGE
    AND rat~OBJVERS EQ 'A'
  INTO TABLE RSAPPL_TMP
  BYPASSING BUFFER
  WHERE ra~OBJVERS EQ 'A'
  ORDER BY ra~APPLNM ra~APPLNM_P.

  LOOP AT RSAPPL_TMP ASSIGNING <WA>.
    EXPORT_LINECLEANED = <WA>-TIMESTMP.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED.

    EXPORT_LINECLEANED1 = <WA>-CONTTIMESTMP.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED1.

    CONCATENATE
    <WA>-APPLNM <WA>-APPLNM_P EXPORT_LINECLEANED EXPORT_LINECLEANED1
    <WA>-TXTLG
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSAPPL_TMP.
ENDFORM.

FORM Z_QUERY_INFOSOURCE_FIELDS
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSKSFIELDNEW,
    ISOURCE TYPE RSKSFIELDNEW-ISOURCE,
    IOBJNM TYPE RSKSFIELDNEW-IOBJNM,
    POSIT TYPE RSKSFIELDNEW-POSIT,
    FIELDNM TYPE RSKSFIELDNEW-FIELDNM,
    DATATYPE TYPE RSKSFIELDNEW-DATATYPE,
    LENG TYPE RSKSFIELDNEW-LENG,
    CONVEXIT TYPE RSKSFIELDNEW-CONVEXIT,
    DECIMALS TYPE RSKSFIELDNEW-DECIMALS,
  END OF TY_RSKSFIELDNEW.
  FIELD-SYMBOLS: <WA> TYPE TY_RSKSFIELDNEW.
  DATA: RSKSFIELDNEW_TMP TYPE TABLE OF TY_RSKSFIELDNEW.

  SELECT rs~ISOURCE rs~IOBJNM rs~POSIT rs~FIELDNM rs~DATATYPE rs~LENG
  rs~CONVEXIT rs~DECIMALS
  FROM RSKSNEW AS ra
  INNER JOIN RSKSFIELDNEW AS rs
    ON ra~ISOURCE EQ rs~ISOURCE
    AND rs~OBJVERS EQ 'A'
  INTO TABLE RSKSFIELDNEW_TMP
  BYPASSING BUFFER
  WHERE ra~OBJVERS EQ 'A'
  ORDER BY rs~FIELDNM rs~ISOURCE rs~IOBJNM.

   LOOP AT RSKSFIELDNEW_TMP ASSIGNING <WA>.
    CONCATENATE
    <WA>-ISOURCE <WA>-IOBJNM <WA>-POSIT
    <WA>-FIELDNM <WA>-DATATYPE <WA>-LENG
    <WA>-CONVEXIT <WA>-DECIMALS
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSKSFIELDNEW_TMP.
ENDFORM.

FORM Z_QUERY_INFOSOURCE
USING P_LANGUAGE TYPE L001TAB-DATA
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSKSNEW,
    ISOURCE TYPE RSKSNEW-ISOURCE,
    APPLNM TYPE RSKSNEW-APPLNM,
    CONTTIMESTMP TYPE RSKSNEW-CONTTIMESTMP,
    TIMESTMP TYPE RSKSNEW-TIMESTMP,
    TXTLG TYPE RSKSNEWT-TXTLG,
  END OF TY_RSKSNEW.
  FIELD-SYMBOLS: <WA> TYPE TY_RSKSNEW.
  DATA: RSKSNEW_TMP TYPE TABLE OF TY_RSKSNEW.
  DATA: EXPORT_LINECLEANED TYPE STRING.
  DATA: EXPORT_LINECLEANED1 TYPE STRING.

  SELECT ra~ISOURCE APPLNM CONTTIMESTMP TIMESTMP rat~TXTLG
  FROM RSKSNEW AS ra
  LEFT OUTER JOIN RSKSNEWT as rat
    ON ra~ISOURCE EQ rat~ISOURCE
    AND rat~LANGU EQ P_LANGUAGE
    AND rat~OBJVERS EQ 'A'
  INTO TABLE RSKSNEW_TMP
  BYPASSING BUFFER
  WHERE ra~OBJVERS EQ 'A'
  ORDER BY ra~ISOURCE ra~APPLNM.

  LOOP AT RSKSNEW_TMP ASSIGNING <WA>.
    EXPORT_LINECLEANED = <WA>-CONTTIMESTMP.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED.

    EXPORT_LINECLEANED1 = <WA>-TIMESTMP.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED1.

    CONCATENATE
    <WA>-ISOURCE <WA>-APPLNM EXPORT_LINECLEANED EXPORT_LINECLEANED1
    <WA>-TXTLG
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSKSNEW_TMP.
ENDFORM.


FORM Z_QUERY_INFO_SETS_OBJ
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSQFOBJ,
    INFOSET TYPE RSQFOBJ-INFOSET,
    FALIAS TYPE RSQFOBJ-FALIAS,
    TALIAS TYPE RSQFOBJ-TALIAS,
    FNAME TYPE RSQFOBJ-FNAME,
    FTYPE TYPE RSQFOBJ-FTYPE,
    KEYFLAG TYPE RSQFOBJ-KEYFLAG,
    MARK TYPE RSQFOBJ-MARK,
    TECHSORT TYPE RSQFOBJ-TECHSORT,
  END OF TY_RSQFOBJ.
  FIELD-SYMBOLS: <WA> TYPE TY_RSQFOBJ.
  DATA: RSQFOBJ_TMP TYPE TABLE OF TY_RSQFOBJ.

  SELECT rs~INFOSET FALIAS rs~TALIAS FNAME FTYPE KEYFLAG MARK TECHSORT
  FROM RSQISET AS ra
  INNER JOIN RSQTOBJ AS rat
    ON ra~INFOSET EQ rat~INFOSET
    AND rat~OBJVERS EQ 'A'
  INNER JOIN RSQFOBJ AS rs
    ON ra~INFOSET EQ rs~INFOSET
    AND rat~TALIAS EQ rs~TALIAS
    AND rs~OBJVERS EQ 'A'
  INTO TABLE RSQFOBJ_TMP
  BYPASSING BUFFER
  WHERE ra~OBJVERS EQ 'A' AND FTYPE EQ 'IO'
  ORDER BY ra~INFOSET.

  LOOP AT RSQFOBJ_TMP ASSIGNING <WA>.
    CONCATENATE
    <WA>-INFOSET <WA>-FALIAS <WA>-TALIAS
    <WA>-FNAME <WA>-FTYPE <WA>-KEYFLAG
    <WA>-MARK <WA>-TECHSORT
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSQFOBJ_TMP.
ENDFORM.

FORM Z_QUERY_INFO_SETS_TABLE
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSQTOBJ,
    INFOSET TYPE RSQTOBJ-INFOSET,
    TALIAS TYPE RSQTOBJ-TALIAS,
    TNAME TYPE RSQTOBJ-TNAME,
    TTYPE TYPE RSQTOBJ-TTYPE,
  END OF TY_RSQTOBJ.
  FIELD-SYMBOLS: <WA> TYPE TY_RSQTOBJ.
  DATA: RSQTOBJ_TMP TYPE TABLE OF TY_RSQTOBJ.

  SELECT ra~INFOSET TALIAS TNAME TTYPE
  FROM RSQISET AS ra
  INNER JOIN RSQTOBJ AS rat
    ON ra~INFOSET EQ rat~INFOSET
    AND rat~OBJVERS EQ 'A'
  INTO TABLE RSQTOBJ_TMP
  BYPASSING BUFFER
  WHERE ra~OBJVERS EQ 'A'
  ORDER BY ra~INFOSET.

  LOOP AT RSQTOBJ_TMP ASSIGNING <WA>.
    CONCATENATE
    <WA>-INFOSET <WA>-TALIAS
    <WA>-TNAME <WA>-TTYPE
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSQTOBJ_TMP.
ENDFORM.

FORM Z_QUERY_INFO_SETS
USING P_LANGUAGE TYPE L001TAB-DATA
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSQISET,
    INFOSET TYPE RSQISET-INFOSET,
    INFOAREA TYPE RSQISET-INFOAREA,
    CONTTIMESTMP TYPE RSQISET-CONTTIMESTMP,
    TIMESTMP TYPE RSQISET-TIMESTMP,
    CRTSTP TYPE RSQISET-CRTSTP,
    TXTLG TYPE RSDIOBJT-TXTLG,
  END OF TY_RSQISET.
  FIELD-SYMBOLS: <WA> TYPE TY_RSQISET.
  DATA: RSQISET_TMP TYPE TABLE OF TY_RSQISET.
  DATA: EXPORT_LINECLEANED TYPE STRING.
  DATA: EXPORT_LINECLEANED1 TYPE STRING.
  DATA: EXPORT_LINECLEANED2 TYPE STRING.

  SELECT ra~INFOSET INFOAREA CONTTIMESTMP TIMESTMP CRTSTP rat~TXTLG
  FROM RSQISET AS ra
  LEFT OUTER JOIN RSQISETT as rat
    ON ra~INFOSET EQ rat~INFOSET
    AND rat~LANGU EQ P_LANGUAGE
    AND rat~OBJVERS EQ 'A'
  INTO TABLE RSQISET_TMP
  BYPASSING BUFFER
  WHERE ra~OBJVERS EQ 'A'
  ORDER BY ra~INFOSET ra~INFOAREA.

  LOOP AT RSQISET_TMP ASSIGNING <WA>.
    EXPORT_LINECLEANED = <WA>-CONTTIMESTMP.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED.

    EXPORT_LINECLEANED1 = <WA>-TIMESTMP.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED1.

    EXPORT_LINECLEANED2 = <WA>-CRTSTP.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED2.

    CONCATENATE
    <WA>-INFOSET <WA>-INFOAREA EXPORT_LINECLEANED EXPORT_LINECLEANED1
    EXPORT_LINECLEANED2 <WA>-TXTLG
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSQISET_TMP.
ENDFORM.

FORM Z_QUERY_INFO_OBJ_KEY
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSDKYF,
    KYFNM TYPE RSDKYF-KYFNM,
    AGGRGEN TYPE RSDKYF-AGGRGEN,
    DATATP TYPE RSDKYF-DATATP,
    KYFDECIM TYPE RSDKYF-KYFDECIM,
    KYFTP TYPE RSDKYF-KYFTP,
  END OF TY_RSDKYF.
  FIELD-SYMBOLS: <WA> TYPE TY_RSDKYF.
  DATA: RSDKYF_TMP TYPE TABLE OF TY_RSDKYF.

  SELECT KYFNM AGGRGEN DATATP
  KYFDECIM KYFTP
  FROM RSDIOBJ AS ra
  INNER JOIN RSDKYF as rs
  ON ra~IOBJNM EQ rs~KYFNM
  INTO TABLE RSDKYF_TMP
  BYPASSING BUFFER
  WHERE ra~OBJVERS EQ 'A' AND rs~OBJVERS EQ 'A'
  ORDER BY KYFNM.

  LOOP AT RSDKYF_TMP ASSIGNING <WA>.

    DATA: l_domname TYPE  DOMNAME,
        l_datatype   TYPE DATATYPE_D,
        l_intlen   TYPE INTLEN,
        l_leng   TYPE DDLENG,
        l_decimal   TYPE DECIMALS,
        info_obj TYPE RSD_S_VIOBJ.

        info_obj-iobjtp = rsd_c_objtp-keyfigure.
        info_obj-iobjnm = <WA>-KYFNM.
*        info_obj-domanm = ""
        info_obj-kyftp = <WA>-KYFTP.
        info_obj-datatp = <WA>-DATATP.

    CALL FUNCTION 'RSD_DOMANM_GET_FOR_IOBJ'
          EXPORTING
            i_s_viobj = info_obj
          IMPORTING
            e_domanm          = l_domname
            e_datatp          = l_datatype
            e_intlen          = l_intlen
            e_leng            = l_leng
            e_decimals        = l_decimal
          EXCEPTIONS
            illegal_input = 1
            doma_not_found = 2.
    IF sy-subrc = 1.
      l_domname = 'illegal_input'.
    ENDIF.
    IF sy-subrc = 2.
      l_domname = 'domain_not_found'.
    ENDIF.
    CONCATENATE
    <WA>-KYFNM <WA>-AGGRGEN <WA>-DATATP
    <WA>-KYFDECIM l_datatype l_leng l_intlen l_decimal l_domname
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSDKYF_TMP.
ENDFORM.

FORM Z_QUERY_INFO_OBJ_PACK_DETAIL
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSDDPA,
    DPANM TYPE RSDDPA-DPANM,
    DATATP TYPE RSDDPA-DATATP,
    OUTPUTLEN TYPE RSDDPA-OUTPUTLEN,
    TXTSHFL TYPE RSDDPA-TXTSHFL,
    TXTMDFL TYPE RSDDPA-TXTMDFL,
    TXTLGFL TYPE RSDDPA-TXTLGFL,
    TXTTABFL TYPE RSDDPA-TXTTABFL,
  INTLEN TYPE RSDDPA-INTLEN,
  END OF TY_RSDDPA.
  FIELD-SYMBOLS: <WA> TYPE TY_RSDDPA.
  DATA: RSDDPA_TMP TYPE TABLE OF TY_RSDDPA.

  SELECT DPANM DATATP OUTPUTLEN
  TXTSHFL TXTMDFL TXTLGFL TXTTABFL INTLEN
  FROM RSDIOBJ AS ra
  INNER JOIN RSDDPA as rs
  ON ra~IOBJNM EQ rs~DPANM
  INTO TABLE RSDDPA_TMP
  BYPASSING BUFFER
  WHERE ra~OBJVERS EQ 'A' AND rs~OBJVERS EQ 'A'
  ORDER BY DPANM.

  LOOP AT RSDDPA_TMP ASSIGNING <WA>.
    CONCATENATE
    <WA>-DPANM <WA>-DATATP <WA>-OUTPUTLEN
    <WA>-TXTSHFL <WA>-TXTMDFL <WA>-TXTLGFL
    <WA>-TXTTABFL <WA>-INTLEN
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSDDPA_TMP.
ENDFORM.


FORM Z_QUERY_INFO_OBJ_CHAR_DETAIL
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSDVCHA,
    CHANM TYPE RSDDPA-DPANM,
    TXTTABFL TYPE RSDDPA-OBJVERS,
    TXTSHFL TYPE RSDDPA-OBJVERS,
    TXTMDFL TYPE RSDDPA-OBJVERS,
    TXTLGFL TYPE RSDDPA-OBJVERS,
    NOLANGU TYPE RSDDPA-OBJVERS,
    TIMDEPFL TYPE RSDDPA-OBJVERS,
  END OF TY_RSDVCHA.
  FIELD-SYMBOLS: <WA> TYPE TY_RSDVCHA.
  DATA: RSDVCHA_TMP TYPE TABLE OF TY_RSDVCHA.

  SELECT CHANM TXTTABFL TXTSHFL
  TXTMDFL TXTLGFL NOLANGU TIMDEPFL
  FROM RSDIOBJ AS ra
  INNER JOIN RSDVCHA as rs
  ON ra~IOBJNM EQ rs~CHANM
  INTO TABLE RSDVCHA_TMP
  BYPASSING BUFFER
  WHERE ra~OBJVERS EQ 'A' AND rs~OBJVERS EQ 'A'
  ORDER BY CHANM.

  LOOP AT RSDVCHA_TMP ASSIGNING <WA>.
    CONCATENATE
    <WA>-CHANM <WA>-TXTTABFL <WA>-TXTSHFL
    <WA>-TXTMDFL <WA>-TXTLGFL <WA>-NOLANGU
    <WA>-TIMDEPFL
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSDVCHA_TMP.
ENDFORM.

FORM Z_QUERY_INFO_OBJ_COMP
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSDIOBJCMP,
    IOBJNM TYPE RSDIOBJCMP-IOBJNM,
    IOBJCMP TYPE RSDIOBJCMP-IOBJCMP,
    POSIT TYPE RSDIOBJCMP-POSIT,
  END OF TY_RSDIOBJCMP.
  FIELD-SYMBOLS: <WA> TYPE TY_RSDIOBJCMP.
  DATA: RSDIOBJCMP_TMP TYPE TABLE OF TY_RSDIOBJCMP.

  SELECT IOBJNM IOBJCMP POSIT
  FROM RSDIOBJCMP
  INTO TABLE RSDIOBJCMP_TMP
  BYPASSING BUFFER
  WHERE OBJVERS EQ 'A'
  ORDER BY IOBJNM IOBJCMP.

  LOOP AT RSDIOBJCMP_TMP ASSIGNING <WA>.
    CONCATENATE
    <WA>-IOBJNM <WA>-IOBJCMP <WA>-POSIT
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSDIOBJCMP_TMP.
ENDFORM.


FORM Z_QUERY_INFO_OBJ_ATTR
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSDBCHATR,
    CHABASNM TYPE RSDBCHATR-CHABASNM,
    ATTRINM TYPE RSDBCHATR-ATTRINM,
    POSIT TYPE RSDBCHATR-POSIT,
  END OF TY_RSDBCHATR.
  FIELD-SYMBOLS: <WA> TYPE TY_RSDBCHATR.
  DATA: RSDBCHATR_TMP TYPE TABLE OF TY_RSDBCHATR.

  SELECT CHABASNM ATTRINM POSIT
  FROM RSDIOBJ AS ra
  INNER JOIN RSDBCHATR AS rs
  ON ra~IOBJNM EQ rs~CHABASNM
  INTO TABLE RSDBCHATR_TMP
  BYPASSING BUFFER
  WHERE ra~OBJVERS EQ 'A' AND rs~OBJVERS EQ 'A'
  ORDER BY CHABASNM ATTRINM.

  SELECT CHABASNM ATTRINM
  FROM RSDIOBJ AS ra
  INNER JOIN RSDBCHATRXXL AS rs
  ON ra~IOBJNM EQ rs~CHABASNM
  APPENDING TABLE RSDBCHATR_TMP
  BYPASSING BUFFER
  WHERE ra~OBJVERS EQ 'A' AND rs~OBJVERS EQ 'A'
  ORDER BY CHABASNM ATTRINM.

  LOOP AT RSDBCHATR_TMP ASSIGNING <WA>.
    CONCATENATE
    <WA>-CHABASNM <WA>-ATTRINM <WA>-POSIT
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSDBCHATR_TMP.
ENDFORM.

FORM Z_QUERY_INFO_OBJ_NAV_ATTR
USING P_LANGUAGE TYPE L001TAB-DATA
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSDATRNAV,
    CHANM TYPE RSDATRNAV-CHANM,
    ATTRINM TYPE RSDATRNAV-ATTRINM,
    ATRNAVNM TYPE RSDATRNAV-ATRNAVNM,
    TXTLG TYPE RSDATRNAVT-TXTLG,
  END OF TY_RSDATRNAV.
  FIELD-SYMBOLS: <WA> TYPE TY_RSDATRNAV.
  DATA: RSDATRNAV_TMP TYPE TABLE OF TY_RSDATRNAV.

  SELECT ra~CHANM ra~ATTRINM ATRNAVNM TXTLG
  FROM RSDATRNAV as ra
  LEFT OUTER JOIN RSDATRNAVT as rat
    ON ra~CHANM EQ rat~CHANM
    AND ra~ATTRINM EQ rat~ATTRINM
    AND rat~LANGU EQ P_LANGUAGE
    AND rat~OBJVERS EQ 'A'
  INTO TABLE RSDATRNAV_TMP
  BYPASSING BUFFER
  WHERE ra~OBJVERS EQ 'A'
  ORDER BY ra~CHANM ra~ATTRINM.

  LOOP AT RSDATRNAV_TMP ASSIGNING <WA>.
    CONCATENATE
    <WA>-CHANM <WA>-ATTRINM <WA>-ATRNAVNM
    <WA>-TXTLG
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSDATRNAV_TMP.
ENDFORM.

FORM Z_QUERY_INFO_OBJ_CHAR_REF
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSDVCHA,
    CHANM TYPE RSDDPA-DPANM,
    CHABASNM TYPE RSDDPA-CHABASNM,
    INFOAREA TYPE RSDDPA-DPANM,
    APPLNM TYPE RSDDPA-DPANM,
    BCHREFFL TYPE RSDDPA-BCHREFFL,
    DATATP TYPE RSDDPA-DATATP,
    OUTPUTLEN TYPE RSDDPA-OUTPUTLEN,
  INTLEN TYPE RSDDPA-INTLEN,
  END OF TY_RSDVCHA.
  FIELD-SYMBOLS: <WA> TYPE TY_RSDVCHA.
  DATA: RSDVCHA_TMP TYPE TABLE OF TY_RSDVCHA.

  SELECT CHANM CHABASNM INFOAREA APPLNM BCHREFFL DATATP OUTPUTLEN INTLEN
  FROM RSDVCHA
  INTO TABLE RSDVCHA_TMP
  BYPASSING BUFFER
  WHERE OBJVERS EQ 'A'.

  LOOP AT RSDVCHA_TMP ASSIGNING <WA>.
    CONCATENATE
    <WA>-CHANM <WA>-CHABASNM <WA>-INFOAREA <WA>-APPLNM
    <WA>-BCHREFFL <WA>-DATATP <WA>-OUTPUTLEN <WA>-INTLEN
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSDVCHA_TMP.
ENDFORM.

FORM Z_QUERY_INFO_OBJ_REF
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSDDPA,
    IOBJNM TYPE RSDDPA-DPANM,
    CHABASNM TYPE RSDDPA-CHABASNM,
    BCHREFFL TYPE RSDDPA-BCHREFFL,
    DATATP TYPE RSDDPA-DATATP,
    OUTPUTLEN TYPE RSDDPA-OUTPUTLEN,
  INTLEN TYPE RSDDPA-INTLEN,
  END OF TY_RSDDPA.
  FIELD-SYMBOLS: <WA> TYPE TY_RSDDPA.
  DATA: RSDDPA_TMP TYPE TABLE OF TY_RSDDPA.

  SELECT TIMNM CHABASNM BCHREFFL DATATP OUTPUTLEN INTLEN
  FROM RSDVTIM
  INTO TABLE RSDDPA_TMP
  BYPASSING BUFFER
  WHERE OBJVERS EQ 'A'.

  SELECT UNINM CHABASNM BCHREFFL DATATP OUTPUTLEN INTLEN
  FROM RSDVUNI
  APPENDING TABLE RSDDPA_TMP
  BYPASSING BUFFER
  WHERE OBJVERS EQ 'A'.

  SELECT DPANM CHABASNM BCHREFFL DATATP OUTPUTLEN INTLEN
  FROM RSDDPA
  APPENDING TABLE RSDDPA_TMP
  BYPASSING BUFFER
  WHERE OBJVERS EQ 'A'.

  LOOP AT RSDDPA_TMP ASSIGNING <WA>.

    CONCATENATE
    <WA>-IOBJNM <WA>-CHABASNM
    <WA>-BCHREFFL <WA>-DATATP <WA>-OUTPUTLEN <WA>-INTLEN
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSDDPA_TMP.
ENDFORM.

FORM Z_QUERY_INFO_OBJ
USING P_LANGUAGE TYPE L001TAB-DATA
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSDIOBJ,
    IOBJNM TYPE RSDIOBJ-IOBJNM,
    CONTTIMESTMP TYPE RSDIOBJ-CONTTIMESTMP,
    TIMESTMP TYPE RSDIOBJ-TIMESTMP,
    IOBJTP TYPE RSDIOBJ-IOBJTP,
    TXTLG TYPE RSDIOBJT-TXTLG,
    TXTSH TYPE RSDIOBJT-TXTSH,
    FIELDNM TYPE RSDIOBJ-FIELDNM,
  END OF TY_RSDIOBJ.
  FIELD-SYMBOLS: <WA> TYPE TY_RSDIOBJ.
  DATA: RSDIOBJ_TMP TYPE TABLE OF TY_RSDIOBJ.
  DATA: EXPORT_LINECLEANED TYPE STRING.
  DATA: EXPORT_LINECLEANED1 TYPE STRING.

  SELECT ra~IOBJNM CONTTIMESTMP TIMESTMP IOBJTP rat~TXTLG rat~TXTSH FIELDNM
  FROM RSDIOBJ AS ra
  LEFT OUTER JOIN RSDIOBJT as rat
    ON ra~IOBJNM EQ rat~IOBJNM
    AND rat~LANGU EQ P_LANGUAGE
    AND rat~OBJVERS EQ 'A'
  INTO TABLE RSDIOBJ_TMP
  BYPASSING BUFFER
  WHERE ra~OBJVERS EQ 'A'
  ORDER BY ra~IOBJNM.

  LOOP AT RSDIOBJ_TMP ASSIGNING <WA>.
    EXPORT_LINECLEANED = <WA>-CONTTIMESTMP.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED.

    EXPORT_LINECLEANED1 = <WA>-TIMESTMP.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED1.

    CONCATENATE
    <WA>-IOBJNM EXPORT_LINECLEANED EXPORT_LINECLEANED1
    <WA>-IOBJTP <WA>-TXTLG <WA>-TXTSH <WA>-FIELDNM
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSDIOBJ_TMP.
ENDFORM.

FORM Z_QUERY_INFO_OBJ_TRAN_ROUTINE
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSAABAP,
    IOBJNM TYPE RSDIOBJ-IOBJNM,
    CODEID TYPE RSAABAP-CODEID,
    LINE_NO TYPE RSAABAP-LINE_NO,
    LINE TYPE RSAABAP-LINE,
  END OF TY_RSAABAP.
  FIELD-SYMBOLS: <WA> TYPE TY_RSAABAP.
  DATA: RSAABAP_TMP TYPE TABLE OF TY_RSAABAP.

  SELECT ra~IOBJNM abap~CODEID LINE_NO LINE
  FROM RSDIOBJ AS ra
  INNER JOIN RSDCHABAS as rat
    ON ra~IOBJNM EQ rat~CHABASNM
    AND rat~OBJVERS EQ 'A'
  INNER JOIN RSAABAP as abap
  ON rat~IOBJROUT EQ abap~CODEID
  AND abap~OBJVERS EQ 'A'
  INTO TABLE RSAABAP_TMP
  BYPASSING BUFFER
  WHERE ra~OBJVERS EQ 'A'
  ORDER BY ra~IOBJNM.

  LOOP AT RSAABAP_TMP ASSIGNING <WA>.

    CONCATENATE
    <WA>-IOBJNM <WA>-CODEID <WA>-LINE_NO <WA>-LINE
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSAABAP_TMP.
ENDFORM.

FORM Z_QUERY_INFO_CUBE_INFO_OBJ
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSDDIME,
    INFOCUBE TYPE RSDCUBEIOBJ-INFOCUBE,
    IOBJNM TYPE RSDCUBEIOBJ-IOBJNM,
    POSIT TYPE RSDCUBEIOBJ-POSIT,
  END OF TY_RSDDIME.
  FIELD-SYMBOLS: <WA> TYPE TY_RSDDIME.
  DATA: RSDDIME_TMP TYPE TABLE OF TY_RSDDIME.

  SELECT cube~INFOCUBE ra~IOBJNM ra~POSIT
  FROM RSDCUBE AS cube
  LEFT JOIN RSDCUBEIOBJ AS ra
    ON cube~INFOCUBE EQ ra~INFOCUBE
    AND ra~OBJVERS EQ 'A'
  INTO TABLE RSDDIME_TMP
  BYPASSING BUFFER
  WHERE cube~OBJVERS EQ 'A' AND CUBETYPE IN ('B', 'R', 'V')
  ORDER BY ra~INFOCUBE ra~IOBJNM.

  LOOP AT RSDDIME_TMP ASSIGNING <WA>.
    CONCATENATE
    <WA>-INFOCUBE <WA>-IOBJNM <WA>-POSIT
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSDDIME_TMP.
ENDFORM.

FORM Z_QUERY_INFO_CUBE_DIM
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSDDIMEIOBJ,
    INFOCUBE TYPE RSDDIMEIOBJ-INFOCUBE,
    DIMENSION TYPE RSDDIMEIOBJ-DIMENSION,
    POSIT TYPE RSDDIMEIOBJ-POSIT,
    IOBJNM TYPE RSDDIMEIOBJ-IOBJNM,
  END OF TY_RSDDIMEIOBJ.
  FIELD-SYMBOLS: <WA> TYPE TY_RSDDIMEIOBJ.
  DATA: RSDDIMEIOBJ_TMP TYPE TABLE OF TY_RSDDIMEIOBJ.

  SELECT ra~INFOCUBE ra~DIMENSION rs~POSIT IOBJNM
  FROM RSDCUBE AS cube
  INNER JOIN RSDDIME AS ra
    ON cube~INFOCUBE EQ ra~INFOCUBE
  INNER JOIN RSDDIMEIOBJ AS rs
    ON rs~INFOCUBE EQ ra~INFOCUBE
  AND rs~DIMENSION EQ ra~DIMENSION
  INTO TABLE RSDDIMEIOBJ_TMP
  BYPASSING BUFFER
  WHERE ra~OBJVERS EQ 'A' AND cube~OBJVERS EQ 'A' AND rs~OBJVERS EQ 'A' AND  CUBETYPE IN ('B', 'R', 'V')
  ORDER BY ra~INFOCUBE ra~DIMENSION.

  LOOP AT RSDDIMEIOBJ_TMP ASSIGNING <WA>.
    CONCATENATE
    <WA>-INFOCUBE <WA>-DIMENSION
    <WA>-POSIT <WA>-IOBJNM
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSDDIMEIOBJ_TMP.
ENDFORM.

FORM Z_QUERY_INFO_CUBE_DETAIL
USING P_LANGUAGE TYPE L001TAB-DATA
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSDDIME,
    INFOCUBE TYPE RSDDIME-INFOCUBE,
    DIMENSION TYPE RSDDIME-DIMENSION,
    POSIT TYPE RSDDIME-POSIT,
    IOBJTP TYPE RSDDIME-IOBJTP,
    TXTLG TYPE RSDDIMET-TXTLG,
  END OF TY_RSDDIME.
  FIELD-SYMBOLS: <WA> TYPE TY_RSDDIME.
  DATA: RSDDIME_TMP TYPE TABLE OF TY_RSDDIME.

  SELECT ra~INFOCUBE ra~DIMENSION ra~POSIT IOBJTP rat~TXTLG
  FROM RSDCUBE AS cube
  INNER JOIN RSDDIME AS ra
    ON cube~INFOCUBE EQ ra~INFOCUBE
  LEFT OUTER JOIN RSDDIMET as rat
    ON ra~INFOCUBE EQ rat~INFOCUBE
    AND ra~DIMENSION EQ rat~DIMENSION
    AND rat~LANGU EQ P_LANGUAGE
    AND rat~OBJVERS EQ 'A'
  INTO TABLE RSDDIME_TMP
  BYPASSING BUFFER
  WHERE ra~OBJVERS EQ 'A' AND cube~OBJVERS EQ 'A' AND CUBETYPE IN ('B', 'R', 'V')
  ORDER BY ra~INFOCUBE ra~DIMENSION.

  LOOP AT RSDDIME_TMP ASSIGNING <WA>.
    CONCATENATE
    <WA>-INFOCUBE <WA>-DIMENSION
    <WA>-POSIT <WA>-IOBJTP <WA>-TXTLG
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSDDIME_TMP.
ENDFORM.

FORM Z_QUERY_INFO_CUBE
USING P_LANGUAGE TYPE L001TAB-DATA
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSDCUBE,
    INFOCUBE TYPE RSDCUBE-INFOCUBE,
    INFOAREA TYPE RSDCUBE-INFOAREA,
    CONTTIMESTMP TYPE RSDCUBE-CONTTIMESTMP,
    TIMESTMP TYPE RSDCUBE-TIMESTMP,
    TXTLG TYPE RSDCUBET-TXTLG,
    CUBETYPE TYPE RSDCUBE-CUBETYPE,
    CUBESUBTYPE TYPE RSDCUBE-CUBESUBTYPE,
    FUNCNAME TYPE RSDCUBE-FUNCNAME,
    WRITECLASNM TYPE RSDCUBE-WRITECLASNM,
  END OF TY_RSDCUBE.
  FIELD-SYMBOLS: <WA> TYPE TY_RSDCUBE.
  DATA: RSDCUBE_TMP TYPE TABLE OF TY_RSDCUBE.
  DATA: EXPORT_LINECLEANED TYPE STRING.
  DATA: EXPORT_LINECLEANED1 TYPE STRING.

  SELECT ra~INFOCUBE ra~INFOAREA CONTTIMESTMP TIMESTMP rat~TXTLG
  CUBETYPE CUBESUBTYPE FUNCNAME WRITECLASNM
  FROM RSDCUBE AS ra
  LEFT OUTER JOIN RSDCUBET as rat
    ON ra~INFOCUBE EQ rat~INFOCUBE
    AND rat~LANGU EQ P_LANGUAGE
    AND rat~OBJVERS EQ 'A'
  INTO TABLE RSDCUBE_TMP
  BYPASSING BUFFER
  WHERE ra~OBJVERS EQ 'A' AND CUBETYPE IN ('B', 'R', 'V')
  ORDER BY ra~INFOCUBE.

  LOOP AT RSDCUBE_TMP ASSIGNING <WA>.
    EXPORT_LINECLEANED = <WA>-CONTTIMESTMP.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED.

    EXPORT_LINECLEANED1 = <WA>-TIMESTMP.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED1.

    CONCATENATE
    <WA>-INFOCUBE <WA>-INFOAREA
    EXPORT_LINECLEANED EXPORT_LINECLEANED1 <WA>-TXTLG
    <WA>-CUBETYPE <WA>-CUBESUBTYPE
    <WA>-FUNCNAME <WA>-WRITECLASNM
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSDCUBE_TMP.
ENDFORM.

FORM Z_QUERY_OBJECT_CATALOG_DEP
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSDIOBCIOBJ,
    INFOOBJCAT TYPE RSDIOBCIOBJ-INFOOBJCAT,
    IOBJNM TYPE RSDIOBCIOBJ-IOBJNM,
  END OF TY_RSDIOBCIOBJ.
  FIELD-SYMBOLS: <WA> TYPE TY_RSDIOBCIOBJ.
  DATA: RSDIOBCIOBJ_TMP TYPE TABLE OF TY_RSDIOBCIOBJ.

  SELECT INFOOBJCAT IOBJNM
  FROM RSDIOBCIOBJ
  INTO TABLE RSDIOBCIOBJ_TMP
  WHERE OBJVERS EQ 'A'
  ORDER BY INFOOBJCAT.

  LOOP AT RSDIOBCIOBJ_TMP ASSIGNING <WA>.
    CONCATENATE
    <WA>-INFOOBJCAT <WA>-IOBJNM
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSDIOBCIOBJ_TMP.
ENDFORM.

FORM Z_QUERY_INFO_OBJECT_CATALOG
USING P_LANGUAGE TYPE L001TAB-DATA
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSDIOBC,
    INFOOBJCAT TYPE RSDIOBC-INFOAREA,
    INFOAREA TYPE RSDIOBC-INFOAREA,
    CONTTIMESTMP TYPE RSDIOBC-CONTTIMESTMP,
    TIMESTMP TYPE RSDIOBC-TIMESTMP,
    TXTLG TYPE RSDIOBCT-TXTLG,
  END OF TY_RSDIOBC.
  FIELD-SYMBOLS: <WA> TYPE TY_RSDIOBC.
  DATA: RSDIOBC_TMP TYPE TABLE OF TY_RSDIOBC.
  DATA: EXPORT_LINECLEANED TYPE STRING.
  DATA: EXPORT_LINECLEANED1 TYPE STRING.

  SELECT ra~INFOOBJCAT ra~INFOAREA CONTTIMESTMP TIMESTMP rat~TXTLG
  FROM RSDIOBC AS ra
  LEFT OUTER JOIN RSDIOBCT as rat
    ON ra~INFOOBJCAT EQ rat~INFOOBJCAT
      AND rat~LANGU EQ P_LANGUAGE
  INTO TABLE RSDIOBC_TMP
  BYPASSING BUFFER
  WHERE ra~OBJVERS EQ 'A'
  ORDER BY ra~INFOOBJCAT.

  LOOP AT RSDIOBC_TMP ASSIGNING <WA>.
  EXPORT_LINECLEANED = <WA>-CONTTIMESTMP.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED.

    EXPORT_LINECLEANED1 = <WA>-TIMESTMP.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED1.

    CONCATENATE
    <WA>-INFOOBJCAT <WA>-INFOAREA
    EXPORT_LINECLEANED EXPORT_LINECLEANED1 <WA>-TXTLG
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSDIOBC_TMP.
ENDFORM.


FORM Z_QUERY_INFO_AREA
USING P_LANGUAGE TYPE L001TAB-DATA
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSDAREA,
    INFOAREA TYPE RSDAREA-INFOAREA,
    INFOAREA_P TYPE RSDAREA-INFOAREA_P,
    CONTTIMESTMP TYPE RSDAREA-CONTTIMESTMP,
    TIMESTMP TYPE RSDAREA-TIMESTMP,
    TXTLG TYPE RSDAREAT-TXTLG,
  END OF TY_RSDAREA.
  FIELD-SYMBOLS: <WA> TYPE TY_RSDAREA.
  DATA: RSDAREA_TMP TYPE TABLE OF TY_RSDAREA.
  DATA: EXPORT_LINECLEANED TYPE STRING.
  DATA: EXPORT_LINECLEANED1 TYPE STRING.

  SELECT ra~INFOAREA ra~INFOAREA_P CONTTIMESTMP TIMESTMP rat~TXTLG
  FROM RSDAREA AS ra
  LEFT OUTER JOIN RSDAREAT as rat
    ON ra~INFOAREA EQ rat~INFOAREA
      AND rat~LANGU EQ P_LANGUAGE
  INTO TABLE RSDAREA_TMP
  BYPASSING BUFFER
  WHERE ra~OBJVERS EQ 'A'
  ORDER BY ra~INFOAREA.

  LOOP AT RSDAREA_TMP ASSIGNING <WA>.
  EXPORT_LINECLEANED = <WA>-CONTTIMESTMP.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED.

    EXPORT_LINECLEANED1 = <WA>-TIMESTMP.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED1.

    CONCATENATE
    <WA>-INFOAREA <WA>-INFOAREA_P
    EXPORT_LINECLEANED EXPORT_LINECLEANED1 <WA>-TXTLG
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSDAREA_TMP.
ENDFORM.

FORM Z_QUERY_DATA_SOURCE3X_FIELDS
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSOLTPSOURCEFIE,
    OLTPSOURCE TYPE RSOLTPSOURCEFIE-OLTPSOURCE,
    LOGSYS TYPE RSOLTPSOURCEFIE-LOGSYS,
    POSIT TYPE RSOLTPSOURCEFIE-POSIT,
    FIELDNM TYPE RSOLTPSOURCEFIE-FIELDNM,
    DATATYPE TYPE RSOLTPSOURCEFIE-DATATYPE,
    LENG TYPE RSOLTPSOURCEFIE-LENG,
    CONVEXIT TYPE RSOLTPSOURCEFIE-CONVEXIT,
    DECIMALS TYPE RSOLTPSOURCEFIE-DECIMALS,
  END OF TY_RSOLTPSOURCEFIE.
  FIELD-SYMBOLS: <WA> TYPE TY_RSOLTPSOURCEFIE.
  DATA: RSOLTPSOURCEFIE_TMP TYPE TABLE OF TY_RSOLTPSOURCEFIE.

  SELECT rs~OLTPSOURCE rs~LOGSYS rs~POSIT rs~FIELDNM rs~DATATYPE rs~LENG
  rs~CONVEXIT rs~DECIMALS
  FROM RSOLTPSOURCEFIE AS rs
  INTO TABLE RSOLTPSOURCEFIE_TMP
  WHERE rs~OBJVERS EQ 'A'
  ORDER BY rs~FIELDNM rs~OLTPSOURCE rs~LOGSYS.

   LOOP AT RSOLTPSOURCEFIE_TMP ASSIGNING <WA>.
    CONCATENATE
    <WA>-OLTPSOURCE <WA>-LOGSYS <WA>-POSIT
    <WA>-FIELDNM <WA>-DATATYPE <WA>-LENG
    <WA>-CONVEXIT <WA>-DECIMALS
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSOLTPSOURCEFIE_TMP.
ENDFORM.

FORM Z_QUERY_DATA_SOURCE3X
USING P_LANGUAGE TYPE L001TAB-DATA
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSOLTPSOURCE,
    OLTPSOURCE TYPE RSOLTPSOURCE-OLTPSOURCE,
    LOGSYS TYPE RSOLTPSOURCE-LOGSYS,
    APPLNM TYPE RSOLTPSOURCE-APPLNM,
    TIMESTMP TYPE RSOLTPSOURCE-TIMESTMP,
    CONTTIMESTMP TYPE RSOLTPSOURCE-CONTTIMESTMP,
    DELTA TYPE RSOLTPSOURCE-DELTA,
    TXTLG TYPE RSOLTPSOURCET-TXTLG,
    TXTSH TYPE RSOLTPSOURCET-TXTSH,
    "XML TYPE XSTRING,
  END OF TY_RSOLTPSOURCE.
  FIELD-SYMBOLS: <WA> TYPE TY_RSOLTPSOURCE.
  DATA: RSOLTPSOURCE_TMP TYPE TABLE OF TY_RSOLTPSOURCE.
  DATA: EXPORT_LINECLEANED TYPE STRING.
  DATA: EXPORT_LINECLEANED1 TYPE STRING.
*  DATA: FILE_LOCATION TYPE STRING.

  SELECT rs~OLTPSOURCE rs~LOGSYS rs~APPLNM rs~TIMESTMP rs~CONTTIMESTMP rs~DELTA
  rst~TXTLG rst~TXTSH "rr~XML
  FROM RSOLTPSOURCE AS rs
  LEFT OUTER JOIN RSOLTPSOURCET as rst
    ON rs~LOGSYS EQ rst~LOGSYS
      AND rs~OLTPSOURCE EQ rst~OLTPSOURCE
      AND rst~LANGU EQ P_LANGUAGE
    AND rst~OBJVERS EQ 'A'
 "LEFT JOIN RSDSACCESSATTR AS rr
  "  ON rs~LOGSYS EQ rr~LOGSYS
   " AND rs~OLTPSOURCE EQ rr~DATASOURCE
    "AND ACCESSMETHOD = 'GUI_UPLOAD'
   " AND CURRENTLY_USED = 'X'
   " AND rr~OBJVERS EQ 'A'
  INTO TABLE RSOLTPSOURCE_TMP
  BYPASSING BUFFER
  WHERE rs~OBJVERS EQ 'A'
  ORDER BY rs~OLTPSOURCE rs~APPLNM rs~LOGSYS.

   LOOP AT RSOLTPSOURCE_TMP ASSIGNING <WA>.
    EXPORT_LINECLEANED = <WA>-CONTTIMESTMP.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED.

    EXPORT_LINECLEANED1 = <WA>-TIMESTMP.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED1.

  "PERFORM Z_FORM_VALUE_FROM_XML USING RSOLTPSOURCE_TMP-XML 'P_FILENAME' CHANGING FILE_LOCATION.

    CONCATENATE
    <WA>-OLTPSOURCE <WA>-LOGSYS <WA>-APPLNM
    EXPORT_LINECLEANED1 EXPORT_LINECLEANED <WA>-DELTA <WA>-TXTLG
    <WA>-TXTSH "FILE_LOCATION
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSOLTPSOURCE_TMP.
ENDFORM.

FORM Z_QUERY_DATA_SOURCE_FIELDS
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSDSSEGFD,
    DATASOURCE TYPE RSDSSEGFD-DATASOURCE,
    LOGSYS TYPE RSDSSEGFD-LOGSYS,
    POSIT TYPE RSDSSEGFD-POSIT,
    FIELDNM TYPE RSDSSEGFD-FIELDNM,
    DATATYPE TYPE RSDSSEGFD-DATATYPE,
    LENG TYPE RSDSSEGFD-LENG,
    CONVEXIT TYPE RSDSSEGFD-CONVEXIT,
    DECIMALS TYPE RSDSSEGFD-DECIMALS,
    CONSTANT TYPE RSDSSEGFD-CONSTANT,
  END OF TY_RSDSSEGFD.
  FIELD-SYMBOLS: <WA> TYPE TY_RSDSSEGFD.
  DATA: RSDSSEGFD_TMP TYPE TABLE OF TY_RSDSSEGFD.

  SELECT rs~DATASOURCE rs~LOGSYS rs~POSIT rs~FIELDNM rs~DATATYPE rs~LENG
  rs~CONVEXIT rs~DECIMALS rs~CONSTANT
  FROM RSDSSEGFD AS rs
  INTO TABLE RSDSSEGFD_TMP
  WHERE rs~OBJVERS EQ 'A'
  ORDER BY rs~FIELDNM rs~DATASOURCE rs~LOGSYS.

   LOOP AT RSDSSEGFD_TMP ASSIGNING <WA>.
    CONCATENATE
    <WA>-DATASOURCE <WA>-LOGSYS <WA>-POSIT
    <WA>-FIELDNM <WA>-DATATYPE <WA>-LENG
    <WA>-CONVEXIT <WA>-DECIMALS <WA>-CONSTANT
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSDSSEGFD_TMP.
ENDFORM.

FORM Z_QUERY_DATA_SOURCE
USING P_LANGUAGE TYPE L001TAB-DATA
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSDS,
    DATASOURCE TYPE RSDS-DATASOURCE,
    LOGSYS TYPE RSDS-LOGSYS,
    APPLNM TYPE RSDS-APPLNM,
    CONTTIMESTMP TYPE RSDS-CONTTIMESTMP,
    TIMESTMP TYPE RSDS-TIMESTMP,
    TSTMPOLTP TYPE RSDS-TSTMPOLTP,
    TXTLG TYPE RSDST-TXTLG,
    XML TYPE XSTRING,
    XML_DB_INFO TYPE XSTRING,
  END OF TY_RSDS.
  FIELD-SYMBOLS: <WA> TYPE TY_RSDS.
  DATA: RSDS_TMP TYPE TABLE OF TY_RSDS.
  DATA: EXPORT_LINECLEANED TYPE STRING.
  DATA: EXPORT_LINECLEANED2 TYPE STRING.
  DATA: EXPORT_LINECLEANED3 TYPE STRING.
  DATA: FILE_LOCATION TYPE STRING.
  DATA: DB_TABLE TYPE STRING.
  DATA: DB_SCHEMA TYPE STRING.

  SELECT rs~DATASOURCE rs~LOGSYS rs~APPLNM rs~CONTTIMESTMP rs~TIMESTMP rs~TSTMPOLTP
  rst~TXTLG rr~XML rr2~XML
  FROM RSDS AS rs
  LEFT OUTER JOIN RSDST as rst
    ON rs~LOGSYS EQ rst~LOGSYS
      AND rs~DATASOURCE EQ rst~DATASOURCE
      AND rst~LANGU EQ P_LANGUAGE
      AND rst~OBJVERS EQ 'A'
  LEFT JOIN RSDSACCESSATTR AS rr
    ON rs~LOGSYS EQ rr~LOGSYS
    AND rs~DATASOURCE EQ rr~DATASOURCE
    AND rr~ACCESSMETHOD = 'GUI_UPLOAD'
    AND rr~CURRENTLY_USED = 'X'
    AND rr~OBJVERS EQ 'A'
  LEFT JOIN RSDSACCESSATTR AS rr2
    ON rs~LOGSYS EQ rr2~LOGSYS
    AND rs~DATASOURCE EQ rr2~DATASOURCE
    AND rr2~ACCESSMETHOD = 'DBEXTRACT'
    AND rr2~CURRENTLY_USED = 'X'
    AND rr2~OBJVERS EQ 'A'
  INTO TABLE RSDS_TMP
  WHERE rs~OBJVERS EQ 'A'
  ORDER BY rs~DATASOURCE rs~APPLNM rs~LOGSYS.

  LOOP AT RSDS_TMP ASSIGNING <WA>.
    EXPORT_LINECLEANED = <WA>-CONTTIMESTMP.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED.

    EXPORT_LINECLEANED2 = <WA>-TIMESTMP.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED2.

    EXPORT_LINECLEANED3 = <WA>-TSTMPOLTP.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED3.

    PERFORM Z_FORM_VALUE_FROM_XML USING <WA>-XML 'P_FILENAME' CHANGING FILE_LOCATION.
    PERFORM Z_FORM_VALUE_FROM_XML USING <WA>-XML_DB_INFO 'OBJNAME' CHANGING DB_TABLE.
    PERFORM Z_FORM_VALUE_FROM_XML USING <WA>-XML_DB_INFO 'OBJSCHEMA' CHANGING DB_SCHEMA.

    CONCATENATE
    <WA>-DATASOURCE <WA>-LOGSYS <WA>-APPLNM
    EXPORT_LINECLEANED EXPORT_LINECLEANED2 EXPORT_LINECLEANED3 <WA>-TXTLG FILE_LOCATION
    DB_TABLE DB_SCHEMA
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSDS_TMP.
ENDFORM.

FORM Z_QUERY_APPLICATION_DS
USING P_LANGUAGE TYPE L001TAB-DATA
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSOAPPL,
    HIER TYPE RSOAPPL-HIER,
    LOGSYS TYPE RSOAPPL-LOGSYS,
    APPLNM TYPE RSOAPPL-APPLNM,
    NAME TYPE RSOAPPL-NAME,
    PARENT TYPE RSOAPPL-PARENT,
    TXTLG TYPE RSOAPPLT-TXTLG,
  END OF TY_RSOAPPL.
  FIELD-SYMBOLS: <WA> TYPE TY_RSOAPPL.
  DATA: RSOAPPL_TMP TYPE TABLE OF TY_RSOAPPL.

  SELECT rs~HIER rs~LOGSYS rs~APPLNM rs~NAME rs~PARENT rst~TXTLG
  FROM RSOAPPL AS rs
  LEFT OUTER JOIN RSOAPPLT as rst
    ON rs~LOGSYS EQ rst~LOGSYS
      AND rs~APPLNM EQ rst~APPLNM
      AND rst~LANGU EQ P_LANGUAGE
  INTO TABLE RSOAPPL_TMP
  BYPASSING BUFFER
  WHERE rs~APPLNM EQ 'NODESNOTCONNECTED' OR
  rs~LOGSYS IN ( SELECT DISTINCT fd~SLOGSYS FROM RSBASIDOC AS fd
  INNER JOIN RSSRCTYPE_MAP AS rsm
    ON fd~SRCTYPE = rsm~SRCTYPE
  WHERE rsm~SAPSYSTEM EQ 'X'
  )
  ORDER BY rs~NAME rs~APPLNM rs~LOGSYS.

   LOOP AT RSOAPPL_TMP ASSIGNING <WA>.
    CONCATENATE
    <WA>-HIER <WA>-LOGSYS <WA>-APPLNM
    <WA>-NAME <WA>-PARENT <WA>-TXTLG
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSOAPPL_TMP.
ENDFORM.

FORM Z_QUERY_SOURCE_SYSTEM
USING P_LANGUAGE TYPE L001TAB-DATA
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSBASIDOC,
    LOGSYS TYPE TBDLS-LOGSYS,
    STEXT TYPE TBDLST-STEXT,
  END OF TY_RSBASIDOC.
  FIELD-SYMBOLS: <WA> TYPE TY_RSBASIDOC.
  DATA: RSBASIDOC_TMP TYPE TABLE OF TY_RSBASIDOC.
*  DATA: EXPORT_LINECLEANED TYPE STRING.

 SELECT DISTINCT tb~LOGSYS t~STEXT
  FROM TBDLS AS tb
  INNER JOIN RSDS AS rsd
  ON tb~LOGSYS = rsd~LOGSYS
  LEFT OUTER JOIN TBDLST AS T
    ON tb~LOGSYS EQ t~LOGSYS
    AND t~LANGU EQ P_LANGUAGE
  INTO TABLE RSBASIDOC_TMP
  BYPASSING BUFFER
  WHERE rsd~OBJVERS = 'A'
  ORDER BY tb~LOGSYS.

  LOOP AT RSBASIDOC_TMP ASSIGNING <WA>.
    CONCATENATE
    <WA>-LOGSYS <WA>-STEXT
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.
  FREE RSBASIDOC_TMP.
ENDFORM.

FORM Z_QUERY_SOURCE_SYSTEM_ATTR
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSBASIDOC,
    LOGSYS TYPE TBDLS-LOGSYS,
    SRCTYPE TYPE RSBASIDOC-SRCTYPE,
    TMP_TIMESTMP TYPE RSBASIDOC-TIMESTMP,
    SAPSYSTEM TYPE RSSRCTYPE_MAP-SAPSYSTEM,
    DESTINATION TYPE RSLOGSYSDEST-DESTINATION,
    SOURCE_SYSTEM_MYSELF TYPE RSBASIDOC-SLOGSYS,
  END OF TY_RSBASIDOC.
  FIELD-SYMBOLS: <WA> TYPE TY_RSBASIDOC.
  DATA: RSBASIDOC_TMP TYPE TABLE OF TY_RSBASIDOC.
  DATA: EXPORT_LINECLEANED TYPE STRING.

 SELECT DISTINCT tb~LOGSYS fd~SRCTYPE fd~TIMESTMP rsm~SAPSYSTEM
    rd~DESTINATION rd2~SLOGSYS
  FROM TBDLS AS tb
  INNER JOIN RSDS AS rsd
   ON tb~LOGSYS = rsd~LOGSYS
  INNER JOIN RSBASIDOC AS fd
   ON tb~LOGSYS = fd~SLOGSYS
  LEFT JOIN RSSRCTYPE_MAP AS rsm
    ON fd~SRCTYPE = rsm~SRCTYPE
  LEFT JOIN RSLOGSYSDEST AS rd
    ON fd~SLOGSYS = rd~LOGSYS
  LEFT JOIN RSBASIDOC AS rd2
    ON fd~RLOGSYS EQ rd2~SLOGSYS AND rd2~SRCTYPE EQ 'M' AND rd2~OBJSTAT EQ 'ACT'
  INTO TABLE RSBASIDOC_TMP
  BYPASSING BUFFER
  WHERE rsd~OBJVERS = 'A'
  ORDER BY tb~LOGSYS.

  LOOP AT RSBASIDOC_TMP ASSIGNING <WA>.
    EXPORT_LINECLEANED = <WA>-TMP_TIMESTMP.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED.
    CONCATENATE
    <WA>-LOGSYS <WA>-SRCTYPE
    EXPORT_LINECLEANED <WA>-SAPSYSTEM <WA>-DESTINATION <WA>-SOURCE_SYSTEM_MYSELF
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.
  FREE RSBASIDOC_TMP.
ENDFORM.

FORM Z_QUERY_SOURCE_SYSTEM_ATTR2
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSBASIDOC,
    LOGSYS TYPE TBDLS-LOGSYS,
    RFCTYPE TYPE RFCDES-RFCTYPE,
    RFCOPTIONS TYPE RFCDES-RFCOPTIONS,
  END OF TY_RSBASIDOC.
  FIELD-SYMBOLS: <WA> TYPE TY_RSBASIDOC.
  DATA: RSBASIDOC_TMP TYPE TABLE OF TY_RSBASIDOC.
*  DATA: EXPORT_LINECLEANED TYPE STRING.

 SELECT DISTINCT tb~LOGSYS rf~RFCTYPE rf~RFCOPTIONS
  FROM TBDLS AS tb
  INNER JOIN RSDS AS rsd
   ON tb~LOGSYS = rsd~LOGSYS
  INNER JOIN RSBASIDOC AS fd
   ON tb~LOGSYS = fd~SLOGSYS
  INNER JOIN RSLOGSYSDEST AS rd
    ON fd~SLOGSYS = rd~LOGSYS
  "LEFT JOIN RSBASIDOC AS rd2
  " ON fd~RLOGSYS EQ rd2~SLOGSYS AND rd2~SRCTYPE EQ 'M' AND rd2~OBJSTAT EQ 'ACT'
  LEFT JOIN RFCDES AS rf
    ON rd~DESTINATION = rf~RFCDEST
  INTO TABLE RSBASIDOC_TMP
  BYPASSING BUFFER
  WHERE rsd~OBJVERS = 'A'
  ORDER BY tb~LOGSYS.

  LOOP AT RSBASIDOC_TMP ASSIGNING <WA>.
    CONCATENATE
    <WA>-LOGSYS <WA>-RFCTYPE <WA>-RFCOPTIONS
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.
  FREE RSBASIDOC_TMP.
ENDFORM.

*	Open ODS only for version 740 and later
FORM Z_QUERY_OPEN_ODS
USING P_LANGUAGE TYPE L001TAB-DATA
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSFBP,
    ODS_NAME TYPE RSFBP-FBPNAME,
    INFOAREA TYPE RSFBP-INFOAREA,
    TIMESTMP TYPE RSFBP-TIMESTMP,
    TXTSH TYPE RSFBPT-TXTSH,
    TXTLG TYPE RSFBPT-TXTLG,
    SEMANTICS TYPE RSFBPT-OBJVERS,
    SRCTYPE(4) TYPE c,
    SRCOBJNM TYPE STRING,
    SLOGSYS(10) TYPE c,
  END OF TY_RSFBP.
  FIELD-SYMBOLS: <WA> TYPE TY_RSFBP.
  DATA: RSFBP_TMP TYPE TABLE OF TY_RSFBP.
  DATA: EXPORT_LINECLEANED TYPE STRING.

  SELECT rs~FBPNAME rs~INFOAREA rs~TIMESTMP rst~TXTSH rst~TXTLG
  source~SEMANTICS SRCTYPE SRCOBJNM SLOGSYS
  FROM RSFBP AS rs
  INNER JOIN RSFBPSEMANTICS as source
    ON rs~FBPNAME EQ source~FBPNAME
      AND source~OBJVERS EQ 'A'
  INNER JOIN RSFBPSOURCE as source1
    ON rs~FBPNAME EQ source1~FBPNAME
      AND source1~OBJVERS EQ 'A'
  LEFT OUTER JOIN RSFBPT as rst
    ON rs~FBPNAME EQ rst~FBPNAME
      AND rst~LANGU EQ P_LANGUAGE
      AND rst~OBJVERS EQ 'A'
  INTO TABLE RSFBP_TMP
  BYPASSING BUFFER
  WHERE rs~OBJVERS EQ 'A'
  ORDER BY rs~FBPNAME.

  LOOP AT RSFBP_TMP ASSIGNING <WA>.
    EXPORT_LINECLEANED = <WA>-TIMESTMP.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED.

    CONCATENATE
    <WA>-ODS_NAME <WA>-INFOAREA EXPORT_LINECLEANED <WA>-TXTSH <WA>-TXTLG
    <WA>-SEMANTICS <WA>-SRCTYPE <WA>-SRCOBJNM <WA>-SLOGSYS
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSFBP_TMP.
ENDFORM.

FORM Z_QUERY_OPEN_ODS_FIELDS
USING P_LANGUAGE TYPE L001TAB-DATA
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSFBPFIELD,
    ODS_NAME TYPE RSFBP-FBPNAME,
    FIELDNAME(12) TYPE c,
    SEMANTICS(1) TYPE c,
    POSIT(4) TYPE n,
    TYPE_ROLE_AGGR(3) TYPE c,
    SRCFIELD TYPE STRING,
    TXTSH(20) TYPE c,
    TXTLG(60) TYPE c,
  END OF TY_RSFBPFIELD.
  FIELD-SYMBOLS: <WA> TYPE TY_RSFBPFIELD.
  DATA: RSFBPFIELD_TMP TYPE TABLE OF TY_RSFBPFIELD.

  SELECT rs~FBPNAME rsf~FIELDNAME rsf~SEMANTICS rsf~POSIT
  TYPE_ROLE_AGGR SRCFIELD rst~TXTSH rst~TXTLG
  FROM RSFBP AS rs
  INNER JOIN RSFBPFIELD AS rsf
  ON rs~FBPNAME EQ rsf~FBPNAME
    AND rsf~OBJVERS EQ 'A'
  LEFT OUTER JOIN RSFBPFIELDT as rst
  ON rs~FBPNAME EQ rst~FBPNAME
    AND rst~LANGU EQ P_LANGUAGE
    AND rst~OBJVERS EQ 'A'
  INTO TABLE RSFBPFIELD_TMP
  BYPASSING BUFFER
  WHERE rs~OBJVERS EQ 'A'
  ORDER BY rs~FBPNAME.

  LOOP AT RSFBPFIELD_TMP ASSIGNING <WA>.

    CONCATENATE
    <WA>-ODS_NAME <WA>-FIELDNAME <WA>-SEMANTICS
    <WA>-POSIT <WA>-TYPE_ROLE_AGGR <WA>-SRCFIELD
    <WA>-TXTSH <WA>-TXTLG
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSFBPFIELD_TMP.
ENDFORM.

FORM Z_QUERY_QUERY_VIEWS
USING P_LANGUAGE TYPE L001TAB-DATA
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSZWVIEW,
    VIEWID TYPE RSZWVIEW-VIEWID,
    CONTTIMESTMP TYPE RSZWVIEW-CONTTIMESTMP,
    TIMESTMP TYPE RSZWVIEW-TIMESTMP,
  COMPUID TYPE RSZWVIEW-COMPUID,
    TXTLG TYPE RSZELTTXT-TXTLG,
  END OF TY_RSZWVIEW.
  FIELD-SYMBOLS: <WA> TYPE TY_RSZWVIEW.
  DATA: RSZWVIEW_TMP TYPE TABLE OF TY_RSZWVIEW.
  DATA: EXPORT_LINECLEANED TYPE STRING.
  DATA: EXPORT_LINECLEANED1 TYPE STRING.
  DATA: EXPORT_LINECLEANED2 TYPE STRING.

  SELECT VIEWID CONTTIMESTMP TIMESTMP COMPUID
  rat~TXTLG
  FROM RSZWVIEW AS ra
  LEFT OUTER JOIN RSZWOBJTXT as rat
    ON ra~VIEWID EQ rat~OBJID
    AND rat~LANGU EQ P_LANGUAGE
    AND rat~OBJVERS EQ 'A'
  AND rat~TYPE EQ '03'
  INTO TABLE RSZWVIEW_TMP
  BYPASSING BUFFER
  WHERE ra~OBJVERS EQ 'A' AND ra~VIEW_TYPE EQ 'QUERY_VIEW' AND ra~BOOKMARK_COMP EQ ''
  ORDER BY ra~VIEWID.

  LOOP AT RSZWVIEW_TMP ASSIGNING <WA>.
    EXPORT_LINECLEANED = <WA>-CONTTIMESTMP.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED.

    EXPORT_LINECLEANED1 = <WA>-TIMESTMP.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED1.

  EXPORT_LINECLEANED2 = <WA>-TXTLG.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED2.

    CONCATENATE
    <WA>-VIEWID EXPORT_LINECLEANED1 EXPORT_LINECLEANED <WA>-COMPUID
    EXPORT_LINECLEANED2
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSZWVIEW_TMP.
ENDFORM.

FORM Z_QUERY_WORKBOOKS
USING P_LANGUAGE TYPE L001TAB-DATA
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSRWBINDEX,
    WORKBOOKID TYPE RSRWBINDEX-WORKBOOKID,
    TIMESTMP TYPE RSRWBINDEX-TIMESTMP,
    CONTTIMESTMP TYPE RSRWBINDEX-CONTTIMESTMP,
    TIMECREATED TYPE RSRWBINDEX-TIMECREATED,
    TITLE TYPE RSRWBINDEXT-TITLE,
    VIEWID TYPE RSZWVIEW-VIEWID,
  END OF TY_RSRWBINDEX.
  FIELD-SYMBOLS: <WA> TYPE TY_RSRWBINDEX.
  DATA: RSRWBINDEX_TMP TYPE TABLE OF TY_RSRWBINDEX.
  DATA: EXPORT_LINECLEANED TYPE STRING.
  DATA: EXPORT_LINECLEANED1 TYPE STRING.
  DATA: EXPORT_LINECLEANED2 TYPE STRING.

  SELECT rs~WORKBOOKID rs~TIMESTMP rs~CONTTIMESTMP rs~TIMECREATED rst~TITLE rsw~VIEWID
  FROM RSRWBINDEX as rs
  LEFT OUTER JOIN RSRWBINDEXT as rst
      ON rs~WORKBOOKID EQ rst~WORKBOOKID
      AND rst~LANGU EQ P_LANGUAGE
      AND rst~OBJVERS EQ 'A'
  LEFT OUTER JOIN RSZWVIEW as rsw
    ON rs~WORKBOOKID EQ rsw~WORKBOOKID
      AND rsw~OBJVERS EQ 'A'
      AND rsw~WORKBOOKID NE ''
  INTO TABLE RSRWBINDEX_TMP
  BYPASSING BUFFER
  WHERE rs~OBJVERS EQ 'A' AND WBTYP EQ ''
  ORDER BY rs~WORKBOOKID.

  LOOP AT RSRWBINDEX_TMP ASSIGNING <WA>.
    EXPORT_LINECLEANED = <WA>-CONTTIMESTMP.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED.

    EXPORT_LINECLEANED1 = <WA>-TIMESTMP.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED1.

  EXPORT_LINECLEANED2 = <WA>-TIMECREATED.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED2.

    CONCATENATE
    <WA>-WORKBOOKID EXPORT_LINECLEANED1 EXPORT_LINECLEANED EXPORT_LINECLEANED2
    <WA>-VIEWID <WA>-TITLE
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSRWBINDEX_TMP.
ENDFORM.


FORM Z_QUERY_WORKBOOKS_DETAIL
USING P_LANGUAGE TYPE L001TAB-DATA
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSRWBINDEX,
    WORKBOOKID TYPE RSRWBINDEX-WORKBOOKID,
  GENUNIID TYPE RSRWORKBOOK-GENUNIID,
  COMPUID TYPE RSRREPDIR-COMPUID,
  END OF TY_RSRWBINDEX.
  FIELD-SYMBOLS: <WA> TYPE TY_RSRWBINDEX.
  DATA: RSRWBINDEX_TMP TYPE TABLE OF TY_RSRWBINDEX.
  DATA: EXPORT_LINECLEANED TYPE STRING.
  DATA: EXPORT_LINECLEANED1 TYPE STRING.
  DATA: EXPORT_LINECLEANED2 TYPE STRING.

SELECT rs~WORKBOOKID rsrd~GENUNIID rsrd~COMPUID
FROM RSRWBINDEX as rs
INNER JOIN RSRWORKBOOK as rsr
  ON rs~WORKBOOKID EQ rsr~WORKBOOKID
    AND rsr~OBJVERS EQ 'A'
    AND rsr~GENUNIID NE ''
INNER JOIN RSRREPDIR as rsrd
  ON rsr~GENUNIID EQ rsrd~GENUNIID
    AND rsrd~OBJVERS EQ 'A'
    AND rsrd~GENUNIID NE ''
INTO TABLE RSRWBINDEX_TMP
WHERE rs~OBJVERS EQ 'A' AND WBTYP EQ ''
ORDER BY rs~WORKBOOKID.

  LOOP AT RSRWBINDEX_TMP ASSIGNING <WA>.
    CONCATENATE
    <WA>-WORKBOOKID <WA>-GENUNIID <WA>-COMPUID
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSRWBINDEX_TMP.
ENDFORM.

FORM Z_QUERY_ROLES
USING P_LANGUAGE TYPE L001TAB-DATA
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_AGR_DEFINE,
    AGR_NAME TYPE AGR_DEFINE-AGR_NAME,
    PARENT_AGR TYPE AGR_DEFINE-PARENT_AGR,
    CHANGE_DAT TYPE AGR_DEFINE-CHANGE_DAT,
    CHANGE_TIM TYPE AGR_DEFINE-CHANGE_TIM,
    CREATE_DAT TYPE AGR_DEFINE-CREATE_DAT,
    CREATE_TIM TYPE AGR_DEFINE-CREATE_TIM,
  END OF TY_AGR_DEFINE.
  FIELD-SYMBOLS: <WA> TYPE TY_AGR_DEFINE.
  DATA: AGR_DEFINE_TMP TYPE TABLE OF TY_AGR_DEFINE.
  DATA: EXPORT_LINECLEANED TYPE STRING.
  DATA: EXPORT_LINECLEANED1 TYPE STRING.
  DATA: EXPORT_LINECLEANED2 TYPE STRING.
  DATA: EXPORT_LINECLEANED3 TYPE STRING.

  SELECT AGR_NAME PARENT_AGR CHANGE_DAT CHANGE_TIM CREATE_DAT CREATE_TIM
  FROM AGR_DEFINE as rs
  INTO TABLE AGR_DEFINE_TMP
  BYPASSING BUFFER
  ORDER BY rs~AGR_NAME.

  LOOP AT AGR_DEFINE_TMP ASSIGNING <WA>.
    EXPORT_LINECLEANED = <WA>-CHANGE_DAT.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED.

    EXPORT_LINECLEANED1 = <WA>-CHANGE_TIM.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED1.

    EXPORT_LINECLEANED2 = <WA>-CREATE_DAT.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED2.

  EXPORT_LINECLEANED3 = <WA>-CREATE_TIM.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED3.

    CONCATENATE
    <WA>-AGR_NAME <WA>-PARENT_AGR EXPORT_LINECLEANED EXPORT_LINECLEANED1 EXPORT_LINECLEANED2 EXPORT_LINECLEANED3
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE AGR_DEFINE_TMP.
ENDFORM.

FORM Z_QUERY_ROLES_TEXTS
USING P_LANGUAGE TYPE L001TAB-DATA
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_AGR_TEXTS,
    AGR_NAME TYPE AGR_DEFINE-AGR_NAME,
    LINE TYPE AGR_TEXTS-LINE,
    TEXT TYPE AGR_TEXTS-TEXT,
  END OF TY_AGR_TEXTS.
  FIELD-SYMBOLS: <WA> TYPE TY_AGR_TEXTS.
  DATA: AGR_TEXTS_TMP TYPE TABLE OF TY_AGR_TEXTS.

  SELECT rs~AGR_NAME LINE TEXT
  FROM AGR_DEFINE as rs
  INNER JOIN AGR_TEXTS as rst
    ON rs~AGR_NAME EQ rst~AGR_NAME
  INTO TABLE AGR_TEXTS_TMP
  BYPASSING BUFFER
  WHERE SPRAS EQ P_LANGUAGE
  ORDER BY rs~AGR_NAME LINE.

  LOOP AT AGR_TEXTS_TMP ASSIGNING <WA>.

    CONCATENATE
    <WA>-AGR_NAME <WA>-TEXT <WA>-LINE
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE AGR_TEXTS_TMP.
ENDFORM.

FORM Z_QUERY_ROLES_INDEXES
USING P_LANGUAGE TYPE L001TAB-DATA
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_AGR_HIER,
    AGR_NAME TYPE AGR_DEFINE-AGR_NAME,
    SAP_GUID TYPE AGR_HIER-SAP_GUID,
  END OF TY_AGR_HIER.
  FIELD-SYMBOLS: <WA> TYPE TY_AGR_HIER.
  DATA: AGR_HIER_TMP TYPE TABLE OF TY_AGR_HIER.

  SELECT rs~AGR_NAME SAP_GUID
  FROM AGR_DEFINE as rs
  INNER JOIN AGR_HIER as rst
    ON rs~AGR_NAME EQ rst~AGR_NAME
  INTO TABLE AGR_HIER_TMP
  BYPASSING BUFFER
  WHERE SAP_GUID NE ''
  ORDER BY rs~AGR_NAME.

  LOOP AT AGR_HIER_TMP ASSIGNING <WA>.

    CONCATENATE
    <WA>-AGR_NAME <WA>-SAP_GUID
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE AGR_HIER_TMP.
ENDFORM.

FORM Z_QUERY_WEB_TEMPLATES
USING P_LANGUAGE TYPE L001TAB-DATA
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSZWTEMPLATE,
    TMPLID TYPE RSZWTEMPLATE-TMPLID,
    CONTTIMESTMP TYPE RSZWTEMPLATE-CONTTIMESTMP,
    TIMESTMP TYPE RSZWTEMPLATE-TIMESTMP,
    TXTLG TYPE RSZWOBJTXT-TXTLG,
    DATA_PROVIDER_ID TYPE RSZWOBJXREF-DATA_PROVIDER_ID,
  DP_IS_QUERY TYPE RSZWOBJXREF-DP_IS_QUERY,
  DATA_PROVIDER TYPE RSZWOBJXREF-DATA_PROVIDER,
  END OF TY_RSZWTEMPLATE.
  FIELD-SYMBOLS: <WA> TYPE TY_RSZWTEMPLATE.
  DATA: RSZWTEMPLATE_TMP TYPE TABLE OF TY_RSZWTEMPLATE.
  DATA: EXPORT_LINECLEANED TYPE STRING.
  DATA: EXPORT_LINECLEANED1 TYPE STRING.

  SELECT rs~TMPLID rs~CONTTIMESTMP rs~TIMESTMP  rst~TXTLG rsw~DATA_PROVIDER_ID
  rsw~DP_IS_QUERY rsw~DATA_PROVIDER
  FROM RSZWTEMPLATE as rs
  LEFT OUTER JOIN RSZWOBJTXT as rst
      ON rs~TMPLID EQ rst~OBJID
      AND rst~LANGU EQ P_LANGUAGE
      AND rst~OBJVERS EQ 'A'
  INNER JOIN RSZWOBJXREF as rsw
    ON rs~TMPLID EQ rsw~TMPLID
      AND rsw~OBJVERS EQ 'A'
      AND rsw~DATA_PROVIDER_ID NE ''
  INTO TABLE RSZWTEMPLATE_TMP
  BYPASSING BUFFER
  WHERE rs~OBJVERS EQ 'A'
  ORDER BY rs~TMPLID.

  LOOP AT RSZWTEMPLATE_TMP ASSIGNING <WA>.
    EXPORT_LINECLEANED = <WA>-CONTTIMESTMP.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED.

    EXPORT_LINECLEANED1 = <WA>-TIMESTMP.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED1.

    CONCATENATE
    <WA>-TMPLID EXPORT_LINECLEANED EXPORT_LINECLEANED1
     <WA>-DP_IS_QUERY <WA>-DATA_PROVIDER <WA>-TXTLG <WA>-DATA_PROVIDER_ID
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSZWTEMPLATE_TMP.
ENDFORM.

FORM Z_QUERY_BEX_WEB_TEMPLATES
USING P_LANGUAGE TYPE L001TAB-DATA
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSZWBTMPHEAD,
    OBJID TYPE RSZWBTMPHEAD-OBJID,
    CONTTIMESTMP TYPE RSZWBTMPHEAD-CONTTIMESTMP,
    TIMESTMP TYPE RSZWBTMPHEAD-TIMESTMP,
    TXTLG TYPE RSZWBTMPHEADTXT-TXTLG,
    OBJNM TYPE RSZWBTMPXREF-OBJNM,
  TLOGO TYPE RSZWBTMPXREF-TLOGO,
  END OF TY_RSZWBTMPHEAD.
  FIELD-SYMBOLS: <WA> TYPE TY_RSZWBTMPHEAD.
  DATA: RSZWBTMPHEAD_TMP TYPE TABLE OF TY_RSZWBTMPHEAD.
  DATA: EXPORT_LINECLEANED TYPE STRING.
  DATA: EXPORT_LINECLEANED1 TYPE STRING.

  SELECT rs~OBJID rs~CONTTIMESTMP rs~TIMESTMP  rst~TXTLG rsw~OBJNM
  rsw~TLOGO
  FROM RSZWBTMPHEAD as rs
  LEFT OUTER JOIN RSZWBTMPHEADTXT as rst
      ON rs~OBJID EQ rst~OBJID
      AND rst~LANGU EQ P_LANGUAGE
      AND rst~OBJVERS EQ 'A'
  INNER JOIN RSZWBTMPXREF as rsw
    ON rs~OBJID EQ rsw~OBJID
      AND rsw~OBJVERS EQ 'A'
      AND rsw~OBJNM NE ''
  INTO TABLE RSZWBTMPHEAD_TMP
  BYPASSING BUFFER
  WHERE rs~OBJVERS EQ 'A'
  ORDER BY rs~OBJID.

  LOOP AT RSZWBTMPHEAD_TMP ASSIGNING <WA>.
    EXPORT_LINECLEANED = <WA>-CONTTIMESTMP.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED.

    EXPORT_LINECLEANED1 = <WA>-TIMESTMP.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED1.

    CONCATENATE
    <WA>-OBJID EXPORT_LINECLEANED EXPORT_LINECLEANED1
     <WA>-OBJNM <WA>-TLOGO <WA>-TXTLG
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSZWBTMPHEAD_TMP.
ENDFORM.

FORM Z_QUERY_ENTERPRISE_REPORTS
USING P_LANGUAGE TYPE L001TAB-DATA
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSERHEADER,
    REPORT_ID TYPE RSERHEADER-REPORT_ID,
    CONTTIMESTMP TYPE RSERHEADER-CONTTIMESTMP,
    TIMESTMP TYPE RSERHEADER-TIMESTMP,
    TEXT TYPE RSERTEXT-TEXT,
    OBJNM TYPE RSZWBTMPXREF-OBJNM,
  TLOGO TYPE RSZWBTMPXREF-TLOGO,
  END OF TY_RSERHEADER.
  FIELD-SYMBOLS: <WA> TYPE TY_RSERHEADER.
  DATA: RSERHEADER_TMP TYPE TABLE OF TY_RSERHEADER.
  DATA: EXPORT_LINECLEANED TYPE STRING.
  DATA: EXPORT_LINECLEANED1 TYPE STRING.

  SELECT rs~REPORT_ID rs~CONTTIMESTMP rs~TIMESTMP  rst~TEXT rsw~OBJNM
  rsw~TLOGO
  FROM RSERHEADER as rs
  LEFT OUTER JOIN RSERTEXT as rst
      ON rs~REPORT_ID EQ rst~REPORT_ID
      AND rst~LANGU EQ P_LANGUAGE
      AND rst~OBJVERS EQ 'A'
  INNER JOIN RSERERPTXREF as rsw
    ON rs~REPORT_ID EQ rsw~REPORT_ID
      AND rsw~OBJVERS EQ 'A'
      AND rsw~OBJNM NE ''
  INTO TABLE RSERHEADER_TMP
  BYPASSING BUFFER
  WHERE rs~OBJVERS EQ 'A'
  ORDER BY rs~REPORT_ID.

  LOOP AT RSERHEADER_TMP ASSIGNING <WA>.
    EXPORT_LINECLEANED = <WA>-CONTTIMESTMP.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED.

    EXPORT_LINECLEANED1 = <WA>-TIMESTMP.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED1.

    CONCATENATE
    <WA>-REPORT_ID EXPORT_LINECLEANED EXPORT_LINECLEANED1
     <WA>-OBJNM <WA>-TLOGO <WA>-TEXT
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSERHEADER_TMP.
ENDFORM.

FORM Z_QUERY_CRYSTAL_REPORTS
USING P_LANGUAGE TYPE L001TAB-DATA
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSRWBINDEX,
    WORKBOOKID TYPE RSRWBINDEX-WORKBOOKID,
    TIMESTMP TYPE RSRWBINDEX-TIMESTMP,
    CONTTIMESTMP TYPE RSRWBINDEX-CONTTIMESTMP,
    TIMECREATED TYPE RSRWBINDEX-TIMECREATED,
    TITLE TYPE RSRWBINDEXT-TITLE,
    VIEWID TYPE RSZWVIEW-VIEWID,
  END OF TY_RSRWBINDEX.
  FIELD-SYMBOLS: <WA> TYPE TY_RSRWBINDEX.
  DATA: RSRWBINDEX_TMP TYPE TABLE OF TY_RSRWBINDEX.
  DATA: EXPORT_LINECLEANED TYPE STRING.
  DATA: EXPORT_LINECLEANED1 TYPE STRING.
  DATA: EXPORT_LINECLEANED2 TYPE STRING.

  SELECT rs~WORKBOOKID rs~TIMESTMP rs~CONTTIMESTMP rs~TIMECREATED rst~TITLE rsw~VIEWID
  FROM RSRWBINDEX as rs
  LEFT OUTER JOIN RSRWBINDEXT as rst
      ON rs~WORKBOOKID EQ rst~WORKBOOKID
      AND rst~LANGU EQ P_LANGUAGE
      AND rst~OBJVERS EQ 'A'
  LEFT OUTER JOIN RSZWVIEW as rsw
    ON rs~WORKBOOKID EQ rsw~WORKBOOKID
      AND rsw~OBJVERS EQ 'A'
      AND rsw~WORKBOOKID NE ''
  INTO TABLE RSRWBINDEX_TMP
  BYPASSING BUFFER
  WHERE rs~OBJVERS EQ 'A' AND WBTYP EQ 'C'
  ORDER BY rs~WORKBOOKID.

  LOOP AT RSRWBINDEX_TMP ASSIGNING <WA>.
    EXPORT_LINECLEANED = <WA>-CONTTIMESTMP.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED.

    EXPORT_LINECLEANED1 = <WA>-TIMESTMP.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED1.

  EXPORT_LINECLEANED2 = <WA>-TIMECREATED.
    PERFORM Z_FORM_CLEANSTRING CHANGING EXPORT_LINECLEANED2.

    CONCATENATE
    <WA>-WORKBOOKID EXPORT_LINECLEANED1 EXPORT_LINECLEANED EXPORT_LINECLEANED2
    <WA>-VIEWID <WA>-TITLE
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSRWBINDEX_TMP.
ENDFORM.


FORM Z_QUERY_CRYSTAL_REPORTS_DETAIL
USING P_LANGUAGE TYPE L001TAB-DATA
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_RSRWBINDEX,
    WORKBOOKID TYPE RSRWBINDEX-WORKBOOKID,
  GENUNIID TYPE RSRWORKBOOK-GENUNIID,
  COMPUID TYPE RSRREPDIR-COMPUID,
  END OF TY_RSRWBINDEX.
  FIELD-SYMBOLS: <WA> TYPE TY_RSRWBINDEX.
  DATA: RSRWBINDEX_TMP TYPE TABLE OF TY_RSRWBINDEX.
  DATA: EXPORT_LINECLEANED TYPE STRING.
  DATA: EXPORT_LINECLEANED1 TYPE STRING.
  DATA: EXPORT_LINECLEANED2 TYPE STRING.

SELECT rs~WORKBOOKID rsrd~GENUNIID rsrd~COMPUID
FROM RSRWBINDEX as rs
INNER JOIN RSRWORKBOOK as rsr
  ON rs~WORKBOOKID EQ rsr~WORKBOOKID
    AND rsr~OBJVERS EQ 'A'
    AND rsr~GENUNIID NE ''
INNER JOIN RSRREPDIR as rsrd
  ON rsr~GENUNIID EQ rsrd~GENUNIID
    AND rsrd~OBJVERS EQ 'A'
    AND rsrd~GENUNIID NE ''
INTO TABLE RSRWBINDEX_TMP
WHERE rs~OBJVERS EQ 'A' AND WBTYP EQ 'C'
ORDER BY rs~WORKBOOKID.

  LOOP AT RSRWBINDEX_TMP ASSIGNING <WA>.
    CONCATENATE
    <WA>-WORKBOOKID <WA>-GENUNIID <WA>-COMPUID
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE RSRWBINDEX_TMP.
ENDFORM.

FORM Z_QUERY_INFOSETCLASSIC
USING P_LANGUAGE TYPE L001TAB-DATA
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_AQGSCAT,
    CLAS TYPE AQGSCAT-CLAS,
    TSTRUC TYPE AQGSCAT-TSTRUC,
    LOGDB TYPE AQGSCAT-LOGDB,
    TEXT TYPE AQGTS-TEXT,
  END OF TY_AQGSCAT.
  FIELD-SYMBOLS: <WA> TYPE TY_AQGSCAT.
  DATA: AQGSCAT_TMP TYPE TABLE OF TY_AQGSCAT.

  SELECT obj~CLAS obj~TSTRUC obj~LOGDB t~TEXT
  FROM AQGSCAT as obj
  LEFT OUTER JOIN AQGTS as t
    ON obj~CLAS EQ t~CLAS
    AND t~SPRSL EQ P_LANGUAGE
    AND t~HEAD EQ 'X'
  INTO TABLE AQGSCAT_TMP
  BYPASSING BUFFER.

  LOOP AT AQGSCAT_TMP ASSIGNING <WA>.
    CONCATENATE <WA>-CLAS <WA>-TSTRUC <WA>-LOGDB <WA>-TEXT
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE AQGSCAT_TMP.

ENDFORM.

FORM Z_QUERY_INFOSETCLASSIC_FIELDS
USING P_LANGUAGE TYPE L001TAB-DATA
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_DDFTX,
    TABNAME TYPE DDFTX-TABNAME,
    FIELDNAME TYPE DDFTX-FIELDNAME,
    POSITION TYPE DDFTX-POSITION,
    DOMNAME TYPE DDFTX-DOMNAME,
    ROLLNAME TYPE DDFTX-ROLLNAME,
    SCRTEXT_S TYPE DDFTX-SCRTEXT_S,
    FIELDTEXT TYPE DDFTX-SCRTEXT_S,
    DDLANGUAGE TYPE DDFTX-DDLANGUAGE,
  END OF TY_DDFTX.
  FIELD-SYMBOLS: <WA> TYPE TY_DDFTX.
  DATA: DDFTX_TMP TYPE TABLE OF TY_DDFTX.

  SELECT f~TABNAME f~FIELDNAME f~POSITION f~DOMNAME f~ROLLNAME f~SCRTEXT_S f~FIELDTEXT f~DDLANGUAGE
  FROM DDFTX as f
  INNER JOIN AQGSCAT as t
    ON f~TABNAME EQ t~TSTRUC
  INTO TABLE DDFTX_TMP
  BYPASSING BUFFER
  WHERE f~DDLANGUAGE EQ P_LANGUAGE.

  LOOP AT DDFTX_TMP ASSIGNING <WA>.
    CONCATENATE <WA>-TABNAME <WA>-FIELDNAME <WA>-POSITION <WA>-DOMNAME
    <WA>-ROLLNAME <WA>-SCRTEXT_S <WA>-FIELDTEXT
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE DDFTX_TMP.

ENDFORM.

FORM Z_QUERY_INFOSET_QUERIES
USING P_LANGUAGE TYPE L001TAB-DATA
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
  TYPES: BEGIN OF TY_AQGQCAT,
    NUM TYPE AQGQCAT-NUM,
    QNUM TYPE AQGQCAT-QNUM,
    CLAS TYPE AQGQCAT-CLAS,
    TEXT TYPE AQGTQ-TEXT,
    SPRSL TYPE AQGTQ-SPRSL,
    HEAD TYPE AQGTQ-HEAD,
  END OF TY_AQGQCAT.
  FIELD-SYMBOLS: <WA> TYPE TY_AQGQCAT.
  DATA: AQGQCAT_TMP TYPE TABLE OF TY_AQGQCAT.

  SELECT obj~NUM obj~QNUM obj~CLAS t~TEXT t~SPRSL t~HEAD
  FROM AQGQCAT as obj
  LEFT OUTER JOIN AQGTQ as t
    ON obj~NUM EQ t~NUM
    AND obj~QNUM EQ t~QNUM
    AND t~SPRSL EQ P_LANGUAGE
    AND t~HEAD EQ 'X'
  INTO TABLE AQGQCAT_TMP
  BYPASSING BUFFER.

  LOOP AT AQGQCAT_TMP ASSIGNING <WA>.
    CONCATENATE <WA>-NUM <WA>-QNUM <WA>-CLAS <WA>-TEXT
    INTO EXPORT_LINE
    SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND EXPORT_LINE TO EXPORT_TABLE.
  ENDLOOP.

  FREE AQGQCAT_TMP.

ENDFORM.

FORM Z_QUERY_INFOSET_COND
USING P_LANGUAGE TYPE L001TAB-DATA
CHANGING EXPORT_TABLE TYPE EXPORT_TABLE_TYPE.

  DATA: EXPORT_LINE TYPE EXPORT_LINE_TYPE.
* Types to query InfoSets
  TYPES: BEGIN OF TY_INFOSET,
    INFOSET TYPE RSQONCOND-INFOSET,
    OBJVERS TYPE RSQONCOND-OBJVERS,
    ONCOND TYPE RSQONCOND-ONCOND,
  END OF TY_INFOSET.
  FIELD-SYMBOLS: <WA> TYPE TY_INFOSET.
  DATA: INFOSET_TMP TYPE TABLE OF TY_INFOSET.

  DATA: lt_on    TYPE RSQ_T_ON.
  DATA: lt_tmon  TYPE RSQ_T_TMON.
  FIELD-SYMBOLS: <WA_COND> TYPE RSQ_S_ON.

  SELECT INFOSET OBJVERS ONCOND
  FROM RSQONCOND
  INTO TABLE INFOSET_TMP
  BYPASSING BUFFER
  WHERE OBJVERS EQ 'A'.

  LOOP AT INFOSET_TMP ASSIGNING <WA>.
* The condition (RSQONCOND-ONCOND) is encoded and stored in a long string
* It can be parsed with BAPI function BAPI_ISET_GETDETAIL or function RSQ_ISET_READ_INFOSET_DB but this is slow.
* As faster alternative, use method cl_rsq_iset_service=>convert_string_to_oncond
    cl_rsq_iset_service=>convert_string_to_oncond( exporting onstring   = <WA>-ONCOND
                                                   importing t_oncond   = lt_on
                                                             t_tmoncond = lt_tmon ).

    LOOP AT lt_on ASSIGNING <WA_COND>.
      CONCATENATE <WA>-INFOSET <WA_COND>-FALIAS_LEFT <WA_COND>-FALIAS_RIGHT
      INTO EXPORT_LINE
      SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
      APPEND EXPORT_LINE TO EXPORT_TABLE.
    ENDLOOP.

  ENDLOOP.

  FREE INFOSET_TMP.

ENDFORM.