Sales Header

hi guys. we are having a problem in some of the sales order we have and we don’t know why this happen. when we checked someof the sales order, the sales header is missing but when we checked the sales line is is actually in the list, we are checking using the object designer using the tables sales header and sales lines. please advise if you encounter this and can someone please tell me on how to resolve this issue, we want to delete the sales line since it is already completed.

many thanks.

Two possible causes come to mind:

1 - The code in the OnDelete trigger of the sales header table was modified, and it now does not remove related sales lines when DELETE(TRUE) is called

2 - The default parameter value of the DELETE command is FALSE, so by default it does not run the OnDelete code. Somewhere in the code there is a SalesHeader.DELETE statement without explicitly setting the parameter to TRUE. The developer assumed that SalesHeader.DELETE also removes the related sales lines.

thanks for that info. do you have any idea on how to delete this sales order? mant thanks.

I think you mean the sales lines.

Do you know the report design? You can do that with a report.

“Run” all your sales line and check if the corresponding SalesHeader exist. If not, just delete the SaleLine. But carefull,don’t forget you have different document types.

If you don’t know how to do it, please ask here for some line of code.

hi, thanks for the info. do you have the code with you? many thanks.

OBJECT Report 50000 Delete Sales Lines
{
OBJECT-PROPERTIES
{
Date=14.01.08;
Time=17:36:35;
Modified=Yes;
Version List=;
}
PROPERTIES
{
}
DATAITEMS
{
{ PROPERTIES
{
DataItemTable=Table37;
DataItemTableView=SORTING(Document Type,Document No.,Line No.)
ORDER(Ascending)
WHERE(Document Type=CONST(Order));
OnAfterGetRecord=BEGIN
IF NOT SalesHeader.GET(“Sales Line”.“Document Type”,“Sales Line”.“Document No.”) THEN
“Sales Line”.DELETE(TRUE);
END;

}
SECTIONS
{
{ PROPERTIES
{
SectionType=Body;
SectionWidth=12000;
SectionHeight=846;
}
CONTROLS
{
}
}
}
}
}
REQUESTFORM
{
PROPERTIES
{
Width=9020;
Height=3410;
}
CONTROLS
{
}
}
CODE
{
VAR
SalesHeader@1000000000 : Record 36;

BEGIN
END.
}
}

“Sales Line”.DELETE(TRUE) to make sure you are NOT deleting lines which are not fully invoiced.