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
0
Comments
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...
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
Yours,
Imaspal