Skip to Content
Technical Articles
Author's profile photo Andre Fischer

Custom and Standard Tasklists for OData service mass maintenance

Updates

  • 14.11.2019 – added information that a new task /IWFND/TL_SERVICE_MAINTENANCE list for mass maintenance is part of the standard as of SAP S/4HANA 1909 (link to documentation)
  • 29.05.2018 – added screen shots to showhow alist of services can be passed
  • 29.05.2018 – fixed Code of IF_STCTM_BG_TASK~EXECUTE so that error messages longer than 50 characters are not truncated

What’s new for SAP S/4HANA

A while ago I wrote a blog about an updated task list that is available that allows to create the repository objects that are generated when activating an OData service in a transportable development package.

What was still missing was an option to perform certain mass changes on activated OData services such as mass deletion and adding or removing a system alias from a group of services.

With SAP S/4HANA 1909 now a new tasklist /IWFND/TL_SERVICE_MAINTENANCE for OData mass maintenance became available as described in the Online documentation.

This tasklist is also available for the following Service Packs of the following versions of the software component SAP_GWFND (see SAP Note 2512479)

  • SAP_GWFND 753 SP03 for SAP S/4HANA 1809
  • SAP_GWFND 753 SP05 for SAP NetWeaver 7.52
  • SAP_GWFND 751 SP09 for SAP NetWeaver 7.51

To address this problem in earlier releases I have developed a task list in the customer name space. So if you are not on 1909 or an equivalent SP (see above) you can build a custom task list that uses two SAP standard tasks to create / use transport and customizing requests. In addition you have to create a new custom task that is used to perform mass changes.

Repository objects needed

In order to create the task list yourself you have to create the following three repository objects:

 Object name Object type Description
 ZCL_STCT_GW_SRV_MASS_MAINT class

This class is used by the new mass maintenance task.

It inherits from the class CL_STCTM_REPORT_UI so that the report ZR_STCT_UI_MAINT_GW_SERVICES can be used as a UI to enter parameters.

 ZR_STCT_UI_MAINT_GW_SERVICES report This report is called in the constructor of the above mentioned class ZCL_STCT_GW_SRV_MASS_MAINT.
 ZCL_GATEWAY_SERVICE class

Class that performs the SAP Gateway service maintenance.

It is called by the class ZCL_STCT_GW_SRV_MASS_MAINT in method IF_STCTM_BG_TASK~EXECUTE

How to section

After you have created an activated the repository objects mentioned above you can start to create your custom task list.

To do so start transaction STC01 and enter a meaningful name for your task list, for example Z_GATEWAY_MAINT_ODATA_SERVICE and press the Create new task list.

In the next windows choose Add new tasks (F5) to add tasks based on the following classes.

  • CL_STCT_CREATE_REQUEST_CUST
  • CL_STCT_CREATE_REQUEST_WBENCH
  • ZCL_STCT_GW_SRV_MASS_MAINT

In the following popup enter the first class name CL_STCT_CREATE_REQUEST_CUST.

Then check the check box and use the green arrow to continue.

Do the same for the two remaining classes CL_STCT_CREATE_REQUEST_WBENCH and
ZCL_STCT_GW_SRV_MASS_MAINT.

Change the order of the tasks such that your custom task is called as the last step.

So that your task list finally looks like follows. Save your changes.

Navigate back with the green back button.

You are now ready to run the task list.

Please note that for the third task there is a parameter check performed that tells you that no services have been selected so far.

 

When you click on the “Display Parameters” button and if you have checked the “Execute” check box in the first column of this list you can enter the following parameters:

The first input parameters allows you to select active services using select options. Here we have selected services whose name is in between ZZ_TEST_10_SRV and ZZ_TEST_12_SRV.

It is also possible to use a list of Services for this just press on the button

and enter a list of Services. Here you can also use F4 Help.

On the above selected services the following actions can be executed:

  1. Add single aliasYou can select one of the system aliases that are available and you can select whether a user role shall be added for the determination of the system alias at run time.
  2. Assign aliases from a templateHere you can select an OData service that is used as a template for the system alias assignment. From the selected services all system aliases are removed and replaced by the assignment found at the service that has been selected as a template.
  3. Remove single aliasYou can select one of the system aliases that are available in your system.  If this system alias is assigned to service that you have selected it will be removed.
  4. Remove all aliasesThis action will simply remove all system alias assignments from all selected services.
  5. Set to co-deployedIf you use embedded deployment you can use the option to use co-deployment.Caution: This will remove all existing system alias assignments from the selected services as well.
  6. Set to routing basedThis action allows you to change a co-deployed service back to routing based. You have to assign system aliases afterwards.
  7. Delete servicesCaution: ALL selected services are deleted.The deletion can be recorded in a customizing and a tranport request as shown in the screen shots below.Which services have been deleted is always written to the log of your task list run.When clicking on the “Details” button a popup shows up that will list the deleted services in a format that can be used as an input by the SAP standard task list SAP_GATEWAY_ACTIVATE_ODATA_SERV so that you can activate your deleted services again very easily.This feature is especially useful if you want to delete OData services that have been activated as “local objects” and that you want to change to become transportable.See also my blog: Updated tasklist available for SAP Gateway service activation

    Please note:
    You are currently prompted to provide a transport request for the deletion of the ICF nodes though you have already provided a transport request as a parameter in this task list. Please choose the same request again. This bug will be fixed.

Source code

Class ZCL_GATEWAY_SERVICE

CLASS zcl_gateway_service DEFINITION
  PUBLIC
  FINAL
  CREATE PUBLIC .

  PUBLIC SECTION.

    METHODS add_alias
      IMPORTING iv_transport_cust  TYPE trkorr OPTIONAL
                iv_system_alias    TYPE /iwfnd/defi_system_alias
                iv_user_role       TYPE /iwfnd/defi_role_name OPTIONAL
                iv_is_default      TYPE abap_bool OPTIONAL
                iv_is_def_for_meta TYPE /iwfnd/mgw_inma_def_alias_meta OPTIONAL
      RAISING   /iwfnd/cx_cof .

    METHODS remove_alias
      IMPORTING iv_transport_cust TYPE trkorr OPTIONAL
                iv_system_alias   TYPE /iwfnd/defi_system_alias
                iv_user_role      TYPE /iwfnd/defi_role_name OPTIONAL
      RAISING   /iwfnd/cx_cof .

    METHODS constructor
      IMPORTING iv_service_id TYPE /iwfnd/med_mdl_srg_identifier
      RAISING   /iwfnd/cx_cof.

    METHODS get_service_id
      RETURNING VALUE(rv_service_id) TYPE /iwfnd/med_mdl_srg_identifier
      RAISING   /iwfnd/cx_cof.

    METHODS get_service_group
      RETURNING VALUE(rv_service_group) TYPE /iwfnd/cl_med_rem_exploration=>ty_s_service_group
      RAISING   /iwfnd/cx_cof.

    METHODS delete
      IMPORTING iv_transport_cust TYPE trkorr DEFAULT space
                iv_transport_dev  TYPE trkorr DEFAULT space
      RAISING   /iwfnd/cx_cof .

    METHODS remove_all_aliases
      IMPORTING iv_transport_cust TYPE trkorr OPTIONAL
      RAISING   /iwfnd/cx_cof.

    METHODS get_aliases
      RETURNING VALUE(rt_system_aliases) TYPE /iwfnd/cl_cof_facade=>ty_gt_system_aliases
      RAISING   /iwfnd/cx_cof .


    METHODS assign_aliases_from_service
      IMPORTING iv_template_service_id TYPE /iwfnd/med_mdl_srg_identifier
                iv_transport_cust      TYPE trkorr OPTIONAL
      RAISING   /iwfnd/cx_cof.

    METHODS set_to_codeployed
      IMPORTING iv_transport_cust TYPE trkorr OPTIONAL
                iv_transport_dev  TYPE trkorr OPTIONAL
      RAISING   /iwfnd/cx_cof.

    METHODS set_to_routing_based
      IMPORTING iv_transport_cust TYPE trkorr OPTIONAL
                iv_transport_dev  TYPE trkorr OPTIONAL
      RAISING   /iwfnd/cx_cof..



  PROTECTED SECTION.



  PRIVATE SECTION.

    DATA: mv_service_id         TYPE /iwfnd/med_mdl_srg_identifier  , "service id
          mv_record_customizing TYPE abap_bool,
          mv_record_workbench   TYPE abap_bool.

    TYPES:
      BEGIN OF root_cause_textid,
        msgid TYPE symsgid,
        msgno TYPE symsgno,
        attr1 TYPE scx_attrname,
        attr2 TYPE scx_attrname,
        attr3 TYPE scx_attrname,
        attr4 TYPE scx_attrname,
      END OF root_cause_textid.

    METHODS does_alias_exist
      IMPORTING iv_system_alias  TYPE /iwfnd/defi_system_alias
      RETURNING VALUE(ev_active) TYPE abap_bool
      RAISING   /iwfnd/cx_cof.

    METHODS get_root_cause_exception
      EXPORTING
        ev_root_cause_textid TYPE zcl_gateway_service=>root_cause_textid
      CHANGING
        cx_previous          TYPE REF TO cx_root.

    METHODS set_process_mode
      IMPORTING
                iv_process_mode   TYPE /iwfnd/med_process_mode
                "iv_system_alias   TYPE /iwfnd/defi_system_alias OPTIONAL
                iv_transport_cust TYPE trkorr OPTIONAL
                iv_transport_dev  TYPE trkorr OPTIONAL
      RAISING   /iwfnd/cx_cof.

    METHODS check_system_change_options

      RAISING /iwfnd/cx_cof.



ENDCLASS.



