Subscribe for automatic updates: RSS icon RSS

Login icon Sign in for full access | Help icon Help
Advanced search

Pages: [1]
  Reply  |  Print  
Author Topic: Need Statement  (Read 10926 times)
Rao S.
Posts: 2


« on: January 07, 2010, 05:24:32 pm »

Hi,

How to use need statement  in Genero Report Designer. 
Any suggestions are greatly appreciated.
Thanks in advance.

Thanks,
Rao
Reuben B.
Four Js
Posts: 1049


« Reply #1 on: January 08, 2010, 01:57:35 am »

Hi,

How to use need statement  in Genero Report Designer. 
Any suggestions are greatly appreciated.
Thanks in advance.

Thanks,
Rao

Do you mind giving an example of what you are trying to achieve.  The answer may vary depending on the context.

The technique for the equivalent of

ON EVERY ROW
   NEED 3 LINES
   PRINT line1
   PRINT line2
   PRINT line3

or

BEFORE GROUP OF group
   NEED 3 LINES
   PRINT header

ON EVERY ROW
   NEED 2 LINES
   PRINT detail

AFTER GROUP OF GROUP
   PRINT total

is different.

Product Consultant (Asia Pacific)
Developer Relations Manager (Worldwide)
Author of https://4js.com/ask-reuben
Contributor to https://github.com/FourjsGenero
Rao S.
Posts: 2


« Reply #2 on: January 08, 2010, 03:29:08 pm »

Hi Reuben,

It is the same technique but I am not able to achieve the correct output using with Genero Report Designer (4rp file).
I have attached the PDF output file. You can see output in Page 4 of PDF file.

Thanks,
Rao

* Report3.pdf (45.72 KB - downloaded 1251 times.)
Reuben B.
Four Js
Posts: 1049


« Reply #3 on: January 11, 2010, 12:29:29 am »

Hi Rao,

To make sure I understand correctly, the situation you are trying to avoid is that on Page 4 where you have the group heading
"Facility:WESTERN LANDFILL" as the last item on the page, and then Page 5 starting with the detail.  With 4GL this was acheived by something like ...

BEFORE GROUP OF facility
   NEED 2 LINES
   PRINT "Facility: ", facility.name

ON EVERY ROW
   PRINT ...

... the end result being that a group heading was never displayed as the last line.

I have been discussing this situation recently with the developers as I have a similar case for one of my clients.

The technique I came up with was to add an empty layout node as the first element of the group

Group facility
   Vertical Box (Layout Node)  <-- Add this
   Facility Header
   OnEveryRow


that would have the following properties
X-size=1cm (any value greater than zero)
Y-size=rest>length("M")*2?0:rest 

What is this saying ... length("M")*2 equals the amount of vertical space required to render 2 lines (substitute 2 for the value in your NEEDS X LINES),

rest is the amount of space left to draw in the page.

hence rest>length("M")*2 returns TRUE if there is more space left on the page than is required to draw 2 lines, and FALSE otherwise.

So if it returned TRUE, we would set the Y-size of the empty layout box to be 0 and it wouldn't be rendered.  If it returned FALSE, it would be rendered and would take up the rest of the remaining space on the page.  Whatever was printed after it would be printed on the next page (hence why the empty layout box is the first child element of the group).

An issue with this technique is that length("M") is an educated guess at the space required to draw a line. It performs its calculation using the current font characteristics.  When you start having different font characteristics on each line, or lines of variable height, the calculation is not correct.  Note: you have the same issue using width("M")*20 to calculate column width.  If you change the font characteristics of the heading, the column headings may get wider when the detail headings don't, and the columns no longer match up.

The developers illustrated another technique to me which isn't a literal interpretation of NEEDS X LINES but I think works quite well to acheive a similar effect.  Structure your report so that the report structure is

Group facility
   Vertical Box (Mini Page)
      Facility Header
      OnEveryRow
         LineDetail

What now happens is that the layouter will attempt to keep a group together on one page where possible.  So not only will a page break occur so that the WESTERN LANDFILL facility is on one page, but if you look at Page 1/2, the Belle Glade Transfer Station won't start printing on Page 1 but will start on Page 2.  In fact looking at the size of the details for each group, your report will be such that no groups will start on one page and finish on a second page.

This technique isn't perfect as it can lead to the user thinking the report has ended when it hasn't due to the amount of whitespace that can appear on a page.  Also I was having trouble with totals.  Say a group including totals takes up 1 page + 1 line.  I end up with the totals on the second page all on their own wheras in 4GL I'd have

ON EVERY ROW
   NEED 2 LINES
   PRINT detail

AFTER GROUP OF
   PRINT group_total.*

so that a total was never the first line on a page.

Hope that helps, let us know what method you end up using.

Reuben



Product Consultant (Asia Pacific)
Developer Relations Manager (Worldwide)
Author of https://4js.com/ask-reuben
Contributor to https://github.com/FourjsGenero
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines