Application Development 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: 

Get files from applicationserver

Former Member
0 Kudos
114

Hello All,

I have a requirement to get the files from shared folder(may be application server), is there any specific function module to get the list of files.

Dilip

6 REPLIES 6

Former Member
0 Kudos
77

to read file from application server,

USE

OPEN DATASET <FILENAME> FOR INPUT IN TEXT MODE ENCODING DEFAULT.

to read the contents of the file,

USE

READ DATASET <FILENAME> INTO V_STRING.

v_string will have the contents (1 line only)

and finally to close the file,

USE

CLOSE DATASET <FILENAME>

regards

srikanth

0 Kudos
77

total logic to get total contents of the file into the program.

data : begin of itab occurs 0,

LINE TYPE STRING,

end of itab.

OPEN DATASET <FILENAME> FOR INPUT IN TEXT MODE ENCODING DEFAULT.

DO.

IF SY-SUBRC <> 0.

EXIT.

ENDIF.

READ DATASET <FILENAME> INTO V_STRING.

IF V_STRING IS NOT INITIAL.

ITAB-LINE = V_STRING.

APPEND ITAB.

ENDIF.

ENDDO.

CLOSE DATASET <FILENAME>.

if you use this logic, the contents of the file will be comes into the internal table ITAB.

but <FILENAME> should be given total path. not the just filename.you should give the absolute path name along with file name.

regards

srikanth

0 Kudos
77

Hi Srikanth,

The filename can be any so first I have to get it the list of files.

Dilip

0 Kudos
77

Hi,

Copy paste this code. you'll get all the files from your dir.

data: begin of tabl occurs 500,

line(400),

end of tabl.

data: unixcom like rlgrap-filename.

data: lines type i.

unixcom = 'ls -al'.

refresh tabl.

call 'SYSTEM' id 'COMMAND' field unixcom

id 'TAB' field tabl[].

describe table tabl lines lines.

loop at tabl.

write:/01 tabl-line.

endloop.

skip 2.

if lines = 0.

write:/ 'NO Occurances were found'.

endif.

Regards,

Sumit.

Former Member
0 Kudos
77

Hi,

This program allows the user to choose a file on application server and downloads the same to an Internal table.



REPORT zes_sample.


DATA : filename LIKE dxfields-longpath.
DATA : BEGIN OF it_test OCCURS 0,
       a(200) TYPE c,
       END OF it_test.

*------------------------------------------

CALL FUNCTION 'F4_DXFILENAME_TOPRECURSION'
EXPORTING
  i_location_flag = 'A'
* I_SERVER = '?'
* I_PATH =
* FILEMASK = '*.*'
* FILEOPERATION = 'R'
IMPORTING
* O_LOCATION_FLAG =
* O_SERVER =
  o_path         = filename
* ABEND_FLAG =
EXCEPTIONS
  rfc_error       = 1
  error_with_gui  = 2
  OTHERS          = 3.


BREAK-POINT.

OPEN DATASET filename FOR INPUT IN BINARY MODE.
WHILE sy-subrc = 0.
  CLEAR it_test .
  READ DATASET filename INTO it_test.
  APPEND it_test.
ENDWHILE.

<b>AS</b>

Former Member
0 Kudos
77

Hai,

You can try the Tx <b>CG3Y/CG3Z</b>.