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: 

read stmt

Former Member
0 Kudos
121

using read stmt is it possible to open the file in presentation server then how?

1 ACCEPTED SOLUTION

Former Member
0 Kudos
82

Hello Mohan,

For reading the file in the presentation server u have to use GUI_UPLOAD Fm.

If useful reward points.

Vasanth

6 REPLIES 6

Former Member
0 Kudos
83

Hello Mohan,

For reading the file in the presentation server u have to use GUI_UPLOAD Fm.

If useful reward points.

Vasanth

Former Member
0 Kudos
82

HI

you can open the file from the presentation server using

gui_upload fm. why you want to use the read statement.

regards

kishore

Former Member
0 Kudos
82

Hi,

Yes, it is possible, refer the following,

  • Retrieve Data file from Application server(Upload from Unix)

DATA: i_file like rlgrap-filename value '/usr/sap/tmp/file.txt'.

OPEN DATASET i_file FOR INPUT IN TEXT MODE.

IF sy-subrc NE 0.

MESSAGE e999(za) WITH 'Error opening file' i_file.

ENDIF.

DO.

  • Reads each line of file individually

READ DATASET i_file INTO wa_datatab.

  • Perform processing here

  • .....

ENDDO.

You can also refer the following link to understand how it works,

http://www.sapdevelopment.co.uk/file/file_updown.htm

Rgds,

Former Member
0 Kudos
82

Hi,

You can use the FM GUI_UPLOAD to fetch the file from the presentation server into an internal table.You can read the internal table to fetch the data.

Former Member
0 Kudos
82

READ statement is used in case of DATASET. For file on presentation server, you should GUI_UPLOAD function or method GUI_UPLOAD of CL_GUI_FRONTEND_SERVICES.

Regards,

Ravi

Note : Please mark all the helpful answers

Former Member
0 Kudos
82

Hi Mohan,

READ TABLE statement is used to read single record of a Internal Tables.

READ cannot be used for reading data from Presentation server(PC).

<b>READ DATASET</b> is used for reading files on Application server.

Consider this code.


DATA : msg(200). "For holding messages during OPEN DATASET
 
DATA : i_int LIKE tedata-data.
 
 
OPEN DATASET w_path FOR INPUT IN TEXT MODE ENCODING DEFAULT MESSAGE msg.
 
 
IF sy-subrc NE 0.
  MESSAGE w_osmsg TYPE 'S' DISPLAY LIKE 'E'.
  LEAVE LIST-PROCESSING.
ENDIF.
 
DO.
  READ DATASET w_path INTO i_int.
 
  IF sy-subrc EQ 0.
    
    APPEND i_int.
    CLEAR  i_int.
    
  ELSE.
 
    EXIT.
  ENDIF.
 
 
ENDDO.
 
  CLOSE DATASET w_path.

If READ DATASET is used before opening a file, READ DATASET tries to open a file (IN BINARY MODE FOR INPUT or with the options of the last OPEN DATASET statement for this file)

For reading files on Presentation server use FM'S <b>GUI_UPLOAD</b> for getting data from Presentation server to ABAP PRogram and <b>GUI_DOWNLOAD</b> for putting data from ABAP PRogram to Presentation server.

Regards,

Arun Samabrgi.