Dear Experts,
I need to delete blank sales orders. Please advise.
*This post is locked for comments
Dear Experts,
I need to delete blank sales orders. Please advise.
*This post is locked for comments
try suresh's suggestion.
clear the posting no. and other no. series fields from table 36 for respective order and try deleting.
Hi,
I have tried as suggested by Saurabh Shah and Alexander Sir, Actuall these sales order are blank nothing is mentioned there except sales order no. and I have searched sale order no. in posted sales invoice list this order no has no invoice but the PSI no which is coming in error is there in the posted sales invoice list with different sales order no.
Kindly advise
Thanks
With Regards
Mandeep Kaur
Did you try Alexander 's suggestion? to use delete invoiced sales orders option in nav?
Hello Mandeep,
Can you please check below:
Open sales order, Go to Invoices action and check whether any number (As given in error) is displayed.
If there is no invoices there, Please go to Posted sales invoices and check by filtering the order number with the same order.
Let us know.
Hi All,
Thanks for your support. I have tried to remove the order no and delete but it is not getting deleted as it is linked with no. series and PSS ,PSI(Posted Sales Shipment, Posted Sales Invoice). I have check the code as well all documents are interlinked. These sales orders are blank and are very old from the year 2013 to 2016 (6-7 sales orders) which I need to delete. Please advise.
IF ("Document Type" = "Document Type"::Quote) AND ("Doc. Sub Type" = "Doc. Sub Type"::Quotation) THEN BEGIN
IF ("Sent for Approval") AND (NOT Approved) THEN
ERROR(Text5003,"Document Type","No.");
END;
IF DOPaymentTransLogEntry.FINDFIRST THEN
DOPaymentTransLogMgt.ValidateCanDeleteDocument("Payment Method Code","Document Type",FORMAT("Document Type"),"No.");
IF NOT UserSetupMgt.CheckRespCenter(0,"Res Center") THEN
ERROR(
Text022,
RespCenter.TABLECAPTION,UserSetupMgt.GetSalesFilter);
IF ("Opportunity No." <> '') AND
("Document Type" IN ["Document Type"::Quote,"Document Type"::Order])
THEN BEGIN
IF Opp.GET("Opportunity No.") THEN BEGIN
IF "Document Type" = "Document Type"::Order THEN BEGIN
IF NOT CONFIRM(Text040,TRUE) THEN
ERROR(Text044);
TempOpportunityEntry.INIT;
TempOpportunityEntry.VALIDATE("Opportunity No.",Opp."No.");
TempOpportunityEntry."Sales Cycle Code" := Opp."Sales Cycle Code";
TempOpportunityEntry."Contact No." := Opp."Contact No.";
TempOpportunityEntry."Contact Company No." := Opp."Contact Company No.";
TempOpportunityEntry."Salesperson Code" := Opp."Salesperson Code";
TempOpportunityEntry."Campaign No." := Opp."Campaign No.";
TempOpportunityEntry."Action Taken" := TempOpportunityEntry."Action Taken"::Lost;
TempOpportunityEntry.INSERT;
TempOpportunityEntry.SETRANGE("Action Taken",TempOpportunityEntry."Action Taken"::Lost);
PAGE.RUNMODAL(PAGE::"Close Opportunity",TempOpportunityEntry);
IF Opp.GET("Opportunity No.") THEN
IF Opp.Status <> Opp.Status::Lost THEN
ERROR(Text043);
END;
Opp."Sales Document Type" := Opp."Sales Document Type"::" ";
Opp."Sales Document No." := '';
Opp.MODIFY;
"Opportunity No." := '';
END;
END;
SalesPost.DeleteHeader(
Rec,SalesShptHeader,SalesInvHeader,SalesCrMemoHeader,ReturnRcptHeader,SalesInvHeaderPrepmt,SalesCrMemoHeaderPrepmt);
VALIDATE("Applies-to ID",'');
ApprovalMgt.DeleteApprovalEntry(DATABASE::"Sales Header","Document Type","No.");
SalesLine.RESET;
SalesLine.LOCKTABLE;
WhseRequest.SETRANGE("Source Type",DATABASE::"Sales Line");
WhseRequest.SETRANGE("Source Subtype","Document Type");
WhseRequest.SETRANGE("Source No.","No.");
WhseRequest.DELETEALL(TRUE);
SalesLine.SETRANGE("Document Type","Document Type");
SalesLine.SETRANGE("Document No.","No.");
SalesLine.SETRANGE(Type,SalesLine.Type::"Charge (Item)");
DeleteSalesLines;
SalesLine.SETRANGE(Type);
DeleteSalesLines;
// 016 +++++++++++++
IF ("Document Type" IN ["Document Type"::Quote,"Document Type"::Order]) THEN BEGIN
//TESTFIELD("Lost Reason");
// UPDATE STATUS ON LEAD
IF (("Document Type" = "Document Type"::Quote) AND ("Doc. Sub Type" = "Doc. Sub Type"::Quotation))
OR ("Document Type" = "Document Type"::Order) THEN BEGIN
LeadHeader.RESET;
LeadHeader.SETRANGE(LeadHeader."Document Type",LeadHeader."Document Type"::Quote);
LeadHeader.SETRANGE(LeadHeader."No.","Lead No.");
IF LeadHeader.FINDFIRST THEN BEGIN
LeadHeader."Lost Reason" := "Lost Reason";
LeadHeader.VALIDATE(LeadHeader."Followup Status",LeadHeader."Followup Status"::Lost);
LeadHeader.MODIFY;
END;
END;
END;
// 016 *************
SalesCommentLine.SETRANGE("Document Type","Document Type");
SalesCommentLine.SETRANGE("No.","No.");
SalesCommentLine.DELETEALL;
GateEntryAttachment2.RESET;
GateEntryAttachment2.SETRANGE("Source Type",GateEntryAttachment2."Source Type"::"Sales Return Order");
GateEntryAttachment2.SETRANGE("Entry Type",GateEntryAttachment2."Entry Type"::Inward);
GateEntryAttachment2.SETRANGE("Source No.","No.");
IF GateEntryAttachment2.FINDFIRST THEN
GateEntryAttachment2.DELETEALL;
StrOrder.SETCURRENTKEY("Document Type","Document No.",Type);
StrOrder.SETRANGE("Document Type","Document Type");
StrOrder.SETRANGE("Document No.","No.");
StrOrder.SETRANGE(Type,StrOrder.Type::Sale);
IF StrOrder.FINDFIRST THEN
StrOrder.DELETEALL;
StrOrderLine.SETCURRENTKEY("Document Type","Document No.",Type);
StrOrderLine.SETRANGE("Document Type","Document Type");
StrOrderLine.SETRANGE("Document No.","No.");
StrOrderLine.SETRANGE(Type,StrOrder.Type::Sale);
IF StrOrderLine.FINDFIRST THEN
StrOrderLine.DELETEALL;
IF (SalesShptHeader."No." <> '') OR
(SalesInvHeader."No." <> '') OR
(SalesCrMemoHeader."No." <> '') OR
(ReturnRcptHeader."No." <> '') OR
(SalesInvHeaderPrepmt."No." <> '') OR
(SalesCrMemoHeaderPrepmt."No." <> '')
THEN BEGIN
COMMIT;
IF SalesShptHeader."No." <> '' THEN
IF CONFIRM(
Text000,TRUE,
SalesShptHeader."No.")
THEN BEGIN
SalesShptHeader.SETRECFILTER;
SalesShptHeader.PrintRecords(TRUE);
END;
IF SalesInvHeader."No." <> '' THEN
IF CONFIRM(
Text001,TRUE,
SalesInvHeader."No.")
THEN BEGIN
SalesInvHeader.SETRECFILTER;
SalesInvHeader.PrintRecords(TRUE);
END;
IF SalesCrMemoHeader."No." <> '' THEN
IF CONFIRM(
Text002,TRUE,
SalesCrMemoHeader."No.")
THEN BEGIN
SalesCrMemoHeader.SETRECFILTER;
SalesCrMemoHeader.PrintRecords(TRUE);
END;
IF ReturnRcptHeader."No." <> '' THEN
IF CONFIRM(
Text023,TRUE,
ReturnRcptHeader."No.")
THEN BEGIN
ReturnRcptHeader.SETRECFILTER;
ReturnRcptHeader.PrintRecords(TRUE);
END;
IF SalesInvHeaderPrepmt."No." <> '' THEN
IF CONFIRM(
Text055,TRUE,
SalesInvHeader."No.")
THEN BEGIN
SalesInvHeaderPrepmt.SETRECFILTER;
SalesInvHeaderPrepmt.PrintRecords(TRUE);
END;
IF SalesCrMemoHeaderPrepmt."No." <> '' THEN
IF CONFIRM(
Text054,TRUE,
SalesCrMemoHeaderPrepmt."No.")
THEN BEGIN
SalesCrMemoHeaderPrepmt.SETRECFILTER;
SalesCrMemoHeaderPrepmt.PrintRecords(TRUE);
END;
END;
Clear the posting No. from the header and then delete the order. If there is posting No. assigned on the header it will try to delete the invoice which is what causing the issue.
Agreed with others. It seems invoice has been created for the order. You can go to sales invoice page and check for the created invoice.
There is also Delete Invoiced Sales Orders Batch Job exists (msdn.microsoft.com/.../hh179047(v=nav.70).aspx)
Agree with [tag:Amol],
use debugger and check where you get exception. you will get idea.
I think somebody has created sales invoice for this order . Kindly check.
André Arnaud de Cal...
292,516
Super User 2025 Season 1
Martin Dráb
231,356
Most Valuable Professional
nmaenpaa
101,156