cancel
Showing results for 
Search instead for 
Did you mean: 

Is there a way to know if current system is Production System, in S/4HANA Cloud Public Edition?

diego_valentino
Explorer
0 Kudos
221

Hi everyone,

For one of my developments in S/4HANA Cloud Public Edition, I need to build some logic depending if the current system is Production System or not.

In On-Premise systems I used to use table T000 or class CL_ABAP_SYST to do so, but I cannot use them in Cloud Public since they are not released for Cloud Development (Contract C1).

Does anyone know if there's another way to get such information? I took a look at all classes released for cloud, including the XCO libraries, but couldn't find anything suitable.

Thanks.

View Entire Topic
Pradeep_Reddy
Participant
0 Kudos

Hi,

 

Use class : cl_abap_context_info and method : get_system_url( ) to get the system URL.

 

DATA(lv_system) TYPE string.
DATA(lv_var1) TYPE string.
DATA(lv_var2) TYPE string.
DATA(it_sys) TYPE TABLE OF REF TO cl_com_system.
DATA(lr_sys) TYPE REF TO cl_com_system.
DATA(systemid) TYPE string.

" Get the system URL
lv_system = cl_abap_context_info=>get_system_url( ).

" Split the URL at '.' into lv_var1 and lv_var2
SPLIT lv_system AT '.' INTO lv_var1 lv_var2.

" Read the communication systems
cl_com_system_factory=>create_instance( )->query_cs( IMPORTING et_com_system = it_sys ).

" Loop through the communication systems


LOOP AT it_sys INTO lr_sys.
" System is the own system
IF lr_sys->is_own_system( ) = abap_true.
systemid = to_upper( lr_sys->get_id( ) ).

exit.
ENDIF.
ENDLOOP.

" Alternatively, loop and check the hostname
LOOP AT it_sys INTO lr_sys.
IF lr_sys->get_hostname( ) CS lv_var1.
systemid = to_upper( lr_sys->get_id( ) ).

exit.
ENDIF.
ENDLOOP.

 

Regrads,

Pradeep.

diego_valentino
Explorer
0 Kudos
Hi Pradeep. The code you provided is a good option, though, I think I'll go with the validation of SY-SYSID. Thank your for your help on this.