Problem when insert in Document Dimension

Hi,

When we create a sales header, Dimensions of both customer and Item are Copied from Default dimension Table to Document Dimension Table for each sales line row. (it’s how system works in our company and i don’t know it it is standard ).

we face the flowing problem when a user Create Warehouse Shipment then he delete it, Item Dimensions will be lost in some line (Particularly line 30000 and 90000).

So to fix the problem i wrote the following code :

Saleslines.RESET;
Saleslines.SETRANGE(Saleslines.“Document Type”,“Document Type”);
Saleslines.SETRANGE(Saleslines.Type,Saleslines.Type::Item);
Saleslines.SETRANGE(Saleslines.“Document No.”,“No.”);
IF Saleslines.FINDFIRST THEN
BEGIN
REPEAT
//Customer 18 , Item 27
//–Check Customer Dimensions
VerifyDimension(‘CUSTOMER CLASS’,Saleslines.“Line No.”,“Sell-to Customer No.”,18,“Document Type”,“No.”);
VerifyDimension(‘REGION’,Saleslines.“Line No.”,“Sell-to Customer No.”,18,“Document Type”,“No.”);
VerifyDimension(‘DEPARTEMENT’,Saleslines.“Line No.”,“Sell-to Customer No.”,18,“Document Type”,“No.”);
VerifyDimension(‘CUSTOMER ACTIVITY’,Saleslines.“Line No.”,“Sell-to Customer No.”,18,“Document Type”,“No.”);
//–Check item Dimension
VerifyDimension(‘ITEM CATEGORY’,Saleslines.“Line No.”,Saleslines.“No.”,27,“Document Type”,“No.”);
VerifyDimension(‘PRODUCT FAMILY’,Saleslines.“Line No.”,Saleslines.“No.”,27,“Document Type”,“No.”);
VerifyDimension(‘PRODUCTION UNIT’,Saleslines.“Line No.”,Saleslines.“No.”,27,“Document Type”,“No.”);
UNTIL Saleslines.NEXT=0 ;
END;

VerifyDimension(Dimension : Text[30];Ligne : Integer;Item : Code[20];Table : Integer;DocType : Option;Document : Code[20]) : Boolean
//-- ----Record Variable ---------------------
//----DocumentDimension : Document Dimension
//----DefaultDimension : Default Dimension
// Check if «Dimension" of “ligne” exist
DocumentDimension.RESET;
DocumentDimension.SETFILTER(“Table ID”, ‘%1’, 37);
DocumentDimension.SETFILTER(“Document Type”, ‘%1’, DocType);
DocumentDimension.SETFILTER(“Document No.”, ‘%1’, Document);
DocumentDimension.SETFILTER(DocumentDimension.“Line No.”, ‘%1’, Ligne);
DocumentDimension.SETFILTER(“Dimension Code”,Dimension);
IF NOT DocumentDimension.FINDFIRST THEN
BEGIN
//—FIND the missed Dimension in default dimension table
DefaultDimension.RESET;
DefaultDimension.SETRANGE(DefaultDimension.“Table ID”,Table);
DefaultDimension.SETRANGE(DefaultDimension.“No.”,Item);
DefaultDimension.SETRANGE(DefaultDimension.“Dimension Code”,Dimension);
IF DefaultDimension.FINDFIRST THEN
BEGIN
//—INSERT the missed dimension in Document dimension table
DocumentDimension.INIT;
DocumentDimension.“Table ID”:=37;
DocumentDimension.“Document Type”:=DocType;
DocumentDimension.“Document No.”:=Document;
DocumentDimension.“Line No.”:=Ligne;
DocumentDimension.“Dimension Code”:=Dimension;
DocumentDimension.“Dimension Value Code”:=DefaultDimension.“Dimension Value Code”;
DocumentDimension.INSERT ;
END;
END;

This Code Works fine for all line except : 30000 and 90000 ?
Any idea about that ?

What do you have in 30000 and 90000 lines?

Articles , this problem does not appear always. But if we have it, in some cases, the user should insert dimension Manually and we would like to avoid that.

Artciles means Items