
Hello everyone,
I'm working with a customer who is generating purchase orders through requisition worksheet, based on sales orders with special order. I have a situation: It's a sales order with 500 pieces of a product and I have shipped 400 pieces. I have a generated purchase order with 500 pieces (that fufills the sales order) and I only have received 400 pieces.
There are 100 pieces that have been cancelled by the customer. So I need to cancel that quantity for both, purchase and sales order.
In order to cancel the purchase order, I can reopen the order, change the original quantity and then run the task to delete invoiced purchase orders. But, I have this error when I try to do the same with the sales order:
If you coud help me, I would really appreciate it.
Thank you!
Valeria.
Others might suggest a more elegant way of resolving this. I've found in this circumstance you no longer need the link and you can progress to the next stage with either document without it. A few ways of doing it code wise but here is one avenue I've used in the past.
pageextension 50100 "SO Subform Ext." extends "Sales Order Subform"
{
actions
{
addafter("Speci&al Order")
{
action(Cancel)
{
ApplicationArea = All;
Caption = 'Cancel Special Order Lines';
trigger OnAction()
var
SalesLine: Record "Sales Line";
PurchLine: Record "Purchase Line";
begin
IF NOT CONFIRM('Would you like to clear the Special Order fields?', TRUE)
THEN EXIT ELSE
SalesLine.RESET;
SalesLine.SETRANGE("Document Type", Rec."Document Type");
SalesLine.SETRANGE("Document No.", Rec."Document No.");
IF SalesLine.FIND('-') THEN
REPEAT
IF PurchLine.GET(Rec."Document Type", SalesLine."Special Order Purchase No.", SalesLine."Special Order Purch. Line No.") THEN BEGIN
CLEAR(PurchLine."Special Order Sales Line No.");
CLEAR(PurchLine."Special Order Sales No.");
CLEAR(PurchLine."Special Order");
CLEAR(PurchLine."Purchasing Code");
PurchLine.MODIFY(TRUE);
END;
CLEAR(SalesLine."Special Order Purch. Line No.");
CLEAR(SalesLine."Special Order Purchase No.");
CLEAR(SalesLine."Special Order");
CLEAR(SalesLine."Purchasing Code");
SalesLine.MODIFY(TRUE);
UNTIL SalesLine.NEXT = 0;
end;
}
}
}
}