Informix Error -4420: The number of lines printed in the IF part of an IF-THEN-ELSE statement of a header or trailer clause must equal the number of lines printed in the ELSE part.
Cause and resolution
The number of lines printed in the IF part of an IF-THEN-ELSE statement of a header or trailer clause must equal the number of lines printed in the ELSE part.
4GL needs to know how many lines will be filled in header and trailer sections (otherwise it could not know how many detail rows to put on the page). Because it cannot tell which part of an IF statement will be executed, it requires that both produce the same number of lines of output.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-4420 fires when an IF-THEN-ELSE inside a header/trailer clause prints a different number of
lines in each branch — per the official guidance, 4GL needs to know header/trailer line counts
in advance, and since it can't predict which branch executes, both must produce the same
number of output lines.
- An
IFbranch and itsELSEbranch printing different numbers of lines within a header/trailer, per the official guidance — the direct, only cause.
Solutions / Resolution
- Make both branches print the same number of lines, adding blank
PRINTstatements to the shorter branch if needed.
Examples
Mismatched line counts between IF and ELSE
PAGE HEADER
IF include_subtitle THEN
PRINT "Title"
PRINT "Subtitle"
ELSE
PRINT "Title"
-- -4420: ELSE prints one line, IF prints two
END IF
Corrected
PAGE HEADER
IF include_subtitle THEN
PRINT "Title"
PRINT "Subtitle"
ELSE
PRINT "Title"
PRINT ""
END IF
Diagnostic Checks
- Count the
PRINTstatements in each branch of everyIF-THEN-ELSEinside a header/trailer, and make both counts equal.
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
PRINTinside loops/CASErather than mismatchedIF/ELSEline counts.
An IF/ELSE pair inside a header/trailer prints different line counts — make both branches
print the same number of lines.