How can i make a report that show me, for example, the sales to a specific client from all companys on the database? I thin changecompany ca do the trick but i con't know how to use it
I've duplicated Cronus database so i have two companys now. I need to list all the costumers from both companys on one single report. Can anyone give me a clue on how to do this please?
Best thing to do it creating a temp record of table Customer. Then build a integer loop (or two) that fills this table from then customer table from both companies. Loop the integer loop as many times as there are customers in both tables. This you could do by summing 2 count statements. But nicer is to break the dataitem if no records exists to progress. (You could use two customer dataitems, but i think it's nicer to use integer dataitem in this case.)
Below a sample in short, there are missing things as you can see, but you have to do the thinking here.
OnPreDataItem()
CangeCompany(Companyname);
OnAfterGetRecord()
if number = 1 then
cust.find('-')
else
cust.next;
TempCust := Cust;
TempCust.insert;
If you will not get an double key conflict, You will have all customer of both companies in one table.
NOTE! If you really want to make something that lasts for ever, you will have to loop your companies. This way you don't have to return to your customer when They add an extra company.
Loop this temp table with an integer loop.
This is an explaintion in short, I know... You have to do the rest.
Good luck!
"Real programmers don't comment their code.
If it was hard to write, it should be hard to understand."
The problem is that afterwards i can't know wich costumer is from wich company. So i tryed the following:
1. I've created a table with the fields i need plus one stating the company from wich the costumer is from.
2. On a codeunit, i've dreated a temp table from my costum table sub-type.
3. Then, looped trough my companys and populated the table.
4. Finaly called a report with report.runmodal, passing as argument the temprecord.
It gives me the duplicated key error is there a obviuos mistake?
Don't go creating new tables for this. Just misuse some other fields for this.
Every customer you insert in this "combined" table has to get a new No. I already warned you for a double key error in my previous post. Save the customer no. in another field, same for you company name.
It's not that nice, but who cares!?
Or you COULD create a new table. Make a table where you have company name and number in the key, then every record should be uniq. But really, I think it's a waste of a perfectly good empty table number.
"Real programmers don't comment their code.
If it was hard to write, it should be hard to understand."
The solution that I have given will generate a report having layout like this
Company Name
Customer Details for the company
Company Name
Customer Details for the company
I am not able to able to understand the doubt that has been raised. You can sort the customers by setting DataItemTableView property. I have tested it and works fine.
Yes, you are right. If you want all - say employees from all the companies to be sorted in a particular order, then usage of a temporary table is necessary. But if you want all records classified by company, its not necessary.
Comments
OnPreDataItem()
RecCount := Company.COUNT;
Table_Name := COPYSTR(Master.TABLENAME,1,30);
ReportDescription := COPYSTR(Table_Name + ' - ' +
'YourReportDescription',1,60);
Window.OPEN('#3############################################################\'+
'Processing #4################ Record#1############ @');
Window.UPDATE(3,ReportDescription);
Window.UPDATE(4,Table_Name);
OnAfterGetRecord()
RecordNo := RecordNo + 1;
Window.UPDATE(1,Company.Name);
Window.UPDATE(2,ROUND(RecordNo/RecCount * 10000,1));
YourTable.CHANGECOMPANY(Company.Name);
etc....
Good Luck!
Denis Petrov.
I've duplicated Cronus database so i have two companys now. I need to list all the costumers from both companys on one single report. Can anyone give me a clue on how to do this please?
Vx
Best thing to do it creating a temp record of table Customer. Then build a integer loop (or two) that fills this table from then customer table from both companies. Loop the integer loop as many times as there are customers in both tables. This you could do by summing 2 count statements. But nicer is to break the dataitem if no records exists to progress. (You could use two customer dataitems, but i think it's nicer to use integer dataitem in this case.)
Below a sample in short, there are missing things as you can see, but you have to do the thinking here.
OnPreDataItem()
CangeCompany(Companyname);
OnAfterGetRecord()
if number = 1 then
cust.find('-')
else
cust.next;
TempCust := Cust;
TempCust.insert;
If you will not get an double key conflict, You will have all customer of both companies in one table.
NOTE! If you really want to make something that lasts for ever, you will have to loop your companies. This way you don't have to return to your customer when They add an extra company.
Loop this temp table with an integer loop.
This is an explaintion in short, I know... You have to do the rest.
Good luck!
If it was hard to write, it should be hard to understand."
1. I've created a table with the fields i need plus one stating the company from wich the costumer is from.
2. On a codeunit, i've dreated a temp table from my costum table sub-type.
3. Then, looped trough my companys and populated the table.
4. Finaly called a report with report.runmodal, passing as argument the temprecord.
It gives me the duplicated key error is there a obviuos mistake?
Vx
Every customer you insert in this "combined" table has to get a new No. I already warned you for a double key error in my previous post. Save the customer no. in another field, same for you company name.
It's not that nice, but who cares!?
Or you COULD create a new table. Make a table where you have company name and number in the key, then every record should be uniq. But really, I think it's a waste of a perfectly good empty table number.
If it was hard to write, it should be hard to understand."
But one thing i couldn't understand. How can i make a temporary table? When i create a record temporary it's only a record right? not a table right?
Vx
If it was hard to write, it should be hard to understand."
I hope this helps. Create a report having two dataitems.
1st DataItem : Company (ID: 2000000006)
2nd DataItem : Customer (ID: 18)
2nd DataItem is indented
OnPreDataItem of Customer write following
Customer.ChangeCompany( Company.name );
In Sections
Body of company dataitem print Name of company
Body of Customer - desired fields from customer table
Thats It !!!!!
All the Best
That is nice... But if you do it like that you are not able to sort your customers by e.g. Search Name.
You will get 2 seprate sections for your customers from different companies.
If it was hard to write, it should be hard to understand."
The solution that I have given will generate a report having layout like this
Company Name
Customer Details for the company
Company Name
Customer Details for the company
I am not able to able to understand the doubt that has been raised. You can sort the customers by setting DataItemTableView property. I have tested it and works fine.
Jyotsna
Thank you again
Vx
What I meant was the following output:
10000 Abraham (Company A)
86280 Bernard (Company
20000 Derk (Company A)
If it was hard to write, it should be hard to understand."
Yes, you are right. If you want all - say employees from all the companies to be sorted in a particular order, then usage of a temporary table is necessary. But if you want all records classified by company, its not necessary.
Regards
Jyotsna