Change quantity on a Sales Order with Drop Shipment

Boran
Boran Member Posts: 7
Hello All,

I have a problem with a program related to order with Drop Shipment.
I want to do the following: when a quantity on a Sales order line (which has a purchase order in drop shipment) is modified, the corresponding quantity in the purchase order line must be modified.

Here is my program :

IF "Purchase Order No." <> '' THEN BEGIN
IF "Purch. Order Line No." <> 0 THEN BEGIN
IF "Quantity Shipped" > Quantity THEN
ERROR(
Text100,
Quantity,
"Quantity Shipped")
ELSE BEGIN
ConfirmationHA:=CONFIRM(Text101,FALSE);
IF ConfirmationHA THEN BEGIN
IF RecCdeAchat.GET("Document Type","Purchase Order No.","Purch. Order Line No.") THEN BEGIN
IF RecCdeAchat."Quantity Received">Quantity THEN
ERROR(
Text100,
Quantity,
RecCdeAchat."Quantity Received")
ELSE BEGIN
RecCdeAchat."MAJ quantité Liv.Directe":=TRUE;
RecCdeAchat.Quantity:=Quantity;
RecCdeAchat.VALIDATE(RecCdeAchat.Quantity);
RecCdeAchat.MODIFY(TRUE);
END;
END;
END;
END;
END;
END;


The program is executed in the « On Validate » trigger of the quantity in
the table « Sales line ».
My problem is that, when I modify the quantity on the Sales line, the quantity on the Purchase line is modified but not the quantity of the sales line. I have an error message :
« Another user has modified the record for this sales line after you
retrieved it from the database…»
If I remove the program line
«PurchaseLine.VALIDATE(PurchaseLine.Quantity);»
I don’t have any more this message but the program on the « On
Validate » of the quantity on the Purchase line will not be executed...

Thank you for your help !!!!!!!!

Comments

  • Arjan
    Arjan Member Posts: 7
    You can create a boolean variable in the Purch.line.
    Set this to true before you validate the Purch.line quantity and back to false after you are done.
    RecCdeAchat.SentFromSalesLine := TRUE;
    RecCdeAchat.Quantity:=Quantity; 
    RecCdeAchat.VALIDATE(RecCdeAchat.Quantity); 
    RecCdeAchat.SentFromSalesLine := FALSE;
    
    In the Quantity OnValidate trigger of the Purch.line read this boolean


    IF NOT SentFromSalesLine THEN BEGIN
      //Code that tries to change the Salesline Quantity here
    END;
    
  • Savatage
    Savatage Member Posts: 7,142
    how do you handle a case where the sale & puch have different UOM's?

    or do all your items have the same purch & sale UOM?
  • Boran
    Boran Member Posts: 7
    Yes the items have the same UOM.

    I try to change the quantity on the sales line and I expect the quantity to be changed on the associated Purchase line. It works with the purchase line, the quantity is updated, but on the sales line I initialy modified, the quantity is wrong and come back to the initial value. Then the message appears : « Another user has modified the record for this sales line after you retrieved it from the database…»
  • Savatage
    Savatage Member Posts: 7,142
    I was curious about your post because I wanted to try something similar but in reverse. http://www.mibuso.com/forum/viewtopic.php?p=81487