Enterprise Resource Planning Blogs by SAP
Get insights and updates about cloud ERP and RISE with SAP, SAP S/4HANA and SAP S/4HANA Cloud, and more enterprise management capabilities with SAP blog posts.
cancel
Showing results for 
Search instead for 
Did you mean: 
dmitry_sharshatkin
Active Participant
Hi All,

I just saw how some people are struggling with activation of Fiori Apps and decided to create a simple ABAP report to simplify this process. (See the coding below).

This report is using data from Fiori App Library. But, no magic, you should download it yourself.

 

Preparation Steps

Just open Fiori App Library: https://fioriappslibrary.hana.ondemand.com/sap/fix/externalViewer/ 

Select all needed Apps, switch to List View, Add Columns and Save data as CSV file.

Two pictures below show this process in details:


Select Needed Fiori Apps


 


Save Data in CSV File


 

 

First Execution

When running the report for the first time, you need to save CSV file in the system.

After that you can use already stored data file.


First Run


 

ABAP Code
*&---------------------------------------------------------------------*
*& Report ZDMSH_ACTIVATE_FIORI_APP
*&---------------------------------------------------------------------*
*& Report is used for activation of Fiori Applications
*& As input, it's using the CSV Export File from Fiori App Library:
*& https://fioriappslibrary.hana.ondemand.com/
*& Find your system version, select all applications and export as Excel.
*&---------------------------------------------------------------------*
report zdmsh_activate_fiori_app.

*** SELECTION SCREEN ...
****************************************************************************************************************************************

" Description...
selection-screen begin of block desc with frame title gc_desc.
selection-screen comment /2(79) gc_desc1.
selection-screen comment /2(79) gc_desc2.
selection-screen comment /2(79) gc_desc3.
selection-screen comment /2(79) gc_desc4.
selection-screen comment /2(79) gc_desc5.
selection-screen end of block desc.

" Main...
selection-screen begin of block main with frame title gc_main.

parameters : p_appid type char30 obligatory default 'F1060'. " Fiori App.ID...
selection-screen skip.

selection-screen begin of block file with frame title gc_fops. " Select Data Source...
parameters : r_fold radiobutton group file user-command file. " RB: Use Stored File...
parameters : r_fnew radiobutton group file. " RB: Upload New File...
parameters : p_file like rlgrap-filename modif id old. " File Name...
parameters : p_store type flag modif id old default 'X'. " Store File Flag...
selection-screen end of block file.

selection-screen begin of block pops with frame title gc_pops. " Specify Processing Option...
parameters : r_act1 radiobutton group act user-command act default 'X'. " Step 1: Activate App in Development System...
parameters : r_act2 radiobutton group act. " Step 2: Activate ICF Services in Remote Systems...
selection-screen end of block pops.

selection-screen begin of block step2 with frame title gc_step2. " Select RFC Desctination...
parameters: p_dest type rfcdest modif id st2. " RFC Destination to Q/P Systems...
selection-screen end of block step2.

selection-screen end of block main.


*** TYPES ...
****************************************************************************************************************************************
types: begin of ty_s_icf_node,
node_guid type icfnodguid,
path type string,
status type flag,
expand type abap_bool,
end of ty_s_icf_node.
types: ty_t_icf_node type standard table of ty_s_icf_node with key node_guid.


types: begin of ty_s_service,
external_service_name type /iwfnd/med_mdl_srg_name, " /CPD/CB_CUSTOMERPROJECT_SRV
namespace type /iwfnd/med_mdl_namespace, " /CPD/
service_name type /iwfnd/med_mdl_service_grp_id, " CB_CUSTOMERPROJECT_SRV
service_version type /iwfnd/med_mdl_version, " 0001
service_status type flag, " A - Active / I - Inactive / 'N' - New
service_identifier type /iwfnd/med_mdl_srg_identifier, " ZCB_CUSTOMERPROJECT_SRV_0001
" details type /iwfnd/s_mgw_reg_service,

icf_node_exist type flag, " ICF Node Exist...
icf_nodes type ty_t_icf_node, " List of Dependent ICF Nodes...
end of ty_s_service.
types: ty_t_service type table of ty_s_service.


*** CONSTANTS ...
****************************************************************************************************************************************

" Separator in CSV File...
constants: gc_separator(1) value ','.

" System Alias...
constants: gc_system_alias type /iwfnd/defi_system_alias value 'LOCAL'.

