{"id":31489,"date":"2025-11-28T10:59:57","date_gmt":"2025-11-28T10:59:57","guid":{"rendered":"https:\/\/www.greytrix.com\/blogs\/sagex3\/?p=31489"},"modified":"2025-11-28T10:59:57","modified_gmt":"2025-11-28T10:59:57","slug":"alternative-to-the-in-operator-of-sql-in-sage-x3","status":"publish","type":"post","link":"https:\/\/www.greytrix.com\/blogs\/sagex3\/2025\/11\/28\/alternative-to-the-in-operator-of-sql-in-sage-x3\/","title":{"rendered":"Alternative to the \u201cIN\u201d Operator of SQL in Sage X3"},"content":{"rendered":"\n<p>In <a href=\"https:\/\/www.greytrix.com\/sage-x3-erp\/development-services\/\" target=\"_blank\" data-type=\"link\" data-id=\"https:\/\/www.greytrix.com\/sage-x3-erp\/development-services\/\" rel=\"noreferrer noopener\">Sage X3<\/a> development, there are times when you need to filter records based on a selective list of values\u2014similar to using the <strong>IN<\/strong>\u00a0operator in SQL. However, Sage X3 does not provide a direct equivalent of SQL\u2019s IN\u00a0operator within its standard 4GL syntax.<\/p>\n\n\n\n<p>Fortunately, there is an effective alternative: the <strong>FIND()<\/strong>&nbsp;function.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Using the <\/strong><strong>FIND()<\/strong><strong>&nbsp;Function as an Alternative to SQL IN<\/strong><strong><\/strong><\/h2>\n\n\n\n<p>The FIND()&nbsp;function allows you to search for one or multiple values in a given character string or list. When used in a table query, it helps you filter records matching the values you specify.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Syntax<\/strong><strong><\/strong><\/h3>\n\n\n\n<p>FIND(column, list_of_elements)<\/p>\n\n\n\n<p>If the function returns a value <strong>other than 0<\/strong>, it means the item was found.<\/p>\n\n\n\n<p>In Sage X3, there are <strong>two ways<\/strong>\u00a0to apply this approach:<\/p>\n\n\n\n<p><strong>1. Using FIND() Directly in a WHERE Condition<\/strong><\/p>\n\n\n\n<p>You can directly include the FIND()&nbsp;function in your tab<\/p>\n\n\n\n<p>le loop\u2019s WHERE&nbsp;clause along with the list of values you want to search for.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Example: Searching Sales Invoice Records<\/strong><strong><\/strong><\/h3>\n\n\n\n<p>## Open table<\/p>\n\n\n\n<p>If !clalev([ZSIH]) : Local File SINVOICE[ZSIH] Endif<\/p>\n\n\n\n<p>## Add WHERE to use FIND function to find list of invoices.<\/p>\n\n\n\n<p>FOR [F:ZSIH] WHERE FIND([F:ZSIH]NUM, &#8220;2012403SINV0001&#8221;, &#8220;2012403SINV0002&#8221;, &#8220;2012403SINV0003&#8221;, &#8220;2012403SINV0004&#8221;) &lt;&gt; 0<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;INFBOX &#8220;Sales Invoice Found : &#8221; + NUM$([F:ZSIH]NUM) &nbsp;&nbsp;## This will return found invoices.<\/p>\n\n\n\n<p>NEXT<\/p>\n\n\n\n<p>This approach is straightforward and works well when you have a small number of values to check.<\/p>\n\n\n\n<p><strong>New Stuff:- <\/strong><a href=\"https:\/\/www.greytrix.com\/blogs\/sagex3\/2025\/11\/18\/how-sage-x3-erp-for-distribution-transforms-inventory-control-for-modern-wholesale-businesses\/\" target=\"_blank\" data-type=\"link\" data-id=\"https:\/\/www.greytrix.com\/blogs\/sagex3\/2025\/11\/18\/how-sage-x3-erp-for-distribution-transforms-inventory-control-for-modern-wholesale-businesses\/\" rel=\"noreferrer noopener\">How Sage X3 ERP for Distribution Transforms Inventory Control for Modern Wholesale Businesses<\/a><\/p>\n\n\n\n<p><strong>2.<\/strong> <strong>Using an Array for Better Flexibility<\/strong><\/p>\n\n\n\n<p>If you want a cleaner, more dynamic solution\u2014especially with a large or variable list of values\u2014you can store the search values in an array and then call FIND()&nbsp;using that array.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Example: Searching Purchase Invoice Records Using an Array<\/strong><strong><\/strong><\/h3>\n\n\n\n<p>## Open Table<\/p>\n\n\n\n<p>If !clalev([ZPIH]) : Local File PINVOICE[ZPIH] Endif<\/p>\n\n\n\n<p>## Create Array that holds the list of finding items (invoice numbers)<\/p>\n\n\n\n<p>LOCAL CHAR ZNUMBOM(50)(5)<\/p>\n\n\n\n<p>## Assign Values to Array<\/p>\n\n\n\n<p>ZNUMBOM(1) = &#8220;IEINV-BOM-0925-00004&#8221;<\/p>\n\n\n\n<p>ZNUMBOM(2) = &#8220;IEINV-BOM-0925-00005&#8221;<\/p>\n\n\n\n<p>ZNUMBOM(3) = &#8220;IEINV-BOM-0925-00006&#8221;<\/p>\n\n\n\n<p>ZNUMBOM(4) = &#8220;IEINV-BOM-0925-01346&#8221;<\/p>\n\n\n\n<p>## Loop through the table to find matching records<\/p>\n\n\n\n<p>FOR [F:ZPIH] WHERE FIND([F:ZPIH]NUM, ZNUMBOM) &lt;&gt; 0<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;INFBOX &#8220;PINV : &#8221; + NUM$([F:ZPIH]NUM) &nbsp;&nbsp;## Found matching record<\/p>\n\n\n\n<p>NEXT<\/p>\n\n\n\n<p>Using an array makes your code easier to maintain, extend, and reuse.<\/p>\n\n\n\n<p><strong>Conclusion<\/strong><\/p>\n\n\n\n<p>While Sage X3 does not support the SQL IN&nbsp;operator directly, the FIND()&nbsp;function provides an excellent alternative for filtering records based on a list of values.<\/p>\n\n\n\n<p>Whether you pass values directly in the WHERE&nbsp;clause or use an array for better organization, FIND()&nbsp;is a powerful tool to achieve similar functionality efficiently.<\/p>\n\n\n\n<p>If you frequently work with dynamic lists, the array method is highly recommended for cleaner and more maintainable code.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>About Us<\/strong><\/h2>\n\n\n\n<p>Greytrix \u2013 a globally recognized and one of the oldest Sage Development Partners is a one-stop solution provider for Sage ERP and Sage CRM organizational needs. Being acknowledged and rewarded for multi-man years of experience and expertise, we bring complete end-to-end assistance for your technical consultations, product customizations, data migration, system integrations, third-party add-on development, and implementation competence.<\/p>\n\n\n\n<p id=\"block-28013e99-0882-44c6-b705-7b16c85053b2\">Greytrix&nbsp;has some unique integration solutions developed for&nbsp;<a href=\"https:\/\/www.greytrix.com\/sage-crm\/\">Sage CRM<\/a>&nbsp;with Sage ERPs&nbsp;namely&nbsp;<a href=\"https:\/\/www.greytrix.com\/sage-x3-erp\/\">Sage X3<\/a>,&nbsp;<a href=\"https:\/\/www.greytrix.com\/sage-intacct\/\">Sage Intacct<\/a>,&nbsp;<a href=\"https:\/\/www.greytrix.com\/sage-100-erp\/\">Sage 100<\/a>,&nbsp;<a href=\"https:\/\/www.greytrix.com\/sage-500-erp\/\">Sage 500<\/a>,&nbsp;and&nbsp;<a href=\"https:\/\/www.greytrix.com\/sage-300-erp\/\">Sage 300<\/a>. We also offer best-in-class&nbsp;Sage ERP&nbsp;and&nbsp;Sage CRM&nbsp;customization and development services&nbsp;to&nbsp;Business&nbsp;Partners,&nbsp;End&nbsp;Users, and Sage PSG worldwide. Greytrix&nbsp;helps in&nbsp;the migration of Sage CRM from&nbsp;Salesforce | ACT! | SalesLogix | Goldmine | Sugar CRM | Maximizer. Our Sage CRM Product Suite includes&nbsp;addons like&nbsp;&nbsp;Greytrix Business Manager,&nbsp;Sage CRM Project Manager,&nbsp;Sage CRM Resource Planner,&nbsp;Sage CRM Contract Manager,&nbsp;Sage CRM Event Manager,&nbsp;Sage CRM Budget Planner,&nbsp;Gmail Integration,&nbsp;Sage CRM Mobile Service Signature,&nbsp;Sage CRM CTI Framework.<\/p>\n\n\n\n<p id=\"block-4bc42a09-fb13-4598-8137-ce5f7b91ce28\">Greytrix is a recognized&nbsp;Sage Champion Partner&nbsp;for GUMU&#x2122; Sage X3 \u2013 Sage CRM integration listed on&nbsp;<a href=\"https:\/\/www.sage.com\/marketplace\/asb_ListingDetail?listingId=a1h24000007PC3aAAG\" target=\"_blank\" rel=\"noreferrer noopener\">Sage Marketplace<\/a>&nbsp;and Sage CRM \u2013 Sage Intacct integration listed on&nbsp;<a href=\"https:\/\/marketplace.intacct.com\/MPListing?lid=a2D0H000007kiHyUAI\" target=\"_blank\" rel=\"noreferrer noopener\">Sage Intacct Marketplace<\/a>. The&nbsp;<a href=\"https:\/\/www.greytrix.com\/gumu\/\" target=\"_blank\" rel=\"noreferrer noopener\">GUMU&#x2122; Cloud framework<\/a>&nbsp;by Greytrix forms the backbone of cloud integrations that are managed in real-time for the processing and execution of application programs at the click of a button.<\/p>\n\n\n\n<p id=\"block-76376301-1c3e-4250-8a09-727595a606f0\">For more information on our integration solutions, please contact us at&nbsp;<a href=\"mailto:sage@greytrix.com\">sage@greytrix.com<\/a>. We will be glad to assist you.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In Sage X3 development, there are times when you need to filter records based on a selective list of values\u2014similar to using the IN\u00a0operator in SQL. However, Sage X3 does not provide a direct equivalent of SQL\u2019s IN\u00a0operator within its standard 4GL syntax. Fortunately, there is an effective alternative: the FIND()&nbsp;function. Using the FIND()&nbsp;Function as\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.greytrix.com\/blogs\/sagex3\/2025\/11\/28\/alternative-to-the-in-operator-of-sql-in-sage-x3\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13,8],"tags":[4434,720,1822,3485],"class_list":["post-31489","post","type-post","status-publish","format-standard","hentry","category-integration","category-sage-erp-x3","tag-arrays-in-sage-x3","tag-erp","tag-sage-x3","tag-sql"],"_links":{"self":[{"href":"https:\/\/www.greytrix.com\/blogs\/sagex3\/wp-json\/wp\/v2\/posts\/31489","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.greytrix.com\/blogs\/sagex3\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.greytrix.com\/blogs\/sagex3\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/sagex3\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/sagex3\/wp-json\/wp\/v2\/comments?post=31489"}],"version-history":[{"count":13,"href":"https:\/\/www.greytrix.com\/blogs\/sagex3\/wp-json\/wp\/v2\/posts\/31489\/revisions"}],"predecessor-version":[{"id":31502,"href":"https:\/\/www.greytrix.com\/blogs\/sagex3\/wp-json\/wp\/v2\/posts\/31489\/revisions\/31502"}],"wp:attachment":[{"href":"https:\/\/www.greytrix.com\/blogs\/sagex3\/wp-json\/wp\/v2\/media?parent=31489"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/sagex3\/wp-json\/wp\/v2\/categories?post=31489"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/sagex3\/wp-json\/wp\/v2\/tags?post=31489"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}