Siemens Industry Online Support
Siemens AG
Entry type: FAQ, Entry ID: 19106712, Entry date: 04/15/2010

How do you parameterize a structured data type in the IN_OUT area of an FB and a function call with an ARRAY variable?

  • Entry
  • Associated product(s)

Variables with structured data types are saved with transit parameters (IN_OUT) of the FB as reference with a 6-byte POINTER (48 bits) in the instance DB. This means that there is not a value, but a six-byte POINTER in the instance DB. This POINTER indicates the actual parameter; therefore, it is imperative that it is parameterized. STEP 7 identifies the following structured data types: "Date_and_Time", "String, Array", "Struct" and "UDT".

Fig. 01 contains an example of how to program indirect access to the first byte of this data type. This procedure from the example is for data backup.

Fig. 01

The 6-byte POINTER is loaded via the IN_OUT variable "Symbol_of_InOut". The number of the data block is then transferred from the 6-byte POINTER into a temporary variable "DB_Num". The DB is opened with this saved DB number via the statement "AUF DB[#DB_Num]" and then the address is loaded into address register 1.

The "+AR1" instruction interprets the value in ACCU1 as a number in the INT format, extends it with the correct +/- sign to 24 bits and adds it to the content of the address register. If the maximum range of the byte address is overshot or undershot (0 ... 65535), this has no effect, because the upper bits are truncated.

The statement "L B[AR1,P#0.0]" provides you with the saved data and correct address. If you were to use the statement "L Symbol_des_InOut[1]" instead of this example, then you would not load the saved data from the address register, but the data directly from the IN_OUT parameter. However, these values might have changed. Please also refer here to the relevant information in the STEP 7 Online Help under

  • "Avoiding errors when calling blocks".

The example described is valid only for DB areas, because otherwise the CPU goes into "STOP". Numbering with 0 (DB0) is not permitted.

The "InOutvar.zip" file includes a STEP 7 project with two S7 stations for the sample program described above:

  • Station: "Beispiel in deutsch" mit den deutschen Kommentaren
  • Station: "Example in English" with English comments

InOutvar.zip ( 222 KB )

Assign parameters to a function call with structured data types
The parameters of a structured data type (ARRAY and STRUCT) offer an efficient way of transferring larger, inter-related volumes of data between the calling block and the block being called. A field or a structure can be transmitted as a complete variable to a called function.

The variables of structured data types can only be saved in a data block or in the local data stack. Consequently, the actual parameter must be declared either in a data block (global or instance DB) or in the local data stack for the called block.

For the purposes of the transfer, a parameter of the same data type as the actual parameter being transferred must be declared in the called function. The supply of these parameters (data type: ARRAY, STRUCT, DATE_AND_TIME and STRING) must take place symbolically.

The LAD/STL/FBD editor checks the compatibility of the data types of the actual parameter and block parameter during transfer of parameters to a function. The actual parameter transfer to the called function is performed by a pointer with a DB number and area-crossing pointer. This pointer is created in the L-stack of the calling block by the CALL macro.

Fig. 02

The variables of a structured data type may only be saved in the local data stack (TEMP variable in the FC12) or in a data block (DB5).

Creation environment
The pictures and downloads in this FAQ were created with STEP 7 version V5.4.


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