" Set of fields in CSV File (Upper Case)...
constants: begin of gc_fields,
fiori_id type string value 'fioriId',
technical_catalog_name type string value 'TechnicalCatalogName',
business_catalog_name type string value 'BusinessCatalogName',
business_group_name type string value 'BusinessGroupName',
leading_business_role_name type string value 'LeadingBusinessRoleName',
additional_business_role_name type string value 'AdditionalBusinessRoleName',
bsp_name type string value 'BSPName',
bsp_application_url type string value 'BSPApplicationURL',
primary_odata_service_name type string value 'PrimaryODataServiceName',
primary_odata_service_version type string value 'PrimaryODataServiceVersion',
additional_odata_services type string value 'AdditionalODataServices',
additional_odata_services_vers type string value 'AdditionalODataServicesVersions',
end of gc_fields.

" Service Statuses...
constants: begin of gc_srv_stat,
active type flag value 'A',
new type flag value 'N',
inactive type flag value 'I',
undefined type flag value '',
end of gc_srv_stat.

" ICF Nodes Statuses...
constants: begin of gc_icf_node_stat,
active type flag value 'A', " Active
inactive type flag value 'I', " Inactive
undefined type flag value '', " Undefined
end of gc_icf_node_stat.


" File Storage...
constants: begin of gc_storage,
name type string value 'FIORI_APP_LIBRARY', " Name
app_name type string value 'ACTIVATE_FIORI_APP', " Application Name
app_namespace type string value 'ZDMSH_', " Application Namespace
data_name type string value '.CSV', " Data File
sess_id type string value 'SESSION_ID', " Session ID (no chnage)
ret_time type i value 2592000, " 1 Month
end of gc_storage.

*** GLOBAL DATA ...
****************************************************************************************************************************************
data: gv_file type string.
data: gv_app_id type string.
data: gt_file_data type string_table.
data: gt_header type string_table.
data: gt_app_data type string_table.
data: gv_key_idx type i.
data: gv_dest type rfcdest.
data: gv_dev_package type devclass.



data: begin of gs_app_data,
fiori_id type string,
primary_odata_service_name type string,
primary_odata_service_version type string,
additional_odata_services type string,
additional_odata_services_vers type string,
bsp_name type string,
bsp_application_url type string,
technical_catalog_name type string,
business_catalog_name type string,
business_group_name type string,
leading_business_role_name type string,
additional_business_role_name type string,
end of gs_app_data.


*** MACROSES ...
****************************************************************************************************************************************
define _add_text_mcr.
%_&1_%_app_%-text = &2.
end-of-definition.


initialization.
authority-check object 'S_TCODE' id 'TCD' field '/IWFND/MAINT_SERVICE'.
if sy-subrc <> 0.
message 'You are not authrized!' type 'E'. "#EC NO_TEXT
endif.

gc_desc = 'Description'.
gc_desc1 = 'This report helps you to activate Fiori App, using App. ID.'.
gc_desc2 = 'To make it work, please open SAP Fiori App Library, using link: '.
gc_desc3 = 'https://fioriappslibrary.hana.ondemand.com/'.
gc_desc4 = 'Find your system version, select all (or just relevant apps) and'.
gc_desc5 = 'export the data aggregated into one CSV file.'.
gc_main = 'Processing options'.
gc_fops = 'Select Data Source'.
gc_pops = 'Specify Processing Option'.
gc_step2 = 'Select RFC Desctination'.


at selection-screen output.
_add_text_mcr p_appid 'Specify Fiori App ID:'.
_add_text_mcr r_fold 'Use Stored Data File'.
_add_text_mcr r_fnew 'Upload New Data File'.
_add_text_mcr p_file 'CSV Data File'.
_add_text_mcr p_store 'Store File in Database'.
_add_text_mcr r_act1 'Step 1: Activate App in DEV'.
_add_text_mcr r_act2 'Step 2: Activate ICF in Q/P'.
_add_text_mcr p_dest 'RFC Destination to Q/P Systems'.


loop at screen.
if screen-group1 = 'OLD'.
screen-input = cond #( when r_fnew = abap_true then '1' else '0' ).
modify screen.
endif.
if screen-group1 = 'ST2'.
screen-active = cond #( when r_act2 = abap_true then '1' else '0' ).
modify screen.
endif.
endloop.


at selection-screen on value-request for p_file.
clear p_file.

