Report Layout Question

ixyatlixyatl Member Posts: 4
I have a question about how to handle a peculiar report layout. I am a novice to NAV and I have been asked to create a report that has two different styles of pages with the second page repeating as necessary. There are three tables associated with the report and they are Header, DetailA and DetailB. The basic layout of the pages are as follows:

Page 1
Header data
first two rows of DetailA data
more data from Header
first four rows of DetailB data
more data from Header
more data from first two rows of DetailA
more data from Header
more data from first four rows of DetailB

Pages 2 - n
more data from Header
next two rows from DetailA data
more data from Header
next ten rows from DetailB data
more data from Header
more data from next two rows of DetailA data
more data from Header
more data from next ten rows of DetailB data

In a nutshell, Header data is sprinkled all over the two different kinds of pages. The first page can contain up to two rows from DetailA and four rows of DetailB. If, and only if, there are more than two rows of data from DetailA or more than four rows of data from DetailB, then we need to add pages 2-n as required.

I've found that I can use the MaxIteration property of the sections to limit the number of times the data is looped through. If I use the PreDataItem event I'm pretty sure that I can set the cursor position to the correct record so that each subsequent call to the other pages pick up where the previous pages left off -- unless it doesn't work that way, I haven't gotten that far. I can use CurrReport.QUIT to stop the report after whatever page I need if I've run out of DetailA and DetailB records, so that's not a problem. I can even use variables to print the correct page numbers on pages 2-n if CurrReport doesn't compute them properly. I'm also of the understanding that I can use CurrPage.NEWPAGE to create new pages whenever I need to, so that shouldn't be an issue.

What I have so far is a functional Page 1 that does exactly what I want it to. It's not pretty, but it works. I basically made the sections as:

Header
DetailA
Header2
DetailB
Header3
DetailA2
Header4
DetailB2

There's no indenting on the sections because I found that when I did so there were extra loops being performed and the report was several pages long for page one. This makes sense because each parent section would re-call all of the indented child sections, which is not ideal for me. All of my OnPreDataItem routines fetch the detail and header rows after the initial selection from the query form presented to the user.

Where I'm stuck is how to go about creating pages 2-n. As I said, I think I can use MaxIterations and some OnPreDataItem code to limit the number of rows displayed on each page and to set the cursor to the correct location within the dataset, but I can't quite wrap my head around how to use the tools within NAV to make this work. I'm not asking for anyone to write anything for me, I'd like to work through this so that I can get some learning done. I have a Programming Microsoft Dynamics NAV book that I've read (and re-read the report section) and I've gone through w1w1adg.pdf several times and I'm at a loss. A gentle prod in the correct direction or, since I'm not familiar with NAV, a built-in report that uses the same sort of process (multiple different pages) would be great.

Thanks in advance for any help you can provide!

Scott

Comments

  • matttraxmatttrax Member Posts: 2,309
    Try adding CURRREPORT.SHOWOUTPUT(CurrReport.PageNo > 1) to the sections for pages 2 to N. Since it's already a mess and complicated to begin with, I think that's the best place for you to start.
  • ixyatlixyatl Member Posts: 4
    I'll look at that command to see if it can be of any avail. As a PS to anyone else reading, if you need something to be more clearly explained, feel free to ask me about this little disaster I'm working on -- I'm happy to clarify the above nonsense.

    Also, I was considering starting from scratch (again) and using a header as Page 1 and implementing something with footers for Pages 2-n. I'd have to use labels and assign the values from the DetailA and DetailB rows to those labels via code, but it might work. I'd have a similar problem where I'd have to re-set the labels to their values each time a new page was printed, otherwise it'd just print the same thing over and over again. This idea sounds interesting to me, I just need to figure out how to add the header and footer sections and then determine a way to loop the footer while changing its values each time. If the header and footer are both defined as 8.5"x11" in size then it may work.

    Any thoughts on this method?

    Scott
  • jversusjjversusj Member Posts: 489
    i have no idea as to what you are trying to build, but could you possible get away with using a set of variable Arrays, and make 1 "page 1" header that is huge, but in that section you lay out specific elements of the array exactly where you need them? you would then programmatically build the arrays (which values go into which position) in OnAfterGetRecord of the main dataitem. this will not solve all of your problems (how big should the arrays be for instance), but maybe it can get you started?

    just thinking from another angle...
    kind of fell into this...
  • ixyatlixyatl Member Posts: 4
    Sorry to bring this up again, I was pulled away from the project for a while to work on something else but now I'm back and still have some issues.

    Page one of the report, which shows the first four records, works just great as an oversized header section; subsequent pages are not working as well. I'm just using the body to repeat each block of ten records that represent the rest of the data. My issue comes in when there are more than 14 rows in total to display. If there are 14 or less, I get one page that is the header with the first four and then a second page (the body) which has between one and ten rows (depending on how many were left to display).

    I have logic set up to repeat records 15..n within the OnPreSection event of the body section. I'm sure that the code works and will reset the values of the array elements to what I need to continue processing. The problem is that I cannot get that event to fire more than once. In the OnPostSection event I put a statement that calls CurrReport.NEWPAGE if there are more records to display, thinking that this would create a new body section that would fire off another instance of OnPreSection and, as a result, parse through more rows of the data. This does not work at all, even though I can verify that the code in the OnPostSection fires and calls CurrReport.NEWPAGE.

    How can I programmatically generate a new page that will fire off the events for that body section? The header section is set to only print once and there is no footer, since there really wouldn't be a difference between body or footer for this exercise. Is the problem that the report's "Record" is a parent record (one row, selected the usual way -- ReqFilterFields) and the data being displayed are the child records for this parent object? Since there's only one parent object I'm guessing that the report thinks that there's only one body section to display? Either way, I just can't seem to figure out how to get a new instance of the body section to be created via code.

    If this was just about any other development environment I'm confident that this report would've been completed ages ago, I just can't seem to wrap my head around how convoluted coding for NAV is.
Sign In or Register to comment.