Problem with a report - help needed..

ImaspalImaspal Member Posts: 68
Hi Experts!

I have a report, where commissions of sales are showed by salesperson like that:

Code--Name--Quantity--Amount
01
Jesse--10
2000
05
James-15
2500
etc.

I have made a DataItemLink using Salesperson Code between tables
- Salesperson/Purchaser,
- Sales Header and
- Sales Line.

These tables are also indented like this:
-Salesperson/Purchaser
--Sales Header
---Sales Line

Now client wants to see also those lines on this report, where field Salesperson Code is empty (''). How can I do this easily, without modifying the table Salesperson/Purchaser? Suggestions and code examples are very awaited.

Yours,
Imaspal

Comments

  • vanrofivanrofi Member Posts: 272
    Hmm, I think you should re-structure you report a little, so that you have dataItem Sales Header first, I don't thik you should Salesperson as data-item. You could create a variable for that in order to Pickup the Name.

    You could fill a temp-table on every change of Salesperson code of Sale Header you fill another Line with the data you need. (or add on existing Line)...

    Or wait for more solutions on this form...
  • garakgarak Member Posts: 3,263
    do you need all three dataitems or it is possible only work with sales lines and use goups
    Do you make it right, it works too!
  • awarnawarn Member Posts: 261
    Maybe this will work (no temp tables, but more sections). if you have a lot of code behind sections / dataitems this might be a pain.

    Dataitems:
    -Salesperson/Purchaser
    --Sales Header
    ---Sales Line
    -Sales Header //this sales header dataitem has the filter 'Salesperson Code = '')
    --Sales Line

    You end up having duplicate sections, and you will may have to handle the totalling yourself. I would do it with temporary tables myself.


    With temporary tables it would look like this:

    temporary variable, tmpSP, salesperson table

    1-Salesperson / Purchaser
    2-Integer
    3--Sales Header
    4---Sales Line

    Dataitem 1 - (no sections)
    Set the DataItemTableView to use the Number key (so the section doesn't show up to the user)

    OnAfterGetRecord:
    tmpSP = Salesperson / Purchaser;
    tmpSP.INSERT;

    OnPostDataItem
    tmpSP.INIT;
    IF tmpSP.INSERT THEN; //in case a blank salesperson exists in the db

    Then treat the Integer as your salesperson dataitem.
    Dataitem 2
    OnPreDataItem
    tmpSP.RESET;
    SETRANGE(Number,1,tmpSP.COUNT);
    bFirst := TRUE; //new boolean global variable

    OnAfterGetRecord
    IF bFirst THEN BEGIN
    bFirst := FALSE;
    tmpSP.FINDSET; //or FIND('-'), depending on the version
    END ELSE
    tmpSP.NEXT;
    SalesHeader.SETRANGE("Salesperson Code",tmpSP.Code); //need this to simulate the link between this section and #3

    That is it - you will need to do whatever code you have in there now for the totalling, just remember you are dealing with the tmpSP record, not the Salesperson / purchaser dataitem.

    -a
  • ImaspalImaspal Member Posts: 68
    Thank you for your advice awarn. I finally succeed with this one, your help was important.

    Yours,
    Imaspal
Sign In or Register to comment.