ABAP Class to Detect SAP is S4 HANA running on Premise or on Cloud
ABAP programmers can use SAP standard class cl_cos_utilities to detect if current SAP system runs on HANA or to detect if SAP S/4HANA system is on premise or is on cloud. In this ABAP tutorial, I just want to show how developers can use cl_cos_utilities class with a sample case.
SAP standard cl_cos_utilities class has a number of static methods that ABAP programmers can keep in mind to use where a requirement occurs.
Here is the list of class static methods for CL_COS_UTILITIES (Utility routines for content separation/client separation)
IS_BYD: Checks if the system is in SAP Business ByDesign mode IS_SUITE: Checks if the system is in Suite mode IS_ADMIN_CLIENT: Checks if the current client is the administrative client IS_SYSTEM_CLIENT: Checks if the current client is a system client IS_APPLICATION_CLIENT: Checks if the current client is an application client IS_S4H: Checks if this is an S/4HANA system. SEE LONGTEXT IS_S4H_CLOUD_WEBGUI: Checks if session is WebGUI in an S/4HANA-like Cloud system IS_S4H_CLOUD: Checks if this is an S/4HANA-like Cloud system. SEE LONGTEXT IS_S4H_MANAGED_CLOUD: Deprecated (returns ABAP_FALSE), use IS_S4H_CLOUD IS_S4H_ON_PREMISE: Checks if this is a S/4 HANA On-Premise system, SEE LONGTEXT IS_S4H_PUBLIC_CLOUD: Deprecated, use IS_S4H_CLOUD IS_SIMPLIFIED_SUITE: Deprecated, use the correct IS_S4H... method instead ASSERT: Asserts if the function is executed in the specified context DISABLE: Disables the function in the specified context GET_CLIENT: Returns the current client IS: Checks if a function is executable in the specified context LOG_EXCEPTION: Logs the error using log-points VALIDATE_GV_S4H: Makes sure GV_S4H is valid, loads data if needed
ABAP programmers can call IS_S4H static method in their custom code to learn if current system is S/4HANA or not and if response is true then programmers can call method IS_S4H_CLOUD or IS_S4H_ON_PREMISE to identify if SAP system is on cloud or is on premise.
Here is the ABAP code for that check