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
148

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.

Accepted Solutions (1)

Accepted Solutions (1)

Pooja_Hadagali
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi

CL_ABAP_SYST was removed from SAP S/4HANA CLOUD 1811 since it wasn't suitable for cloud deployments.

As alternative you may use CL_ABAP_CONTEXT_INFO.

And also you can use SY-SYSID is a system field which gives the system ID

For more info, Refer the below doc

ABAP Keyword Documentation

Best Regards,

Pooja

diego_valentino
Explorer
0 Kudos

Hi  @Pooja_Hadagali  

I was expecting to have some flag like the one on table T000 which shows "P" when we work on a production system, but that's ok. I think I'll go with a SY-SYSID validation.

Thanks for the information

EDIT: When I tried to release my transport, Eclipse showed the ATC error "The use of the hard-coded system ID can present a security risk". I'll have to go for the URL option.

It's a shame that SAP put all this stoppers everywhere we go, even for simple things.

Answers (1)

Answers (1)

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.