call function 'WS_FILENAME_GET'
exporting
def_filename = space
def_path = space
mask = ',*.csv,*.csv.'
mode = 'O'
title = 'Select Data File from Fiori App. Library'
importing
filename = p_file
exceptions
inv_winsys = 04
no_batch = 08
selection_cancel = 12
selection_error = 16.

start-of-selection.

gv_file = p_file.
gv_app_id = p_appid.
gv_dest = p_dest.
clear: gv_dev_package.

" Get CSV File...
perform get_csv_file.

" Extract CSV File...
perform extract_csv_file.

" Fill Work-Structure...
perform fill_app_structure.

" Activate OData Services...
perform service_activation.


***********************************************************************************************************************************************
*** ABAP FORMS...
***********************************************************************************************************************************************


*** STORE CSV FILE...
***********************************************************************************************************************************************
form store_csv_file.
data: lv_string type string.

check: p_store is not initial and gt_file_data[] is not initial.

concatenate lines of gt_file_data[] into lv_string separated by cl_abap_char_utilities=>newline.
try.
call method cl_bsp_server_side_cookie=>set_server_cookie(
exporting
name = gc_storage-name
application_name = gc_storage-app_name
application_namespace = gc_storage-app_namespace
data_name = gc_storage-data_name
expiry_time_rel = gc_storage-ret_time
username = sy-uname
session_id = gc_storage-sess_id
data_value = lv_string ).
catch cx_root.
message 'File storage failed!' type 'E'. "#EC NO_TEXT
endtry.
endform.


*** UPLOAD CSV FILE...
***********************************************************************************************************************************************
form upload_csv_file.
refresh: gt_file_data[].

call function 'GUI_UPLOAD'
exporting
filename = gv_file
filetype = 'ASC'
has_field_separator = 'X'
tables
data_tab = gt_file_data
exceptions
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
others = 17.
if sy-subrc <> 0.
message 'Could not open the file...' type 'E'. "#EC NO_TEXT
endif.
if p_store = abap_true.
perform store_csv_file.
endif.

endform.


*** RESTORE CSV FILE...
***********************************************************************************************************************************************
form restore_csv_file.

data: lv_string type string.
data: lt_cookies type tsscookiei.
data: ls_cookie type sscookiei.

check: r_fold = abap_true.

try.
" Search Files In DB...
call method cl_bsp_server_side_cookie=>get_server_cookie_info
exporting
name = gc_storage-name
application_name = gc_storage-app_name
application_namespace = gc_storage-app_namespace
importing
cookies = lt_cookies.

check: lt_cookies[] is not initial.
sort lt_cookies[] by expiryd descending expiryt descending.
read table lt_cookies[] into ls_cookie index 1.

" Get Last File...
call method cl_bsp_server_side_cookie=>get_server_cookie(
exporting
name = gc_storage-name
application_name = gc_storage-app_name
application_namespace = gc_storage-app_namespace
data_name = gc_storage-data_name
username = ls_cookie-usr
session_id = gc_storage-sess_id
changing
data_value = lv_string ).

check: lv_string is not initial.
clear: gt_file_data[].
split lv_string at cl_abap_char_utilities=>newline into table gt_file_data[].
catch cx_root.
message 'Could not restore file...' type 'E'. "#EC NO_TEXT
endtry.
endform.


*** GET CSV FILE...
***********************************************************************************************************************************************
form get_csv_file.

case abap_true.
when r_fnew. perform upload_csv_file.
when r_fold. perform restore_csv_file.
endcase.
if gt_file_data[] is initial.
message 'CSV File does not contain any data...' type 'E'. "#EC NO_TEXT
endif.
endform.


*** EXTRACT CSV FILE...
***********************************************************************************************************************************************
form extract_csv_file.

data: lt_data type string_table.
data: lt_data_tmp type string_table.
data: lv_complete_string type string.

check: gt_file_data[] is not initial.
clear: gt_app_data[].

write: /, 'Extracting CSV File...' color col_positive.

loop at gt_file_data into data(lv_file_line).

check: lv_file_line is not initial.

" Header...
if sy-tabix = 1.
clear: gt_header[].
translate lv_file_line to upper case.
split lv_file_line at gc_separator into table gt_header[].

