{"id":17,"date":"2011-05-20T14:14:00","date_gmt":"2011-05-20T14:14:00","guid":{"rendered":"http:\/\/greytrix.com\/Blogs\/sageaccpacerp\/?p=17"},"modified":"2024-02-13T09:20:45","modified_gmt":"2024-02-13T09:20:45","slug":"how-to-programmatically-get-list-of-companies-from-the-accpac-system","status":"publish","type":"post","link":"https:\/\/www.greytrix.com\/blogs\/sageaccpacerp\/2011\/05\/20\/how-to-programmatically-get-list-of-companies-from-the-accpac-system\/","title":{"rendered":"How to programmatically get List of Companies from the Accpac system"},"content":{"rendered":"<p style=\"text-align: justify;\">Almost every integration that we do between Sage Accpac ERP and 3rd Party Product, on our setup screen we have to display the list of all Accpac companies so that our connector knows which Accpac companies data is getting integrated with the 3rd party Product.<\/p>\n<p style=\"text-align: justify;\">If you are also writing something like this and need to get the list of Accpac companies programmatically and are looking for a solution then this blog would be helpful to you.<\/p>\n<p style=\"text-align: justify;\">Accpac ERP stores the list of all the companies in a file \u201cORGS.ISAM\u201d located under \u201c&lt; Accpac Installation folder &gt;: Program FilesAccpacSite\u201d folder. You must read this file and store this information in some array or recordset etc. Now the question is that would come to your mind is how to read the file? Well, below code snippet should answer your question.<\/p>\n<div>Here is the code to read the \u201cORGS.ISAM\u201d file\u2026<\/div>\n<p><strong>Script:<\/strong><br \/>\n<i>Declare following variables and functions at the module level.<\/i><br \/>\n&#8216;Org type (database catagory)<br \/>\nGlobal Const ORG_TYPE_SYSTEM = 0<br \/>\nGlobal Const ORG_TYPE_COMPANY = 1<br \/>\n&#8216;Security levels<br \/>\nGlobal Const ORG_SECLVL_NONE = 0<br \/>\nGlobal Const ORG_SECLVL_DB = 1<br \/>\nGlobal Const ORG_SECLVL_USER = 2<br \/>\n&#8216;Status<br \/>\nGlobal Const ORG_ACTIVE = 0<br \/>\nGlobal Const ORG_ = 1<br \/>\n&#8216;Errors<br \/>\nGlobal Const ORG_ERROR_SIZE = 1001<br \/>\nGlobal Const SIZEOF_ORGID = 6<br \/>\nGlobal Const SIZEOF_ORGDESC = 30<br \/>\nGlobal Const SIZEOF_DB = 260<br \/>\nGlobal Const SIZEOF_USERID = 8<br \/>\nGlobal Const SIZEOF_PASSWORD = 8<br \/>\nType ORGRecord<br \/>\nwSizeOrg As Integer<br \/>\nsOrgId As String * SIZEOF_ORGID<br \/>\nsDesc As String * SIZEOF_ORGDESC<br \/>\nwOrgType As Integer<br \/>\nsSystemOrgID As String * SIZEOF_ORGID<br \/>\nwDriverID As Integer<br \/>\nsDatabase As String * SIZEOF_DB<br \/>\nwSecLevel As Integer<br \/>\nsSignonID As String * SIZEOF_USERID<br \/>\nsSignonPW As String * SIZEOF_PASSWORD<br \/>\nfSecEnabled As Integer<br \/>\nwStatus As Integer<br \/>\nEnd Type<br \/>\nDeclare Function orgOpen Lib &#8220;a4wapi.dll&#8221; (reserved As Long, ByRef lHandle As Long) As Long<br \/>\nDeclare Function orgClose Lib &#8220;a4wapi.dll&#8221; (ByVal lHandle As Long) As Long<br \/>\nDeclare Function orgGet Lib &#8220;a4wapi.dll&#8221; (ByVal lHandle As Long, ByRef cmpList As ORGRecord) As Long<br \/>\nDeclare Function orgGetGE Lib &#8220;a4wapi.dll&#8221; (ByVal lHandle As Long, ByRef cmpList As ORGRecord) As Long<br \/>\nDeclare Function orgGetNext Lib &#8220;a4wapi.dll&#8221; (ByVal lHandle As Long, ByRef cmpList As ORGRecord) As Long<br \/>\n&#8216;The below Function is for Getting all companies from Accpac.<br \/>\nPublic Function GetCompanyList() As ADODB.Recordset<br \/>\n&#8216;Use this code to get the ORGS records:<br \/>\nDim CompanyDef As ORGRecord<br \/>\nDim rotoHandle As Long<br \/>\nDim lngStatus As Long<br \/>\nDim strOrgType As String<br \/>\nDim strDriver As String<br \/>\n&#8216;Set the recordset<br \/>\nSet rsCompanies = New ADODB.Recordset<br \/>\n&#8216;Create new fields in the recordset<br \/>\nWith rsCompanies<br \/>\n.Fields.Append &#8220;COMPANYID&#8221;, adVarChar, 60, adFldIsNullable<br \/>\n.Fields.Append &#8220;COMPANYNAME&#8221;, adVarChar, 60, adFldIsNullable<br \/>\n.CursorLocation = adUseClient<br \/>\n.CursorType = adOpenDynamic<br \/>\n.Open<br \/>\nEnd With<br \/>\n&#8216;Open ORGS.ISM<br \/>\nlngStatus = orgOpen(0, rotoHandle)<br \/>\nCompanyDef.wSizeOrg = Len(CompanyDef)<br \/>\nCompanyDef.sOrgId = VBA.String(SIZEOF_ORGID, &#8221; &#8220;)<br \/>\norgGetGE rotoHandle, CompanyDef<br \/>\n&#8216;Get rest of the entries<br \/>\nDo &#8216;orgGetNext(rotoHandle, CompanyDef) = 0 &#8216;lngStatus = 0<br \/>\nIf CompanyDef.wOrgType = 1 Then<br \/>\nrsCompanies.AddNew<br \/>\nrsCompanies.Fields(&#8220;COMPANYID&#8221;).Value = CompanyDef.sOrgId<br \/>\nrsCompanies.Fields(&#8220;COMPANYNAME&#8221;).Value = CompanyDef.sDesc<br \/>\nrsCompanies.Update<br \/>\nEnd If<br \/>\nLoop While orgGetNext(rotoHandle, CompanyDef) = 0<br \/>\n&#8216;Close ORGS.ISM<br \/>\norgClose (rotoHandle)<br \/>\nSet GetCompanyList = rsCompanies<br \/>\nEnd Function<br \/>\n<span style=\"font-size: Medium;\"><strong>About Us<\/strong><\/span><br \/>\nGreytrix is a one stop solution provider for Sage ERP and Sage CRM needs. We provide complete end-to-end assistance for your technical consultations, product customizations, data migration, system integrations, third party add-on development and implementation expertise.<br \/>\n<a href=\"http:\/\/www.greytrix.com\/\">Greytrix<\/a>\u00a0has some unique solutions of\u00a0<a href=\"http:\/\/www.greytrix.com\/product\/sage-crm\/gumu-sage-300-erp-integration\">Sage 300 integration with Sage CRM,<\/a>\u00a0<a href=\"http:\/\/www.greytrix.com\/product\/sage-300-erp\/gumu-300-salesforce-integration\">Salesforce.com\u00a0<\/a>and\u00a0<a href=\"http:\/\/www.greytrix.com\/product\/sage-300-erp\/ecommerce-magento-integration\">Magento eCommerce<\/a> along with Sage 300 Migration from Sage 50 US, Sage 50 CA, Sage PRO, QuickBooks, Sage Business Vision and Sage Business Works. We also offer best-in-class\u00a0<a href=\"http:\/\/www.greytrix.com\/product\/erp-development\/sage-300-erp-development\">Sage 300 customization and development services<\/a>\u00a0to Sage business partners, end users, and Sage PSG worldwide.<br \/>\nFor more details on Sage 300 Services, please contact us at\u00a0<a href=\"mailto:accpac@greytrix.com\">accpac@greytrix.com<\/a>. We will be glad to assist you.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Almost every integration that we do between Sage Accpac ERP and 3rd Party Product, on our setup screen we have to display the list of all Accpac companies so that our connector knows which Accpac companies data is getting integrated with the 3rd party Product. If you are also writing something like this and need\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.greytrix.com\/blogs\/sageaccpacerp\/2011\/05\/20\/how-to-programmatically-get-list-of-companies-from-the-accpac-system\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[91,1026,1474,2051,2052,2415,2416,2449],"class_list":["post-17","post","type-post","status-publish","format-standard","hentry","category-sage-accpac","tag-accpac-system","tag-functions-to-get-list-of-companies","tag-list-of-companies-from-accpac-system","tag-program-filesaccpacsite","tag-programmatically-get-list-of-companies","tag-sage-300-technical-assistance","tag-sage-300-technical-blogs","tag-sage-accpac-and-third-party-integration"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to programmatically get List of Companies from the Accpac system<\/title>\n<meta name=\"description\" content=\"How to obtain data programmatically Companies listed in the Accpac system getting integrated with the 3rd Party Product.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.greytrix.com\/blogs\/sageaccpacerp\/2011\/05\/20\/how-to-programmatically-get-list-of-companies-from-the-accpac-system\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to programmatically get List of Companies from the Accpac system\" \/>\n<meta property=\"og:description\" content=\"How to obtain data programmatically Companies listed in the Accpac system getting integrated with the 3rd Party Product.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.greytrix.com\/blogs\/sageaccpacerp\/2011\/05\/20\/how-to-programmatically-get-list-of-companies-from-the-accpac-system\/\" \/>\n<meta property=\"og:site_name\" content=\"Sage 300 ERP \u2013 Tips, Tricks and Components\" \/>\n<meta property=\"article:published_time\" content=\"2011-05-20T14:14:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-02-13T09:20:45+00:00\" \/>\n<meta name=\"author\" content=\"sage300\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"sage300\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.greytrix.com\/blogs\/sageaccpacerp\/2011\/05\/20\/how-to-programmatically-get-list-of-companies-from-the-accpac-system\/\",\"url\":\"https:\/\/www.greytrix.com\/blogs\/sageaccpacerp\/2011\/05\/20\/how-to-programmatically-get-list-of-companies-from-the-accpac-system\/\",\"name\":\"How to programmatically get List of Companies from the Accpac system\",\"isPartOf\":{\"@id\":\"https:\/\/www.greytrix.com\/blogs\/sageaccpacerp\/#website\"},\"datePublished\":\"2011-05-20T14:14:00+00:00\",\"dateModified\":\"2024-02-13T09:20:45+00:00\",\"author\":{\"@id\":\"https:\/\/www.greytrix.com\/blogs\/sageaccpacerp\/#\/schema\/person\/1aced4e22c30ccf606960de27c9542f5\"},\"description\":\"How to obtain data programmatically Companies listed in the Accpac system getting integrated with the 3rd Party Product.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.greytrix.com\/blogs\/sageaccpacerp\/2011\/05\/20\/how-to-programmatically-get-list-of-companies-from-the-accpac-system\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.greytrix.com\/blogs\/sageaccpacerp\/2011\/05\/20\/how-to-programmatically-get-list-of-companies-from-the-accpac-system\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.greytrix.com\/blogs\/sageaccpacerp\/2011\/05\/20\/how-to-programmatically-get-list-of-companies-from-the-accpac-system\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.greytrix.com\/blogs\/sageaccpacerp\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to programmatically get List of Companies from the Accpac system\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.greytrix.com\/blogs\/sageaccpacerp\/#website\",\"url\":\"https:\/\/www.greytrix.com\/blogs\/sageaccpacerp\/\",\"name\":\"Sage 300 ERP \u2013 Tips, Tricks and Components\",\"description\":\"Explore the world of Sage 300 with our insightful blogs, expert tips, and the latest updates. We\u2019ll empower you to leverage Sage 300 to its fullest potential. As your one-stop partner, Greytrix delivers exceptional solutions and integrations for Sage 300. Our blogs extend our support to businesses, covering the latest insights and trends. Dive in and transform your Sage 300 experience with us! \",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.greytrix.com\/blogs\/sageaccpacerp\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.greytrix.com\/blogs\/sageaccpacerp\/#\/schema\/person\/1aced4e22c30ccf606960de27c9542f5\",\"name\":\"sage300\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.greytrix.com\/blogs\/sageaccpacerp\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/c3b4325cb326e36467f945b9b9adf2bb85e907fe092d42eb36b39743b492e626?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/c3b4325cb326e36467f945b9b9adf2bb85e907fe092d42eb36b39743b492e626?s=96&d=mm&r=g\",\"caption\":\"sage300\"},\"url\":\"https:\/\/www.greytrix.com\/blogs\/sageaccpacerp\/author\/sageaccpac\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to programmatically get List of Companies from the Accpac system","description":"How to obtain data programmatically Companies listed in the Accpac system getting integrated with the 3rd Party Product.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.greytrix.com\/blogs\/sageaccpacerp\/2011\/05\/20\/how-to-programmatically-get-list-of-companies-from-the-accpac-system\/","og_locale":"en_US","og_type":"article","og_title":"How to programmatically get List of Companies from the Accpac system","og_description":"How to obtain data programmatically Companies listed in the Accpac system getting integrated with the 3rd Party Product.","og_url":"https:\/\/www.greytrix.com\/blogs\/sageaccpacerp\/2011\/05\/20\/how-to-programmatically-get-list-of-companies-from-the-accpac-system\/","og_site_name":"Sage 300 ERP \u2013 Tips, Tricks and Components","article_published_time":"2011-05-20T14:14:00+00:00","article_modified_time":"2024-02-13T09:20:45+00:00","author":"sage300","twitter_card":"summary_large_image","twitter_misc":{"Written by":"sage300","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.greytrix.com\/blogs\/sageaccpacerp\/2011\/05\/20\/how-to-programmatically-get-list-of-companies-from-the-accpac-system\/","url":"https:\/\/www.greytrix.com\/blogs\/sageaccpacerp\/2011\/05\/20\/how-to-programmatically-get-list-of-companies-from-the-accpac-system\/","name":"How to programmatically get List of Companies from the Accpac system","isPartOf":{"@id":"https:\/\/www.greytrix.com\/blogs\/sageaccpacerp\/#website"},"datePublished":"2011-05-20T14:14:00+00:00","dateModified":"2024-02-13T09:20:45+00:00","author":{"@id":"https:\/\/www.greytrix.com\/blogs\/sageaccpacerp\/#\/schema\/person\/1aced4e22c30ccf606960de27c9542f5"},"description":"How to obtain data programmatically Companies listed in the Accpac system getting integrated with the 3rd Party Product.","breadcrumb":{"@id":"https:\/\/www.greytrix.com\/blogs\/sageaccpacerp\/2011\/05\/20\/how-to-programmatically-get-list-of-companies-from-the-accpac-system\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.greytrix.com\/blogs\/sageaccpacerp\/2011\/05\/20\/how-to-programmatically-get-list-of-companies-from-the-accpac-system\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.greytrix.com\/blogs\/sageaccpacerp\/2011\/05\/20\/how-to-programmatically-get-list-of-companies-from-the-accpac-system\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.greytrix.com\/blogs\/sageaccpacerp\/"},{"@type":"ListItem","position":2,"name":"How to programmatically get List of Companies from the Accpac system"}]},{"@type":"WebSite","@id":"https:\/\/www.greytrix.com\/blogs\/sageaccpacerp\/#website","url":"https:\/\/www.greytrix.com\/blogs\/sageaccpacerp\/","name":"Sage 300 ERP \u2013 Tips, Tricks and Components","description":"Explore the world of Sage 300 with our insightful blogs, expert tips, and the latest updates. We\u2019ll empower you to leverage Sage 300 to its fullest potential. As your one-stop partner, Greytrix delivers exceptional solutions and integrations for Sage 300. Our blogs extend our support to businesses, covering the latest insights and trends. Dive in and transform your Sage 300 experience with us! ","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.greytrix.com\/blogs\/sageaccpacerp\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.greytrix.com\/blogs\/sageaccpacerp\/#\/schema\/person\/1aced4e22c30ccf606960de27c9542f5","name":"sage300","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.greytrix.com\/blogs\/sageaccpacerp\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/c3b4325cb326e36467f945b9b9adf2bb85e907fe092d42eb36b39743b492e626?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/c3b4325cb326e36467f945b9b9adf2bb85e907fe092d42eb36b39743b492e626?s=96&d=mm&r=g","caption":"sage300"},"url":"https:\/\/www.greytrix.com\/blogs\/sageaccpacerp\/author\/sageaccpac\/"}]}},"_links":{"self":[{"href":"https:\/\/www.greytrix.com\/blogs\/sageaccpacerp\/wp-json\/wp\/v2\/posts\/17","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.greytrix.com\/blogs\/sageaccpacerp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.greytrix.com\/blogs\/sageaccpacerp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/sageaccpacerp\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/sageaccpacerp\/wp-json\/wp\/v2\/comments?post=17"}],"version-history":[{"count":1,"href":"https:\/\/www.greytrix.com\/blogs\/sageaccpacerp\/wp-json\/wp\/v2\/posts\/17\/revisions"}],"predecessor-version":[{"id":33645,"href":"https:\/\/www.greytrix.com\/blogs\/sageaccpacerp\/wp-json\/wp\/v2\/posts\/17\/revisions\/33645"}],"wp:attachment":[{"href":"https:\/\/www.greytrix.com\/blogs\/sageaccpacerp\/wp-json\/wp\/v2\/media?parent=17"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/sageaccpacerp\/wp-json\/wp\/v2\/categories?post=17"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/sageaccpacerp\/wp-json\/wp\/v2\/tags?post=17"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}