Skip to Content

SAP HANA Application Accelerator Scenario Editor

SAP HANA Application Accelerator Scenario Editor

rda_xml_editor.JPG

The Application Accelerator is a great tool to boost ERP applications with the use of the HANA tables/DB views from ABAP programs without changing code. Note 1696402 describes the requirements for HANA Application Accelerator to setup in the HANA ERP sidecar scenario. A requirement is to have the HANA Application Accelerator Add On (SWT2DB, SAP Note 1696402) installed on a 7.21+ kernel. SWT2DB Add On provides you the possibility to upload/maintain scenarios via report RDA_MAINTAIN. A scenario is a set of table names and program names or job names which can be activated to read data from replicated tables on the SAP HANA database via a secondary database connection and not from the main database. HANA applications can provide SAP standard scenarios or you can create custom scenarios. For custom scenarios I thought the Add On is missing an editor to create or maintain the scenario XML files to be maintained via the standard RDA_MAINTAIN report. Therefore I created this report with the following features to maintain these XML HANA Application Accelerator files:

– Load existing scenarios to the editor

– Check if table names and program names exist in the system

– Save XML file for further processing in RDA_MAINTAIN

– Maintain the tables to be read from HANA

Installation:

– SWT2DB Add On must been installed

– Create an ABAP report named “zhana_rda_scenario_editor” and copy the following code to the new report:

*&———————————————————————*

*& Report  zhana_rda_scenario_editor

*&

*&———————————————————————*

*&   NOT A standard SAP AG report! This is a custom community report

*&   more information: onno.bagijn@sap.com

*&———————————————————————*

REPORT  zhana_rda_scenario_editor.

TYPES: BEGIN OF t_context_wa,

          tabname   TYPE rda_context-tabname,

          mainprog  TYPE rda_context-mainprog,

          jobname   TYPE rda_context-jobname,

       END OF t_context_wa,

       t_context TYPE STANDARD TABLE OF t_context_wa WITH DEFAULT KEY,

       BEGIN OF t_scenario_wa,

         name        TYPE rda_control-scenario,

         version     TYPE rda_control-version,

         description TYPE rda_control-description,

         context     TYPE t_context,

       END OF t_scenario_wa.

DATA: lt_tables TYPE TABLE OF t_context_wa,

      lv_table  TYPE t_context_wa,

      lv_rda_scenario TYPE rda_scenario,

      lv_rdacontrol   TYPE rda_control.

DATA: ls_fieldcat TYPE slis_fieldcat_alv,

      lt_fieldcatelog TYPE slis_t_fieldcat_alv.

DATA  gt_events TYPE  slis_t_event.

DATA: gr_table TYPE REF TO cl_salv_table.

CLEAR ls_fieldcat.

ls_fieldcat-col_pos   = 1.

ls_fieldcat-fieldname = ‘TABNAME’.

ls_fieldcat-tabname   = ‘DD02L’.

ls_fieldcat-seltext_m = ‘Table’.

ls_fieldcat-outputlen = ’36’.

ls_fieldcat-edit      = ‘X’.

ls_fieldcat-ref_tabname   = ‘DD02L’.

ls_fieldcat-ref_fieldname = ‘TABNAME’.

ls_fieldcat-input     = ‘X’.

APPEND ls_fieldcat TO lt_fieldcatelog.

CLEAR ls_fieldcat.

ls_fieldcat-col_pos  = 2.

ls_fieldcat-fieldname = ‘MAINPROG’.

ls_fieldcat-tabname = ‘MAINPROG’.

ls_fieldcat-seltext_m = ‘Main program’.

ls_fieldcat-outputlen = ’36’.

ls_fieldcat-edit      = ‘X’.

APPEND ls_fieldcat TO lt_fieldcatelog.

CLEAR ls_fieldcat.

ls_fieldcat-col_pos  = 3.

ls_fieldcat-fieldname = ‘JOBNAME’.

