There are lot of cases where you need to run a whole program or its piece in development or testing environment only and you want to avoid running it in production. Or vice versa. In the following article I’ll show you a construct which will check if you’re running on production system or not.
SELECT SINGLE cccategory
FROM t000
INTO t000-cccategory
WHERE mandt EQ sy-mandt.
IF NOT t000-cccategory EQ 'P'
" do stuff for non-production system here
ENDIF.
The above snippet is part of a function called ‘PRGN_CHECK_SYSTEM_PRODUCTIVE’ so you can do the same as above by calling a function module:
DATA: l_production TYPE flag.
CALL FUNCTION 'PRGN_CHECK_SYSTEM_PRODUCTIVE'
EXCEPTIONS
client_is_productive = 1
OTHERS = 2.
IF sy-subrc <> 0.
l_production = abap_true.
ENDIF.