Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Function module to get files from application server into internal table

ram_sahoo
Participant
0 Likes
3,579

Hello Friends,

I am looking function modules for get files from application server path to internal table, I got some function modules but it is not working. Please suggest.

RZL_READ_DIR_LOCAL

EPS_GET_DIRECTORY_LISTING

both are giving error file not found, but if I go with same path in AL11, I can see the files.

Thanks.

13 REPLIES 13
Read only

ArthurParisius
Contributor
0 Likes
2,681

I don't know of any function modules but here's something I've seen used in the past.

data: begin of lt_tabl occurs 0,
 line type c length 2000,
 end of lt_tabl.
data: ls_line type c length 2000.

data: i_tab type table of string.

data: l_f_dir type c length 128,
 l_t_dir type c length 128,
 l_dir type c length 128,
 l_file type c length 30.
 
 l_file = '*.*'.
 l_t_dir = '/usr/sap/trans/log/'.
 concatenate l_t_dir l_file into l_f_dir.

* get files in directory.
 clear: l_dir.
 l_dir(7) = 'ls -ld '.
 l_dir+7(45) = l_f_dir.

 refresh lt_tabl.
 call 'SYSTEM' id 'COMMAND' field l_dir
 id 'TAB' field lt_tabl-*sys*.

 loop at lt_tabl into ls_line.
 refresh i_tab.
 clear l_file.
 split ls_line at '/' into table i_tab.
 check not i_tab[] is initial.
 loop at i_tab into l_file.
 endloop.

 endloop.

Read only

Read only

0 Likes
2,681

Hi Horst,

Thanks for the warning. As I said in my answer, it's something I came across in the past that fulfilled the purpose. Knowing the possible issues thanks to your link will have me looking for alternatives.

Regards,
Arthur

Read only

0 Likes
2,681

The link you provided is for presentation server not application server.

Read only

0 Likes
2,681

You only read the 2 or 3 first lines?

Read only

matt
Active Contributor
0 Likes
2,681

"Not working"

Is that the actual error message you get?

Read only

ram_sahoo
Participant
0 Likes
2,681

got solution I was trying in SE37, If we try with program level these function modules will work fine.

Read only

RaymondGiuseppi
Active Contributor
2,681

I Suppose lowercase checkbox in SE37 test mode... (again)

Read only

ram_sahoo
Participant
0 Likes
2,681

Hello Guys,

Now i got new requirement while collecting files from path should filter with date as per user entered. Any one can suggest how to achieve this kind of requirement.

Thanks.

Read only

matt
Active Contributor
0 Likes
2,681

Looks like you were right Raymond!

Read only

matt
Active Contributor
0 Likes
2,681

Ask a new question as a new question. Don't continue this one. Though you might confirm that your problem was caused because you didn't check the "lower case" check box when testing in SE37.

Read only

roberto_forti
Contributor
0 Likes
2,681

Hi Sahoo,

Try this FM TXW_FILE_OPEN_FOR_READ or creating "Z" Class~method or FM with below ABAP code.

...
OPEN DATASET <filename> FOR ... IN TEXT MODE ENCODING DEFAULT.

IF sy-subrc NE 0.
   MESSAGE or EXCEPTION...
ELSE.
   DO.
      READ DATASET <filename> INTO work-area.
      IF sy-subrc NE 0.
         EXIT.
      ELSE.
         APPEND work-area TO internal table.
      ENDIF.
      CLEAR: work-area.
   ENDDO.
ENDIF.

CLOSE DATASET <filename>.
IF sy-subrc NE 0.
   MESSAGE or EXCEPTION...
ENDIF.
...

Regards,