{"id":785,"date":"2017-08-03T10:09:57","date_gmt":"2017-08-03T10:09:57","guid":{"rendered":"http:\/\/www.se80.co.uk\/training-education\/?p=785"},"modified":"2019-02-23T00:28:33","modified_gmt":"2019-02-23T00:28:33","slug":"abap-read-table-with-or-condition","status":"publish","type":"post","link":"https:\/\/www.se80.co.uk\/training-education\/abap-read-table-with-or-condition\/","title":{"rendered":"ABAP read table with OR condition"},"content":{"rendered":"<p>\u200b<\/p>\n<p>So is it possible to add an OR condition to the key values of the read statement? The simple answer is no, but you can replicate this functionality using one of two methods.<\/p>\n<h3><\/h3>\n<p>Method 1 &#8211; Using multiple ABAP READ statements within nested IF statements<\/p>\n<p><span><\/span><\/p>\n<p>The first method would be to use multiple READ statements to check each condition but nest these within IF statements. i.e. Read condition 1 if no entry found read condition 2 if no entry found read condition 3 etc etc<\/p>\n<h3><\/h3>\n<p>Method 2 &#8211; Using an ABAP LOOP&nbsp;statement<\/p>\n<p><span><\/span><\/p>\n<p>The second method would be to use a LOOP statement with all the options within the where clause and simply EXIT on the first loop pass.i.e.LOOP at itab where condition 1 or condition 2.EXIT.ENDLOOP.If sy-subrc eq 0.&#8221;Data foundendif.<\/p>\n<p>data: IT_COMPONENT type standard table of SEOCOMPO,WA_COMPONENT like line of IT_COMPONENT.select *from SEOCOMPO as A inner join SEOCOMPOTX as Bon B~CLSNAME = A~CLSNAMEand B~CMPNAME = A~CMPNAMEinner join SEOCOMPODF as Con C~CLSNAME = A~CLSNAMEand C~CMPNAME = A~CMPNAMEinto corresponding fields of table IT_COMPONENTwhere A~CMPTYPE in (0,1,2)and B~LANGU eq SY-LANGU.sort IT_COMPONENT by clsname cmptype.&#8221;READ solutionread table IT_COMPONENT transporting no fieldswith key CLSNAME = WA_CLASS-CLSNAMECMPTYPE = 0 binary search.if SY-SUBRC eq 0.&#8221;perform entry_found.else.read table IT_COMPONENT transporting no fieldswith key CLSNAME = WA_CLASS-CLSNAMECMPTYPE = 1 binary search.if SY-SUBRC eq 0.&#8221;perform entry_found.else.EXIT.endif.endif.&#8221;loop solutionLOOP at IT_COMPONENT into WA_COMPONENT where  CLSNAME = WA_CLASS-CLSNAMEAND ( CMPTYPE = 0 or CMPTYPE = 1 ).ENDLOOP.if sy-subrc eq 0.&#8221;at least one entry foundelse.EXIT.endif.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u200b So is it possible to add an OR condition to the key values of the read statement? The simple answer is no, but you can replicate this functionality using one of two methods. Method 1 &#8211; Using multiple ABAP READ statements within nested IF statements The first method would be to use multiple READ [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[11],"tags":[34,36,35,33],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.0 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>ABAP read table to replictae OR condition in SAP report<\/title>\n<meta name=\"description\" content=\"ABAP read table with OR condition is not possible in SAP but you can replicates this funcionality quite easiy using the following methods\" \/>\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.se80.co.uk\/training-education\/abap-read-table-with-or-condition\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"ABAP read table to replictae OR condition in SAP report\" \/>\n<meta property=\"og:description\" content=\"ABAP read table with OR condition is not possible in SAP but you can replicates this funcionality quite easiy using the following methods\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.se80.co.uk\/training-education\/abap-read-table-with-or-condition\/\" \/>\n<meta property=\"og:site_name\" content=\"SAP Help, Training and Education\" \/>\n<meta property=\"article:published_time\" content=\"2017-08-03T10:09:57+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-02-23T00:28:33+00:00\" \/>\n<meta name=\"author\" content=\"se80\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"se80\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.se80.co.uk\/training-education\/abap-read-table-with-or-condition\/\",\"url\":\"https:\/\/www.se80.co.uk\/training-education\/abap-read-table-with-or-condition\/\",\"name\":\"ABAP read table to replictae OR condition in SAP report\",\"isPartOf\":{\"@id\":\"https:\/\/www.se80.co.uk\/training-education\/#website\"},\"datePublished\":\"2017-08-03T10:09:57+00:00\",\"dateModified\":\"2019-02-23T00:28:33+00:00\",\"author\":{\"@id\":\"https:\/\/www.se80.co.uk\/training-education\/#\/schema\/person\/ddc6a049c1b0790f62d70278be75e511\"},\"description\":\"ABAP read table with OR condition is not possible in SAP but you can replicates this funcionality quite easiy using the following methods\",\"breadcrumb\":{\"@id\":\"https:\/\/www.se80.co.uk\/training-education\/abap-read-table-with-or-condition\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.se80.co.uk\/training-education\/abap-read-table-with-or-condition\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.se80.co.uk\/training-education\/abap-read-table-with-or-condition\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.se80.co.uk\/training-education\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"ABAP read table with OR condition\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.se80.co.uk\/training-education\/#website\",\"url\":\"https:\/\/www.se80.co.uk\/training-education\/\",\"name\":\"SAP Help, Training and Education\",\"description\":\"Learn SAP\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.se80.co.uk\/training-education\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.se80.co.uk\/training-education\/#\/schema\/person\/ddc6a049c1b0790f62d70278be75e511\",\"name\":\"se80\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.se80.co.uk\/training-education\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/3fd4e388f05bf3c763e46cd1f77afeb2?s=96&d=retro&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/3fd4e388f05bf3c763e46cd1f77afeb2?s=96&d=retro&r=g\",\"caption\":\"se80\"},\"url\":\"https:\/\/www.se80.co.uk\/training-education\/author\/se80\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"ABAP read table to replictae OR condition in SAP report","description":"ABAP read table with OR condition is not possible in SAP but you can replicates this funcionality quite easiy using the following methods","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.se80.co.uk\/training-education\/abap-read-table-with-or-condition\/","og_locale":"en_US","og_type":"article","og_title":"ABAP read table to replictae OR condition in SAP report","og_description":"ABAP read table with OR condition is not possible in SAP but you can replicates this funcionality quite easiy using the following methods","og_url":"https:\/\/www.se80.co.uk\/training-education\/abap-read-table-with-or-condition\/","og_site_name":"SAP Help, Training and Education","article_published_time":"2017-08-03T10:09:57+00:00","article_modified_time":"2019-02-23T00:28:33+00:00","author":"se80","twitter_card":"summary_large_image","twitter_misc":{"Written by":"se80","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.se80.co.uk\/training-education\/abap-read-table-with-or-condition\/","url":"https:\/\/www.se80.co.uk\/training-education\/abap-read-table-with-or-condition\/","name":"ABAP read table to replictae OR condition in SAP report","isPartOf":{"@id":"https:\/\/www.se80.co.uk\/training-education\/#website"},"datePublished":"2017-08-03T10:09:57+00:00","dateModified":"2019-02-23T00:28:33+00:00","author":{"@id":"https:\/\/www.se80.co.uk\/training-education\/#\/schema\/person\/ddc6a049c1b0790f62d70278be75e511"},"description":"ABAP read table with OR condition is not possible in SAP but you can replicates this funcionality quite easiy using the following methods","breadcrumb":{"@id":"https:\/\/www.se80.co.uk\/training-education\/abap-read-table-with-or-condition\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.se80.co.uk\/training-education\/abap-read-table-with-or-condition\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.se80.co.uk\/training-education\/abap-read-table-with-or-condition\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.se80.co.uk\/training-education\/"},{"@type":"ListItem","position":2,"name":"ABAP read table with OR condition"}]},{"@type":"WebSite","@id":"https:\/\/www.se80.co.uk\/training-education\/#website","url":"https:\/\/www.se80.co.uk\/training-education\/","name":"SAP Help, Training and Education","description":"Learn SAP","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.se80.co.uk\/training-education\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.se80.co.uk\/training-education\/#\/schema\/person\/ddc6a049c1b0790f62d70278be75e511","name":"se80","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.se80.co.uk\/training-education\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/3fd4e388f05bf3c763e46cd1f77afeb2?s=96&d=retro&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/3fd4e388f05bf3c763e46cd1f77afeb2?s=96&d=retro&r=g","caption":"se80"},"url":"https:\/\/www.se80.co.uk\/training-education\/author\/se80\/"}]}},"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.se80.co.uk\/training-education\/wp-json\/wp\/v2\/posts\/785"}],"collection":[{"href":"https:\/\/www.se80.co.uk\/training-education\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.se80.co.uk\/training-education\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.se80.co.uk\/training-education\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.se80.co.uk\/training-education\/wp-json\/wp\/v2\/comments?post=785"}],"version-history":[{"count":3,"href":"https:\/\/www.se80.co.uk\/training-education\/wp-json\/wp\/v2\/posts\/785\/revisions"}],"predecessor-version":[{"id":2000,"href":"https:\/\/www.se80.co.uk\/training-education\/wp-json\/wp\/v2\/posts\/785\/revisions\/2000"}],"wp:attachment":[{"href":"https:\/\/www.se80.co.uk\/training-education\/wp-json\/wp\/v2\/media?parent=785"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.se80.co.uk\/training-education\/wp-json\/wp\/v2\/categories?post=785"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.se80.co.uk\/training-education\/wp-json\/wp\/v2\/tags?post=785"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}