Eliminare righe spedizioni C/G

Vorrei eliminare le righe di una spedizione ma il sistema non consente questa operazione quando queste non contengono articoli ma conti. Il problema è che non mi è possibile eliminare l’ordine. Esiste una qualche soluzione?

Devi creare codice. Questo è un esempio di un cliente che gestiva spese spedizione semplicemente su un conto C/G. OBJECT Codeunit 50005 Annulla Spese Spedizione1 { OBJECT-PROPERTIES { Date=22/02/06; Time=12.16.21; Modified=Yes; Version List=NAVW13.70.00.09; } PROPERTIES { TableNo=111; Permissions=TableData 37=imd, TableData 111=imd, TableData 359=imd, TableData 6507=ri; OnRun=BEGIN IF NOT FIND(’-’) THEN EXIT; IF NOT HideDialog THEN IF NOT CONFIRM(Text000) THEN EXIT; SalesShptLine.COPY(Rec); Code; Rec := SalesShptLine; END; } CODE { VAR SalesShptLine@1001 : Record 111; TempTrackingSpecification@1011 : TEMPORARY Record 336; SalesShptTempTrackingSpec@1021 : TEMPORARY Record 336; TempWhseJnlLine@1017 : TEMPORARY Record 7311; ItemJnlPostLine@1000 : Codeunit 22; Text000@1003 : TextConst ‘ENU=Do you really want to undo the selected Shipment lines?’; Text001@1009 : TextConst ‘ENU=Undo quantity posting…’; Text002@1008 : TextConst ‘ENU=You cannot undo line %1, if Warehouse Worksheet lines have been created.’; Text003@1007 : TextConst ‘ENU=You cannot undo line %1, because an item charge has already been invoiced.’; Text004@1004 : TextConst ‘ENU=You cannot undo line %1, because there is an item charge assigned to it on %2 Doc No. %3 Line %4’; Text005@1002 : TextConst ‘ENU=There is not enough space to insert correction lines.’; WhseUndoQty@1015 : Codeunit 7320; HideDialog@1005 : Boolean; Text006@1010 : TextConst ‘ENU=You cannot undo line %1, because the %2 is 0.’; Text007@1006 : TextConst ‘ENU=Checking lines…’; Text008@1013 : TextConst ‘ENU=You cannot undo line %1, if Warehouse Put-away lines have been created.’; Text009@1012 : TextConst ‘ENU=You cannot undo line %1, if Warehouse Receipt lines have been created.’; Text010@1016 : TextConst ‘ENU=Some shipment lines may have unused service items. Do you want to delete them?’; Text011@1018 : TextConst ‘ENU=You cannot undo line %1, if Warehouse Activity lines have been posted’; Text012@1019 : TextConst ‘ENU=You cannot undo line %1, if Inventory Put-away lines have been posted.’; Text013@1020 : TextConst ‘ENU=You cannot undo line %1, if Inventory Pick lines have been posted.’; NextLineNo@1014 : Integer; Text014@1023 : TextConst ‘ENU=You cannot undo line %1, if Warehouse Receipt lines have been posted.’; Text015@1022 : TextConst ‘ENU=You cannot undo line %1, if Warehouse Shipment lines have been posted.’; PROCEDURE SetHideDialog@8(NewHideDialog@1000 : Boolean); BEGIN HideDialog := NewHideDialog; END; LOCAL PROCEDURE Code@2(); VAR ServItem@1003 : Record 5940; Window@1001 : Dialog; ItemShptEntryNo@1002 : Integer; DeleteServItems@1000 : Boolean; BEGIN WITH SalesShptLine DO BEGIN TESTFIELD(Type,Type::“G/L Account”); TESTFIELD(“Qty. Shipped Not Invoiced”,Quantity); CLEAR(ItemJnlPostLine); SETRANGE(Correction,FALSE); REPEAT IF NOT HideDialog THEN Window.OPEN(Text007); CheckSalesShptLine(SalesShptLine); UNTIL NEXT = 0; ServItem.SETCURRENTKEY(“Sales Shipment Document No.”); ServItem.SETRANGE(“Sales Shipment Document No.”,SalesShptLine.“Document No.”); IF ServItem.FIND(’-’) THEN IF NOT HideDialog THEN DeleteServItems := CONFIRM(Text010,TRUE) ELSE DeleteServItems := TRUE; FIND(’-’); REPEAT IF NOT HideDialog THEN Window.OPEN(Text001); InsertNewShipmentLine(SalesShptLine,ItemShptEntryNo); UpdateSalesOrderLine(SalesShptLine); IF (“Blanket Order No.” <> ‘’) AND (“Blanket Order Line No.” <> 0) THEN UpdateBlanketOrder(SalesShptLine); IF DeleteServItems THEN DeleteSalesShptLineServItems(SalesShptLine); “Quantity Invoiced” := Quantity; “Qty. Invoiced (Base)” := “Quantity (Base)”; “Qty. Shipped Not Invoiced” := 0; Correction := TRUE; MODIFY; UNTIL NEXT = 0; END; END; LOCAL PROCEDURE CheckSalesShptLine@3(SalesShptLine@1001 : Record 111); VAR Item@1004 : Record 27; ItemLedgEntry@1000 : Record 32; WhseShipmentLine@1009 : Record 7321; WhseReceiptLine@1005 : Record 7317; PostWhseRcptLine@1014 : Record 7319; PostWhseShptLine@1002 : Record 7323; WhseActivLine@1006 : Record 5767; WhseWkshLine@1007 : Record 7326; RgstrdWhseActivLine@1011 : Record 5773; PostedInvtPutAwayLine@1012 : Record 7341; PostedInvtPickLine@1013 : Record 7343; ItemChargeAssgntSales@1008 : Record 5809; ValueEntry@1010 : Record 5802; UsesItemTracking@1003 : Boolean; BEGIN CLEAR(UsesItemTracking); WITH SalesShptLine DO BEGIN TESTFIELD(“Qty. Shipped Not Invoiced”,Quantity); TESTFIELD(“Drop Shipment”,FALSE); ValueEntry.SETCURRENTKEY(“Item Ledger Entry No.”); ValueEntry.SETRANGE(“Item Ledger Entry No.”,“Item Shpt. Entry No.”); ValueEntry.SETFILTER(“Item Charge No.”,’<>%1’,’’); IF SalesShptTempTrackingSpec.FIND(’-’) THEN; REPEAT IF UsesItemTracking THEN ValueEntry.SETRANGE(“Item Ledger Entry No.”,SalesShptTempTrackingSpec.“Appl.-to Item Entry”); IF ValueEntry.FIND(’-’) THEN ERROR(Text003,“Line No.”); IF (Item.“Costing Method” = Item.“Costing Method”::Specific) THEN SalesShptTempTrackingSpec.TESTFIELD(“Serial No.”); UNTIL SalesShptTempTrackingSpec.NEXT = 0; ItemChargeAssgntSales.SETCURRENTKEY(“Document Type”,“Document No.”,“Document Line No.”,“Line No.”); ItemChargeAssgntSales.SETRANGE(“Document Type”, ItemChargeAssgntSales.“Document Type”::Order); ItemChargeAssgntSales.SETRANGE(“Document No.”,“Order No.”); ItemChargeAssgntSales.SETRANGE(“Document Line No.”,SalesShptLine.“Order Line No.”); IF ItemChargeAssgntSales.FIND(’-’) THEN REPEAT ItemChargeAssgntSales.DELETE; UNTIL ItemChargeAssgntSales.NEXT=0; END; END; LOCAL PROCEDURE InsertNewShipmentLine@1(OldSalesShptLine@1000 : Record 111;ItemShptEntryNo@1001 : Integer); VAR NewSalesShptLine@1002 : Record 111; LineSpacing@1003 : Integer; BEGIN WITH OldSalesShptLine DO BEGIN NewSalesShptLine.SETRANGE(“Document No.”,“Document No.”); NewSalesShptLine.“Document No.” := “Document No.”; NewSalesShptLine.“Line No.” := “Line No.”; NewSalesShptLine.FIND(’=’); IF NewSalesShptLine.FIND(’>’) THEN BEGIN LineSpacing := (NewSalesShptLine.“Line No.” - “Line No.”) DIV 2; IF LineSpacing = 0 THEN ERROR(Text005); END ELSE LineSpacing := 10000; NewSalesShptLine.RESET; NewSalesShptLine.INIT; NewSalesShptLine.COPY(OldSalesShptLine); NewSalesShptLine.“Line No.” := “Line No.” + LineSpacing; NewSalesShptLine.Quantity := -Quantity; NewSalesShptLine.“Qty. Shipped Not Invoiced” := 0; NewSalesShptLine.“Quantity (Base)” := -“Quantity (Base)”; NewSalesShptLine.“Quantity Invoiced” := NewSalesShptLine.Quantity; NewSalesShptLine.“Qty. Invoiced (Base)” := NewSalesShptLine.“Quantity (Base)”; NewSalesShptLine.Correction := TRUE; NewSalesShptLine.INSERT; CopyShipmentLineDimensions(OldSalesShptLine,NewSalesShptLine); IF FindTrackingSpecification THEN BEGIN UpdateItemTrackingInfo; InsertItemEntryRelation(NewSalesShptLine); END; END; END; LOCAL PROCEDURE UpdateSalesOrderLine@4(SalesShptLine@1000 : Record 111); VAR SalesLine@1001 : Record 37; BEGIN WITH SalesShptLine DO BEGIN SalesLine.GET(SalesLine.“Document Type”::Order,“Order No.”,SalesShptLine.“Order Line No.”); SalesLine.“Quantity Shipped” := SalesLine.“Quantity Shipped” - Quantity; SalesLine.“Qty. Shipped (Base)” := SalesLine.“Qty. Shipped (Base)” - “Quantity (Base)”; SalesLine.InitOutstanding; SalesLine.InitQtyToShip; SalesLine.MODIFY; END; END; LOCAL PROCEDURE CopyShipmentLineDimensions@6(FromSalesShptLine@1000 : Record 111;ToSalesShptLine@1001 : Record 111); VAR ToPostedDocDim@1002 : Record 359; FromPostedDocDim@1003 : Record 359; BEGIN FromPostedDocDim.SETRANGE(“Table ID”,DATABASE::“Sales Shipment Line”); FromPostedDocDim.SETRANGE(“Document No.”,FromSalesShptLine.“Document No.”); FromPostedDocDim.SETRANGE(“Line No.”,FromSalesShptLine.“Line No.”); IF FromPostedDocDim.FIND(’-’) THEN REPEAT ToPostedDocDim.COPY(FromPostedDocDim); ToPostedDocDim.“Document No.” := ToSalesShptLine.“Document No.”; ToPostedDocDim.“Line No.” := ToSalesShptLine.“Line No.”; ToPostedDocDim.INSERT; UNTIL FromPostedDocDim.NEXT = 0; END; LOCAL PROCEDURE UpdateBlanketOrder@7(SalesShptLine@1000 : Record 111); VAR BlanketOrderLine@1001 : Record 37; BEGIN WITH SalesShptLine DO BEGIN IF BlanketOrderLine.GET( BlanketOrderLine.“Document Type”::“Blanket Order”,“Blanket Order No.”,“Blanket Order Line No.”) THEN BEGIN BlanketOrderLine.TESTFIELD(Type,Type); BlanketOrderLine.TESTFIELD(“No.”,“No.”); BlanketOrderLine.TESTFIELD(“Sell-to Customer No.”,“Sell-to Customer No.”); IF BlanketOrderLine.“Qty. per Unit of Measure” = “Qty. per Unit of Measure” THEN BlanketOrderLine.“Quantity Shipped” := BlanketOrderLine.“Quantity Shipped” - Quantity ELSE BlanketOrderLine.“Quantity Shipped” := BlanketOrderLine.“Quantity Shipped” - ROUND(“Qty. per Unit of Measure” / BlanketOrderLine.“Qty. per Unit of Measure” * Quantity,0.00001); BlanketOrderLine.“Qty. Shipped (Base)” := BlanketOrderLine.“Qty. Shipped (Base)” - “Quantity (Base)”; BlanketOrderLine.InitOutstanding; BlanketOrderLine.MODIFY; END; END; END; LOCAL PROCEDURE UpdateItemTrackingInfo@11(); VAR SalesLine@1009 : Record 37; NewTrackingSpecification@1002 : Record 336; OldReservEntry@1003 : Record 337; SourceSpecification@1006 : Record 336; OldTrackingSpecification@1010 : Record 336; ItemTrackingForm@1007 : Form 6510; TotalSourceSpecQty@1008 : Decimal; BEGIN TempTrackingSpecification.RESET; IF TempTrackingSpecification.FIND(’-’) THEN BEGIN REPEAT NewTrackingSpecification := TempTrackingSpecification; NewTrackingSpecification.“Buffer Status” := 0; NewTrackingSpecification.InitQtyToShip; NewTrackingSpecification.Correction := TRUE; IF TempTrackingSpecification.“Buffer Status” = TempTrackingSpecification.“Buffer Status”::MODIFY THEN NewTrackingSpecification.MODIFY ELSE NewTrackingSpecification.INSERT; UNTIL TempTrackingSpecification.NEXT = 0; TempTrackingSpecification.DELETEALL; END; WITH SalesShptTempTrackingSpec DO BEGIN FIND(’-’); OldReservEntry.SETCURRENTKEY( “Source Type”,“Source Subtype”,“Source ID”,“Source Batch Name”, “Source Prod. Order Line”,“Source Ref. No.”); OldReservEntry.SETRANGE(“Source Type”,“Source Type”); OldReservEntry.SETRANGE(“Source Subtype”,“Source Subtype”); OldReservEntry.SETRANGE(“Source ID”,“Source ID”); OldReservEntry.SETRANGE(“Source Batch Name”,“Source Batch Name”); OldReservEntry.SETRANGE(“Source Prod. Order Line”,“Source Prod. Order Line”); OldReservEntry.SETRANGE(“Source Ref. No.”,“Source Ref. No.”); TotalSourceSpecQty := 0; IF OldReservEntry.FIND(’-’) THEN BEGIN OldReservEntry.CALCSUMS(“Quantity (Base)”); TotalSourceSpecQty := -OldReservEntry.“Quantity (Base)”; END; SourceSpecification.INIT; SourceSpecification := SalesShptTempTrackingSpec; SalesLine.GET(“Source Subtype”,“Source ID”,“Source Ref. No.”); SourceSpecification.“Quantity (Base)” := TotalSourceSpecQty + SalesLine.“Quantity (Base)” - SalesLine.“Outstanding Qty. (Base)”; SourceSpecification.“Qty. to Handle (Base)” := SourceSpecification.“Quantity (Base)”; SourceSpecification.“Qty. to Invoice (Base)” := 0; SourceSpecification.“Qty. to Invoice” := 0; SourceSpecification.“Quantity Handled (Base)” := 0; SourceSpecification.“Quantity Invoiced (Base)” := 0; SourceSpecification.Correction := TRUE; REPEAT TempTrackingSpecification.INIT; TempTrackingSpecification := SalesShptTempTrackingSpec; TempTrackingSpecification.“Quantity (Base)” := -“Quantity (Base)”; TempTrackingSpecification.“Qty. to Handle (Base)” := -“Quantity (Base)”; TempTrackingSpecification.“Qty. to Invoice (Base)” := -“Qty. to Invoice (Base)”; TempTrackingSpecification.“Quantity Handled (Base)” := -“Quantity Handled (Base)”; TempTrackingSpecification.“Quantity Invoiced (Base)” := -“Quantity Invoiced (Base)”; TempTrackingSpecification.Positive := TempTrackingSpecification.“Quantity (Base)” > 0; TempTrackingSpecification.INSERT; OldTrackingSpecification.GET(“Entry No.”); OldTrackingSpecification.Correction := TRUE; OldTrackingSpecification.MODIFY; UNTIL NEXT = 0; END; ItemTrackingForm.SetBlockCommit(TRUE); ItemTrackingForm.RegisterItemTrackingLines (SourceSpecification,SalesShptLine.“Shipment Date”,TempTrackingSpecification); END; LOCAL PROCEDURE InsertItemEntryRelation@12(NewSalesShptLine@1000 : Record 111); VAR TrackingSpecification@1001 : Record 336; ItemEntryRelation@1002 : Record 6507; BEGIN WITH TrackingSpecification DO BEGIN SETCURRENTKEY( “Source ID”,“Source Type”,“Source Subtype”,“Source Batch Name”, “Source Prod. Order Line”,“Source Ref. No.”); SETRANGE(“Source Type”,DATABASE::“Sales Line”); SETRANGE(“Source Subtype”,1); SETRANGE(“Source Batch Name”,’’); SETRANGE(“Source Prod. Order Line”,0); SETRANGE(“Source ID”,NewSalesShptLine.“Order No.”); SETRANGE(“Source Ref. No.”,NewSalesShptLine.“Order Line No.”); SETRANGE(Correction,TRUE); FIND(’-’); REPEAT IF NOT ItemEntryRelation.GET(“Appl.-to Item Entry”) THEN BEGIN ItemEntryRelation.INIT; ItemEntryRelation.“Item Entry No.” := “Appl.-to Item Entry”; ItemEntryRelation.“Serial No.” := “Serial No.”; ItemEntryRelation.“Lot No.” := “Lot No.”; ItemEntryRelation.TransferFieldsSalesShptLine(NewSalesShptLine); ItemEntryRelation.INSERT; END; UNTIL NEXT = 0; END; END; LOCAL PROCEDURE FindTrackingSpecification@9() : Boolean; VAR TrackingSpecification@1000 : Record 336; ItemEntryRelation@1002 : Record 6507; Found@1003 : Boolean; BEGIN SalesShptTempTrackingSpec.RESET; SalesShptTempTrackingSpec.DELETEALL; WITH ItemEntryRelation DO BEGIN SETCURRENTKEY( “Source ID”,“Source Type”,“Source Subtype”,“Source Ref. No.”, “Source Prod. Order Line”,“Source Batch Name”); SETRANGE(“Source ID”,SalesShptLine.“Document No.”); SETRANGE(“Source Type”,DATABASE::“Sales Shipment Line”); SETRANGE(“Source Subtype”,0); SETRANGE(“Source Ref. No.”,SalesShptLine.“Line No.”); SETRANGE(“Source Prod. Order Line”,0); SETRANGE(“Source Batch Name”,’’); IF FIND(’-’) THEN BEGIN TrackingSpecification.SETCURRENTKEY( “Source ID”,“Source Type”,“Source Subtype”,“Source Batch Name”, “Source Prod. Order Line”,“Source Ref. No.”); TrackingSpecification.SETRANGE(“Source Type”,DATABASE::“Sales Line”); TrackingSpecification.SETRANGE(“Source Subtype”,1); TrackingSpecification.SETRANGE(“Source Batch Name”,’’); TrackingSpecification.SETRANGE(“Source Prod. Order Line”,0); TrackingSpecification.SETRANGE(Positive,SalesShptLine.Quantity < 0); TrackingSpecification.SETRANGE(Correction,FALSE); REPEAT TrackingSpecification.SETRANGE(“Source ID”,“Order No.”); TrackingSpecification.SETRANGE(“Source Ref. No.”,“Order Line No.”); TrackingSpecification.SETRANGE(“Appl.-to Item Entry”,“Item Entry No.”); IF TrackingSpecification.FIND(’-’) THEN BEGIN SalesShptTempTrackingSpec := TrackingSpecification; SalesShptTempTrackingSpec.INSERT; Found := TRUE; END; UNTIL NEXT = 0; END; END; EXIT(Found); END; PROCEDURE DeleteSalesShptLineServItems@10(SalesShptLine@1000 : Record 111); VAR ServItem@1003 : Record 5940; BEGIN ServItem.SETCURRENTKEY(“Sales Shipment Document No.”,“Sales Shipment Line No.”); ServItem.SETRANGE(“Sales Shipment Document No.”,SalesShptLine.“Document No.”); ServItem.SETRANGE(“Sales Shipment Line No.”,SalesShptLine.“Line No.”); IF ServItem.FIND(’-’) THEN REPEAT IF ServItem.CheckIfCanBeDeleted() = ‘’ THEN IF ServItem.DELETE(TRUE) THEN; UNTIL ServItem.NEXT = 0; END; BEGIN END. } }