CLASS ZCL_GATEWAY_SERVICE IMPLEMENTATION.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method ZCL_GATEWAY_SERVICE->ADD_ALIAS
* +-------------------------------------------------------------------------------------------------+
* | [--->] IV_TRANSPORT_CUST              TYPE        TRKORR(optional)
* | [--->] IV_SYSTEM_ALIAS                TYPE        /IWFND/DEFI_SYSTEM_ALIAS
* | [--->] IV_USER_ROLE                   TYPE        /IWFND/DEFI_ROLE_NAME(optional)
* | [--->] IV_IS_DEFAULT                  TYPE        ABAP_BOOL(optional)
* | [--->] IV_IS_DEF_FOR_META             TYPE        /IWFND/MGW_INMA_DEF_ALIAS_META(optional)
* | [!CX!] /IWFND/CX_COF
* +--------------------------------------------------------------------------------------</SIGNATURE>
  METHOD add_alias.

    DATA: ls_root_cause_textid TYPE root_cause_textid,
          lv_process_mode      TYPE /iwfnd/med_process_mode,
          lo_config_facade     TYPE REF TO /iwfnd/cl_cof_facade,
          lx_previous          TYPE REF TO cx_root.

    IF mv_record_customizing = abap_true AND iv_transport_cust IS INITIAL.

      CLEAR ls_root_cause_textid.
      ls_root_cause_textid-attr1 = iv_system_alias && ' cannot be assigned because no customizing request has been provided'.
      ls_root_cause_textid-msgid = '/IWFND/CM_COS'.
      ls_root_cause_textid-msgno = 163.

      RAISE EXCEPTION TYPE /iwfnd/cx_cof
        EXPORTING
          textid = ls_root_cause_textid.
    ENDIF.

    IF does_alias_exist( iv_system_alias ) = abap_true.

      TRY.
          lv_process_mode = me->get_service_group( )-process_mode.
          "system aliases shall only be assigned to services that are routing based
          IF lv_process_mode <> /iwfnd/if_mgw_core_types=>gcs_process_mode-routing_based.

            CLEAR ls_root_cause_textid.
            ls_root_cause_textid-attr1 = iv_system_alias && ' cannot be assigned because ' && mv_service_id && ' is not routing based'.
            ls_root_cause_textid-msgid = '/IWFND/CM_COS'.
            ls_root_cause_textid-msgno = 163.

            RAISE EXCEPTION TYPE /iwfnd/cx_cof
              EXPORTING
                textid = ls_root_cause_textid.

          ENDIF.

          lo_config_facade = /iwfnd/cl_cof_facade=>get_instance( ).

          lo_config_facade->assign_sys_alias_to_srv(
             EXPORTING
              iv_transport_cust  = iv_transport_cust " Request/Task
              iv_srg_identifier  = mv_service_id " Service Document Identifier
              iv_system_alias    = iv_system_alias " SAP System Alias
              iv_user_role       = iv_user_role " Name of a User Role
              iv_is_default      = iv_is_default " System Alias is default - Used for Create and Metadata
              iv_is_def_for_meta = iv_is_def_for_meta" System Alias is default for metadata (";mo" scenarios only)
           ).

        CATCH cx_root INTO lx_previous.

          get_root_cause_exception(
            IMPORTING
              ev_root_cause_textid = ls_root_cause_textid
            CHANGING
              cx_previous = lx_previous ).


          RAISE EXCEPTION TYPE /iwfnd/cx_cof
            EXPORTING
              textid = ls_root_cause_textid.

      ENDTRY.

    ELSE.

      CLEAR ls_root_cause_textid.
      "System alias '&1' is not available
      ls_root_cause_textid-msgid = '/IWFND/CM_MGW'.
      ls_root_cause_textid-msgno = 13.
      ls_root_cause_textid-attr1 = iv_system_alias.

      RAISE EXCEPTION TYPE /iwfnd/cx_cof
        EXPORTING
          textid = ls_root_cause_textid.

    ENDIF.

  ENDMETHOD.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method ZCL_GATEWAY_SERVICE->ASSIGN_ALIASES_FROM_SERVICE
* +-------------------------------------------------------------------------------------------------+
* | [--->] IV_TEMPLATE_SERVICE_ID         TYPE        /IWFND/MED_MDL_SRG_IDENTIFIER
* | [--->] IV_TRANSPORT_CUST              TYPE        TRKORR(optional)
* | [!CX!] /IWFND/CX_COF
* +--------------------------------------------------------------------------------------</SIGNATURE>
  METHOD assign_aliases_from_service.

    DATA: ls_root_cause_textid TYPE root_cause_textid,
          lt_system_aliases    TYPE /iwfnd/cl_cof_facade=>ty_gt_system_aliases,
          ls_system_aliases    TYPE /iwfnd/cl_cof_facade=>ty_gs_system_alias,
          lo_config_facade     TYPE REF TO /iwfnd/cl_cof_facade,
          lv_srg_identifier    TYPE /iwfnd/med_mdl_srg_identifier,
          lx_previous          TYPE REF TO cx_root.

    "-check whether service group from which aliases shall be copied does exist
    SELECT SINGLE srv_identifier FROM /iwfnd/i_med_srh
      INTO @lv_srg_identifier
        WHERE srv_identifier = @iv_template_service_id.

    IF sy-subrc NE 0.
      CLEAR ls_root_cause_textid.
      ls_root_cause_textid-attr1 = 'template service:' && iv_template_service_id && ' does not exist.'.
      ls_root_cause_textid-msgid = '/IWFND/CM_COS'.
      ls_root_cause_textid-msgno = 163.

      RAISE EXCEPTION TYPE /iwfnd/cx_cof
        EXPORTING
          textid = ls_root_cause_textid.
    ENDIF.

    IF mv_record_customizing = abap_true AND iv_transport_cust IS INITIAL.

      CLEAR ls_root_cause_textid.
      ls_root_cause_textid-attr1 = 'Aliases from ' && iv_template_service_id && ' cannot be assigned to ' && mv_service_id && ' because no customizing request has been provided'.
      ls_root_cause_textid-msgid = '/IWFND/CM_COS'.
      ls_root_cause_textid-msgno = 163.

      RAISE EXCEPTION TYPE /iwfnd/cx_cof
        EXPORTING
          textid = ls_root_cause_textid.
    ENDIF.

    "retrieve system alias assignment from template service
    TRY.

        lo_config_facade = /iwfnd/cl_cof_facade=>get_instance( ).
        lt_system_aliases = lo_config_facade->get_sys_aliases_of_srv( iv_service_id = iv_template_service_id ).

        IF lt_system_aliases IS INITIAL.

          CLEAR ls_root_cause_textid.
          ls_root_cause_textid-attr1 = iv_template_service_id && ' : has no aliases assigned.'.
          ls_root_cause_textid-msgid = '/IWFND/CM_COS'.
          ls_root_cause_textid-msgno = 163.

          RAISE EXCEPTION TYPE /iwfnd/cx_cof
            EXPORTING
              textid = ls_root_cause_textid.

        ENDIF.

        "remove all aliases from our service

        me->remove_all_aliases(
           iv_transport_cust = iv_transport_cust
        ).

        "add aliases from template service

        LOOP AT lt_system_aliases INTO ls_system_aliases.

          me->add_alias(
            EXPORTING
              iv_transport_cust  = iv_transport_cust
              iv_system_alias    = ls_system_aliases-system_alias
              iv_user_role       = ls_system_aliases-user_role
              iv_is_default      = ls_system_aliases-is_default
              iv_is_def_for_meta = ls_system_aliases-is_def_for_meta
          ).

        ENDLOOP.

      CATCH cx_root INTO lx_previous.

        get_root_cause_exception(
          IMPORTING
            ev_root_cause_textid = ls_root_cause_textid
          CHANGING
            cx_previous = lx_previous ).

        RAISE EXCEPTION TYPE /iwfnd/cx_cof
          EXPORTING
            textid = ls_root_cause_textid.

    ENDTRY.

  ENDMETHOD.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Private Method ZCL_GATEWAY_SERVICE->CHECK_SYSTEM_CHANGE_OPTIONS
* +-------------------------------------------------------------------------------------------------+
* | [!CX!] /IWFND/CX_COF
* +--------------------------------------------------------------------------------------</SIGNATURE>
  METHOD check_system_change_options.

    DATA: lv_systemedit         TYPE edtflag,
          lv_systemname         TYPE syst_sysid,
          lv_systemtype         TYPE syst_sysid,
          lv_system_client_edit TYPE cccoractiv,
          lv_sys_cliinddep_edit TYPE ccnocliind,
          lv_sytem_client_role  TYPE cccategory.

    DATA ls_root_cause_textid TYPE root_cause_textid.

    CALL FUNCTION 'TR_SYS_PARAMS'
      IMPORTING
        systemedit         = lv_systemedit
        systemname         = lv_systemname "System Name (e.g. C11)
        systemtype         = lv_systemtype "Type ('SAP' or 'CUSTOMER')
        system_client_edit = lv_system_client_edit "Change Option for Client-Dependent Customizing Objects
        sys_cliinddep_edit = lv_sys_cliinddep_edit "Change Option for Repository Objects in Logon Client
        system_client_role = lv_sytem_client_role
      EXCEPTIONS
        no_systemname      = 1
        no_systemtype      = 2
        OTHERS             = 3.

    IF sy-subrc <> 0.

      CLEAR ls_root_cause_textid.
      IF sy-subrc = 2.
        ls_root_cause_textid-attr1 = 'System has no system name'.
      ELSEIF sy-subrc = 3.
        ls_root_cause_textid-attr1 = 'System has no system type ("SAP" or "CUSTOMER")'.
      ELSE.
        ls_root_cause_textid-attr1 = 'Error when calling TR_SYS_PARAMS'.
      ENDIF.
      ls_root_cause_textid-msgid = '/IWFND/CM_COS'.
      ls_root_cause_textid-msgno = 163.

      RAISE EXCEPTION TYPE /iwfnd/cx_cof
        EXPORTING
          textid = ls_root_cause_textid.

    ENDIF.


    "' '  No automatic recording of changes for transport
    "'1'  Changes are recorded in transport request
    "'2'  Customizing in this client cannot be changed
    "'3'  Customizing: Can be changed as req., but cannot be transp.

    IF lv_system_client_edit = '1'.
      mv_record_customizing = abap_true.
    ELSE. " at '' '2' and '3' changes are note recorded in a customizing request
      mv_record_customizing = abap_false.
    ENDIF.

    IF lv_system_client_edit = '2'.

      CLEAR ls_root_cause_textid.
      ls_root_cause_textid-attr1 = 'No changes to customizing allowed'.
      ls_root_cause_textid-msgid = '/IWFND/CM_COS'.
      ls_root_cause_textid-msgno = 163.

      RAISE EXCEPTION TYPE /iwfnd/cx_cof
        EXPORTING
          textid = ls_root_cause_textid.

    ENDIF.

    "' '  Changes to Repository and cross-client Customizing allowed
    "'1'  No changes to cross-client Customizing objects
    "'2'  No changes to Repository objects
    "'3'  No changes to Repository and cross-client Customizing objs

    IF lv_sys_cliinddep_edit = ' '.
      mv_record_workbench = abap_true.
    ELSE.
      mv_record_workbench = abap_false.
    ENDIF.

    IF lv_sys_cliinddep_edit = '2' OR lv_sys_cliinddep_edit = '3'.

      CLEAR ls_root_cause_textid.
      ls_root_cause_textid-attr1 = 'No changes to repository objects allowed'.
      ls_root_cause_textid-msgid = '/IWFND/CM_COS'.
      ls_root_cause_textid-msgno = 163.

      RAISE EXCEPTION TYPE /iwfnd/cx_cof
        EXPORTING
          textid = ls_root_cause_textid.

    ENDIF.

  ENDMETHOD.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method ZCL_GATEWAY_SERVICE->CONSTRUCTOR
