Ask Reuben

GRW 4gl Gather Data

Why does SKIP TO TOP OF PAGE not work in my GRW Report?

When working with GRW Reports, as per the architecture there are two inputs into the Genero Report Engine, the design of the report in the .4rp file, and the DataStream coming from in our case the 4gl program.  Their is a simple mantra to remember

  • the 4gl developer gathers the data
  • the 4rp designer lays out the data.

The 4gl program that creates the DataStream should not contain any syntax that “lays out” the data.  This means the REPORT block should NOT contain instructions like

SKIP TO TOP OF PAGE
NEEDS x LINES
PAGE HEADER
PAGE TRAILER

These will either be ignored or potentially cause confusion with instructions in the 4rp that do the equivalent.

This concept of gathering data in the 4gl program also extends to what variables you send to the report engine.

  • avoid rounding, send as much precision as you can and allow the Report Designer to specify what if any rounding takes place.
  • send all variables so the report developer can make a choice.  A good example of this is with net and gross figures, send both figures and the developer can choose what figure to use.

If you have a system flag that controls precision, controls what figures are used (net or gress) etc, include that system flag in the DataStream.  We should see …

PRINT x.nett, x.tax, x.gross, system.print_tax_inclusive_flag

as opposed to

IF system.print_tax_inclusive_flag = "Y"
    PRINT x.gross
ELSE
    PRINT x.nett
END IF

I found that a good 4rp program ended up looking like

FIRST PAGE HEADER
    ...
    PRINT report.*

BEFORE GROUP OF header1
    ...
    PRINT header1.*

BEFORE GROUP OF header2
    ...
    PRINT header2.*

ON EVERY ROW
    ...
    PRINT detail.*

AFTER GROUP OF header2
    LET header2_total.field_name = GROUP SUM(header2.field_name)
    PRINT header2_total.*

AFTER GROUP OF header1
    LET header1_total.field_name = GROUP SUM(header2.field_name)
    PRINT header1_total.*

ON LAST ROW
    LET report_total.field_name = SUM(total.field_name)
    PRINT report_total.*

… that is gathering the information at each step and printing it all in a single PRINT at the end of the block.