Gathering info from several companys

rvalfreixorvalfreixo Member Posts: 9
edited 2003-08-21 in Navision Attain
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

Thank you in advance
Vx

Comments

  • Denis_PetrovDenis_Petrov Member Posts: 107
    This is what I have for my GLOBAL reports (we have 165 companies in our db)



    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!
    Best regards,

    Denis Petrov.
  • rvalfreixorvalfreixo Member Posts: 9
    Can anyone help me?

    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
  • eromeineromein Member Posts: 589
    It's not that hard.

    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."
  • rvalfreixorvalfreixo Member Posts: 9
    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?

    Vx
  • eromeineromein Member Posts: 589
    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."
  • rvalfreixorvalfreixo Member Posts: 9
    Nice, i've made what i needed and i guess this problem's solved. I've made a report that gathers the info and makes the calculation on the fly.. Nice

    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
  • eromeineromein Member Posts: 589
    Yes. A temporary table is fact a temporary record variable. I (we) just call it a temporary table.
    "Real programmers don't comment their code.
    If it was hard to write, it should be hard to understand."
  • jyotsnasjyotsnas Member Posts: 62
    Hi

    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
    ______Doubt is the father of Invension_______
  • eromeineromein Member Posts: 589
    jyotsnas,

    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.
    "Real programmers don't comment their code.
    If it was hard to write, it should be hard to understand."
  • jyotsnasjyotsnas Member Posts: 62
    Hi

    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
    ______Doubt is the father of Invension_______
  • rvalfreixorvalfreixo Member Posts: 9
    yes, it is working now and i thank you for your help :) i was complicatig more that i had to :)

    Thank you again

    Vx
  • eromeineromein Member Posts: 589
    jyotsnas,

    What I meant was the following output:

    10000 Abraham (Company A)
    86280 Bernard (Company B)
    20000 Derk (Company A)
    "Real programmers don't comment their code.
    If it was hard to write, it should be hard to understand."
  • jyotsnasjyotsnas Member Posts: 62
    Hi Eromin

    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
    ______Doubt is the father of Invension_______
Sign In or Register to comment.