Hi,
I got a question:
On the sales order, i added a button Process. When you click on this button a "Packing Order" gets created and opened.
In this new "Packing Order" i fill in some data, and then i Approve this "Packing Order" and close it.
When i close the "Packing Order" and see my "Sales Order" again then i receive the Error:
Another user has modified the record for this Sales Header after you retrieved it from the database...
Now i guess this is because of the following:
When i approve the new "Packing Order" following gets executed:
IF lv_SalesHeader.GET(lv_SalesHeader."Document Type"::Order,Ordernumber) THEN BEGIN
lv_SalesHeader.TESTFIELD("Linked Packing Order","Packinglist No.");
lv_SalesHeader.VALIDATE("No. Of Pallets",lv_NoOfPallets);
lv_SalesHeader."Packing List Current" := lv_SalesHeader."Packing List Current"::Completed;
lv_SalesHeader.MODIFY;
END;
So this modifies the sales header, for the order that is still open under the "Packing Order"
How could i solve this so i dont get this error message?
0
Comments
This will update the form without saving the record...
Which means after the
If your button is like this:
OnPush:
..Some code here which leads to
lv_SalesHeader.MODIFY;
then at the end of the OnPush and after everything is completed place your update.
RIS Plus, LLC
MVP - Business Apps
This piece of code is on the "Packing Form", not on the Sales Order
IF lv_SalesHeader.GET(lv_SalesHeader."Document Type"::Order,Ordernumber) THEN BEGIN
lv_SalesHeader.TESTFIELD("Linked Packing Order","Packinglist No.");
lv_SalesHeader.VALIDATE("No. Of Pallets",lv_NoOfPallets);
lv_SalesHeader."Packing List Current" := lv_SalesHeader."Packing List Current"::Completed;
lv_SalesHeader.MODIFY;
END;
But this Packing Form is modifying the "Sales Header" that is opened on the Sales Order, under the Packing Order..
So on the "Sales Order" i just press a button "Process". Then it opens the "Packing Form" for that Sales order
without closing the Sales Order... So "Packing Form" is now above the "Sales Order".
Now we fill in some data in the "Packing Form" and Press approove in the "Packing Form".
The approove button execute the code to modify the "Sales Header". After pressing approove i close the "Packing Form"
And now my "Sales Order" is back actived. But because the "Packing Form" has modified the "Sales Header" i get the error...
Also there is a situation where this will not work. If your code call a form or a report like Form.RUN and NOT Form.RUNMODAL (or report.RUNMODAL) then the UDPATE(FALSE) will be executed before the change of the record. So I think we need to see exactly the code on your button to help you with this.
This is the code of the Button "Process" on the "Sales Order" which will create and open the "Packing Form":
CreatePackingOrder:
Then after the FORM.RUNMODAL(50003,lv_PackingHeader);
has been executed the users now fill in some data and Approove the "Packing Order"
When he approoves following code gets executed (This code is in the Packing Order):
But its just that message saying that another user has modified the record in the sales order which annoys me
That error message happens when two processes try to MODIFY the same record, without refreshing the record with what the other process is doing. What you need to do is one of two things:
1 - you pass the sales header by reference, so that the modified record comes back into your code
2 - you retrieve the record from the database after the call to the other process
You said you added a button, and that the code on the button is causing the error message. To me that sounds like something in that code needs to be changed so that the error doesn't occur, not the object that is called from that button. Maybe that other object needs to be changed to accommodate this new process, but I think it is reasonable to assume that it is the custom code that causes the error.
My first reaction would be to add a line to your code, right after the other object is done, that retrieves the sales header from the database.
The cause of the error message is that you are on Sales Order X, which is sent into this report. This report then changes the same sales order, ,and writes the change to the database (MODIFY does that). Then when it comes back to the form that you are on, it is still looking at the sales order from before the change was made. The form then tries to modify the record (which at that point is an old version), and you get that error.
RIS Plus, LLC
MVP - Business Apps