{"id":1260,"date":"2009-11-09T15:27:11","date_gmt":"2009-11-09T08:27:11","guid":{"rendered":"http:\/\/www.todsapon.com\/story\/?p=1260"},"modified":"2020-12-16T15:22:56","modified_gmt":"2020-12-16T08:22:56","slug":"import-text-file-to-internal-table","status":"publish","type":"post","link":"http:\/\/www.todsapon.com\/story\/archive-blog\/import-text-file-to-internal-table","title":{"rendered":"ABAP Code:\u0e01\u0e32\u0e23\u0e19\u0e33\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25 Text File \u0e08\u0e32\u0e01\u0e02\u0e49\u0e32\u0e07\u0e19\u0e2d\u0e01 \u0e21\u0e32\u0e40\u0e01\u0e47\u0e1a\u0e44\u0e27\u0e49\u0e43\u0e19 Internal Table"},"content":{"rendered":"<p>\u0e2a\u0e37\u0e1a\u0e40\u0e19\u0e37\u0e48\u0e2d\u0e07\u0e08\u0e32\u0e01\u0e44\u0e14\u0e49\u0e23\u0e31\u0e1a\u0e2b\u0e19\u0e49\u0e32\u0e17\u0e35\u0e48\u0e40\u0e02\u0e35\u0e22\u0e19\u0e42\u0e1b\u0e23\u0e41\u0e01\u0e23\u0e21 <strong>\u0e17\u0e35\u0e48\u0e21\u0e35\u0e01\u0e32\u0e23\u0e42\u0e2b\u0e25\u0e14\u0e44\u0e1f\u0e25\u0e4c\u0e08\u0e32\u0e01\u0e04\u0e2d\u0e21\u0e1e\u0e34\u0e27\u0e40\u0e15\u0e2d\u0e23\u0e4c (\u0e44\u0e1f\u0e25\u0e4c .txt)<\/strong> \u0e41\u0e25\u0e49\u0e27\u0e40\u0e2d\u0e32\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25<br \/>\n\u0e21\u0e32\u0e40\u0e0a\u0e47\u0e04\u0e43\u0e19\u0e23\u0e30\u0e1a\u0e1a\u0e27\u0e48\u0e32\u0e21\u0e35\u0e2d\u0e22\u0e39\u0e48\u0e2b\u0e23\u0e37\u0e2d\u0e44\u0e21\u0e48\u0e41\u0e25\u0e30\u0e15\u0e23\u0e07\u0e01\u0e31\u0e19\u0e2b\u0e23\u0e37\u0e2d\u0e44\u0e2b\u0e21  \u0e2b\u0e25\u0e31\u0e07\u0e08\u0e32\u0e01\u0e19\u0e31\u0e49\u0e19 \u0e43\u0e2b\u0e49\u0e41\u0e2a\u0e14\u0e07\u0e2d\u0e2d\u0e01\u0e21\u0e32\u0e40\u0e1b\u0e47\u0e19\u0e23\u0e32\u0e22\u0e07\u0e32\u0e19 \u0e0b\u0e36\u0e48\u0e07\u0e2b\u0e25\u0e31\u0e01\u0e01\u0e32\u0e23\u0e01\u0e47<br \/>\n<strong>\u0e19\u0e33\u0e44\u0e1f\u0e25\u0e4c\u0e08\u0e32\u0e01\u0e02\u0e49\u0e32\u0e07\u0e19\u0e2d\u0e01\u0e21\u0e32\u0e43\u0e2a\u0e48\u0e43\u0e19 Internal Table<\/strong> \u0e41\u0e25\u0e49\u0e27\u0e01\u0e47\u0e14\u0e36\u0e07\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e08\u0e32\u0e01\u0e23\u0e30\u0e1a\u0e1a\u0e21\u0e32\u0e44\u0e27\u0e49\u0e43\u0e19 Internal Table \u0e2d\u0e35\u0e01\u0e2d\u0e31\u0e19 \u0e41\u0e25\u0e49\u0e27\u0e40\u0e2d\u0e32<br \/>\n\u0e17\u0e31\u0e49\u0e07 2 Internal Table \u0e21\u0e32\u0e40\u0e0a\u0e47\u0e04\u0e01\u0e31\u0e19 \u0e41\u0e15\u0e48\u0e43\u0e19\u0e17\u0e35\u0e48\u0e19\u0e35\u0e49 \u0e40\u0e1b\u0e47\u0e19 Code <strong>\u0e2a\u0e33\u0e2b\u0e23\u0e31\u0e1a\u0e01\u0e32\u0e23\u0e19\u0e33\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e17\u0e35\u0e48\u0e44\u0e14\u0e49\u0e42\u0e2b\u0e25\u0e14\u0e08\u0e32\u0e01\u0e04\u0e2d\u0e21\u0e1e\u0e34\u0e27\u0e40\u0e15\u0e2d\u0e23\u0e4c\u0e21\u0e32\u0e40\u0e01\u0e47\u0e1a\u0e44\u0e27\u0e49<br \/>\n\u0e43\u0e19 Internal Table<br \/>\n<\/strong><\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\n*  Program      : ZGETFILE\n*  Title        : Get file to internal table\n*  Author       : Todsapon Kumnuan (todsapon.com)\n*  R\/3 Release  : ECC5\n\nREPORT ztestpon\nMESSAGE-ID fi.\n\n*   I N T E R N A L   T A B L E S\nTYPES: BEGIN OF t_import_file,\ndata(1000),\nEND   OF t_import_file.\n\nTYPES: BEGIN OF t_record_file,\n001(50),\n002(50),\n003(50),\n004(50),\nEND OF t_record_file.\n\n*   DATA\nDATA: i_record_file    TYPE TABLE OF t_record_file           WITH HEADER LINE,\ni_import_file   TYPE TABLE OF t_import_file            WITH HEADER LINE.\n\n* UPLOAD_FILE_LOCAL\n* Used to upload external file from presentation server to internal\n* table\n*  --&amp;amp;gt;  &amp;amp;amp;1        file name\n*  --&amp;amp;gt;  &amp;amp;amp;2        file type 'DAT' 'ASC'\n*  --&amp;amp;gt;  &amp;amp;amp;3        internal table\n*--&amp;amp;gt; \u0e40\u0e23\u0e35\u0e22\u0e01\u0e43\u0e0a\u0e49\u0e1f\u0e31\u0e07\u0e01\u0e4c\u0e0a\u0e31\u0e48\u0e19 Upload\nDEFINE upload_file_local.\ncall function 'WS_UPLOAD'\nexporting\nfilename                = &amp;amp;amp;1\nfiletype                = &amp;amp;amp;2\ntables\ndata_tab                = &amp;amp;amp;3\nexceptions\nfile_open_error         = 1\nfile_read_error         = 2\nno_batch                = 3\ngui_refuse_filetransfer = 4\nothers                  = 5.\nif sy-subrc &amp;amp;lt;&amp;amp;gt; 0.\nif sy-subrc = 1.\nmessage i000(38) with 'File not found.' &amp;amp;amp;1 &amp;amp;amp;2 &amp;amp;amp;3.\nelse.\nmessage i000(38) with 'Error uploading file.' &amp;amp;amp;1 &amp;amp;amp;2 &amp;amp;amp;3.\nendif.\nendif.\n\nEND-OF-DEFINITION.\n\n*   S E L E C T - O P T I O N S   A N D   P A R A M E T E R S\nPARAMETERS: p_file  LIKE rlgrap-filename OBLIGATORY.\n\n*               A T   S E L E C T I O N - S C R E E N\nAT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.\n*--&amp;amp;gt; \u0e40\u0e23\u0e35\u0e22\u0e01\u0e43\u0e0a\u0e49\u0e1f\u0e31\u0e07\u0e01\u0e4c\u0e0a\u0e31\u0e48\u0e19 \u0e40\u0e25\u0e37\u0e2d\u0e01\u0e44\u0e1f\u0e25\u0e4c\nCALL FUNCTION 'KD_GET_FILENAME_ON_F4'\nEXPORTING\nmask      = ',*.txt,*.*'\nstatic    = 'X'\nCHANGING\nfile_name = p_file.\n\nSTART-OF-SELECTION.\nPERFORM get_data.\nPERFORM display_report.\n\n*                    S U B   R O U T I N E S\n*      Form  get_data\nFORM get_data.\nupload_file_local p_file 'ASC' i_import_file.\n*--&amp;amp;gt; \u0e15\u0e23\u0e27\u0e08\u0e2a\u0e2d\u0e1a\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e44\u0e1f\u0e25\u0e4c \u0e27\u0e48\u0e32\u0e21\u0e35\u0e04\u0e48\u0e32\u0e27\u0e48\u0e32\u0e07\u0e2b\u0e23\u0e37\u0e2d\u0e44\u0e2b\u0e21\nIF i_import_file[] IS INITIAL.\nMESSAGE i899 WITH 'No data on this file'.\nELSE.\nPERFORM create_file.\nENDIF.\nENDFORM.                    &amp;amp;quot; get_data\n\n*&amp;amp;amp;      Form  create_rtndata\nFORM create_file.\n*--&amp;amp;gt; \u0e19\u0e33\u0e02\u0e47\u0e2d\u0e21\u0e39\u0e25\u0e44\u0e1f\u0e25\u0e4c\u0e17\u0e35\u0e48\u0e44\u0e14\u0e49\u0e08\u0e32\u0e01\u0e01\u0e32\u0e23\u0e2b\u0e19\u0e49\u0e32\u0e08\u0e2d\u0e21\u0e32\u0e43\u0e2a\u0e48\u0e43\u0e19 Internal Table\nCLEAR: i_import_file, i_record_file.\nLOOP AT i_import_file.\n*--&amp;amp;gt; \u0e42\u0e14\u0e22\u0e01\u0e32\u0e23\u0e43\u0e0a\u0e49\u0e04\u0e2d\u0e21\u0e21\u0e32 \u0e40\u0e1b\u0e47\u0e19\u0e01\u0e32\u0e23\u0e41\u0e1a\u0e48\u0e07\u0e04\u0e2d\u0e25\u0e31\u0e21\u0e19\u0e4c\nSPLIT i_import_file-data AT ',' INTO i_record_file-001 i_record_file-002\ni_record_file-003 i_record_file-004\n.\nCONDENSE: i_record_file-001, i_record_file-002, i_record_file-003,\ni_record_file-004.\nAPPEND i_record_file.\nCLEAR  i_record_file.\nENDLOOP.\nENDFORM.                    &amp;amp;quot; create_file\n\n*&amp;amp;amp;      Form  display_report\nFORM  display_report.\nLOOP AT i_record_file.\nWRITE: \/ i_record_file-001, i_record_file-002, i_record_file-003,\ni_record_file-004.\nENDLOOP.\nENDFORM.                    &amp;amp;quot;display_report\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u0e2a\u0e37\u0e1a\u0e40\u0e19\u0e37\u0e48\u0e2d\u0e07\u0e08\u0e32\u0e01\u0e44\u0e14\u0e49\u0e23\u0e31\u0e1a\u0e2b\u0e19\u0e49\u0e32\u0e17\u0e35\u0e48\u0e40\u0e02\u0e35\u0e22\u0e19\u0e42\u0e1b\u0e23\u0e41\u0e01\u0e23\u0e21 \u0e17\u0e35\u0e48\u0e21\u0e35\u0e01\u0e32\u0e23\u0e42\u0e2b\u0e25\u0e14\u0e44\u0e1f\u0e25\u0e4c\u0e08\u0e32\u0e01\u0e04\u0e2d\u0e21\u0e1e\u0e34\u0e27\u0e40\u0e15\u0e2d\u0e23\u0e4c (\u0e44\u0e1f\u0e25\u0e4c .txt) \u0e41\u0e25\u0e49\u0e27\u0e40\u0e2d\u0e32\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25 \u0e21\u0e32\u0e40\u0e0a\u0e47\u0e04\u0e43\u0e19\u0e23\u0e30\u0e1a\u0e1a\u0e27\u0e48\u0e32\u0e21\u0e35\u0e2d\u0e22\u0e39\u0e48\u0e2b\u0e23\u0e37\u0e2d\u0e44\u0e21\u0e48\u0e41\u0e25\u0e30\u0e15\u0e23\u0e07\u0e01\u0e31\u0e19\u0e2b\u0e23\u0e37\u0e2d\u0e44\u0e2b\u0e21 \u0e2b\u0e25\u0e31\u0e07\u0e08\u0e32\u0e01\u0e19\u0e31\u0e49\u0e19 \u0e43\u0e2b\u0e49\u0e41\u0e2a\u0e14\u0e07\u0e2d\u0e2d\u0e01\u0e21\u0e32\u0e40\u0e1b\u0e47\u0e19\u0e23\u0e32\u0e22\u0e07\u0e32\u0e19 \u0e0b\u0e36\u0e48\u0e07\u0e2b\u0e25\u0e31\u0e01\u0e01\u0e32\u0e23\u0e01\u0e47 \u0e19\u0e33\u0e44\u0e1f\u0e25\u0e4c\u0e08\u0e32\u0e01\u0e02\u0e49\u0e32\u0e07\u0e19\u0e2d\u0e01\u0e21\u0e32\u0e43\u0e2a\u0e48\u0e43\u0e19 Internal Table \u0e41\u0e25\u0e49\u0e27\u0e01\u0e47\u0e14\u0e36\u0e07\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e08\u0e32\u0e01\u0e23\u0e30\u0e1a\u0e1a\u0e21\u0e32\u0e44\u0e27\u0e49\u0e43\u0e19 Internal Table \u0e2d\u0e35\u0e01\u0e2d\u0e31\u0e19 \u0e41\u0e25\u0e49\u0e27\u0e40\u0e2d\u0e32 \u0e17\u0e31\u0e49\u0e07 2 Internal Table \u0e21\u0e32\u0e40\u0e0a\u0e47\u0e04\u0e01\u0e31\u0e19 \u0e41\u0e15\u0e48\u0e43\u0e19\u0e17\u0e35\u0e48\u0e19\u0e35\u0e49 \u0e40\u0e1b\u0e47\u0e19 Code \u0e2a\u0e33\u0e2b\u0e23\u0e31\u0e1a\u0e01\u0e32\u0e23\u0e19\u0e33\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e17\u0e35\u0e48\u0e44\u0e14\u0e49\u0e42\u0e2b\u0e25\u0e14\u0e08\u0e32\u0e01\u0e04\u0e2d\u0e21\u0e1e\u0e34\u0e27\u0e40\u0e15\u0e2d\u0e23\u0e4c\u0e21\u0e32\u0e40\u0e01\u0e47\u0e1a\u0e44\u0e27\u0e49 \u0e43\u0e19 Internal Table<\/p>\n","protected":false},"author":1,"featured_media":1654,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"footnotes":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_options":[]},"categories":[384,250,251],"tags":[],"class_list":["post-1260","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-archive-blog","category-programmer","category-sap-abap"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"http:\/\/www.todsapon.com\/story\/wp-content\/uploads\/2020\/08\/sap.png","jetpack_shortlink":"https:\/\/wp.me\/p5sZE6-kk","amp_enabled":true,"_links":{"self":[{"href":"http:\/\/www.todsapon.com\/story\/wp-json\/wp\/v2\/posts\/1260","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.todsapon.com\/story\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.todsapon.com\/story\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.todsapon.com\/story\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.todsapon.com\/story\/wp-json\/wp\/v2\/comments?post=1260"}],"version-history":[{"count":5,"href":"http:\/\/www.todsapon.com\/story\/wp-json\/wp\/v2\/posts\/1260\/revisions"}],"predecessor-version":[{"id":1682,"href":"http:\/\/www.todsapon.com\/story\/wp-json\/wp\/v2\/posts\/1260\/revisions\/1682"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.todsapon.com\/story\/wp-json\/wp\/v2\/media\/1654"}],"wp:attachment":[{"href":"http:\/\/www.todsapon.com\/story\/wp-json\/wp\/v2\/media?parent=1260"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.todsapon.com\/story\/wp-json\/wp\/v2\/categories?post=1260"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.todsapon.com\/story\/wp-json\/wp\/v2\/tags?post=1260"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}