Hide lines in report with No. = 'XYZ-00*'

aishah
aishah Member Posts: 2
Hi, I'm using Navision 4.0 sp1. In a report, I have a roundloop of table 39 (Purchase Line). In the report, how do I hide lines with "No." = 'XYZ-00*' ( * means there might be other chararcter at the back)?

If the No. = 'XYZ-0011*' or 'XYZ-0099', the line will not appear.

However, if the Document No = 'XYZ-0900', the line will appear.

Can anyone help me with the coding?

RoundLoop - On AfterGetRecord()

SETRANGE(Number,1,PurchLine.COUNT);

intPos := 1;

IF Number = 1 THEN

PurchLine.FIND('-');

ELSE

PurchLine.NEXT;

IF (PurchLine."No." = ???????? ) THEN // I try (PurchLine."No." = 'XYZ-09*' ) but not success.

intPos := intPos + 1;

IF (PurchLine."No." = ???????? ) THEN // I try (PurchLine."No." = 'XYZ-00*' ) but not success.

CurrReport.BREAK; <--I just break the report when it found 'XYZ-00*'

END;

Comments

  • manlue
    manlue Member Posts: 30
    Hi,

    try to compare only the first part of the number with your search string. Like
    IF COPYSTR(PurchLine."No.",1,6) = 'XYZ-00' THEN...
    

    With this COPYSTR you take a substring from Position 1 and Length 6 to compare...
  • kine
    kine Member Posts: 12,562
    NEVER use Magic constants in the code. This is not good. Try to solve it in some systematic way. Like add some setup for the filter, use it etc...

    Like why not apply the filter on the record variable directly? Why you are iterating through all lines, when you want only which are different form your filter? Why you are using CurrReport.BREAK when you want to just SKIP the record?
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • matttrax
    matttrax Member Posts: 2,309
    Yeah, a SETFILTER("No.", '<>XYZ-00*') will work just fine.