* +-------------------------------------------------------------------------------------------------+
* | [--->] IV_SERVICE_ID                  TYPE        /IWFND/MED_MDL_SRG_IDENTIFIER
* | [!CX!] /IWFND/CX_COF
* +--------------------------------------------------------------------------------------</SIGNATURE>
  METHOD constructor.

    DATA :  lv_srg_identifier  TYPE /iwfnd/med_mdl_srg_identifier  .

    "-check whether service group exists
    SELECT SINGLE srv_identifier FROM /iwfnd/i_med_srh
      INTO @lv_srg_identifier
        WHERE srv_identifier = @iv_service_id.

    IF sy-subrc EQ 0.
      mv_service_id = iv_service_id.
    ELSE.
      RAISE EXCEPTION TYPE /iwfnd/cx_cof
        EXPORTING
          textid = /iwfnd/cx_cof=>service_grp_does_not_exist.
    ENDIF.

    me->check_system_change_options( ).

  ENDMETHOD.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method ZCL_GATEWAY_SERVICE->DELETE
* +-------------------------------------------------------------------------------------------------+
* | [--->] IV_TRANSPORT_CUST              TYPE        TRKORR (default =SPACE)
* | [--->] IV_TRANSPORT_DEV               TYPE        TRKORR (default =SPACE)
* | [!CX!] /IWFND/CX_COF
* +--------------------------------------------------------------------------------------</SIGNATURE>
  METHOD delete.

    DATA: ls_root_cause_textid TYPE root_cause_textid,
          lo_config_facade     TYPE REF TO /iwfnd/cl_cof_facade,
          lx_previous          TYPE REF TO cx_root.

    IF ( mv_record_customizing = abap_true AND iv_transport_cust IS INITIAL ).

      CLEAR ls_root_cause_textid.
      ls_root_cause_textid-attr1 = mv_service_id && ' cannot be deleted because no customizing request has been provided'.
      ls_root_cause_textid-msgid = '/IWFND/CM_COS'.
      ls_root_cause_textid-msgno = 163.

      RAISE EXCEPTION TYPE /iwfnd/cx_cof
        EXPORTING
          textid = ls_root_cause_textid.
    ENDIF.

    IF ( mv_record_workbench = abap_true AND iv_transport_dev IS INITIAL ) .
      CLEAR ls_root_cause_textid.
      ls_root_cause_textid-attr1 = mv_service_id && ' cannot be deleted because no workbench request has been provided'.
      ls_root_cause_textid-msgid = '/IWFND/CM_COS'.
      ls_root_cause_textid-msgno = 163.

      RAISE EXCEPTION TYPE /iwfnd/cx_cof
        EXPORTING
          textid = ls_root_cause_textid.
    ENDIF.

    TRY.
        lo_config_facade = /iwfnd/cl_cof_facade=>get_instance( ).

        lo_config_facade->deactivate_service(
          EXPORTING
            iv_service_identifier = mv_service_id
            iv_transport_dev      = iv_transport_dev
            iv_transport_cust     = iv_transport_cust
        ).

      CATCH cx_root INTO lx_previous.

        get_root_cause_exception(
          IMPORTING
            ev_root_cause_textid = ls_root_cause_textid
          CHANGING
            cx_previous = lx_previous ).

        RAISE EXCEPTION TYPE /iwfnd/cx_cof
          EXPORTING
            textid = ls_root_cause_textid.
    ENDTRY.

  ENDMETHOD.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Private Method ZCL_GATEWAY_SERVICE->DOES_ALIAS_EXIST
* +-------------------------------------------------------------------------------------------------+
* | [--->] IV_SYSTEM_ALIAS                TYPE        /IWFND/DEFI_SYSTEM_ALIAS
* | [<-()] EV_ACTIVE                      TYPE        ABAP_BOOL
* | [!CX!] /IWFND/CX_COF
* +--------------------------------------------------------------------------------------</SIGNATURE>
  METHOD does_alias_exist.

    DATA :  ls_dfsyal  TYPE /iwfnd/c_dfsyal.

    "Check if system alias does exist
    SELECT SINGLE *
    FROM /iwfnd/c_dfsyal
    INTO @ls_dfsyal
    WHERE system_alias = @iv_system_alias.

    IF ( sy-subrc = 0 ). "System alias exists
      ev_active = abap_true.
    ELSE.
      ev_active = abap_false.
    ENDIF.

  ENDMETHOD.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method ZCL_GATEWAY_SERVICE->GET_ALIASES
* +-------------------------------------------------------------------------------------------------+
* | [<-()] RT_SYSTEM_ALIASES              TYPE        /IWFND/CL_COF_FACADE=>TY_GT_SYSTEM_ALIASES
* | [!CX!] /IWFND/CX_COF
* +--------------------------------------------------------------------------------------</SIGNATURE>
  METHOD get_aliases.

    DATA: ls_root_cause_textid TYPE root_cause_textid,
          lo_config_facade     TYPE REF TO /iwfnd/cl_cof_facade,
          lx_previous          TYPE REF TO cx_root.

    TRY.

        lo_config_facade = /iwfnd/cl_cof_facade=>get_instance( ).
        rt_system_aliases = lo_config_facade->get_sys_aliases_of_srv( iv_service_id = mv_service_id ).

      CATCH cx_root INTO lx_previous.

        get_root_cause_exception(
          IMPORTING
            ev_root_cause_textid = ls_root_cause_textid
          CHANGING
            cx_previous = lx_previous ).

        RAISE EXCEPTION TYPE /iwfnd/cx_cof
          EXPORTING
            textid = ls_root_cause_textid.

    ENDTRY.
  ENDMETHOD.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Private Method ZCL_GATEWAY_SERVICE->GET_ROOT_CAUSE_EXCEPTION
* +-------------------------------------------------------------------------------------------------+
* | [<---] EV_ROOT_CAUSE_TEXTID           TYPE        ZCL_GATEWAY_SERVICE=>ROOT_CAUSE_TEXTID
* | [<-->] CX_PREVIOUS                    TYPE REF TO CX_ROOT
* +--------------------------------------------------------------------------------------</SIGNATURE>
  METHOD get_root_cause_exception.

    DATA lx_root_cause TYPE REF TO /iwfnd/cx_base.

    "the caller of this class should retrieve an error message of the root cause
    "that has been originally raised by the config facade

    IF cx_previous->previous IS NOT INITIAL .

      WHILE cx_previous->previous IS NOT INITIAL ."BOUND.
        cx_previous = cx_previous->previous.    " Get the exception that caused this exception
        TRY.
            lx_root_cause ?= cx_previous.
          CATCH cx_sy_move_cast_error.
        ENDTRY.
      ENDWHILE.

      ev_root_cause_textid-attr1 = lx_root_cause->get_longtext(  ).

    ELSE.

      ev_root_cause_textid-attr1 = cx_previous->get_longtext(  ).

    ENDIF.

    ev_root_cause_textid-msgid = '/IWFND/CM_COS'.
    ev_root_cause_textid-msgno = 163.

  ENDMETHOD.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method ZCL_GATEWAY_SERVICE->GET_SERVICE_GROUP
* +-------------------------------------------------------------------------------------------------+
* | [<-()] RV_SERVICE_GROUP               TYPE        /IWFND/CL_MED_REM_EXPLORATION=>TY_S_SERVICE_GROUP
* | [!CX!] /IWFND/CX_COF
* +--------------------------------------------------------------------------------------</SIGNATURE>
  METHOD get_service_group.

    DATA :  ls_srg_header  TYPE /iwfnd/i_med_srh .

    SELECT SINGLE * FROM /iwfnd/i_med_srh
              INTO @ls_srg_header
                WHERE srv_identifier = @mv_service_id.

    IF sy-subrc NE 0.
      RAISE EXCEPTION TYPE /iwfnd/cx_cof
        EXPORTING
          textid = /iwfnd/cx_cof=>service_grp_does_not_exist.
    ENDIF.

    rv_service_group-technical_name = ls_srg_header-object_name.
    rv_service_group-namespace = ls_srg_header-namespace.
    rv_service_group-external_name = ls_srg_header-service_name.
    rv_service_group-version =  ls_srg_header-service_version.
    rv_service_group-is_sap_service = ls_srg_header-is_sap_service.
    rv_service_group-soft_state_status = ls_srg_header-soft_state_stat.
    rv_service_group-process_mode = ls_srg_header-process_mode.

  ENDMETHOD.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method ZCL_GATEWAY_SERVICE->GET_SERVICE_ID