ls_fieldcat-tabname = ‘JOBNAME’.

ls_fieldcat-seltext_m = ‘Jobname’.

ls_fieldcat-outputlen = ’36’.

ls_fieldcat-edit      = ‘X’.

APPEND ls_fieldcat TO lt_fieldcatelog.

CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY’

  EXPORTING

    i_callback_program                = sy-cprog

    i_callback_pf_status_set          = ‘SET_PF_STATUS’

    i_callback_user_command           = ‘USER_COMMAND ‘

    it_fieldcat                       = lt_fieldcatelog

* IMPORTING

*   E_EXIT_CAUSED_BY_CALLER           =

*   ES_EXIT_CAUSED_BY_USER            =

  TABLES

    t_outtab                          = lt_tables

EXCEPTIONS

   program_error                     = 1

   OTHERS                            = 2

          .

IF sy-subrc <> 0.

ENDIF.

*&———————————————————————*

*&      Form  USER_COMMAND

*&———————————————————————*

*       text

*———————————————————————-*

*      –>R_UCOMM      text

*      –>RS_SELFIELD  text

*———————————————————————-*

FORM user_command  USING r_ucomm LIKE sy-ucomm

                         rs_selfield TYPE slis_selfield.

  DATA: lc_ref_alv TYPE REF TO cl_gui_alv_grid.

  DATA: lt_sval TYPE TABLE OF sval,

        lv_sval TYPE sval,

        lv_rdacontext   TYPE rda_context,

        lt_rdacontrol   TYPE TABLE OF rda_control.

  DATA: lv_scenario  TYPE t_scenario_wa,

        lvxml_string TYPE string,

        ltxml_string TYPE TABLE OF string,

        lv_filename  TYPE string,

        lv_filename2 TYPE string,

        lv_path      TYPE string.

  DATA: ad_fdcat TYPE slis_fieldcat_alv,

        lt_ad_fdcat TYPE slis_t_fieldcat_alv,

        lv_selfsel  TYPE slis_selfield,

        lv_count    TYPE i,

        lv_message  TYPE string.

  CALL FUNCTION ‘GET_GLOBALS_FROM_SLVC_FULLSCR’

    IMPORTING

      e_grid = lc_ref_alv.

  IF NOT lc_ref_alv IS INITIAL.

    CALL METHOD lc_ref_alv->check_changed_data .

  ENDIF.

  CASE r_ucomm.

    WHEN ‘ADD’.

      CLEAR lv_table.

      APPEND lv_table TO lt_tables.

      rs_selfield-refresh = ‘X’.

    WHEN ‘REM’.

      IF rs_selfield-tabindex > 0.

        DELETE lt_tables INDEX rs_selfield-tabindex.

        rs_selfield-refresh = ‘X’.

      ENDIF.

    WHEN ‘LOAD’.

      ad_fdcat-col_pos = 1.

      ad_fdcat-fieldname = ‘SCENARIO’.

      ad_fdcat-tabname = ‘RDA_CONTROL’.

      ad_fdcat-seltext_l = ‘Scenario’.

      ad_fdcat-hotspot = ‘X’.

      APPEND ad_fdcat TO lt_ad_fdcat.

      SELECT * FROM rda_control INTO TABLE lt_rdacontrol.

      CALL FUNCTION ‘REUSE_ALV_POPUP_TO_SELECT’

        EXPORTING

          i_title       = ‘Select a scenario’

          i_selection   = ‘X’

          i_tabname     = ‘RDA_CONTROL’

          it_fieldcat   = lt_ad_fdcat

        IMPORTING

          es_selfield   = lv_selfsel

        TABLES

          t_outtab      = lt_rdacontrol

        EXCEPTIONS

          program_error = 1

          OTHERS        = 2.

      IF sy-subrc = 0.

        CLEAR lt_tables.

        lv_rda_scenario = lv_selfsel-value.

        SELECT SINGLE * INTO lv_rdacontrol FROM rda_control WHERE scenario = lv_rda_scenario.

        SELECT * INTO lv_rdacontext FROM rda_context WHERE scenario = lv_rda_scenario.

          CLEAR lv_table.

          lv_table-tabname  = lv_rdacontext-tabname.

          lv_table-mainprog = lv_rdacontext-mainprog.

          lv_table-jobname  = lv_rdacontext-jobname.

          APPEND lv_table TO lt_tables.

        ENDSELECT.

        rs_selfield-refresh = ‘X’.

      ENDIF.

    WHEN ‘SAVE’.

      lv_scenario-context = lt_tables.

      IF NOT lv_rdacontrol IS INITIAL.

        lv_scenario-name        = lv_rdacontrol-scenario.

        lv_scenario-version     = lv_rdacontrol-version.

        lv_scenario-description = lv_rdacontrol-description.

      ELSE.

        lv_sval-fieldname = ‘SCENARIO’.

        lv_sval-tabname   = ‘RDA_CONTROL’.

        lv_sval-comp_tab  = ‘RDA_CONTROL’.

        lv_sval-comp_field  = ‘SCENARIO’.

        APPEND lv_sval TO lt_sval.

        CLEAR lv_sval.

        lv_sval-fieldname = ‘VERSION’.

        lv_sval-tabname   = ‘RDA_CONTROL’.

        lv_sval-value     = ‘1’.

        APPEND lv_sval TO lt_sval.

        CLEAR lv_sval.

        lv_sval-fieldname = ‘DESCRIPTION’.

        lv_sval-tabname   = ‘RDA_CONTROL’.

        lv_sval-fieldtext = ‘Description’.

        APPEND lv_sval TO lt_sval.

        CALL FUNCTION ‘POPUP_GET_VALUES’

          EXPORTING

            popup_title     = ‘Scenario information’

          TABLES

            fields          = lt_sval

          EXCEPTIONS

            error_in_fields = 1

            OTHERS          = 2.

        READ TABLE lt_sval INTO lv_sval INDEX 1.

        lv_scenario-name        = lv_sval-value.

        READ TABLE lt_sval INTO lv_sval INDEX 2.

        lv_scenario-version     = lv_sval-value.

        READ TABLE lt_sval INTO lv_sval INDEX 3.

        lv_scenario-description = lv_sval-value.

      ENDIF.

      CALL METHOD cl_gui_frontend_services=>file_save_dialog

        EXPORTING

          window_title      = ‘Save XML file to’

          initial_directory = ”

          default_extension = cl_gui_frontend_services=>filetype_xml

          file_filter       = cl_gui_frontend_services=>filetype_xml

        CHANGING

          filename          = lv_filename2

          path              = lv_path

          fullpath          = lv_filename.

      CALL TRANSFORMATION id

        SOURCE

          format_version = ‘1’

          scenario = lv_scenario

        RESULT XML lvxml_string.

      APPEND lvxml_string TO ltxml_string.

      CALL FUNCTION ‘GUI_DOWNLOAD’

        EXPORTING

          filename                = lv_filename

        TABLES

          data_tab                = ltxml_string

        EXCEPTIONS

          file_write_error        = 1

          no_batch                = 2

          gui_refuse_filetransfer = 3

          invalid_type            = 4

          no_authority            = 5

          unknown_error           = 6

          header_not_allowed      = 7

          separator_not_allowed   = 8

          filesize_not_allowed    = 9

          header_too_long         = 10

          dp_error_create         = 11

          dp_error_send           = 12

          dp_error_write          = 13

          unknown_dp_error        = 14

          access_denied           = 15

          dp_out_of_memory        = 16

          disk_full               = 17

          dp_timeout              = 18

          file_not_found          = 19

          dataprovider_exception  = 20

          control_flush_error     = 21

          OTHERS                  = 22.

      IF sy-subrc = 0.

        CONCATENATE ‘Scenario ‘ lv_scenario-name ‘ saved.’ INTO lv_message RESPECTING BLANKS.

        CALL FUNCTION ‘POPUP_TO_DISPLAY_TEXT’

          EXPORTING

            titel     = ‘File saved’

            textline1 = lv_message.

      ENDIF.

    WHEN ‘CHECK’.

      LOOP AT lt_tables INTO lv_table.

        CLEAR lv_count.

        SELECT COUNT(*) INTO lv_count FROM dd02l WHERE tabname = lv_table-tabname.

        IF lv_count = 0.

          CONCATENATE ‘Table ‘ lv_table-tabname ‘ doesn”t exist!’ INTO lv_message RESPECTING BLANKS.

          CALL FUNCTION ‘POPUP_TO_DISPLAY_TEXT’

            EXPORTING

              titel     = ‘Error’

              textline1 = lv_message.

        ENDIF.

        CLEAR lv_count.

        SELECT COUNT(*) INTO lv_count FROM trdir WHERE name = lv_table-mainprog.

        IF lv_count = 0.

          CONCATENATE ‘Program ‘ lv_table-mainprog ‘ doesn”t exist!’ INTO lv_message RESPECTING BLANKS.

          CALL FUNCTION ‘POPUP_TO_DISPLAY_TEXT’

            EXPORTING

              titel     = ‘Error’

              textline1 = lv_message.

        ENDIF.

      ENDLOOP.

    WHEN OTHERS.

      LEAVE PROGRAM.

  ENDCASE.

