
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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.
- Related Questions & Answers
- Saving an internal table to SAP directory in csv format
- Saving an internal table to SAP directory in csv format
- Saving an internal table to SAP directory in csv format
- How to map output of a function to an internal table in SAP ABAP using Gateway service
- Inserting rows to an internal table through debug in SAP ABAP
- How to read CSV files in Golang?
- Adding rows in an internal table with header line in SAP ABAP
- Sorting an already sorted internal table in ABAP
- How can I get the list of files in a directory using C/C++?
- How to read data from all files in a directory using Java?
- How to read and parse CSV files in C++?
- How can I get the list of files in a directory using C or C++?
- Usage of subqueries in internal table as condition in SAP ABAP source code.
- Modification not working for both internal table and control table in SAP ABAP
- How can I iterate over files in a given directory in Python?
Advertisements