How to retrieve all company data from one company

Jacob1227Jacob1227 Member Posts: 128
Hi All,

I have created one xml port which used to export one company data from one table( table A). But now I want to retrieve all the company details from that table'A' without changing the company.

Ex: Table 'A' - has all company(Cronus usa,Cronus canada...etc) data. I am accessing canada USA,I want to export all the company data without changing to another the company

Can you please help me to do this.

Thanks in advance,
Jacob.A


Best Answer

Answers

  • Brax007Brax007 Member Posts: 26
    Hi, you can use the function CHNAGECOMPANY and then repeat it on eachy company in your export
  • Jacob1227Jacob1227 Member Posts: 128
    Thanks Brax,

    Can you please provide me some code snippet for this.
  • JJMcJJMc Member Posts: 59
    Why don't you simply copy the company?
  • mucamuca Member Posts: 42
    edited 2019-10-18
    You have two Variables that is Record TableA
    TableA1 and TableA2
    When You use these table variables they will use data from current company
    TableA1.FINDFIRST;
    REPEAT
    .....
    UNTIL TableA1.NEXT=0;

    But when You use
    TableA2.CHANGECOMPANY('Other database company name');
    TableA2.FINDFIRST;
    REPEAT
    .....
    UNTIL TableA2.NEXT=0;
    You will get all records from TableA, but from other (not current) company ;o)

    In XML port it can be two names where OnPreXMLItem You can use this CHANGECOMPANY
  • Jacob1227Jacob1227 Member Posts: 128
    muca wrote: »
    You have two Variables that is Record TableA
    TableA1 and TableA2
    When You use these table variables they will use data from current company
    TableA1.FINDFIRST;
    REPEAT
    .....
    UNTIL TableA1.NEXT=0;

    But when You use
    TableA2.CHANGECOMPANY('Other database company name');
    TableA2.FINDFIRST;
    REPEAT
    .....
    UNTIL TableA2.NEXT=0;
    You will get all records from TableA, but from other (not current) company ;o)

    In XML port it can be two names where OnPreXMLItem You can use this CHANGECOMPANY

    Thanks for your suggestion.

    I have more than 20 companies in my environment.

    So is this possible to get all company data without hard coding individual company name company name?


  • Jacob1227Jacob1227 Member Posts: 128
    Hi Shaihulud,

    It seems to be working.

    Thank you so much :)

    Warm regards,
    Jacob.A
  • Jacob1227Jacob1227 Member Posts: 128
    Hi @ShaiHulud ,

    Where I have to use the code snippet in xml port?

    when i was trying the code in codeunit ther it works.

    But in xml port it didnot work. I was putting the code in onprexmlport() trigger.

    Please help me with the correct trigger to put the code.and also i want to get the data for only five companies not for all 20 companies.

    Guide me,,,

    Thanks,
    Jacob.A
  • Jacob1227Jacob1227 Member Posts: 128
    edited 2019-10-31
    Hi @ShaiHulud, Can you please help me on this.
  • ShaiHuludShaiHulud Member Posts: 228
    Jacob1227 wrote: »
    Hi @ShaiHulud, Can you please help me on this.

    This entirely depends on how your XML port is structured. I had actually written a reply to you earlier, but Mibuso for some reason dumped it into "waiting for approval".
    Anyway, in short, you could have a codeunit that switches companies on your chosen table, and that passes that table to an XMLPort. Something along the lines of
    Company.SETFILTER(Name, 'whatever filter you make to select only those 5 companies');
    IF Company.FINDSET THEN BEGIN
      REPEAT
        TableA.CHANGECOMPANY(Company.Name);
        XMLport.RUN (50000, FALSE, FALSE, TableA); //replace 50000 with your XMLPort No.
      UNTIL Company.NEXT = 0;
    END;
    

    Again, that depends entirely on how your XMLPort is structured. The approach I suggest depends on you having your TableA as the "root" record in the XMLPort.
Sign In or Register to comment.