{"id":180,"date":"2023-12-28T03:22:35","date_gmt":"2023-12-28T03:22:35","guid":{"rendered":"https:\/\/sapabap.dwimansolution.com\/?p=180"},"modified":"2023-12-28T03:22:35","modified_gmt":"2023-12-28T03:22:35","slug":"sap-abap-new-open-sql-query-substring-numc","status":"publish","type":"post","link":"https:\/\/sapabap.dwimansolution.com\/index.php\/2023\/12\/28\/sap-abap-new-open-sql-query-substring-numc\/","title":{"rendered":"SAP ABAP &#8211; NEW OPEN SQL &#8211; Query Substring NUMC"},"content":{"rendered":"\n<p>There are some fields with data type NUMC that we want to fetch using a query table.<\/p>\n\n\n\n<p>In this case, I want to show you how to split the DATS data type into Year, Month, and Day in a single query.<\/p>\n\n\n\n<ol>\n<li>We have a SUBSTRING function in open SQL to cut your data by the length.\n<ul>\n<li>SUBSTRING( &lt;data> , &lt;start_pointer> , &lt;sub_length> )<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>The return of the SUBSTRING function is data with data type CHAR. So we have to convert it to NUMC again using the CAST function.\n<ul>\n<li>CAST( &lt;data> AS &lt;data_type> )<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<p>Here the example<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>  TYPES: BEGIN OF ty_data,\r\n           year  TYPE numc4,\r\n           month TYPE numc2,\r\n           day   TYPE numc2,\r\n         END OF ty_data,\r\n         tt_data TYPE TABLE OF ty_data.\r\n  DATA: ls_data TYPE ty_data.\r\n\r\n  SELECT SINGLE\r\n    CAST( substring( fldate, 1, 4 ) AS NUMC ) AS year,\r\n    CAST( substring( fldate, 5, 2 ) AS NUMC ) AS month,\r\n    CAST( substring( fldate, 7, 2 ) AS NUMC ) AS day\r\n    FROM sbook\r\n    WHERE fldate NE '00000000'\r\n    INTO @ls_data.\r\n\r\n  WRITE:\/(8) 'Year' , ':', ls_data-year.\r\n  WRITE:\/(8) 'Month' , ':', ls_data-month.\r\n  WRITE:\/(8) 'Day' , ':', ls_data-day.<\/code><\/pre>\n\n\n\n<p>Thank you for reading. I hope you can do it better. See you on the next post.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>There are some fields with data type NUMC that we want to fetch using a query table. In this case, I want to show you how to split the DATS data type into Year, Month, and Day in a single query. Here the example Thank you for reading. I hope you can do it better&#8230;.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/sapabap.dwimansolution.com\/index.php\/wp-json\/wp\/v2\/posts\/180"}],"collection":[{"href":"https:\/\/sapabap.dwimansolution.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sapabap.dwimansolution.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sapabap.dwimansolution.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sapabap.dwimansolution.com\/index.php\/wp-json\/wp\/v2\/comments?post=180"}],"version-history":[{"count":1,"href":"https:\/\/sapabap.dwimansolution.com\/index.php\/wp-json\/wp\/v2\/posts\/180\/revisions"}],"predecessor-version":[{"id":181,"href":"https:\/\/sapabap.dwimansolution.com\/index.php\/wp-json\/wp\/v2\/posts\/180\/revisions\/181"}],"wp:attachment":[{"href":"https:\/\/sapabap.dwimansolution.com\/index.php\/wp-json\/wp\/v2\/media?parent=180"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sapabap.dwimansolution.com\/index.php\/wp-json\/wp\/v2\/categories?post=180"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sapabap.dwimansolution.com\/index.php\/wp-json\/wp\/v2\/tags?post=180"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}