Calculation more Request Order

Hi Everybody.

On Purchase Line of my include more Request Order. I want calculation Amount on all Request. But wrong.

This procedure only calculates 1 line. It can not repeat for the remaining lines by conditional :

RecRequisition.SETRANGE("Requisition No",RecPurchLine."Requisition No");

RecRequisition.RESET;
RecRequisition.SETRANGE("Requisition No",RecPurchLine."Requisition No");
IF RecRequisition.FIND('+') THEN BEGIN
  REPEAT
    RecRequisition.SETRANGE("Requisition No",RecPurchLine."Requisition No");
    RecRequisition.CALCSUMS(Amount);
    PRAmount:=RecRequisition.Amount;
  UNTIL RecRequisition.NEXT=0   ;
END;
MESSAGE(Txt0001,PRAmount);

Please help me fix code. Thanks so much

Best Regards,

Dinh Son

Parents Reply
  • Then we are back to:.

    Yes, of course. You only have one purchase line per requisition no. and you filter on the requisition no. - so will only return one line.

    If that's your whole dataset, then no code can change that. But I assume it's not, even though you didn't tell us...

    So far we know that you have a table Requisition with a primary field of Requisition No. and Item No. It also contains a field Amount, which is declared as a sum index field (assuming part of the primary key).

    In that case this could/should work:

    PROCEDURE GetRequisitionAmount(RequisitionNo: Code[20]): Decimal;
    VAR
      Requisition: RECORD Requisition;
    BEGIN
      Requisition.SETRANGE("Requisition No",RequisitionNo);
      IF Requisition.ISEMPTY THEN EXIT(0);
      Requisition.CALCSUMS(Amount);
      EXIT(Requisition.Amount);
    END;

Children
Related
Recommended