Posted Package Report

johnsogjjohnsogj Member Posts: 103
hello, I'm trying to display then number of packages posted on a given day per ship to customer and as a total. I figured I'd first calculate the number of packages per customer for a given day, but the report only calculates it for the first customer it finds. Here is what I used:


PostedPkg.SETRANGE("Posting Date", "Posting Date");
PostedPkg.SETRANGE("Ship-to No.", "Ship-to No.");
IF PostedPkg.FINDSET THEN
TotalPkgs := PostedPkg.COUNT;

It shows 11 pkgs for the first customer, but doesnt show the 3 pkgs for the other customer. what am I missing?

Comments

  • garakgarak Member Posts: 3,263
    edited 2009-01-05
    is there some code above the first PostedPkg.SETRANGE() Line and in which Trigger is that code?
    PostedPkg.SETRANGE("Posting Date", "Posting Date");
    PostedPkg.SETRANGE("Ship-to No.", "Ship-to No.");
    IF PostedPkg.FINDSET THEN
    TotalPkgs := PostedPkg.COUNT;
    

    The (IF PostedPkg.FINDSET THEN) you doesn't need if you use it only for the count. Use the findset if you want to make a loop.

    so better, if you doen't want to make a loop
    PostedPkg.reset;
    PostedPkg.SETRANGE("Posting Date", "Posting Date");
    PostedPkg.SETRANGE("Ship-to No.", "Ship-to No.");
    TotalPkgs := PostedPkg.COUNT;
    
    Do you make it right, it works too!
  • TomasTomas Member Posts: 420
    johnsogj wrote:
    hello, I'm trying to display then number of packages posted on a given day per ship to customer and as a total. I figured I'd first calculate the number of packages per customer for a given day, but the report only calculates it for the first customer it finds. Here is what I used:


    PostedPkg.SETRANGE("Posting Date", "Posting Date");
    PostedPkg.SETRANGE("Ship-to No.", "Ship-to No.");
    IF PostedPkg.FINDSET THEN
    TotalPkgs := PostedPkg.COUNT;

    It shows 11 pkgs for the first customer, but doesnt show the 3 pkgs for the other customer. what am I missing?

    Where did you put that code?
    OnAfterGetRecord?
  • johnsogjjohnsogj Member Posts: 103
    yes, its in the "onaftergetrecord" section.

    I tried taking out the findset piece of code. so now it is


    PostedPkg.RESET;
    PostedPkg.SETRANGE("Posting Date", "Posting Date");
    PostedPkg.SETRANGE("Ship-to No.", "Ship-to No.");
    TotalPkgs := PostedPkg.COUNT;

    but I still get the same outcome. its not finding or displaying the second set of pkgs for the other customer on that day
  • TomasTomas Member Posts: 420
    johnsogj wrote:
    yes, its in the "onaftergetrecord" section.

    I tried taking out the findset piece of code. so now it is


    PostedPkg.RESET;
    PostedPkg.SETRANGE("Posting Date", "Posting Date");
    PostedPkg.SETRANGE("Ship-to No.", "Ship-to No.");
    TotalPkgs := PostedPkg.COUNT;

    but I still get the same outcome. its not finding or displaying the second set of pkgs for the other customer on that day

    What about your dataitems? I think you might have only one dataitem? (if it is returning only one customer). You could try debugging and checking which data it's going through.

    As I understand, you should have two dataitems:
    - Customer
    -- PostedPkg (linked to customer)
  • garakgarak Member Posts: 3,263
    "Ship-to No." is the filter for the Customer No. ?
    Do you make it right, it works too!
  • johnsogjjohnsogj Member Posts: 103
    hmmm. my only data item is the Posted Packages table. I didnt think I needed the Customer table since "Ship To" is a field in the Posted Packages table. should the Customer table be a nested table underneath the Posted Packages table?
  • garakgarak Member Posts: 3,263
    hello, I'm trying to display then number of packages posted on a given day per ship to customer and as a total. I figured I'd first calculate the number of packages per customer for a given day, but the report only calculates it for the first customer it finds. Here is what I used:

    PostedPkg.SETRANGE("Posting Date", "Posting Date");
    PostedPkg.SETRANGE("Ship-to No.", "Ship-to No.");
    IF PostedPkg.FINDSET THEN
    TotalPkgs := PostedPkg.COUNT;

    It shows 11 pkgs for the first customer, but doesnt show the 3 pkgs for the other customer. what am I missing?
    johnsogj wrote:
    hmmm. my only data item is the Posted Packages table. I didnt think I needed the Customer table since "Ship To" is a field in the Posted Packages table. should the Customer table be a nested table underneath the Posted Packages table?

    now i'm confused.

    You go through the "Posted Packages table" (the only DataItem). In these DataItem u use a new Record variable with name PostedPkg to count all PostedPkges with the same "Posting Date" and the same "Ship-to No." based on the "Posted Packages" Record in your DataItem. So where is here the customer ;-)
    Do you make it right, it works too!
  • johnsogjjohnsogj Member Posts: 103
    I've been using "customer" and "Ship To No." interchangebly. sorry for the confusion. hope that clears it up
  • garakgarak Member Posts: 3,263
    edited 2009-01-18
    ok, how looks your whole report.
    There must be something wrong in your report structure or your properties.

    Let's see the whole reportsource here in a (CODE)(/Code) section as text
    Do you make it right, it works too!
  • johnsogjjohnsogj Member Posts: 103
    ah ha! you are on to something with the structure. I changed it so all of my output fields are just in a "body" section. now the report finds all of the records, however, since there are 11 packages for the ship to "A", there are also 11 lines on the report output (all displaying the same info). and then there are 3 packages for ship to "B", so there are 3 lines on the report for that ship to. how do I get it to only display one line on the report for each ship to? I tried a group footer, but it only showed 1 line on the report and used the information for ship to "B" (3 packages). I would expect to have 2 lines in the report. 1 line to show 11 packages for ship to "A", and 1 line to show 3 packages for ship to "B".
  • MBergerMBerger Member Posts: 413
    You need to loop your customers, and THEN you need to loop the packages.
    Make a report with Customer as the first dataitem, and then your packages table indented. Use the Link properties to Link it with the Customer ( no need for a setrange on Ship-to no), and the setrange on the Posting date can be done in the OnBeforeDataItem of the Packages table
  • johnsogjjohnsogj Member Posts: 103
    Thanks for the feedback. I modified the data items set up as you suggested. However, I still get 14 lines on the output. The first 3 lines are for ship to "A", but it shows the total packages is 0. (it should be 3). The next 11 lines are for ship to "B". It shows the total packages as 14 (it should be 11). ideas?
  • johnsogjjohnsogj Member Posts: 103
    hmmm. I just move that section of code to the "OnAfterGetRecord" section. Now all 14 lines show up but regardless of the ship to on the line, the total packages is "14".
  • johnsogjjohnsogj Member Posts: 103
    Never mind. I just played around with some stuff and figured it out. THANK YOU!
  • garakgarak Member Posts: 3,263
    why do you not post the report here as text?
    So we will find your :bug:
    Do you make it right, it works too!
Sign In or Register to comment.