* +-------------------------------------------------------------------------------------------------+
* | [<-()] RV_SERVICE_ID                  TYPE        /IWFND/MED_MDL_SRG_IDENTIFIER
* | [!CX!] /IWFND/CX_COF
* +--------------------------------------------------------------------------------------</SIGNATURE>
  METHOD get_service_id.
    rv_service_id = me->mv_service_id.
  ENDMETHOD.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method ZCL_GATEWAY_SERVICE->REMOVE_ALIAS
* +-------------------------------------------------------------------------------------------------+
* | [--->] IV_TRANSPORT_CUST              TYPE        TRKORR(optional)
* | [--->] IV_SYSTEM_ALIAS                TYPE        /IWFND/DEFI_SYSTEM_ALIAS
* | [--->] IV_USER_ROLE                   TYPE        /IWFND/DEFI_ROLE_NAME(optional)
* | [!CX!] /IWFND/CX_COF
* +--------------------------------------------------------------------------------------</SIGNATURE>
  METHOD remove_alias.

    DATA: ls_root_cause_textid TYPE root_cause_textid,
          lo_config_facade     TYPE REF TO /iwfnd/cl_cof_facade,
          lx_previous          TYPE REF TO cx_root.

    IF mv_record_customizing = abap_true AND iv_transport_cust IS INITIAL.

      CLEAR ls_root_cause_textid.
      ls_root_cause_textid-attr1 = iv_system_alias && ' cannot be removed from ' && mv_service_id && ' because no customizing request has been provided'.
      ls_root_cause_textid-msgid = '/IWFND/CM_COS'.
      ls_root_cause_textid-msgno = 163.

      RAISE EXCEPTION TYPE /iwfnd/cx_cof
        EXPORTING
          textid = ls_root_cause_textid.
    ENDIF.

    IF does_alias_exist( iv_system_alias ) = abap_true.

      TRY.

          lo_config_facade = /iwfnd/cl_cof_facade=>get_instance( ).

          lo_config_facade->unassign_sys_alias_from_srv(
            EXPORTING
              iv_transport_cust =  iv_transport_cust   " Request/Task
              iv_srg_identifier =  mv_service_id   " Service Document Identifier
              iv_system_alias   =  iv_system_alias   " SAP System Alias
              iv_user_role      =  iv_user_role   " Name of a User Role
          ).

        CATCH cx_root INTO lx_previous.

          get_root_cause_exception(
            IMPORTING
              ev_root_cause_textid = ls_root_cause_textid
            CHANGING
              cx_previous = lx_previous ).

          RAISE EXCEPTION TYPE /iwfnd/cx_cof
            EXPORTING
              textid = ls_root_cause_textid.

      ENDTRY.

    ELSE.

      CLEAR ls_root_cause_textid.
      "System alias '&1' is not available
      ls_root_cause_textid-msgid = '/IWFND/CM_MGW'.
      ls_root_cause_textid-msgno = 13.
      ls_root_cause_textid-attr1 = iv_system_alias.

      RAISE EXCEPTION TYPE /iwfnd/cx_cof
        EXPORTING
          textid = ls_root_cause_textid.

    ENDIF.
  ENDMETHOD.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method ZCL_GATEWAY_SERVICE->REMOVE_ALL_ALIASES
* +-------------------------------------------------------------------------------------------------+
* | [--->] IV_TRANSPORT_CUST              TYPE        TRKORR(optional)
* | [!CX!] /IWFND/CX_COF
* +--------------------------------------------------------------------------------------</SIGNATURE>
  METHOD remove_all_aliases.

    DATA: ls_root_cause_textid TYPE root_cause_textid,
          lo_config_facade     TYPE REF TO /iwfnd/cl_cof_facade,
          lx_previous          TYPE REF TO cx_root,
          lt_system_aliases    TYPE /iwfnd/cl_cof_facade=>ty_gt_system_aliases,
          ls_system_aliases    TYPE /iwfnd/cl_cof_facade=>ty_gs_system_alias.

    IF mv_record_customizing = abap_true AND iv_transport_cust IS INITIAL.

      CLEAR ls_root_cause_textid.
      ls_root_cause_textid-attr1 = 'System aliases cannot be removed from ' && mv_service_id && ' because no customizing request has been provided'.
      ls_root_cause_textid-msgid = '/IWFND/CM_COS'.
      ls_root_cause_textid-msgno = 163.

      RAISE EXCEPTION TYPE /iwfnd/cx_cof
        EXPORTING
          textid = ls_root_cause_textid.
    ENDIF.

    TRY.

        lo_config_facade = /iwfnd/cl_cof_facade=>get_instance( ).
        lt_system_aliases = lo_config_facade->get_sys_aliases_of_srv( iv_service_id = mv_service_id ).

      CATCH cx_root INTO lx_previous.

        get_root_cause_exception(
          IMPORTING
             ev_root_cause_textid = ls_root_cause_textid
          CHANGING
            cx_previous = lx_previous ).

        RAISE EXCEPTION TYPE /iwfnd/cx_cof
          EXPORTING
            textid = ls_root_cause_textid.

    ENDTRY.

    LOOP AT lt_system_aliases INTO ls_system_aliases.
      TRY.
          me->remove_alias(
            EXPORTING
              iv_transport_cust = iv_transport_cust
              iv_system_alias   = ls_system_aliases-system_alias
              iv_user_role      = ls_system_aliases-user_role
          ).

        CATCH cx_root INTO lx_previous.

          get_root_cause_exception(
            IMPORTING
               ev_root_cause_textid = ls_root_cause_textid
            CHANGING
              cx_previous = lx_previous ).

          RAISE EXCEPTION TYPE /iwfnd/cx_cof
            EXPORTING
              textid = ls_root_cause_textid.

      ENDTRY.
    ENDLOOP.

  ENDMETHOD.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Private Method ZCL_GATEWAY_SERVICE->SET_PROCESS_MODE
* +-------------------------------------------------------------------------------------------------+
* | [--->] IV_PROCESS_MODE                TYPE        /IWFND/MED_PROCESS_MODE
* | [--->] IV_TRANSPORT_CUST              TYPE        TRKORR(optional)
* | [--->] IV_TRANSPORT_DEV               TYPE        TRKORR(optional)
* | [!CX!] /IWFND/CX_COF
* +--------------------------------------------------------------------------------------</SIGNATURE>
  METHOD set_process_mode.

    DATA: ls_root_cause_textid TYPE root_cause_textid,
          lo_config_facade     TYPE REF TO /iwfnd/cl_cof_facade,
          lx_previous          TYPE REF TO cx_root,
          mo_rem_activator     TYPE REF TO /iwfnd/cl_med_rem_activation,
          lv_transport_dev     TYPE trkorr.

    IF ( mv_record_customizing = abap_true AND iv_transport_cust IS INITIAL ).

      CLEAR ls_root_cause_textid.
      ls_root_cause_textid-attr1 = mv_service_id && ': process mode cannot be changed because no customizing request has been provided'.
      ls_root_cause_textid-msgid = '/IWFND/CM_COS'.
      ls_root_cause_textid-msgno = 163.

      RAISE EXCEPTION TYPE /iwfnd/cx_cof
        EXPORTING
          textid = ls_root_cause_textid.
    ENDIF.

    IF ( mv_record_workbench = abap_true AND iv_transport_dev IS INITIAL ) .
      CLEAR ls_root_cause_textid.
      ls_root_cause_textid-attr1 = mv_service_id && ': process mode cannot be changed because no workbench request has been provided'.
      ls_root_cause_textid-msgid = '/IWFND/CM_COS'.
      ls_root_cause_textid-msgno = 163.

      RAISE EXCEPTION TYPE /iwfnd/cx_cof
        EXPORTING
          textid = ls_root_cause_textid.
    ENDIF.


    TRY.

        mo_rem_activator = /iwfnd/cl_med_rem_activation=>get_remote_activator( ).


        DATA : ls_service_group   TYPE /iwfnd/cl_med_rem_exploration=>ty_s_service_group.

        "Name of transport request has to be provided using a changing parameter.
        "Since input parameters iv_* cannot be changed
        "iv_transport_dev is moved to a local variable
        lv_transport_dev = iv_transport_dev.

        IF iv_process_mode <> /iwfnd/if_mgw_core_types=>gcs_process_mode-routing_based
         AND iv_process_mode <> /iwfnd/if_mgw_core_types=>gcs_process_mode-co_deployed_only.

          CLEAR ls_root_cause_textid.
          ls_root_cause_textid-attr1 = 'iv_process_mode must be equal to "C" or " "'.
          ls_root_cause_textid-msgid = '/IWFND/CM_COS'.
          ls_root_cause_textid-msgno = 163.

          RAISE EXCEPTION TYPE /iwfnd/cx_cof
            EXPORTING
              textid = ls_root_cause_textid.

        ENDIF.

        ls_service_group = me->get_service_group( ).

        "set processing mode to either co-deployed or routing based
        ls_service_group-process_mode = iv_process_mode.

        "remove all aliases if running co-deployed
        IF iv_process_mode = /iwfnd/if_mgw_core_types=>gcs_process_mode-co_deployed_only.
          me->remove_all_aliases(
              iv_transport_cust = iv_transport_cust
          ).
        ENDIF.

        mo_rem_activator->update_process_mode(
          EXPORTING
            is_service_group     =    ls_service_group " Service Group
            iv_srv_identifier    =    mv_service_id " Service Document Identifier
          CHANGING
            cv_transport         =   lv_transport_dev  " Request/Task
        ).

      CATCH cx_root INTO lx_previous.

        get_root_cause_exception(
          IMPORTING
            ev_root_cause_textid = ls_root_cause_textid
          CHANGING
            cx_previous = lx_previous ).

        RAISE EXCEPTION TYPE /iwfnd/cx_cof
          EXPORTING
            textid = ls_root_cause_textid.

    ENDTRY.

  ENDMETHOD.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method ZCL_GATEWAY_SERVICE->SET_TO_CODEPLOYED
