Dear folks, I posted this a few days ago but the situation has changed. I post my problem actually.
I've created a report that shows information of an item. This report prints automatically when you are in sales ordes and push Register+Print. For it I put on Codeunit 82 Sales Post+Print the following code:
salesline.RESET;
salesline.SETRANGE("Document Type", SalesHeader."Document Type");
salesline.SETRANGE("Document No.", SalesHeader."No.");
salesline.SETRANGE("Sell-to Customer No.", SalesHeader."Sell-to Customer No.");
IF salesline.FIND('-') THEN BEGIN
salesline.CALCFIELDS(serial);
IF salesline.serial='SERIE' THEN REPEAT
RptNumserie.SETTABLEVIEW(SalesShptHeader) ;
RptNumserie.USEREQUESTFORM := FALSE;
RptNumserie.RUNMODAL ;
CLEAR(RptNumserie) ;
UNTIL salesline.NEXT=0;
END;
saleslines is Sales Line table
RptNumserie is the report
serial field is a flowfiled (from Item table)
from saleslines table and SERIAL is an information from that field
When I register a sales order that has an item that has the serial field as SERIAL the report prints automatically and it doesn't prints is this field is different than SERIAL. It runs well.
But my problem is that seems doesn't go over the sales line table, because if I put first an item that hasn't the information SERIAL and after an item that yes it has, the report doesn't prints, it seems go over only the first line form the sales order. How can I do go over all the lines?, I've put a "find" and an "until" but it seems don't work.
Thanks in advance for help.
Comments
Put the REPEAT statement before the CALCFIELDS 8)
Albert
and i suggest to NOT use magic constants like the 'SERIE' value you have in your code. make these things a setting somewhere in a setup table, because these things tend to change over time.
But, also, as MBerger said, it prints 2 times if there are two lines. Is there any way to solve it? :roll: .
Thanks everybody for help and time.
IF salesline.FIND('-') THEN BEGIN
REPEAT
salesline.CALCFIELDS(serial);
IF salesline.serial='SERIE' THEN BEGIN
booleanPrint := TRUE;
UNTIL
(salesline.NEXT = 0) OR (booleanPrint = TRUE);
END;
IF booleanPrint THEN BEGIN
RptNumserie.SETTABLEVIEW(SalesShptHeader) ;
RptNumserie.USEREQUESTFORM := FALSE;
RptNumserie.RUNMODAL ;
CLEAR(RptNumserie) ;
END;
Thanks again.