Quantcast
Channel: SCN : Popular Discussions - ABAP Connectivity
Viewing all articles
Browse latest Browse all 898

Read file into internal table using OPEN DATASET FOR INPUT

$
0
0

Hi

 

i want to save a internal table (simple structure) to a file on the application server using the OPEN DATASET x FOR OUTPUT IN TEXT MODE (...). I don't have a problem creating the file - so far so good.

Afterwards i want to load the same file into a internal table.

The OPEN DATASET x FOR INPUT IN TEXT MODE (...) and the following READ DATASET x INTO y doean't accept the original structure as the input structure y.

Is there an easy way to "press" a input file line into a structure if the structure that was used to create the file is known?

 

Example:

 

1. Create file using the internal table it_data (structure ls_data):

 

OPEN DATASET file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

 

LOOP AT it_data INTO ls_data.

 

TRANSFER ls_data TO file.

 

ENDLOOP.

 

2. Read the file into the table (NOT WORKING)

 

OPEN DATASET file FOR INPUT IN TEXT MODE ENCODING DEFAULT.

 

DO.

 

READ DATASET file INTO ls_data.   " NOT WORKING !!!

 

IF sy-subrc EQ 0.

   APPEND ls_data TO it_data.

ELSE.

   EXIT.

ENDIF.

 

ENDDO:

 

 

The second step is not working because only a string structure seems to be accepted to read a dataset into.

Does anybody know a easy way to read the file into the internal table?

 

Thank you

Manfred


Viewing all articles
Browse latest Browse all 898

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>