* +-------------------------------------------------------------------------------------------------+
* | [--->] IV_TRANSPORT_CUST              TYPE        TRKORR(optional)
* | [--->] IV_TRANSPORT_DEV               TYPE        TRKORR(optional)
* | [!CX!] /IWFND/CX_COF
* +--------------------------------------------------------------------------------------</SIGNATURE>
  METHOD set_to_codeployed.

    DATA : ls_root_cause_textid TYPE root_cause_textid,
           lx_previous          TYPE REF TO cx_root.

    TRY.

        me->set_process_mode(
          EXPORTING
            iv_process_mode   =  /iwfnd/if_mgw_core_types=>gcs_process_mode-co_deployed_only
            iv_transport_cust = iv_transport_cust
            iv_transport_dev  = iv_transport_dev
        ).


      CATCH cx_root INTO lx_previous.

        get_root_cause_exception(
          IMPORTING
            ev_root_cause_textid = ls_root_cause_textid
          CHANGING
            cx_previous = lx_previous ).

        RAISE EXCEPTION TYPE /iwfnd/cx_cof
          EXPORTING
            textid = ls_root_cause_textid.

    ENDTRY.

  ENDMETHOD.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method ZCL_GATEWAY_SERVICE->SET_TO_ROUTING_BASED
* +-------------------------------------------------------------------------------------------------+
* | [--->] IV_TRANSPORT_CUST              TYPE        TRKORR(optional)
* | [--->] IV_TRANSPORT_DEV               TYPE        TRKORR(optional)
* | [!CX!] /IWFND/CX_COF
* +--------------------------------------------------------------------------------------</SIGNATURE>
  METHOD set_to_routing_based.

    DATA : ls_root_cause_textid TYPE root_cause_textid,
           lx_previous          TYPE REF TO cx_root.

    TRY.

        me->set_process_mode(
          EXPORTING
            iv_process_mode   =  /iwfnd/if_mgw_core_types=>gcs_process_mode-routing_based
            iv_transport_cust = iv_transport_cust
            iv_transport_dev  = iv_transport_dev
        ).


      CATCH cx_root INTO lx_previous.

        get_root_cause_exception(
          IMPORTING
            ev_root_cause_textid = ls_root_cause_textid
          CHANGING
            cx_previous = lx_previous ).

        RAISE EXCEPTION TYPE /iwfnd/cx_cof
          EXPORTING
            textid = ls_root_cause_textid.

    ENDTRY.

  ENDMETHOD.
ENDCLASS.

Class ZCL_STCT_GW_SRV_MASS_MAINT

CLASS zcl_stct_gw_srv_mass_maint DEFINITION
PUBLIC
  INHERITING FROM cl_stctm_report_ui
  FINAL
  CREATE PUBLIC .

  PUBLIC SECTION.

    INTERFACES if_stctm_bg_task .

    CLASS-DATA mv_initial TYPE abap_bool .


    METHODS constructor .

    METHODS if_stctm_task~get_description
        REDEFINITION .
    METHODS if_stctm_task~get_docu_object
        REDEFINITION .
    METHODS if_stctm_ui_task~maintained
        REDEFINITION .
    METHODS if_stctm_task~show_message_details
        REDEFINITION.

  PROTECTED SECTION.
  PRIVATE SECTION.

    TYPES: BEGIN OF ty_deleted_service,
             technical_name TYPE /iwfnd/med_mdl_srg_name,
             version        TYPE  /iwfnd/med_mdl_version,
           END OF ty_deleted_service.

    DATA: lt_deleted_gw_service_group TYPE STANDARD TABLE OF ty_deleted_service,
          ls_deleted_gw_service_group TYPE ty_deleted_service.



ENDCLASS.



CLASS ZCL_STCT_GW_SRV_MASS_MAINT IMPLEMENTATION.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method ZCL_STCT_GW_SRV_MASS_MAINT->CONSTRUCTOR
* +-------------------------------------------------------------------------------------------------+
* +--------------------------------------------------------------------------------------</SIGNATURE>
  METHOD constructor.
    super->constructor( 'ZR_STCT_UI_MAINT_GW_SERVICES' ).
    if_stctm_task~p_phase     = cl_stc_task_utilities=>c_phase-config.
    if_stctm_task~p_component = 'GATEWAY'.
    if_stctm_task~p_multiple_usage = abap_true.

    " required predecessor
    APPEND 'CL_STCT_CREATE_REQUEST_CUST' TO if_stctm_task~pt_predecessor.
    APPEND 'CL_STCT_CREATE_REQUEST_WBENCH' TO if_stctm_task~pt_predecessor.

    mv_initial = abap_true.
  ENDMETHOD.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method ZCL_STCT_GW_SRV_MASS_MAINT->IF_STCTM_BG_TASK~CHECKMODE
* +-------------------------------------------------------------------------------------------------+
* | [--->] IR_TASKLIST                    TYPE REF TO CL_STCTM_TASKLIST
* | [<-()] R_CHECKMODE                    TYPE        IF_STCTM_TASK=>T_BOOL
* +--------------------------------------------------------------------------------------</SIGNATURE>
  METHOD if_stctm_bg_task~checkmode.

  ENDMETHOD.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method ZCL_STCT_GW_SRV_MASS_MAINT->IF_STCTM_BG_TASK~EXECUTE
* +-------------------------------------------------------------------------------------------------+
* | [--->] IR_TASKLIST                    TYPE REF TO CL_STCTM_TASKLIST
* | [--->] I_TRACE                        TYPE        STC_TRACE(optional)
* | [--->] I_CHECK                        TYPE        STC_CHECKRUN(optional)
* | [EXC!] ERROR_OCCURED
* | [EXC!] WARNING_OCCURED
* +--------------------------------------------------------------------------------------</SIGNATURE>
  METHOD if_stctm_bg_task~execute.

    DATA: ls_variant        TYPE t_variant,
          ls_variant_detail TYPE t_variant.

    DATA: it_e071  TYPE tr_objects ##NEEDED,
          it_e071k TYPE tr_keys,
          wa_e071  TYPE ko200,
          wa_e071k TYPE e071k.

    DATA: "parameter needed to deactivate a service
      lv_deact     TYPE c LENGTH 1,
      "parameters needed to add an alias
      lv_add       TYPE c LENGTH 1,
      lv_aliasa    TYPE  /iwfnd/c_dfsyal-system_alias, " /iwfnd/defi_system_alias
      lv_role      TYPE /iwfnd/defi_role_name,
      lv_isdef     TYPE c LENGTH 1,
      lv_isdefm    TYPE c LENGTH 1,
      "parameters needed to remove an alias
      lv_remove    TYPE c LENGTH 1,
      lv_aliasr    TYPE  /iwfnd/c_dfsyal-system_alias, " /iwfnd/defi_system_alias
      "parameters needed to add aliases from a template service
      lv_gettmp    TYPE c LENGTH 1,
      lv_tmp_id    TYPE  /iwfnd/i_med_srh-srv_identifier, "service that shall be used as a template
      "parameters needed for co-deployment, routing based setup and to remove all aliases
      lv_setco     TYPE c LENGTH 1,
      lv_setrou    TYPE c LENGTH 1,
      lv_remall    TYPE c LENGTH 1,
      "selected services
      ls_i_med_srh TYPE /iwfnd/i_med_srh,
      lrt_srv_id   LIKE RANGE OF ls_i_med_srh-srv_identifier,
      lrs_srv_id   LIKE LINE OF  lrt_srv_id.

    DATA ls_task TYPE cl_stctm_tasklist=>ts_task.

    "customizing request
    DATA ls_task_creq TYPE cl_stctm_tasklist=>ts_task.
    DATA lo_task_creq TYPE REF TO cl_stct_create_request_cust.
    DATA lx_cast_exc_creq TYPE REF TO cx_sy_move_cast_error ##NEEDED.
    DATA lv_request_cust TYPE char20.
    DATA lv_client_changes_allowed TYPE abap_bool.

    "workbench request
    DATA ls_task_wreq TYPE cl_stctm_tasklist=>ts_task.
    DATA lo_task_wreq TYPE REF TO cl_stct_create_request_wbench.
    DATA lx_cast_exc_wreq TYPE REF TO cx_sy_move_cast_error ##NEEDED.
    DATA lv_request_work TYPE char20.

    "maintain gw service
    DATA lv_message TYPE string.
    DATA lv_bapi_msg_text(220) TYPE c.

    DATA lo_gw_service TYPE REF TO zcl_gateway_service.

    DATA lv_error_occured TYPE abap_bool.

    DATA :  lv_deleted_gw_service_group TYPE /iwfnd/cl_med_rem_exploration=>ty_s_service_group.

