Informix Error -4310: Files cannot be printed within report headers or trailers.
Cause and resolution
Files cannot be printed within report headers or trailers.
4GL needs to know how many lines of space will be devoted to page headers and trailers; otherwise, it does not know how many detail rows to allow on a page. Since it cannot predict how many lines are in a file, it forbids printing a file in a header or trailer. You can write PRINT statements in the control blocks for FIRST PAGE HEADER, PAGE HEADER, and PAGE TRAILER. However, you cannot write PRINT FILE statements in these control blocks.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-4310 fires when PRINT FILE appears inside a FIRST PAGE HEADER, PAGE HEADER, or PAGE TRAILER section — per the official guidance, 4GL needs to know header/trailer line counts in
advance, and it can't predict how many lines a file contains.
- A
PRINT FILEstatement inside a header/trailer section, per the official guidance — the direct, only cause.
Solutions / Resolution
- Remove the
PRINT FILEstatement from the header/trailer section, per the official guidance — plainPRINTstatements remain allowed there.
Examples
PRINT FILE inside a page header
PAGE HEADER
PRINT FILE "letterhead.txt"
-- -4310: file line count isn't statically known
Corrected
Print a fixed, known number of lines instead, or move the file's content into the report body where its line count doesn't need to be predicted in advance.
Diagnostic Checks
- Check every header/trailer section for a
PRINT FILEstatement, and remove or relocate it.
Related Errors / Related Topics
- -4309 — "Printing cannot be done within a loop or CASE statement contained in report
headers or trailers." A related header/trailer restriction, about loops/
CASErather thanPRINT FILEspecifically.
PRINT FILE appears in a header/trailer section, which isn't allowed — remove or relocate it.