Issue with CHANGECOMPANY

brijleo
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!
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!
0
Comments
-
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)0
-
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 --0 -
Thanks Jup,
It working, as suggested i have made the function in the XML port and pass the company name from the codeunit.0 -
Hello Could You Please share your codeuint to how to pass the company name to XMLPORT from codeuint0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions