- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Using SAP ABAP, how can I read content of CSV files in a directory to an internal table?
There are many functions that can be used to read csv however many are broken and read part of content. You need to go through each file and then process the file content. I would prefer to perform this manually.
You can use the READ DATASET to read data from a file on the application server. Below is the syntax:
READ DATASET <dsn> INTO <f> [LENGTH <len>].
Below is SAP documentation link that you can use to know more about reading data from files:
Example
Incase you are using binary mode, you can use LENGTH to find the length of data transferred to <f>. The value of variable length is set by system in <len> as below:
DATA FNAME(60) VALUE 'file'. DATA: TEXT1(10) VALUE 'helloworld', TEXT3(5), LENG TYPE I. OPEN DATASET FNAME FOR OUTPUT IN BINARY MODE. TRANSFER TEXT1 TO FNAME. CLOSE DATASET FNAME. OPEN DATASET FNAME FOR INPUT IN BINARY MODE. DO. READ DATASET FNAME INTO TEXT2 LENGTH LENG. WRITE: / SY-SUBRC, TEXT2, LENG. IF SY-SUBRC <> 0. EXIT. ENDIF. ENDDO. CLOSE DATASET FNAME.
Advertisements