read table gt_header[] with key table_line = to_upper( gc_fields-fiori_id ) transporting no fields.
if sy-subrc = 0.
gv_key_idx = sy-tabix.
else.
message 'Wrong CSV File Structure!' type 'E'. "#EC NO_TEXT
endif.
else.
" Body...
clear: lt_data[], lt_data_tmp[].
split lv_file_line at gc_separator into table lt_data_tmp[].
if lt_data_tmp[] is not initial and gv_key_idx > 0.

" Search our App.ID....
read table lt_data_tmp[] with key table_line = gv_app_id transporting no fields.
if sy-subrc = 0.

loop at lt_data_tmp[] into data(lv_data_tmp).
data(len) = strlen( lv_data_tmp ) - 1.

if lv_data_tmp is initial.
if lv_complete_string is initial.
append lv_data_tmp to lt_data[].
else.
lv_complete_string = lv_complete_string && gc_separator && lv_data_tmp.
endif.
else.
if lv_data_tmp(1) = '"' and lv_data_tmp+len(1) = '"'. " Complete string: "Start plus Finish..."
append lv_data_tmp to lt_data[].

elseif lv_data_tmp(1) = '"' and lv_data_tmp+len(1) <> '"'. " Begining: " Start...,
lv_complete_string = lv_data_tmp.

elseif lv_data_tmp(1) <> '"' and lv_data_tmp+len(1) <> '"'. " Middle: ... plus ...

" This might be a complete string...
if lv_complete_string is initial.
append lv_data_tmp to lt_data[].
else.
lv_complete_string = lv_complete_string && gc_separator && lv_data_tmp.
endif.

elseif lv_data_tmp(1) <> '"' and lv_data_tmp+len(1) = '"'. " End: ... Finish"
lv_complete_string = lv_complete_string && gc_separator && lv_data_tmp.
append lv_complete_string to lt_data[].
clear: lv_complete_string.
endif.
endif.
endloop.

exit.
endif.
endif.
endif.
endloop.


" Errors...
if lt_data[] is initial.
message 'Data for APP ID: ' && gv_app_id && ' not found' type 'E'. "#EC NO_TEXT
else.
gt_app_data[] = lt_data[].
endif.

" Free up memory...
refresh: gt_file_data[].

write: /, 'CSV File for APP.' && gv_app_id && ' extracted!' color col_positive.

endform.



*** EXTRACT CSV FILE...
***********************************************************************************************************************************************
form fill_app_structure.

define: _extract_field.
read table gt_header[] with key table_line = to_upper( gc_fields-&1 ) transporting no fields.
if sy-subrc = 0.
read table gt_app_data[] into gs_app_data-&1 index sy-tabix.
endif.
end-of-definition.

write: /, 'Collecting Data...' color col_positive.

check: gt_app_data[] is not initial.


" Fiori App. Id...
gs_app_data-fiori_id = gv_app_id.

" Primary OData Service...
_extract_field: primary_odata_service_name.
_extract_field: primary_odata_service_version.
_extract_field: additional_odata_services.
_extract_field: additional_odata_services_vers.
_extract_field: bsp_name.
_extract_field: bsp_application_url.
_extract_field: technical_catalog_name.
_extract_field: business_catalog_name.
_extract_field: business_group_name.
_extract_field: leading_business_role_name.
_extract_field: additional_business_role_name.

if gs_app_data-additional_odata_services is not initial.
replace all occurrences of '"' in gs_app_data-additional_odata_services with space.
replace all occurrences of '"' in gs_app_data-additional_odata_services_vers with space.
condense: gs_app_data-additional_odata_services no-gaps.
condense: gs_app_data-additional_odata_services_vers no-gaps.
endif.

write: /, sy-uline.
write: /, 'Application Information:'.
write: /, 'Primary OData: ' && gs_app_data-primary_odata_service_name.
write: /, 'OData Version: ' && gs_app_data-primary_odata_service_version.
write: /, 'Add. OData: ' && gs_app_data-additional_odata_services.
write: /, 'BSP App.: ' && gs_app_data-bsp_name.
write: /, 'BSP URL: ' && gs_app_data-bsp_application_url.
write: /, 'Tech. Catalog: ' && gs_app_data-technical_catalog_name.
write: /, 'Busi. Catalog: ' && gs_app_data-business_catalog_name.
write: /, 'Business Group:' && gs_app_data-business_group_name.
write: /, 'Business Role1:' && gs_app_data-leading_business_role_name.
write: /, 'Business Role2:' && gs_app_data-additional_business_role_name.
write: /, sy-uline.
endform.


