SQL Server administration and T-SQL development, Web Programming with ASP.NET, HTML5 and Javascript, Windows Phone 8 app development, SAP Smartforms and ABAP Programming, Windows 7, Visual Studio and MS Office software SAP ABAP Programming and HANA Database Tutorials
Development resources, articles, tutorials, samples, codes and tools for .Net, SQL Server, Windows, Windows Phone, SAP and ABAP, like SAP UI5, Screen Personas, etc.

CRM Companies List
Web Based CRM Software

Check if SAP System is Productive, Development or Test

ABAP developers require to check the role of SAP system that the program is running to see if it is production system, test or development system. SAP provides function modules to see the system role like TR_SYS_PARAMS or PRGN_CHECK_SYSTEM_PRODUCTIVE. Although ABAP programmer can use these function modules, the main source that the decision to check whether a SAP system is used as productive, test or customizing (development) is T000 Clients transparent table CCCATEGORY Client Control (Role of Client) field.

In your SAP landscape, if you use a consistent naming for your SAP systems, you can develop your own solution to check the role of a SAP system. But with addition of new SAP systems, it will be more difficult to maintain the consistency at least for far future.
Althouth it is not recommended, you can build a naming convention for SAP systems like S0D (D for Development), S0C or S0T (for Certification or for Test), S0P (for Production), etc.

If you prefer to take the above method, you can use the SY-SYSID+2(1) for the third character of the SAP system name and test with D,C,T or P character values.

Best practise to control if a SAP system is being used as development, test or for production SAP Clients T000 transparent table is used.
As you can see in below screenshot, for each client a field CCCATEGORY is used for client control to store the role of SAP system client (production, test, development, etc).

SAP Clients transparent table T000

If ABAP programmers check the value range for the domain CCCATEGORY (Client control: Category of a client), following possible values can be seen for each SAP client:
P Production
T Test
C Customizing
D Demo
E Training/Education
S SAP reference

This means if the current SAP system client data is queried using a simple SELECT statement, the CCCATEGORY field can be used to determine the category, or role for the current SAP client.

Here is a sample ABAP code script

check SAP system role and category

ABAP programmers can copy below code for testing this code solution.

select single cccategory from t000
 into @data(lv_role) where mandt = @sy-mandt.

case lv_role.
 when 'P'.
  write 'Production'.
 when 'T'.
  write 'Test'.
 when 'C'.
  write 'Customizing'. " Development
 when 'D'.
  write 'Demo'.
 when 'E'.
  write 'Training/Education'.
 when 'S'.
  write 'SAP reference'.
 when others.
  " ?

An other option is using function module TR_SYS_PARAMS used to determine system name, type, change option, etc.
Here is the use of ABAP function module TR_SYS_PARAMS to determine the SAP client category, if it is development system, test or production system.

data lv_role type cccategory. " like T000-CCCATEGORY.
*P Production
*T Test
*C Customizing
*D Demo
*E Training/Education
*S SAP reference

call function 'TR_SYS_PARAMS'
  system_client_role = lv_role
  no_systemname = 1
  no_systemtype = 2
  others = 3.
if sy-subrc <> 0.
* Implement suitable error handling here

ABAP function module TR_SYS_PARAMS will return the SAP client usage purpose using the lv_role variable. I again added the possible values within the code.

ABAP function module TR_SYS_PARAMS

Another ABAP function module PRGN_CHECK_SYSTEM_PRODUCTIVE can be used to test whether the current SAP client is productive or not.
One restriction about this ABAP function module is that it only checks if the system is production system or not again by using the T000-CCCATEGORY field value for the current client sy-mandt

  client_is_productive = 1
  others = 2.
if sy-subrc = 1.
 write 'Production'.
elseif sy-subrc = 2.
 " error
 write 'Non-Production'.

ABAP function module PRGN_CHECK_SYSTEM_PRODUCTIVE for production test

SAP Tutorials

SAP Tutorial

SAP Forums

SAP Tools

SAP Transaction Codes Table

Copyright © 2004 - 2017 Eralper YILMAZ. All rights reserved.
Community Server by Telligent Systems