Line loop

axBobSEaxBobSE Member Posts: 17
edited 2008-06-24 in Navision Financials
I seem to be missing a table referance somewhere.

I have a report with 2 dataItems salesInvoiceHeader salesInvoiceLine
the Header got x lines bound to it. On the data items I make a file that with the data from the tables.

salesInvoiceHeader salesInvoiceHeader
salesInvoiceLine salesInvoiceLine
salesInvoiceHeader - OnPreDataItem()
SETRANGE("Nummer",InvoiceNum); 

salesInvoiceHeader - OnAfterGetRecord()
...f.WRITE(record)...

salesInvoiceLine - OnPreDataItem()
SETRANGE("Bilagsnr.",InvoiceNum);

salesInvoiceLine - OnAfterGetRecord()
REPEAT
...f.WRITE(record)
UNTIL NEXT = 0;

This all works as intended (included it incase it was there I missed something)

I created a Body for the salesInvoiceHeader
with some Labels and TextFields and put the Sourcescr= salesInvoiceHeader.fields
(this is shown as I want with the data from the SalesInvoiceHeader)

Now the problem
I created a salesInvoiceLine Header with some labels in a line, and under that I created a body with a matching line containing textFields where I set the Sourcescr = salesInvoiceLine.field.

But I dont seem to have a referance to the salesInvoiceLine in my body
what am I missing to get the referance to the lines? into the SalesInvoiceLine body?

Answers

  • DenSterDenSter Member Posts: 8,304
    I bet it has something to do with the REPEAT UNTIL in the salesInvoiceLine dataitem. To get all the invoice lines into your file, all you have to do is put one f.WRITE(record) in OnAfterGetRecord, the report will do the looping for you. It will execute the OnAfterGetRecord trigger for all records in the filter.
  • axBobSEaxBobSE Member Posts: 17
    oh it had, when I removed the REPEAT/UNTIL it worked O:)

    Thanks DenStar.

    btw, REPEAT/UNTIL when would that be used, only if its a variable (tabel) your iterating through?
  • kinekine Member Posts: 12,562
    axBobSE wrote:
    oh it had, when I removed the REPEAT/UNTIL it worked O:)

    Thanks DenStar.

    btw, REPEAT/UNTIL when would that be used, only if its a variable (tabel) your iterating through?

    You need it when you are not in the report and you are not using the OnAfterGetRecord trigger. Because this loop is done automatically by the report...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • axBobSEaxBobSE Member Posts: 17
    ok, think I got it now, thanks again.
  • DenSterDenSter Member Posts: 8,304
    axBobSE wrote:
    Thanks DenStar.
    You're welcome :mrgreen: good to hear you got that to work

    You'd use REPEAT UNTIL for loops that you want to execute at least once, until the condition evaluates to TRUE

    For loops that you only want to run if a certain condition is TRUE (0 times or more) you'd use WHILE

    You don't need to use either one in a report, at least not for tables that you have a dataitem for, because the report will do the looping for you.

    Check the C/SIDE reference guide, under the help menu for more information about syntax, and a document called w1w1adg.pdf in the Doc folder on your product disc for more detailed application designer information.
Sign In or Register to comment.