*** GET REQUIRED ODATA SERVICES...
***********************************************************************************************************************************************
form get_odata_services changing ct_service_data type ty_t_service.

data: ls_service_data type ty_s_service.
data: lt_str_tab_1 type string_table.
data: lt_str_tab_2 type string_table.
data: lv_tabix type i.

write: /, 'Identifying relavant OData services...' color col_positive.

" 1). Search OData Service(s)...
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" Main OData service...
clear: ls_service_data.
ls_service_data-external_service_name = gs_app_data-primary_odata_service_name.
ls_service_data-service_version = gs_app_data-primary_odata_service_version.
append ls_service_data to ct_service_data[].

" Additional Odata services...
if gs_app_data-additional_odata_services is not initial.

" Additional Services...
clear: lt_str_tab_1[].
if gs_app_data-additional_odata_services cs gc_separator.
split gs_app_data-additional_odata_services at gc_separator into table lt_str_tab_1[].
else.
append gs_app_data-additional_odata_services to lt_str_tab_1[].
endif.

" Additional Service Versions...
if gs_app_data-additional_odata_services_vers is not initial.
clear: lt_str_tab_2[].
if gs_app_data-additional_odata_services_vers cs gc_separator.
split gs_app_data-additional_odata_services_vers at gc_separator into table lt_str_tab_2[].
else.
append gs_app_data-additional_odata_services_vers to lt_str_tab_2[].
endif.
endif.

" Collect Result...
loop at lt_str_tab_1 into data(lv_str1).
lv_tabix = sy-tabix.

clear: ls_service_data.
ls_service_data-external_service_name = lv_str1.

" Normalize the name...
call method /iwfnd/cl_med_utils=>normalize_srv_mdl_name
exporting
iv_service_name = conv #( ls_service_data-external_service_name )
importing
ev_namespace = ls_service_data-namespace
ev_name = ls_service_data-service_name.

read table lt_str_tab_2 into data(lv_str2) index lv_tabix.
if sy-subrc = 0.
ls_service_data-service_version = lv_str2.
endif.
append ls_service_data to ct_service_data[].
endloop.
endif.

delete ct_service_data[] where external_service_name is initial.

if ct_service_data[] is initial.
write: /, 'Relavant OData services not identified!' color col_negative.
else.
write: /, 'Relavant OData services identified:' color col_positive.
loop at ct_service_data[] assigning field-symbol(<fs_service_data>).
write: / , ' Service: ' && <fs_service_data>-external_service_name &&
' Version: ' && <fs_service_data>-service_version color col_positive.
endloop.
endif.
endform.


*** GET SERVICE STATUS...
***********************************************************************************************************************************************
form get_service_status changing cs_service type ty_s_service.

statics: st_new_services type /iwfnd/cl_med_rem_exploration=>ty_t_service_groups.

if cs_service-service_version is initial.
cs_service-service_version = '0001'.
endif.

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

lo_config_facade->is_service_active(
exporting
iv_service_name_bep = cs_service-external_service_name
iv_service_version_bep = cs_service-service_version
importing
ev_active = data(lv_active) ).
catch cx_root into data(lx_root).
data(lv_message_text) = /iwfnd/cl_cof_util=>get_message_text( ix_message = lx_root ).
message lv_message_text type 'I' display like 'E'.
return.
endtry.
if lv_active = abap_true.
cs_service-service_status = gc_srv_stat-active.
exit.
endif.

" Get New Odata Services...
if st_new_services[] is initial.
try.
data(lo_exploration) = /iwfnd/cl_med_rem_exploration=>get_remote_explorer( ).
lo_exploration->get_bep_service_groups(
exporting iv_system_alias = gc_system_alias
importing et_service_groups = st_new_services[] ).
catch cx_root into lx_root.
lv_message_text = /iwfnd/cl_cof_util=>get_message_text( ix_message = lx_root ).
message lv_message_text type 'I' display like 'E'.
return.
endtry.
endif.

" Check if Service can be Created...
read table st_new_services transporting no fields
with key technical_name = cs_service-external_service_name.
if sy-subrc = 0.
cs_service-service_status = gc_srv_stat-new.
exit.
endif.

endform.


*** ADD NEW SERVICE...
***********************************************************************************************************************************************
form add_new_service changing cs_service type ty_s_service.

constants: gc_prefix(1) value 'Z'.

