Hi,
In a Transfer Order Shipment Posting routine, the values are posted to GLEntry,Item Ledger Entry, and Posted Transfer order shipment Table. After posting the values Transfer Order Shipment table has to be deleted. For this requirement Coding written as follow..
"Posted Br.TransferHeader".INIT;
"Posted Br.TransferHeader".TRANSFERFIELDS("Br.TransferHeader");
"Posted Br.TransferHeader".INSERT;
"Br.TransferLine".Reset;
"Br.TransferLine".SETRANGE("Br.TransferLine".Type,"Br.TransferHeader".Type);
"Br.TransferLine".SETRANGE("Br.TransferLine"."Document No","Br.TransferHeader".No);
IF "Br.TransferLine".FIND('-') THEN
REPEAT
"Posted Br.TransferLine".INIT;
"Posted Br.TransferLine".TRANSFERFIELDS("Br.TransferLine");
"Posted Br.TransferLine"."Posting Date" := "Br.TransferHeader"."Posting Date";
"Posted Br.TransferLine".INSERT;
UNTIL "Br.TransferLine".NEXT = 0;
"Br.TransferLine".DELETEALL;
"Br.TransferHeader".DELETE;
When Concurrent users are Posting, the Posted Transfer order Shipment is also getting deleted..
How to change the code, to avoid these deletion when concurrent users are posting? Can any one Suggest me?
Thanx In Advance
Comments
RIS Plus, LLC
MVP - Business Apps
Now we have modified the code as:
"Posted Br.TransferHeader".INIT;
"Posted Br.TransferHeader".TRANSFERFIELD("Br.TransferHeader");
"Br.TransferLine".RESET;
"Br.TransferLine".SETRANGE"Br.TransferLine".Type,"Br.TransferHeader".Type);
"Br.TransferLine".SETRANGE("Br.TransferLine"."Document No","Br.TransferHeader".No);
IF "Br.TransferLine".FIND('-') THEN BEGIN
REPEAT
"Posted Br.TransferLine".INIT;
"Posted Br.TransferLine".TRANSFERFIELDS("Br.TransferLine");
"Posted Br.TransferLine".INSERT;
"Br.TransferLine".DELETE;
UNTIL "Br.TransferLine".NEXT = 0;
END;
"Posted Br.TransferHeader".INSERT;
"Br.TransferHeader".DELETE;
Can u suggest me whether this modifid code will resolve the problem.
Thanx in Advance
Sujatha.N
Doesn't delete the Rec that you use for a loop. If you are under native and you delete the actual "Br.TransferLine", then the next=0 will find no next and stop looping. so use a separate instance for deleting like:
Thanx.. Let me try out this..
Sujatha.N
Well, from a logical point of view there are only 3 possibilities, when a record is "getting deleted":
1.) In the code there is something like "Posted Br.TransferHeader".DELETE (or DELETEALL)
2.) The "Posted Br.TransferHeader" has never been inserted (as DenSter pointed out) - in your case, this would mean that there are COMMITs in the posting routines before the INSERT (to be sure that there are no commits you have to check this with the client monitor!) but in your code, the posted record is inserted before the unposted one is deleted, so if there would occur an error or a "broken transaction" during posting, the unposted record should not have been deleted, too, and could be posted again... - and, if an error occurs, the user is notified (and perhaps can remember) that something has gone wrong, when he is later ashtonished that the posted record cannot be found.
3.) One or another user deletes the record manually.
My suggestion is that you verify, that 3.) is not possible.
By the way, it is not critical to delete a looping record within the loop, because the NEXT statement (in my experience) works as if the record is still "alive".