Siemens Industry Online Support
Siemens AG
Entry type: FAQ, Entry ID: 52258437, Entry date: 12/28/2015

How do you define the constants in an S7-SCL program in STEP 7 (TIA Portal)?

  • Entry
  • Associated product(s)
In Step 7 V5.x you can only define local constants in the declaration part of the SCL block code and use it in the program. Contrarily TIA Portal V13 differentiates between local and global user constants which are defined in the block interface or in the PLC tags.

In STEP 7 V5.x you can define the local constants in the declaration part on the SCL block code and use them in the program as shown in Fig. 1.

Fig. 1

In TIA Portal it is not possible to define constants in the declaration part CONST/END_CONST of the SCL program code.

This is how you define constants in TIA Portal V13:

  • You define the local user constants in the block interface of an FC/FB under "Constant" and you can then use them in the block program. Here you must define a data type for the use constants.

Fig. 2
  • You define the global user constants, which are to be available CPU-wide, in the PLC tags in the "User constants" tab. Also when defining the global user constants you must define the data type.

Fig. 3

Only use local constants within a block. In this way the block remains universal and can be used in a library.

In TIA Portal V11 and V12 you can define global user constants. Refer to the information given in the Online Help when migrating projects from STEP 7 V5.5 to STEP 7 (TIA Portal).

Excerpt of the Online Help:
"In the TIA portal, symbolic constants cannot be declared in the block interface. If symbolic constants are declared in the original program, they are converted to global constant declarations and are available in the PLC tag table. Name conflicts are handled as below.

  • If both constants have the same value, a global constant is created with that value.
  • If the values are different, the two constants are renamed. The renaming is performed consistently at all points of usage."

Creation Environment
The screens in this FAQ response were created with STEP 7 (TIA Portal) V13.0 and STEP 7 V5.3.

Further Information
More rules and recommendations for programming are available in the Programming Style Guide for S7-1200/S7-1500 in Entry ID 109478084.



Security information
In order to protect plants, systems, machines and networks against cyber threats, it is necessary to implement – and continuously maintain – a holistic, state-of-the-art industrial security concept. Siemens’ products and solutions constitute one element of such a concept. For more information about industrial security, please visit