Issue with CHANGECOMPANY

brijleobrijleo Member Posts: 70
Hi,

There is a scenario we want to export vendor master using XML port for all the company.
For this i have written the codeunit and used the CHANGECOMPANY function to export the data for all the company.
Code which i have written is :
recCompany.FIND('-');
REPEAT
CLEAR(recFile);
CLEAR(recSetup);
CLEAR(recVendor);
recSetup.CHANGECOMPANY(recCompany.Name);
recSetup.GET;
recFile.CREATE(recSetup."File Location"+'\'+recCompany.Name+'_Vendor'+ '.xml');
recFile.CREATEOUTSTREAM(FileOutsream);
CLEAR(recVendor);
recVendor.CHANGECOMPANY(recCompany.Name);
IF recVendor.FINDSET THEN
XMLPORT.EXPORT(50007,FileOutsream,recVendor);
recFile.CLOSE;
UNTIL recCompany.NEXT=0;

When i check the output XML file, data in all the XML file is same for all the company from which i run this codeunit. can anybody suggest why this is happening?

Thanks!

Comments

  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    Probably because XMLPort 50007 doesn't contain the CHANGECOMPANY statements.
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • jupjup Member Posts: 7
    It seems that you cannot use the CHANGECOMPANY on the Vendor rec and then use it as TableView (also tried the SETTABLEVIEW function of an XMLPort variable, but didn't work).
    I suggest you to create a function (i.e. setCompany) in your XMLPort and call it to pass the company name, then perform the CHANGECOMPANY directly in the OnPreXMLPort trigger..
    -- Jup --
  • brijleobrijleo Member Posts: 70
    Thanks Jup,

    It working, as suggested i have made the function in the XML port and pass the company name from the codeunit.
  • majid1222majid1222 Member Posts: 1
    Hello Could You Please share your codeuint to how to pass the company name to XMLPORT from codeuint
Sign In or Register to comment.