data: lv_edit type tadir-edtflag.
data: ls_tadir type tadir.
data: ls_tdevc type tdevc.

call function 'TR_SYS_PARAMS'
importing
systemedit = lv_edit
exceptions
no_systemname = 1
no_systemtype = 2
others = 3.
if sy-subrc <> 0 or lv_edit = 'N'.
message 'System locked for chnages! Use Development system.' type 'E'. "#EC NO_TEXT
endif.

" Get Package...
if gv_dev_package is initial.
ls_tadir-pgmid = 'R3TR'.
ls_tadir-object = 'IWSG'.
ls_tadir-obj_name = gc_prefix && cs_service-service_name && '_' && cs_service-service_version.
ls_tadir-srcsystem = sy-sysid.
ls_tadir-author = sy-uname.
ls_tadir-masterlang = sy-langu.
ls_tadir-created_on = sy-datum.

call function 'TRINT_TADIR_POPUP'
exporting
wi_tadir = ls_tadir
wi_no_tadir = 'X'
wi_no_delete_function = 'X'
importing
ev_tdevc = ls_tdevc
exceptions
display_mode = 01
exit = 02
others = 03.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.

gv_dev_package = ls_tdevc-devclass.
write: / , 'Development Package: ' && gv_dev_package.
endif.


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

lo_config_facade->activate_service(
exporting
iv_service_name_bep = cs_service-external_service_name
iv_service_version_bep = cs_service-service_version
iv_suppress_dialog = abap_false
iv_prefix = conv #( gc_prefix )
iv_system_alias = gc_system_alias
iv_package = gv_dev_package
importing
ev_srg_identifier = cs_service-service_identifier ).

catch cx_root into data(lx_root).
endtry.

commit work and wait.
wait up to 1 seconds.

perform get_service_status changing cs_service.

endform.


*** GET ICF NODES...
***********************************************************************************************************************************************
form get_icf_nodes changing cs_service type ty_s_service.

data: lt_subnodes type icfservtbl.

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

call method lo_config_facade->check_icf_node(
exporting
iv_service_name_bep = cs_service-external_service_name
importing
ev_icf_node_exists = data(lv_icf_node_exists)
ev_icf_node_is_active = data(lv_icf_node_is_active)
ev_icf_service_guid = data(lv_icf_service_guid)
ev_icf_namespace_guid = data(lv_icf_namespace_guid)
ev_icf_root_node_guid = data(lv_icf_root_node_guid) ).
catch cx_root into data(lx_root).
exit.
endtry.

cs_service-icf_node_exist = lv_icf_node_exists.

" Root...
if lv_icf_root_node_guid is not initial.
append value #( node_guid = lv_icf_root_node_guid ) to cs_service-icf_nodes[].
endif.

" Namespace...
if lv_icf_namespace_guid is not initial.
append value #( node_guid = lv_icf_namespace_guid ) to cs_service-icf_nodes[].
endif.

" Service Node...
if lv_icf_service_guid is not initial and lv_icf_node_exists = abap_true.
append value #( node_guid = lv_icf_service_guid
expand = abap_true ) to cs_service-icf_nodes[].
endif.

" Application Node...
if gs_app_data-bsp_application_url is not initial.
translate gs_app_data-bsp_application_url to lower case.
append value #( path = gs_app_data-bsp_application_url
expand = abap_true ) to cs_service-icf_nodes[].
endif.

" Fill Path & Status...
loop at cs_service-icf_nodes[] assigning field-symbol(<fs_icf_node>).

" Get Path from GUID...
if <fs_icf_node>-node_guid is not initial and <fs_icf_node>-path is initial.
call function 'HTTP_GET_URL_FROM_NODGUID'
exporting
nodguid = <fs_icf_node>-node_guid
importing
extended_url = <fs_icf_node>-path
exceptions
icf_inconst = 1
others = 2.
endif.

" Get GUID from Path...
if <fs_icf_node>-node_guid is initial and <fs_icf_node>-path is not initial.
call method cl_icf_tree=>if_icf_tree~service_from_url
exporting
hostnumber = 0
url = <fs_icf_node>-path
importing
icfnodguid = <fs_icf_node>-node_guid
exceptions
wrong_application = 1
no_application = 2
not_allow_application = 3
wrong_url = 4
no_authority = 5.
endif.

