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
But assuming that your tables/code otherwise is ok, then try to change
PRAmount := RecRequisition.Amount;
to
PRAmount += RecRequisition.Amount;
Hi Erik
Thanks you, But it's not work.
Below is the structure of 2 tables. Please help me
Thanks so much
If you only have one purchase line per requisition no. then maybe that is why it is only returning one line...
Hi Erik.
Exactly it only returns one line. Please help me solution.
Thanks so much.
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.
You still have note written exactly what it is that you're actually trying to do?
Hi Erik,
I want to calculate the Amount of purchase requests versus the PO before receiving the goods into the warehouse.
Then you don't need all that code. This should be enough:
PROCEDURE GetRequisitionAmount(RequisitionNo: Integer): Decimal; BEGIN IF NOT Requisition.GET(RequisitionNo) then EXIT(0); EXIT(Requisition.Amount); END;
You need to define the variable in the function also, but then you can just call it where you need it.
Thanks Erik
I write procedure : define RequisitionNo type : Code
GetRequisitionAmount(RequisitionNo : Code[20]) : Decimal BEGIN IF NOT RecRequisition.GET(RecPurchLine.RequisitionNo) THEN EXIT(0); EXIT(RecRequisition.Amount); END;
then i call it by :
PRAmount:=GetRequisitionAmount(RecPurchLine.RequisitionNo);
MESSAGE(Txt000002,PRAmount);
But it's not work.
What is the primary key of RecRequisition?
Primary key of RecRequisition: RequisitionNo,Item.
Yes, then the code will not work. That would have been something you should have mentioned in the first place. Also if other filters where set.
Is the Amount field defined as a SumIndexField? CALCSUMS only work with fields defined as SumIndexFields.
Yes.Amount field defined as a SumIndexField
As part of which key? Has to be the same key as you filter on.