ENDFORM.                    “user_command

*&———————————————————————*

*&      Form  SET_PF_STATUS

*&———————————————————————*

*       text

*———————————————————————-*

*      –>RT_EXTAB   text

*———————————————————————-*

FORM set_pf_status USING rt_extab TYPE slis_t_extab.

  SET PF-STATUS ‘ZHANA_TOOLBAR’ EXCLUDING rt_extab .

ENDFORM.                    “SET_PF_STATUS

– Create a GUI Status obejct for this report named “ZHANA_TOOLBAR” and add the following toolbar buttons:

guistatus.JPG

  

18 Comments
You must be Logged on to comment or reply to a post.
  • Hi Onno, thanks for explanation. Just I’m curious with regards to report RDA_MAINTAIN. Where RDA acronym comes from? Does it stand for Real-Time Data Acquisition as we know it from SAP BW world?

    Thanks, martin

  • Hi Onno,

    thanks for the article and the coding example.

    How does the system behave in the case that HANA is down? Will the request then be directed to the “primary” database again or will the transaction fail?

    Thanks,

    Falk

    • Hi Falk,

      Depending on the solution. For example HANA RDS solutions you can customize what to do. For example use “primary” database or prompt the user or show error when the HANA system is down. If it’s a custom developed solution it’s up to the development of the solution.

      BR, Onno

      • Bagijin

        I am little confused about your answer because once you set up scenario for particular report to use HANA accelerator approach then it will through short dump in system. I am not able to find option where we can customize RDS solution so that it can automatically switch to primary DB in case my secondary DB HANA is down.

    • Hi Michael,

      The SWT2DB add-on can be downloaded from the SAP service marketplace (service.sap.com). If the add-on is not available on marketplace for you please contact your SAP account manager.

      BR, Onno

      • How did you get it?

        As an internal/external employee of SAP or by licensing it (how?)?

        One of my colleagues sees it, but cannot download it because of missing authorizations, so I am interested to know which product you must have bought to get it.

        Many thanks,

        Michael

        P.S.: You can contact me via my email address michaelkretz@me.com

  • Hello Bagijin,

    We have few SE37 function modules under a function group. Will it be possible to maintain all the tables(Which is connecting to function module) to HANA through RDA_Maintain or any other way to run the function module with HANA as a DB to read the tables.

    Cheers!!

    Vasanth S