Multiple CONDITION Command: Incorrect Solution

The example in Figure Example of INCORRECT Solution demonstrates how two CONDITION commands can interact to give unintended results. Specifically, one CONDITION command causes a change of page format and then a second CONDITION command inspects a field with a WHEN CHANGE subcommand.

The purpose of condition:

NEWREP
Starts a new report on a new sheet of paper whenever the specified field changes and jogs the output so the report can be easily located.
SHIFTB and SHIFTF
Handle the situation where all four subpages of the front (or back) contain data.

In this situation, the objective is to change the print direction of the text on the page.

In the situation where both conditions seem to be true at the same time, the results may be unexpected.

Note: Condition SHIFTB (or SHIFTF) takes effect after the current subpage and therefore precedes the before subpage processing defined by condition NEWREP. Because condition SHIFTB results in starting a new page format, condition NEWREP returns a false value, and the expected new report processing is not performed.

Example of INCORRECT Solution

FORMDEF XMPICO OFFSET 0 0 DUPLEX RTUMBLE JOG YES REPLACE YES;
  COPYGROUP CG1;
        OVERLAY OVLY1;
        OVERLAY OVLY2;
        SUBGROUP       OVERLAY OVLY1 FRONT;
        SUBGROUP       OVERLAY OVLY2 BACK ;
 
PAGEDEF XMPICO REPLACE YES;
        FONT GT24;
        FONT GT12;
 
        /* Definition of pageformat for front side */
        PAGEFORMAT PFFRONT WIDTH 11 IN HEIGHT 8.5 IN DIRECTION UP;
SETUNITS 1 PELS 1 PELS LINESP 16 LPI;
          PRINTLINE REPEAT 1 CHANNEL 1 FONT GT24 POSITION 75 188;
          CONDITION NEWREP START 8 LENGTH 3
            WHEN CHANGE BEFORE SUBPAGE COPYGROUP CG1 PAGEFORMAT PFFRONT;
          PRINTLINE REPEAT 40 FONT GT24 POSITION 75 NEXT;
          ENDSUBPAGE;
 
          PRINTLINE REPEAT 1 CHANNEL 1 FONT GT24 POSITION 1377 188;
          CONDITION NEWREP START 8;
          PRINTLINE REPEAT 40 FONT GT24 POSITION 1377 NEXT;
          ENDSUBPAGE;
 
          PRINTLINE REPEAT 1 CHANNEL 1 FONT GT24 POSITION 75 1102;
          CONDITION NEWREP START 8;
          PRINTLINE REPEAT 40 FONT GT24 POSITION 75 NEXT;
          ENDSUBPAGE;
 
          PRINTLINE REPEAT 1 CHANNEL 1 FONT GT24 POSITION 1377 1102;
          CONDITION NEWREP START 8;
          CONDITION SHIFTB START 1 LENGTH 1
            WHEN GE X'00' AFTER SUBPAGE NULL PAGEFORMAT PFBACK;
          PRINTLINE REPEAT 40 FONT GT24 POSITION 1377 NEXT;
          ENDSUBPAGE;
 
        /* Definition of pageformat for back side    */
        PAGEFORMAT PFBACK WIDTH 8.5 IN HEIGHT 11 IN DIRECTION ACROSS;
        SETUNITS 1 PELS 1 PELS LINESP 8 LPI;
          PRINTLINE REPEAT 1 CHANNEL 1 FONT GT12 POSITION 75 61;
          CONDITION NEWREP START 8;
          PRINTLINE REPEAT 40 FONT GT12 POSITION 75 NEXT;
          ENDSUBPAGE;
 
          PRINTLINE REPEAT 1 CHANNEL 1 FONT GT12 POSITION 75 1335;
          CONDITION NEWREP START 8;
          CONDITION SHIFTF START 1 LENGTH 1
            WHEN GE X'00' AFTER SUBPAGE NULL PAGEFORMAT PFFRONT;
          PRINTLINE REPEAT 40 FONT GT12 POSITION 75 NEXT;
          ENDSUBPAGE;