" Set Status for Node...
if <fs_icf_node>-path is initial or
<fs_icf_node>-node_guid is initial.
<fs_icf_node>-status = gc_icf_node_stat-undefined.
else.
data(lv_active) = cl_icf_tree=>is_service_active( nodeguid = <fs_icf_node>-node_guid ).
if lv_active = abap_true.
<fs_icf_node>-status = gc_icf_node_stat-active.
elseif lv_active = abap_false.
<fs_icf_node>-status = gc_icf_node_stat-inactive.
endif.
endif.
endloop.
endform.



*** Activate ICF Nodes...
form activate_icf_nodes using iv_destination type rfcdest
changing cs_service type ty_s_service.

check cs_service-icf_nodes[] is not initial.

loop at cs_service-icf_nodes[] assigning field-symbol(<fs_icf_node>)
where status <> gc_icf_node_stat-active.

" Activate the service...
if iv_destination is initial.
call function 'HTTP_ACTIVATE_NODE'
exporting
nodeguid = <fs_icf_node>-node_guid
expand = <fs_icf_node>-expand
exceptions
node_not_existing = 1
enqueue_error = 2
no_authority = 3
url_and_nodeguid_space = 4
url_and_nodeguid_fill_in = 5.
else.
call function 'HTTP_ACTIVATE_NODE' destination iv_destination
exporting
nodeguid = <fs_icf_node>-node_guid
expand = <fs_icf_node>-expand
exceptions
node_not_existing = 1
enqueue_error = 2
no_authority = 3
url_and_nodeguid_space = 4
url_and_nodeguid_fill_in = 5.
endif.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 into data(dummy).
write: /, dummy.
write: /, 'Activation ICF Node failed: ' && <fs_icf_node>-path color col_negative.
else.
<fs_icf_node>-status = gc_icf_node_stat-active.
write: /, 'ICF Node activated: ' && <fs_icf_node>-path color col_positive.
endif.
endloop.


endform.




*** SERVICE ACTIVATION
***********************************************************************************************************************************************
form service_activation.

data: lt_service type ty_t_service.

" Get Requested OData Services...
perform get_odata_services changing lt_service[].
if lt_service[] is initial.
message 'No OData Services for Activation' type 'E'. "#EC NO_TEXT
endif.

write: /, 'Start OData service processing...' color col_positive. "#EC NO_TEXT

" Process Services...
loop at lt_service assigning field-symbol(<ls_service>).

write: /, 'Service: ' && <ls_service>-external_service_name color col_positive.

perform get_service_status changing <ls_service>.

" Activate Service Locally...
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
if r_act1 = abap_true.
if <ls_service>-service_status = gc_srv_stat-new.
perform add_new_service changing <ls_service>.
endif.
if <ls_service>-service_status <> gc_srv_stat-active.
write: /, 'Service: ' && <ls_service>-external_service_name && ' was not activated.' color col_negative.
else.
write: /, 'Service: ' && <ls_service>-external_service_name && ' was activated.' color col_positive.
endif.


" Get ICF Nodes...
perform get_icf_nodes changing <ls_service>.

" Activate ICF Nodes...
perform activate_icf_nodes using space
changing <ls_service>.
endif.


" Activate ICF Nodes Remotely...
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
if r_act2 = abap_true.
if gv_dest is initial.
message 'RFC Destination not specified!' type 'E'. "#EC NO_TEXT
endif.

if <ls_service>-service_status <> gc_srv_stat-active.
write: /, 'Service: ' && <ls_service>-external_service_name && ' was not activated.' color col_negative.
continue.
else.
" Get ICF Nodes...
perform get_icf_nodes changing <ls_service>.

" Activate ICF Nodes...
perform activate_icf_nodes using gv_dest
changing <ls_service>.

endif.
endif.
endloop.


write: / , sy-uline.
write: / , 'Finish !'.
endform.

 

Disclaimer:

It's just a custom report I've developed and want to share with you.  It can be used completely or partially. Neither myself, nor SAP have any responsibility for this report, its behavior or potential damages. It's basically just a template you can adjust to your needs.

If it's not working, please don't write here. Try to find the reason yourself. For me it was working good.

 

Note: 

This report was intended to be used in DEV systems only. I guess, it's obvious.

Next thing, what you could think of is to get the data for your Fiori Apps right from Fiori App Library via OData (SAPUI5 App or just BSP Application). But for me it was OK jus so.

 

Good luck with Fiori !

BR, Dima