Sales Invoice Sorting Issue

thetallblokethetallbloke Member Posts: 66
Hi All,

I have a very weird situation that probably has some sensible explaination...

I ran the Sales Invoice Report (206) and it came up with an invoice and 3 items sorted by the primary key of Document No. and Line No.

I have since added a new field to the Sales Invoice Line table (113) called "Warehouse Class Code". I did this so that I could add a new key to the table of:
    Document No. Warehouse Class Code Description
However when I change the DataItemTableView for the SalesInvoiceLine section of the report from:
SORTING(Document No.,Line No.) ORDER(Ascending)
To
SORTING(Document No.,Warehouse Class Code,Description) ORDER(Ascending)

The report now behaves stangely. My first invoice no longer has 3 items on it... it has 1, 1 of the other items has been shifted onto another invoice (different customer, 20 pages along) and the 3rd item has gone completely and doesn't show on any invoice.

There is a SETRANGE line in the following standard code that once commented makes my report run correctly. so I once again have the 3 expected items on my invoice.
Sales Invoice Line - OnPreDataItem()
VATAmountLine.DELETEALL;
SalesShipmentBuffer.RESET;
SalesShipmentBuffer.DELETEALL;
FirstValueEntryNo := 0;
MoreLines := FIND('+');
WHILE MoreLines AND (Description = '') AND ("No." = '') AND (Quantity = 0) AND (Amount = 0) DO
  MoreLines := NEXT(-1) <> 0;
IF NOT MoreLines THEN
  CurrReport.BREAK;

{**********************************
   THIS LINE
 **********************************}
      SETRANGE("Line No.",0,"Line No.");
{**********************************}
CurrReport.CREATETOTALS("Line Amount",Amount,"Amount Including VAT","Inv. Discount Amount");

I guess my questions are:
    Can someone shed some light on why its there..?? Can I comment it out..?? What will that affect??? Is there a better way to get what I want..?? ie my report to sort by my chosen key fields.

I've just done some more testing and found that if all the Warehouse Class Codes are the same or in ascending order in the table, the report works fine.. if I set them to be 3, 2, and 1 for a 3 item invoice, only the first one displays...

I hope this points to a solution from someone..

Many thanks..
.
I'm not crazy !!! Just ask my toaster...
.

Comments

  • thetallblokethetallbloke Member Posts: 66
    I've accidentally posted this in the Navision Exams & Certification forum....

    Can someone please move it into the General Version >= 3.70 and <= 5.0 group...

    Thanks

    Sorry...
    .
    I'm not crazy !!! Just ask my toaster...
    .
  • krikikriki Member, Moderator Posts: 9,110
    [Topic moved from Navision Exams & Certification forum to Navision forum]

    PS to report this (and other things) that require moderator- (or admin-) action, you can use the reporting-functionality (=the red ! at the right of the post).
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • gulamdastagirgulamdastagir Member Posts: 411
    Hi

    Even i Face a similar Problem that is to sort the invoice lines by Item no rather than Lino no
    so i added a new key on the Sales Invoice Line called "Document No.","Type","No."
    and [My Code] is shown Below.

    However it sorts all invoice lines according to the new key except doesnt Show invoice lines with type "G/L Account" on the Invoice(report).

    Any Experts out there?


    Sales Invoice Line - OnPreDataItem()
    VATAmountLine.DELETEALL;
    SalesShipmentBuffer.RESET;
    SalesShipmentBuffer.DELETEALL;
    FirstValueEntryNo := 0;
    MoreLines := FIND('+');
    WHILE MoreLines AND (Description = '') AND ("No." = '') AND (Quantity = 0) AND (Amount = 0) DO
      MoreLines := NEXT(-1) <> 0;
    IF NOT MoreLines THEN
      CurrReport.BREAK;
    
          SETRANGE("Line No.",0,"Line No.");
    
    
    [MY CODE>>>]TempSIL.COPY("Sales Invoice Line");
    TempSIL.RESET;
    TempSIL.SETCURRENTKEY("Document No.","Type","No.");
    TempSIL.SETFILTER("Document No.","Document No.");
    TempSIL.SETFILTER("Type",'%1',"Type"::Item);
    if TempSIL.FIND('-') then
    "Sales Invoice Line".COPY(TempSIL);
    [<<<<<MY CODE]
    CurrReport.CREATETOTALS("Line Amount",Amount,"Amount Including VAT","Inv. Discount Amount");
    
    Regards,

    GD
Sign In or Register to comment.