Identify SAP Instance Number or System Number using ABAP Code
In this SAP tutorial, I want to show how ABAP programmers and data professionals can identify SAP system number or SAP instance number of the SAP system that you are trying to establish a connection. Recently, I was requested to establish a connection to a SAP system from Theobald XU Xtract Universal application. One of the connection methods requires host or server information and SAP system no as you will see in following sections in this tutorial.
SAP professionals can guess SAP system number easily in most cases since it is either 00, 01 or 02 in most cases. Unfortunately, recently I came across with a case where the SAP instance number is configured as 40 during setup process. As you will understand, it is nearly impossible for me to guess the number 40 as SAP system number easily.
ABAP programmers can use ABAP function module GET_SYSTEM_NUMBER in order to get two-digit system number, SYSNO or SAP instance number.
When you call the ABAP function module GET_SYSTEM_NUMBER, if you don't provide an RFC target system, the result will be for the current active SAP system.
Here as seen in below screenshot, the ABAP function module GET_SYSTEM_NUMBER returned 2-digit 40 as the system number or instance number information of the current SAP system.
ABAP programmers can use following ABAP code block to get the SAP instance number or the SAP system number in their programs.
On SAP Logon GUI tool, it is also possible to see the system number under the column "instance no"
But to my experience, this information is missing for most SAP systems.
Let's return back to the original requirement for identifying the SAP system number. As I mentioned before, for establishing a connection from Theobald Xtract Universal server to the target SAP system, I need the host or server name, or IP address and the SAP system number.