S IT POSSIBLE FROM A COMPANIES, TO CREATE AN ORDER OF HE/SHE BUYS IN ANOTHER COMPANY AND TO REGISTER IT? THANK YOU.
Yes it is. You can access a company from another company using the instruction CHANGECOMPANY of a record variable. For example, suppose you are working in the company X and you want create an order in the company Y; the code to write is: SalesOrder.CHANGECOMPANY(‘Y’); SalesOrder.INIT; SalesOrder.“Document Type” := SalesOrder.“Document Type”::Order; SalesOrder.“No.” := ‘’; SalesOrder.INSERT(TRUE); SalesOrder.VALIDATE(“Sell-to Customer No.”,‘10000’); SalesOrder.MODIFY; where SalesOrder is a record variable that “points” to table 36. Those lines just create an order header using the numbering defined in Sales Setup. After creating the lines (using CHANGECOMPANY), you can post the order in the usual way (send the header to codeunit 80 after setting the fields Ship and Invoice). Hope this helps you Best regards Marco Ferrari
and in the codeunit 80, do I have to use the changecompany in all the table?
Yes, I think so, because there’s not a way to change a company for the entire application area. In this case you have to change the company name for local variables too (and it’s not a good way of working). Best regards Marco
yes i agree. in marco’s codeunit, when any validation is done it is done to the company that you are in currently opening. company1 → is the company you are opening currently company2 → is the external company, which you would like to insert some records with validation if you were to do any kind of validation on company2 from company1 by using CHANGECOMPANY(), it will be validated against all the tables in company1. the work around here is to create a batch job. this batch job has to be run from company2. when run from company2, it will pick up all the data from a temptable and start’s it processing. any kind of processing here will be validated against company2.