purchase order report

I have a report that should prints the image of the products that are in the related purchase order ( print only the images of the products that has the property Imprimir Desenho checked on Quality product requirement)
the code I have in the report is

*Requisito produto Qualidade - OnAfterGetRecord()

IF ReqQualidade.GET("Requisito produto Qualidade".Requisito) THEN
BEGIN
IF ReqQualidade."Imprimir Desenho" THEN
BEGIN
ItemTemp."No.":=PurchLine."No.";
IF ItemTemp.INSERT THEN
BEGIN
ndesenhos+=1;
flagglobal:=TRUE;
END;
END;
END;

*Desenho - OnPreDataItem()
IF NOT flagglobal THEN
CurrReport.BREAK;

Desenho.SETRANGE(Number,1,ndesenhos);
ItemTemp.FINDFIRST;

*Desenho - OnAfterGetRecord()

IF ItemI.GET(ItemTemp."No.") THEN
BEGIN
manufactsetup.GET;
ItemTemp.DELETEALL;
IF filee.OPEN(manufactsetup.Destino+'\'+ItemI.Ficheiros) THEN
BEGIN
filee.CREATEINSTREAM(Instream);
ItemTemp.Picture.CREATEOUTSTREAM(OutStream2);
COPYSTREAM(OutStream2,Instream);
ItemTemp.INSERT;
ItemTemp.CALCFIELDS(Picture);
filee.CLOSE;
END;
END;


The report only prints the first product that has the property Imprimir Desenho checked on Quality product requirement, but it print it as many time as products in the order with that same characteristic.
For example
in an order with 2 products with the requirement "Imprimir Desenho" it only prints the image of the first but 2 times

Can same one tell me where the problem is?

Answers

  • AlexeyShaminAlexeyShamin Member Posts: 80
    Why you create deleteall in ItemTemp in Desenho - OnAfterGetRecord() trigger
  • AlexeyShaminAlexeyShamin Member Posts: 80
    Try delete line with deleteall and add ItemTemp.Next
    Like:
    IF ItemI.GET(ItemTemp."No.") THEN BEGIN
    manufactsetup.GET;
    IF filee.OPEN(manufactsetup.Destino+'\'+ItemI.Ficheiros) THEN BEGIN
    filee.CREATEINSTREAM(Instream);
    ItemTemp.Picture.CREATEOUTSTREAM(OutStream2);
    COPYSTREAM(OutStream2,Instream);
    ItemTemp.INSERT;
    ItemTemp.CALCFIELDS(Picture);
    filee.CLOSE;
    END;
    END;
    ItemTemp.NEXT;
  • ACN_PACN_P Member Posts: 2
    thank you for your answer
    I did note create the code I´m trying to fix it because it does not do what is supose to, but I´m not been able to find the error
    the change you suggest does not work because if I delete ItemTemp.DELETEALL the report does not run
    I think it enters in loop because it gives an error the productXXX already exists
Sign In or Register to comment.