*----------------------------------------------------------------
* GET UI PARAMETER
*----------------------------------------------------------------
    LOOP AT pt_variant INTO ls_variant.

      CASE  ls_variant-selname.

        WHEN 'P_DEACT'.
          lv_deact = ls_variant-low.

        WHEN 'P_ADD'.
          lv_add = ls_variant-low.

          READ TABLE pt_variant INTO ls_variant_detail WITH KEY selname = 'P_ALIASA'.
          IF ls_variant_detail-low IS NOT INITIAL. "alias to be added has been selected
            lv_aliasa = ls_variant_detail-low.
          ENDIF.

          READ TABLE pt_variant INTO ls_variant_detail WITH KEY selname = 'P_ROLE'.
          IF ls_variant_detail-low IS NOT INITIAL. "alias to be added has been selected
            lv_role = ls_variant_detail-low.
          ENDIF.

          READ TABLE pt_variant INTO ls_variant_detail WITH KEY selname = 'P_ISDEF'.
          IF ls_variant_detail-low IS NOT INITIAL. "alias to be added has been selected
            lv_isdef = ls_variant_detail-low.
          ENDIF.

          READ TABLE pt_variant INTO ls_variant_detail WITH KEY selname = 'P_ISDEFM'.
          IF ls_variant_detail-low IS NOT INITIAL. "alias to be added has been selected
            lv_isdefm = ls_variant_detail-low.
          ENDIF.

        WHEN 'P_REMOVE'.
          lv_remove  = ls_variant-low.

          READ TABLE pt_variant INTO ls_variant_detail WITH KEY selname = 'P_ALIASR'.
          IF ls_variant_detail-low IS NOT INITIAL. "alias to be removed has been selected
            lv_aliasr = ls_variant_detail-low.
          ENDIF.

        WHEN 'P_GETTMP'.
          lv_gettmp = ls_variant-low.

          READ TABLE pt_variant INTO ls_variant_detail WITH KEY selname = 'P_TMP_ID'.
          IF ls_variant_detail-low IS NOT INITIAL. "service that shall be used as a template
            lv_tmp_id = ls_variant_detail-low.
          ENDIF.

        WHEN 'P_SETCO'.
          lv_setco  = ls_variant-low.

        WHEN 'P_SETROU'.
          lv_setrou = ls_variant-low.

        WHEN 'S_SRV_ID'.
          lrs_srv_id-low = ls_variant-low.
          lrs_srv_id-high = ls_variant-high.
          lrs_srv_id-option = ls_variant-option.
          lrs_srv_id-sign = ls_variant-sign.
          APPEND lrs_srv_id TO lrt_srv_id.


        WHEN 'P_REMALL'.
          lv_remall = ls_variant-low.


      ENDCASE.
    ENDLOOP.


*----------------------------------------------------------------
* GET REQUEST CUST
*----------------------------------------------------------------



    " get stored data from prerequiste task 'CREATE CUSTOMIZING REQUEST'
    READ TABLE ir_tasklist->ptx_task INTO ls_task_creq WITH KEY taskname = 'CL_STCT_CREATE_REQUEST_CUST'.

    IF sy-subrc = 0.
      TRY.
          lo_task_creq ?= ls_task_creq-r_task.
          lv_request_cust = lo_task_creq->p_request_customizing.
          lv_client_changes_allowed = lo_task_creq->p_client_changes_allowed.

        CATCH cx_sy_move_cast_error INTO lx_cast_exc_creq.
          MESSAGE e000(s_lmcfg_core_tasks) WITH 'Could not get Request from Task CREATE CUSTOMIZING REQUEST' INTO if_stctm_task~pr_log->dummy ##MG_ARG_LEN ##NO_TEXT.
          if_stctm_task~pr_log->add_syst( ).
          RAISE error_occured.
      ENDTRY.
    ENDIF.


*----------------------------------------------------------------
* GET REQUEST WORK
*----------------------------------------------------------------

    " get stored data from prerequiste task 'CREATE CUSTOMIZING REQUEST'
    READ TABLE ir_tasklist->ptx_task INTO ls_task_wreq WITH KEY taskname = 'CL_STCT_CREATE_REQUEST_WBENCH'.

    IF sy-subrc = 0.
      TRY.
          lo_task_wreq ?= ls_task_wreq-r_task.
          lv_request_work = lo_task_wreq->p_request_workbench.

        CATCH cx_sy_move_cast_error INTO lx_cast_exc_wreq.
          MESSAGE e000(s_lmcfg_core_tasks) WITH 'Could not get Request from Task CREATE WORKING REQUEST' INTO if_stctm_task~pr_log->dummy ##MG_ARG_LEN ##NO_TEXT.
          if_stctm_task~pr_log->add_syst( ).
          RAISE error_occured.
      ENDTRY.
    ENDIF.



    IF i_check EQ 'X' . "check mode
      " check if required predecessor task "Create/Select Customizing Request (SE09)" is in tasklist
      READ TABLE ir_tasklist->ptx_task INTO ls_task WITH KEY taskname = 'CL_STCT_CREATE_REQUEST_CUST'.

      IF sy-subrc NE 0.
        MESSAGE e124(s_lmcfg_core_tasks) WITH 'Create Customizing Request (SE09)' INTO if_stctm_task~pr_log->dummy ##NO_TEXT.
        if_stctm_task~pr_log->add_syst( ).
        RAISE error_occured.
      ENDIF.

      " check if required predecessor task "Create/Select Customizing Request (SE09)" is in tasklist
      READ TABLE ir_tasklist->ptx_task INTO ls_task WITH KEY taskname = 'CL_STCT_CREATE_REQUEST_WBENCH'.

      IF sy-subrc NE 0.
        MESSAGE e124(s_lmcfg_core_tasks) WITH 'Create Working Request (SE09)' INTO if_stctm_task~pr_log->dummy ##NO_TEXT.
        if_stctm_task~pr_log->add_syst( ).
        RAISE error_occured.
      ENDIF.

