//code to modify purchase line IF RecPurchaseLine.FINDSET THEN BEGIN IF RecPurchaseLine.Quantity <= OrderedQty THEN BEGIN tempQtyRec := RecPurchaseLine."Qty. to Receive"; RecPurchaseLine.VALIDATE(Quantity, OrderedQty); RecPurchaseLine.VALIDATE ("Qty. to Receive" ,tempQtyRec); // Validate n update field value RecPurchaseLine.MODIFY; // modify record set. COMMIT; END; END; // code to process order to receipt ProcessPoToReceipt(DocumentNo : Text[20];DocumentType : Text[30]) RetMsg : Text[1000] IF DocumentType = 'Order' THEN BEGIN CLEAR(RecPurchaseHeader); RecPurchaseHeader.INIT; RecPurchaseHeader.SETFILTER("No.",DocumentNo); RecPurchaseHeader.SETFILTER("Document Type",DocumentType); IF RecPurchaseHeader.FIND('-') THEN BEGIN RecPurchaseHeader.Receive := TRUE; // SETTING PROPERTY TO RECEIVE RecPurchaseHeader.Invoice := FALSE; IF cuPurchPost.RUN(RecPurchaseHeader) THEN BEGIN MESSAGE('processed'); RetMsg := 'Receipt Created Successfully'; END ELSE BEGIN ERROR(GETLASTERRORTEXT); RetMsg := GETLASTERRORTEXT; END; END; END;
Answers
So you've retrieved a record from the database.
Something changes that record.
It tries to change it again, but it sees that it doesn't have the same version of the record that has been written back to the database in the step above. Since it doesn't know what needs to change anymore it gives an error.
Solution, change the way your code works, or retrieve the record from the database again. There might be other solutions, but those are the two that I'm aware of.
Hope that's enough to get you started.
Please comment on this..
regards,
This will retrieve a new copy of the record from the database. You might even be able to use the same record variable.
thanks alot.
regards,
I am facing the same problem, all of the sudden the posting of purchase order was working then it stopped saying at the beginning that another user has modified the purchase header record then when i press ok and i try to post again it says that purchase line already exists.
appreciate you help on this
Best
HAYAN
you need to put down your code here as there may be a different reason. I was modifying the same record twice i believe.
it also happens when you get a record, and try to change any primary key field of it then you get the same error as well.
As you said that first you get another user has modified the record and then you get purchase line already exists in that case, please check the following.
1- when you try to post first time, are you modifying the same record twice or are you trying to modify the primary key.
if you are trying to modify primary key field(s) then you will have to use two record variables.
2- Before second try to post when you get purchase line already exists, check if PurhcaseHeader."Posting No." is populated?
If i remember i had similar error and i cleared "posting no." field and it worked.
add your code with little details what you are trying to achieve, so that someone can advise you better.
regards