2

I have a directory with a lot of files, but I only want to read .CSV files. I passed all the files in the directory to an internal table, and now I want to read these files (read the content of these files to the screen).

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
Gil Mota
  • 79
  • 1
  • 11
  • It might be important to know whether your application server runs on Windows or Unix-like machine. If it is the latter then the case matters! – Jagger Oct 12 '12 at 15:09
  • Jagger, assuming that the files were read using a function module like EPS2_GET_DIRECTORY_LISTING, that should be the case... although... after re-reading the thread below...... – vwegert Oct 12 '12 at 20:16

2 Answers2

1

Assuming that you use EPS2_GET_DIRECTORY_LISTING as recommended for example in this question, you could just delete all lines of the table that do not end in .csv:

DELETE lt_file_list WHERE name NP '*.CSV'.

Be aware that the CP/NP operators are case-insensitive (this is probably the intende behavior in this case).

Community
  • 1
  • 1
vwegert
  • 18,371
  • 3
  • 37
  • 55
  • I need to use the 'OPEN DATASET file_s FOR INPUT IN TEXT MODE ENCODING NON-UNICODE'. But launches the the error: 'Error to open file', in all files of the directory. the directory is on the server. – Gil Mota Oct 12 '12 at 11:10
  • OPEN DATASET does not "launch" any "error"s. Please specify exactly what you're doing and what's happening. – vwegert Oct 12 '12 at 11:26
  • Sorry, I expressed myself wrong. I did this: OPEN DATASET file_s FOR INPUT IN TEXT MODE ENCODING NON-UNICODE. IF sy-subrc NE 0. WRITE:/ 'Erro na leitura do ficheiro ', tabf-message ,'.'. CONCATENATE 'Erro na leitura do ficheiro ' tabf-message '.' INTO texto SEPARATED BY space. APPEND texto. CLEAR texto. ELSE. The result of this is the message "Erro na leitura do ficheiro". The files are not being open. – Gil Mota Oct 12 '12 at 11:31
  • And have you tried to catch the actual error message as documented for OPEN DATASET? – vwegert Oct 12 '12 at 11:43
  • The result of SY-SUBRC is 8. But I don't understand, the internal table have all the files. – Gil Mota Oct 12 '12 at 11:46
  • As I said, try to catch the actual error message, and for $DEITY's sake, please read the documentation: http://help.sap.com/abapdocu_702/en/abapopen_dataset_error_handling.htm – vwegert Oct 12 '12 at 11:57
  • Can you find back the files with AL11 ? – tomdemuyt Oct 14 '12 at 01:00
0

I solve the problem. When I pass (concatenate) the info into the internal table, I was passing some wrong data. Thanks.

Gil Mota
  • 79
  • 1
  • 11