*----------------------------------------------------------------
* excecution mode
*----------------------------------------------------------------

    ELSE. " execution mode

      lv_error_occured = abap_false.

      SELECT * FROM /iwfnd/i_med_srh INTO TABLE @DATA(lt_i_med_srh)
      WHERE srv_identifier IN @lrt_srv_id.


      LOOP AT lt_i_med_srh INTO ls_i_med_srh.

        DATA(p_srv_id) = ls_i_med_srh-srv_identifier.

        TRY.
            lo_gw_service = NEW zcl_gateway_service( iv_service_id = p_srv_id  ).
          CATCH /iwfnd/cx_cof INTO DATA(ocx_my).
            lv_message   = ocx_my->get_text( ).

            MESSAGE w101(s_lmcfg_core_tasks) WITH lv_message INTO if_stctm_task~pr_log->dummy ##NO_TEXT.
            if_stctm_task~pr_log->add_syst( ).

            lv_error_occured = abap_true.



            EXIT.
        ENDTRY.

        IF lv_deact = abap_true.

          TRY.
              lv_deleted_gw_service_group = lo_gw_service->get_service_group( ).
              lo_gw_service->delete(
                EXPORTING
                  iv_transport_cust = lv_request_cust
                  iv_transport_dev  = lv_request_work
              ).

              CONCATENATE  lv_deleted_gw_service_group-technical_name  lv_deleted_gw_service_group-version ' deleted successfully.' INTO lv_bapi_msg_text SEPARATED BY space .
              "lv_bapi_msg_text = lv_deleted_gw_service_group-technical_name && lv_deleted_gw_service_group-version && ' deleted successfully.'.

              "MESSAGE i101(s_lmcfg_core_tasks) WITH lv_bapi_msg_text INTO if_stctm_task~pr_log->dummy ##NO_TEXT.
              if_stctm_task~pr_log->add_text( EXPORTING i_text = lv_bapi_msg_text ).

              ls_deleted_gw_service_group-technical_name = lv_deleted_gw_service_group-technical_name.
              ls_deleted_gw_service_group-version = lv_deleted_gw_service_group-version.
              APPEND ls_deleted_gw_service_group TO lt_deleted_gw_service_group.

            CATCH /iwfnd/cx_cof INTO ocx_my.
              lv_message   = ocx_my->get_text( ).

              DATA: lt_string_comp TYPE STANDARD TABLE OF swastrtab,
                    ls_string_comp TYPE swastrtab.



              CALL FUNCTION 'SWA_STRING_SPLIT'
                EXPORTING
                  input_string         = lv_message     "string to be split
                  max_component_length = 50
              "   TERMINATING_SEPARATORS             =
              "   OPENING_SEPARATORS   =
                TABLES
                  string_components    = lt_string_comp
                  " EXCEPTIONS
              "   MAX_COMPONENT_LENGTH_INVALID       = 1
              "   OTHERS               = 2
                .
              IF sy-subrc <> 0.
                " Implement suitable error handling here
                " try to pass the original string
                MESSAGE w101(s_lmcfg_core_tasks) WITH lv_message INTO if_stctm_task~pr_log->dummy ##NO_TEXT.
              ELSE.
                "itab lt_string_comp contains strings with a length of max. 50 characters

                IF strlen( lv_message ) <= 50.
                  MESSAGE w101(s_lmcfg_core_tasks) WITH lt_string_comp[ 1 ]-str INTO if_stctm_task~pr_log->dummy ##NO_TEXT.

                ELSEIF strlen( lv_message ) <= 100.
                  MESSAGE w101(s_lmcfg_core_tasks) WITH lt_string_comp[ 1 ]-str lt_string_comp[ 2 ]-str INTO if_stctm_task~pr_log->dummy ##NO_TEXT.

                ELSEIF strlen( lv_message ) <= 150.
                  MESSAGE w101(s_lmcfg_core_tasks) WITH lt_string_comp[ 1 ]-str lt_string_comp[ 2 ]-str lt_string_comp[ 3 ]-str INTO if_stctm_task~pr_log->dummy ##NO_TEXT.

                ELSE. "max length of a parameter is 50 characters and we can have at max. 4 parameters => not more than 200 characters can be passed
                  MESSAGE w101(s_lmcfg_core_tasks) WITH lt_string_comp[ 1 ]-str lt_string_comp[ 2 ]-str lt_string_comp[ 3 ]-str lt_string_comp[ 4 ]-str INTO if_stctm_task~pr_log->dummy ##NO_TEXT.

                ENDIF.

              ENDIF.

              if_stctm_task~pr_log->add_syst( ).

              lv_error_occured = abap_true.

          ENDTRY.

        ELSEIF lv_add = abap_true.
          TRY.
              lo_gw_service->add_alias(
                EXPORTING
                  iv_transport_cust  = lv_request_cust
                  iv_system_alias    = lv_aliasa
                  iv_user_role       = lv_role
                  iv_is_default      = lv_isdef
                  iv_is_def_for_meta = lv_isdefm
              ).
              CONCATENATE  p_srv_id  'Alias '  lv_aliasa  ' added.' INTO lv_bapi_msg_text SEPARATED BY space.
              if_stctm_task~pr_log->add_text( EXPORTING i_text = lv_bapi_msg_text ).
            CATCH /iwfnd/cx_cof INTO ocx_my.
              lv_message   = ocx_my->get_text( ).
              MESSAGE w101(s_lmcfg_core_tasks) WITH lv_message INTO if_stctm_task~pr_log->dummy ##NO_TEXT.
              if_stctm_task~pr_log->add_syst( ).

              lv_error_occured = abap_true.

          ENDTRY.

        ELSEIF lv_remove = abap_true.
          TRY.
              lo_gw_service->remove_alias(
                EXPORTING
                  iv_transport_cust = lv_request_cust
                  iv_system_alias   = lv_aliasr
                  iv_user_role      = lv_role
              ).
              CONCATENATE  p_srv_id  'Alias '  lv_aliasr  ' removed.' INTO lv_bapi_msg_text SEPARATED BY space.
              if_stctm_task~pr_log->add_text( EXPORTING i_text = lv_bapi_msg_text ).
            CATCH /iwfnd/cx_cof INTO ocx_my.
              lv_message   = ocx_my->get_text( ).
              MESSAGE w101(s_lmcfg_core_tasks) WITH lv_message INTO if_stctm_task~pr_log->dummy ##NO_TEXT.
              if_stctm_task~pr_log->add_syst( ).

              lv_error_occured = abap_true.
          ENDTRY.

        ELSEIF  lv_gettmp = abap_true.
          TRY.
              lo_gw_service->assign_aliases_from_service(
                EXPORTING
                  iv_template_service_id = lv_tmp_id
                  iv_transport_cust      =  lv_request_cust
              ).
              CONCATENATE  p_srv_id  'Aliases from '  lv_tmp_id  ' assigned.' INTO lv_bapi_msg_text SEPARATED BY space.
              if_stctm_task~pr_log->add_text( EXPORTING i_text = lv_bapi_msg_text ).
            CATCH /iwfnd/cx_cof INTO ocx_my.
              lv_message   = ocx_my->get_text( ).
              MESSAGE w101(s_lmcfg_core_tasks) WITH lv_message INTO if_stctm_task~pr_log->dummy ##NO_TEXT.
              if_stctm_task~pr_log->add_syst( ).

              lv_error_occured = abap_true.
          ENDTRY.

        ELSEIF lv_setco = abap_true.
          TRY.
              lo_gw_service->set_to_codeployed(
                  iv_transport_cust = lv_request_cust
                  iv_transport_dev = lv_request_work
              ).
              CONCATENATE  p_srv_id  ' set to co-deployed.' INTO lv_bapi_msg_text SEPARATED BY space.
              if_stctm_task~pr_log->add_text( EXPORTING i_text = lv_bapi_msg_text ).
            CATCH /iwfnd/cx_cof INTO ocx_my.
              lv_message   = ocx_my->get_text( ).
              MESSAGE w101(s_lmcfg_core_tasks) WITH lv_message INTO if_stctm_task~pr_log->dummy ##NO_TEXT.
              if_stctm_task~pr_log->add_syst( ).

              lv_error_occured = abap_true.
          ENDTRY.

        ELSEIF lv_setrou = abap_true.
          TRY.
              lo_gw_service->set_to_routing_based(
               iv_transport_cust = lv_request_cust
               iv_transport_dev = lv_request_work
           ).
              CONCATENATE  p_srv_id  ' set to routing based.' INTO lv_bapi_msg_text SEPARATED BY space.
              if_stctm_task~pr_log->add_text( EXPORTING i_text = lv_bapi_msg_text ).
            CATCH /iwfnd/cx_cof INTO ocx_my.
              lv_message   = ocx_my->get_text( ).
              MESSAGE w101(s_lmcfg_core_tasks) WITH lv_message INTO if_stctm_task~pr_log->dummy ##NO_TEXT.
              if_stctm_task~pr_log->add_syst( ).

              lv_error_occured = abap_true.
          ENDTRY.

        ELSEIF lv_remall = abap_true.

          TRY.
              lo_gw_service->remove_all_aliases(
               iv_transport_cust = lv_request_cust
           ).
              CONCATENATE  p_srv_id ' :all aliases have been removed.'   INTO lv_bapi_msg_text SEPARATED BY space.
              if_stctm_task~pr_log->add_text( EXPORTING i_text = lv_bapi_msg_text ).
            CATCH /iwfnd/cx_cof INTO ocx_my.
              lv_message   = ocx_my->get_text( ).
              MESSAGE w101(s_lmcfg_core_tasks) WITH lv_message INTO if_stctm_task~pr_log->dummy ##NO_TEXT.
              if_stctm_task~pr_log->add_syst( ).

              lv_error_occured = abap_true.
          ENDTRY.

        ELSE.
          lv_bapi_msg_text = 'nothing selected'.
          if_stctm_task~pr_log->add_text( EXPORTING i_text = lv_bapi_msg_text ).
        ENDIF.

      ENDLOOP.

      DATA lv_number_of_deleted_services TYPE string.

      IF lv_deact = abap_true.

        DESCRIBE TABLE lt_deleted_gw_service_group LINES lv_number_of_deleted_services.

        CONCATENATE lv_number_of_deleted_services 'services deleted. For the list of deleted services click here'
         INTO lv_bapi_msg_text SEPARATED BY space.

        if_stctm_task~pr_log->add_text(
             EXPORTING
               i_type        = 'I'    " Message type
               i_text        = lv_bapi_msg_text  " Message text
               i_details     = 'X'
           ).


      ENDIF.
      "an error occured when maintaining one of the selected services
      "raising the error only after all services have been maintained.

      IF lv_error_occured  = abap_true.
        if_stctm_task~pr_log->add_text(
                  EXPORTING
                    i_type        = 'E'    " Message type
                    i_text        = 'One or more maintenace operations failed.'    " Message text
                ).

        RAISE error_occured.

      ENDIF.


    ENDIF.

  ENDMETHOD.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method ZCL_STCT_GW_SRV_MASS_MAINT->IF_STCTM_BG_TASK~LONGRUNNER
* +-------------------------------------------------------------------------------------------------+
* | [--->] IR_TASKLIST                    TYPE REF TO CL_STCTM_TASKLIST
* | [<-()] R_LONGRUNNER                   TYPE        IF_STCTM_TASK=>T_BOOL
* +--------------------------------------------------------------------------------------</SIGNATURE>
  METHOD if_stctm_bg_task~longrunner.
    r_longrunner = if_stctm_task=>c_bool-false.
  ENDMETHOD.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method ZCL_STCT_GW_SRV_MASS_MAINT->IF_STCTM_BG_TASK~RESUMABLE
* +-------------------------------------------------------------------------------------------------+
* | [--->] IR_TASKLIST                    TYPE REF TO CL_STCTM_TASKLIST
* | [<-()] R_RESUMABLE                    TYPE        IF_STCTM_TASK=>T_BOOL
* +--------------------------------------------------------------------------------------</SIGNATURE>
  METHOD if_stctm_bg_task~resumable.
    r_resumable = if_stctm_task=>c_bool-true.
  ENDMETHOD.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method ZCL_STCT_GW_SRV_MASS_MAINT->IF_STCTM_TASK~GET_DESCRIPTION
* +-------------------------------------------------------------------------------------------------+
* | [<-()] RV_DESCR                       TYPE        STC_TASK_DESCR
* +--------------------------------------------------------------------------------------</SIGNATURE>
  METHOD if_stctm_task~get_description.
    rv_descr = 'Mass maintenance for OData V2 services'.
  ENDMETHOD.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method ZCL_STCT_GW_SRV_MASS_MAINT->IF_STCTM_TASK~GET_DOCU_OBJECT
* +-------------------------------------------------------------------------------------------------+
* | [<---] EV_DOKU_ID                     TYPE        DOKU_ID
* | [<---] EV_DOKU_OBJ                    TYPE        DOKU_OBJ
* | [<---] EV_VAR1                        TYPE        SYMSGV
* | [<---] EV_VAR2                        TYPE        SYMSGV
* | [<---] EV_VAR3                        TYPE        SYMSGV
* | [<---] EV_VAR4                        TYPE        SYMSGV
* +--------------------------------------------------------------------------------------</SIGNATURE>
  METHOD if_stctm_task~get_docu_object.

    ev_doku_id  = 'TX'.
    ev_doku_obj = 'Z_STCT_GW_SRV_MASS_MAINT'.

  ENDMETHOD.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method ZCL_STCT_GW_SRV_MASS_MAINT->IF_STCTM_TASK~SHOW_MESSAGE_DETAILS
* +-------------------------------------------------------------------------------------------------+
* | [--->] I_DETAILS                      TYPE        STRING
* | [EXC!] ERROR_OCCURED
* +--------------------------------------------------------------------------------------</SIGNATURE>
  METHOD if_stctm_task~show_message_details.

    CALL METHOD cl_demo_output=>display_data
      EXPORTING
        value = lt_deleted_gw_service_group
*       name  =     " Name
      .


  ENDMETHOD.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method ZCL_STCT_GW_SRV_MASS_MAINT->IF_STCTM_UI_TASK~MAINTAINED
* +-------------------------------------------------------------------------------------------------+
* | [--->] IR_TASKLIST                    TYPE REF TO CL_STCTM_TASKLIST(optional)
* | [--->] IR_MESSAGES                    TYPE REF TO IF_STCTM_TASK_MESSAGES(optional)
* | [<-()] R_MAINTAINED                   TYPE        IF_STCTM_TASK=>T_BOOL
* +--------------------------------------------------------------------------------------</SIGNATURE>
  METHOD if_stctm_ui_task~maintained.

    DATA ls_variant TYPE LINE OF tt_variant.

    DATA: sep(1)         TYPE c VALUE ' ',
          txt1(256)      TYPE c,
          outputtxt(256) TYPE c.

    DATA: task_selected TYPE stc_task_status.

* call ui maintain method
    r_maintained = super->if_stctm_ui_task~maintained( ir_tasklist ).

