STEP 7 V5.4: Recovering Lost Data Block and UDT Comments from an Online PLC
Affected controllers: SIMATIC S7-300, S7-400, C7, ET 200S, ET 200M, ET 200pro with classic S7-300/400 firmware
Required tool: SIMATIC Manager (component of STEP 7 V5.4)
Optional tool: S7-GRAPH, S7-SCL, S7-PDIAG add-on packages (for source-based recovery)
Symptom: Block title, block comment, network title, network comment, and symbol/inline comments inside a Data Block (DB) or User Defined Type (UDT) are empty after a fresh upload, a project move, or a hardware reconfiguration.
This technical reference documents the field-proven procedure to restore lost comments inside SIMATIC S7-300 and S7-400 Data Blocks and UDTs programmed with STEP 7 V5.4. The procedure exploits the fact that the offline project archive retains human-readable comment text, while the online PLC CPU only contains compressed machine code. By copying the live (comment-stripped) blocks from the online CPU into a comment-bearing backup project, the engineer effectively re-hydrates the live program with the missing documentation.
1. Problem Statement
After one of the following events, the offline STEP 7 V5.4 project suddenly shows empty Block Title, Block Comment, Network Title, Network Comment, and Symbolic Comment fields for one or more DBs or UDTs:
- A new project was created from the File > New Project wizard and blocks were uploaded with PLC > Upload Station to PG.
- The S7 program was dragged from an archive into a freshly created project (program-level move, not block-level move).
- Hardware was reconfigured with HW Config and the project was recompiled.
- The PC hostname was changed, breaking the path references inside the STEP 7 database.
- An older service pack (e.g. V5.4 SP2) opened a project last saved with V5.4 SP5, silently stripping long multi-line comments.
- The Options > Customize > Editor > Comments setting was unintentionally toggled off.
Despite the comments being absent, the program logic in OB1, FB, FC, and DB still compiles and executes. Only the documentation layer is gone. The PLC itself never stored those comments in the first place - it only stores compressed block content in load memory (MMC card or internal flash) and in work memory (RAM).
2. Why Comments Disappear in STEP 7 V5.4
STEP 7 V5.4 stores the user project in two distinct locations, and the comments live only in one of them:
| Storage Location | Contents | Contains Comments? |
|---|---|---|
| Offline PG project (S7P/S7L/S7R/S7D files) | Full blocks, symbol table, source files, hardware configuration, and the entire comment layer | Yes - stored in the offline database as ASC strings |
| Online PLC load memory (MMC / RAM) | Compiled, compressed block content only; SDBs for hardware; system data | No - all comment fields are stripped during compilation to MC7 code |
| Source files (SCL/STL/LAD/FBD source in the Sources folder) | Human-readable text representation including comments and pragmas | Yes - the most durable copy when present |
The MC7 code inside the CPU is the binary result of the compiler and contains no comment strings whatsoever. Uploading a station therefore yields blocks with empty comment fields. The original comment text only survives in the offline .s7d file or in STL/SCL source files that were saved to disk using File > Generate Source.
Consequences:
- If the only copy of the project is the CPU (no recent backup, no source files), comments are unrecoverable and must be re-typed.
- If a backup exists, the backup's offline database contains the comments. The CPU contains the current code. The two must be merged.
- If a source file exists, regenerating the blocks from the source restores the comments without touching the CPU.
3. Recovery Strategy Decision Matrix
| Available Artifact | Recommended Method | Comments Restored? | Code Stays Current? | Risk Level |
|---|---|---|---|---|
| Old backup with comments + Online PLC accessible | Method A: Online/Offline Block Merge | Yes | Yes | Low |
| Old backup with comments + PLC not accessible | Method B: Selective DB/UDT Copy between archives | Yes (DBs/UDTs only) | No (revert to backup code) | Medium |
| STL/SCL source file present, no usable backup | Method C: Re-compile from source | Yes (only blocks present in source) | No (only what source contains) | Low |
| No backup, no source, only online PLC | Manual re-insertion of comments | No - re-type from documentation | Yes | Time-consuming |
4. Prerequisites
Before executing any of the recovery procedures, confirm the following:
- STEP 7 V5.4 (any SP) is installed on the engineering station.
- You have read rights to the project folder containing the comment-bearing backup.
- You have physical or routed (e.g. through a CP343-1 Lean) online access to the target CPU with PG/PC interface set to TCP/IP, MPI, or PROFIBUS as appropriate.
- The PG/PC interface is correctly assigned in Options > Set PG/PC Interface (e.g.
TCP/IP -> Intel(R) PRO/1000...for an S7-300 with CP343-1, orPC Adapter (MPI)for the classic MPI cable). - No write-protected MMC is currently inserted that would prevent the CPU from accepting a download.
- You have created a fresh archive of the current (comment-stripped) project before any recovery action.
.zip file on a network share with a timestamped filename (e.g. PreRecovery_20240115_1430.zip).5. Solution A - Online/Offline Block Merge (Primary Method)
This is the field-proven technique. The principle is:
- Open the comment-bearing backup in SIMATIC Manager. This is the container for comment text.
- Establish an Online view of the same CPU. The online view is the container for the most up-to-date MC7 code.
- Copy the online blocks (excluding SDBs and system blocks) into the offline project's Blocks folder with Overwrite enabled.
- Save the resulting project - it now contains the latest code with all the original comments.
5.1 Procedure
- Insert the STEP 7 V5.4 installation DVD or mount the ISO. Open SIMATIC Manager from the Windows start menu: Start > SIMATIC > SIMATIC Manager.
- From the menu, choose File > Retrieve and browse to the comment-bearing backup file. Default extension:
*.zipor the original archive folder. - Extract the project to a new working directory, e.g.
D:\STEP7\Recovery\Project_With_Comments. - In the project tree on the left, expand SIMATIC 300 Station (or SIMATIC 400 Station) > CPU > S7 Program > Blocks. Verify that the DBs and UDTs still show their comments by double-clicking one - the Block Title and Block Comment rows at the top of the editor should contain text.
- Click the Online button in the toolbar (or press Ctrl+Alt+O). The project view switches to the Online window showing the live CPU contents.
- Navigate to Online > [Your CPU] > S7 Program > Blocks. You will see all blocks currently loaded on the CPU. Comment fields will appear empty - this is expected.
- Select all user blocks. Use the menu Edit > Select All, then deselect the system blocks (SDBs, SFBs, SFCs, SFB-instances inserted as system) by holding Ctrl and clicking them. The blocks you want are:
- OB1, OB10, OB35, OB100, OB101, OB102 (organization blocks)
- FB1 ... FBxxx (function blocks)
- FC1 ... FCxxx (functions)
- DB1 ... DBxxx (data blocks)
- UDT1 ... UDTxxx (user defined types)
- Any instance DBs (DBxxx associated with an FB)
- Right-click the selection and choose Copy (or Edit > Copy, or
Ctrl+C). - Click the Offline button (or Ctrl+Alt+O again) to return to the offline project view.
- Right-click the Blocks folder of the offline project and choose Paste (or
Ctrl+V). - A dialog will appear for each block: "Do you want to overwrite the existing block <DBxxx>?". Click Yes to All to accept the overwrite of every user block.
- Wait for the paste to complete. SIMATIC Manager will show a progress bar in the status line.
- Save the project: File > Save (or
Ctrl+S). - Re-archive the project immediately: File > Archive and store the new zip file with a timestamped name.
5.2 Verification After Method A
- Double-click any DB (e.g. DB100) in the Blocks folder. The Block Title and Block Comment fields at the top of the data view must contain text.
- Open the Declaration View tab. Each row's Comment column must show the original description (e.g. "Motor speed setpoint in RPM").
- Open a UDT (e.g. UDT20). The UDT comment should be intact and the individual member comments should be present.
- Open FB1, navigate to each network, and verify the Network Title and Network Comment rows are filled in.
- Switch to Online view and compare: the online blocks should now have empty comment fields (because the CPU strips them) but the program logic must match the offline blocks exactly. Use PLC > Compare for a detailed online/offline comparison.
6. Solution B - Selective DB/UDT Copy Between Archives
When the PLC is not reachable but two project archives exist on disk (one with comments, one with the latest code), you can copy DBs and UDTs directly from the older comment-bearing archive into the newer one. The constraint is that the DB/UDT structure must be identical between the two archives, or the paste will be rejected with the error "The block structure differs".
6.1 Procedure
- Retrieve both archives into separate working folders:
-
D:\STEP7\Archive_Old_WithComments\- older archive, comments intact -
D:\STEP7\Archive_New_Current\- newer archive, comments missing
-
- Open SIMATIC Manager with the new archive.
- Open a second instance of SIMATIC Manager by launching it again from Start > SIMATIC > SIMATIC Manager. Open the old archive in the second instance.
- In the old-instance window, navigate to the source Blocks folder. Select the DBs and UDTs you want to copy (e.g. DB10, DB11, DB20, UDT1, UDT2).
- Right-click > Copy, or press
Ctrl+C. - Switch to the new-instance window, click on its Blocks folder, and Paste (
Ctrl+V). - Confirm Yes to All when prompted to overwrite.
- Open a DB to verify that the comment text now appears in the Block Comment and per-row Comment columns.
7. Solution C - Re-compile From STL or SCL Source
If a source file was generated before the comments were lost, it is the most reliable recovery artifact because it is plain text and can be opened in any editor for inspection.
7.1 Locate the Source
- In SIMATIC Manager, check the Sources folder under S7 Program. Look for files of type STL source or SCL source.
- If a source file exists with a name such as FB100_SOURCE or ALL_BLOCKS, double-click it to open in the STL or SCL editor.
- Verify that the source contains the
//STL comment markers or the SCL(*...*)and//comment blocks.
7.2 Regenerate the Block
- From the source editor, choose File > Compile (or press
Ctrl+Bin the STL source editor). - STEP 7 will create a new block in the Blocks folder that matches the source. The block retains every comment from the source.
- Open the new block to verify the comments appear.
- Delete the old (comment-stripped) block if the new one has the same number, accepting the overwrite prompt.
8. UDT-Specific Recovery Notes
UDTs (User Defined Types) behave differently from DBs in two important ways:
| Aspect | Data Block (DB) | User Defined Type (UDT) |
|---|---|---|
| Comment field location | Header + per-row comments in Declaration view | Header + per-member comments in Declaration view |
| Dependency | Standalone or referenced UDTs | Referenced by any DB that uses the UDT as a row type |
| Paste into Blocks folder | Allowed (creates DB) | Allowed (creates UDT) |
| Paste into Declaration view of a DB | n/a | Allowed via Insert > UDT in the DB declaration |
The original symptom report from the user "Eddie" mentioned that he could not enter the UDT under the Type column of a DB declaration. This happens when the UDT is missing from the target project's Blocks folder. Fix it by first pasting the UDT (from the comment-bearing backup) into the Blocks folder of the target project, then returning to the DB declaration to insert the UDT reference.
8.1 Procedure to Recover a UDT and Re-link It
- Open the comment-bearing backup in a second SIMATIC Manager instance.
- Locate the UDT (e.g. UDT5) in Blocks.
- Copy with
Ctrl+C. - Paste into the new project Blocks folder.
- Open the DB that references UDT5. In the Declaration View, the rows that were previously "UDT5" in the Type column will now resolve correctly because the UDT is present.
- Save the DB and verify that the UDT's row comments appear inline in the data view.
9. Common Pitfalls and Edge Cases
9.1 "The block has a different interface" error during paste
The DB or UDT structure has changed between archives. The paste is blocked to prevent data corruption. Do not force it. Either:
- Use Method A (Online/Offline merge) so the live code is the destination, not the source.
- Manually re-create the missing comments in the new structure.
9.2 Comments disappear again after Save
STEP 7 V5.4 with no service pack installed has a known issue where comments containing non-ASCII characters (e.g. German umlauts, Cyrillic, CJK) are lost on save. Apply the latest service pack from the Siemens Industry Online Support portal.
9.3 Online block size smaller than offline block
The online block in Online > Blocks is always smaller than the offline block in Blocks because comments are stripped. This is normal and not a sign of corruption.
9.4 Project language
If the project was created in German (object language = Deutsch) and the PG has only the English language pack installed, comments may appear empty. Switch the object language via Options > Language for Display Devices and re-open the project.
9.5 PC hostname change
STEP 7 V5.4 stores absolute paths in the s7lg0000.lis index file. If the PC hostname changed, comments may fail to load. Either rename the PC back to the original name or use File > Reorganize to rebuild the index.
10. Process Flow Diagram
11. Prevention and Long-Term Best Practices
-
Archive before every modification. Use File > Archive and keep at least the last 10 archives in a revision-controlled folder structure (e.g.
\\fileserver\projects\PlantA\S7-400_Batch3\2024-01-15_1430.zip). -
Generate STL or SCL source files for every FB, FC, DB, and UDT after each approved revision. Sources are plain text and survive backup media degradation far better than binary
.s7dfiles. - Configure the STEP 7 autosave option via Options > Customize > General to back up working files every 15 minutes to a dedicated folder.
- Use the Symbol Table (S7T) for as much documentation as possible. Symbols are stored separately and are easier to recover than inline block comments.
- Avoid creating new projects from uploaded stations unless absolutely necessary. Always open the existing offline project and download it instead.
- Apply the latest STEP 7 V5.4 service pack from the Siemens Industry Online Support portal to address the non-ASCII comment corruption issue.
- Enable the PG access protection on the CPU to prevent unauthorized stations from accidentally uploading the project without comments.
12. Reference: Where STEP 7 V5.4 Stores Comments
For a deeper understanding of the storage mechanism, the comment strings are stored in these locations within a STEP 7 V5.4 project:
| File | Location in Project | Comment Type Stored |
|---|---|---|
*.s7d |
Blocks subfolder | Block title, block comment, network title, network comment |
*.s7d |
Blocks subfolder (inside DB/UDT) | Per-row declaration comment |
*.s7p |
Project root | Project metadata, last editor |
*.s7l |
Project root | Symbol table, hardware configuration references |
*.s7r |
Project root | User text and revision metadata |
| Source files (STL/SCL) | Sources subfolder | All comments in plain text via // or (*...*)
|
For authoritative documentation, refer to:
- Siemens Industry Online Support - main portal for STEP 7 manuals, firmware, and service packs
- STEP 7 V5.4 Programming and Operating Manual (entry ID 109742403) - covers the online/offline project model
- STEP 7 V5.4 Reference Manual: Software Installation (entry ID 1117397) - covers service pack contents and bug fixes
- SIMATIC S7-300 CPU 31xC and CPU 31x Operating Instructions - hardware-level online behavior
- SIMATIC S7-400 CPU 41x Operating Instructions - hardware-level online behavior
13. Frequently Asked Questions
Does the online PLC CPU actually store the comments I typed in the editor?
No. The CPU stores only the compiled MC7 code. All comment text (block title, block comment, network title, network comment, declaration comment) is stripped during compilation and lives exclusively in the offline PG project database (.s7d files) or in STL/SCL source files.
After Method A, will the online CPU now contain the comments if I download the project?
No. The comments remain in the offline project only. A Download to the CPU uploads the compiled MC7 code without comments. The comment field is a property of the offline database, not of the CPU load memory. This is by design and applies to all STEP 7 versions including TIA Portal.
I get the error "Block could not be pasted - inconsistent interface" when I try Method B. What now?
This means the DB or UDT structure differs between the two archives. Do not force the paste. Switch to Method A (Online/Offline merge) which uses the live CPU as the source and avoids structural conflicts, or manually re-enter the comments in the new structure.
My STEP 7 V5.4 was installed without any service pack and comments vanish on Save. Why?
STEP 7 V5.4 base release has a known issue with comments containing non-ASCII characters (umlauts, accented characters, CJK). Apply the latest V5.4 service pack (V5.4 SP6 or later) from the Siemens Industry Online Support portal, which fixes this defect.
Can I open a STEP 7 V5.4 project in TIA Portal and keep the comments?
Yes, but with caveats. Use TIA Portal > Project > Migrate project to import a STEP 7 V5.4 project. Comments, symbol table entries, and block titles are migrated. However, complex multi-line network comments may be truncated. Always verify the migrated project on a test workstation before commissioning.
What is the safest long-term backup strategy for STEP 7 V5.4 projects?
Use a three-layer approach: (1) File > Archive the full project into a timestamped .zip after every approved change, retained in version control; (2) File > Generate Source for all FB, FC, DB, and UDT, storing the resulting .awl or .scl files in the same version control repository; (3) Periodically upload the project to a second offline PG and verify the round-trip integrity by re-downloading to a test CPU.