* check if task is selected (01 - selected / 02 - not selected)
    task_selected = if_stctm_task~p_status.

* display parameter description
    IF task_selected = '02' OR r_maintained <> 'X'.

      " clear param description
      if_stctm_ui_task~p_variant_descr = ''.

    ELSE.

      " check if services have been selected
      READ TABLE pt_variant INTO ls_variant WITH KEY selname = 'S_SRV_ID'.

      IF ls_variant-low IS NOT INITIAL. "services have been selected

        txt1 = 'OK' .

        READ TABLE pt_variant INTO ls_variant WITH KEY selname = 'P_ADD'.

        IF ls_variant-low IS NOT INITIAL. "check if a system alias have been entered
          READ TABLE pt_variant INTO ls_variant WITH KEY selname = 'P_ALIASA'.
          IF ls_variant-low IS INITIAL. "No alias to be added has been selected
            r_maintained =''.
            txt1 = 'No alias to be added has been selected'.
          ENDIF.
        ENDIF.

        READ TABLE pt_variant INTO ls_variant WITH KEY selname = 'P_REMOVE'.

        IF ls_variant-low IS NOT INITIAL. "check if a system alias have been entered
          READ TABLE pt_variant INTO ls_variant WITH KEY selname = 'P_ALIASR'.
          IF ls_variant-low IS INITIAL. "No alias to be removed has been selected
            r_maintained =''.
            txt1 = 'No alias to be removed has been selected'.
          ENDIF.
        ENDIF.

        READ TABLE pt_variant INTO ls_variant WITH KEY selname = 'P_GETTMP'.

        IF ls_variant-low IS NOT INITIAL. "check if a service as a template for service assingments has been entered
          READ TABLE pt_variant INTO ls_variant WITH KEY selname = 'P_TMP_ID'.
          IF ls_variant-low IS INITIAL. "No service has been selected as a template
            r_maintained =''.
            txt1 = 'No service has been selected as a template'.
          ENDIF.
        ENDIF.

      ELSE.
        r_maintained =''.
        txt1 = 'No services selected'.
      ENDIF.





      CONCATENATE 'Parameter check:' txt1 INTO outputtxt SEPARATED BY sep.

      "output in parameter description
      if_stctm_ui_task~p_variant_descr = outputtxt.

    ENDIF.
  ENDMETHOD.
ENDCLASS.

 

 

Report  ZR_STCT_UI_MAINT_GW_SERVICES

 

Please note that you have to create

*&---------------------------------------------------------------------*
*& Report zr_stct_ui_maint_gw_services
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT zr_stct_ui_maint_gw_services.

DATA: lv_service_name_bep    TYPE /iwfnd/med_mdl_srg_name,
      lv_service_version_bep TYPE /iwfnd/med_mdl_version,
      ls_i_med_srh           TYPE /iwfnd/i_med_srh.



SELECTION-SCREEN BEGIN OF BLOCK part0 WITH FRAME .
SELECT-OPTIONS s_srv_id FOR ls_i_med_srh-srv_identifier.
SELECTION-SCREEN END OF BLOCK part0 .

SELECTION-SCREEN BEGIN OF BLOCK part2 WITH FRAME .

PARAMETERS: p_add    RADIOBUTTON GROUP opt . "add specified alias to the selected services

"details of the system alias that shall be assigned to the selected services
SELECTION-SCREEN BEGIN OF BLOCK part2a WITH FRAME.

"alias that shall be added
PARAMETERS : p_aliasa TYPE  /iwfnd/c_dfsyal-system_alias, " /iwfnd/defi_system_alias,
             p_role   TYPE /iwfnd/defi_role_name,
             p_isdef  AS CHECKBOX,
             p_isdefm AS CHECKBOX.


SELECTION-SCREEN END OF BLOCK part2a .

SELECTION-SCREEN ULINE.

PARAMETERS: p_gettmp RADIOBUTTON GROUP opt .  "replace aliases of selected services by the aliases that are assigned to the template service
"service that shall be used from system alias assignment
SELECTION-SCREEN BEGIN OF BLOCK part2b WITH FRAME .
PARAMETERS: p_tmp_id TYPE  /iwfnd/i_med_srh-srv_identifier. "service that shall be used as a template
SELECTION-SCREEN END OF BLOCK part2b.

SELECTION-SCREEN ULINE.

PARAMETERS : p_remove RADIOBUTTON GROUP opt . "remove specified alias from the selected services

SELECTION-SCREEN BEGIN OF BLOCK part2c WITH FRAME.

"alias that shall be removed
PARAMETERS : p_aliasr  TYPE  /iwfnd/c_dfsyal-system_alias.

SELECTION-SCREEN END OF BLOCK part2c .

SELECTION-SCREEN ULINE.

PARAMETERS: p_remall RADIOBUTTON GROUP opt . "remove all aliases from selected services

SELECTION-SCREEN ULINE.

PARAMETERS : p_setco  RADIOBUTTON GROUP opt. "set to co-deployed

SELECTION-SCREEN ULINE.

PARAMETERS: p_setrou RADIOBUTTON GROUP opt. "set to routing based

TYPE-POOLS sctsc .

SELECTION-SCREEN ULINE.

PARAMETERS: p_deact  RADIOBUTTON GROUP opt . "delete selected services

SELECTION-SCREEN END OF BLOCK part2 .

**********************************************************************

INITIALIZATION.

*----------------------------------------------------
* NO EXECUTION ---> Execution done with Task Manager
*----------------------------------------------------

START-OF-SELECTION.
  WRITE: / 'NOTE: Execution is done with Task Manager (transaction STC01)'.

For the report  ZR_STCT_UI_MAINT_GW_SERVICES you have to create the following text elements:

 

P_ADD	        Add single alias
P_ALIASA	SAP system alias
P_ALIASR	SAP system alias
P_DEACT	        Delete services
P_GETTMP	Assign aliases from a template
P_ISDEF	        Set is default
P_ISDEFM	Set is default for metadata
P_REMALL	Remove all aliases
P_REMOVE	Remove single alias
P_ROLE	        User role
P_SETCO	        Set to co-deployed
P_SETROU	Set to routing based
P_TMP_ID	Service used as a template
S_SRV_ID	Services

Assigned Tags

      14 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Gregor Wolf
      Gregor Wolf

      Hi Andre,

      that is a lot of source code. What's about the idea to use abapGit and provide it to GitHub or any other public Git repository?

      Best regards
      Gregor

      Author's profile photo Andre Fischer
      Andre Fischer
      Blog Post Author

      Hi Gregor,

      I am planning to do so.

      But to publish on GitHub I have to go trough an internal process which will take a while.

      Best Regards,

      Andre

       

      Author's profile photo Kenny Zhang
      Kenny Zhang

      Thank you Gregor. This is a brilliant approach.

      Author's profile photo Ning Tong
      Ning Tong

      A great work, thanks for this sharing.

      Question:

      Action ‘Set to co-deployed’ is same for using SAP system alias LOCAL in Add singe alias for co-deployed S/4HANA system?

      Author's profile photo Daniel Mahoney
      Daniel Mahoney

      Good day,

      Do you maybe have something similar that works in the same way - Where I can input the service names from /iwfnd/maint_service and do a mass activation of the ICF Nodes instead of an Alias update..?

      Thank you for a great article.

       

      Re,

      Daniel

      Author's profile photo Andre Fischer
      Andre Fischer
      Blog Post Author

      You can use the existing task list “SAP_GATEWAY_ACTIVATE_ODATA_SERV” for that.

      I tried it out with one service and existing system alias assignments were kept.

       

      Author's profile photo Sergio Garcia
      Sergio Garcia

      Hi Andre.

       

      1.  I'm stuck in this step

      It inherits from the class CL_STCTM_REPORT_UI so that the report ZR_STCT_UI_MAINT_GW_SERVICES can be used as a UI to enter parameters.

       

      Look what happend to me:

       

      So i cant continue with the rest , any idea about it  ?

       

       

      thks a lot .

       

       

      Author's profile photo Tarik Lahyaoui
      Tarik Lahyaoui

      Hi Sergio,

       

      Did you managed to solve this issue. I have the same error and i don't kwow how to fix it ?

      Thanks in advance.

       

      Tarik

      Author's profile photo Tarik Lahyaoui
      Tarik Lahyaoui

      Hello Andre,

       

      Thanks for this sharing.

      I have an issue when adding "ZR_STCT_UI_MAINT_GW_SERVICES" in stc01 :

      <Task object ZCL_STCT_GW_SRV_MASS_MAINT could not be created>

       

      Could you please show me how to fix this error ?

      Thanks

      Author's profile photo Willem Lourens
      Willem Lourens

      Hi

       

      I have the same issue.  Maybe this code no longer works with S/4HANA 1809.

      And there is no other way to mass-maintain odata services yet (SAP note 2658433)  🙁

      Author's profile photo Ning Tong
      Ning Tong

      For S/4HANA 1809 (maybe also higher), use tastlist SAP_GATEWAY_ACTIVATE_ODATA_SERV mentioned in KBA 2658433 to mass-maintain OData services.

      Author's profile photo Venkat dattatreya
      Venkat dattatreya

      Hi,

      When i try to add the service to transport using /IWFND/TL_SERVICE_MAINTENANCE, it is showing the 0 services selected. What could be the problem?

       

       

       

       

       

      Author's profile photo Akos Grabecz
      Akos Grabecz

      In case someone else has the same problem, one possible cause can be that the _0001 is missing from the end of the service names. You can type in your service name, add a star * at the end, and press F4, then select the needed service.

      Make%20sure%20to%20select%20your%20service%20from%20the%20search%20help

      Make sure to select your service from the search help

      Author's profile photo Willem Lourens
      Willem Lourens

      Hi,

      How to do this in mass if alias should be added to 100+ ODATA services?

      I would really like a way to get a list of all ODATA services that is routing-based with no alias assigned, then mass assign an alias to all of them.