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

Read from a file to a Xstring

DG
Active Contributor
0 Likes
4,659

Hi,

I need to read a file and sent it with a proxy. The file is on hte server

I therefore need to get the file content as an XString. I'm unable to make any code work for tatk.

Daniel

Edited by: Daniel Graversen on Aug 20, 2010 12:12 PM

1 ACCEPTED SOLUTION
Read only

fred_verheul
Active Contributor
0 Likes
2,789

Hi Daniel,

I'm not sure what requirement you exactly have, but would CL_FILE_SYSTEM_MANAGER->LOAD_FILE, followed by some string-to-xstring conversion (e.g. by function module SCMS_STRING_TO_XSTRING) help?

Cheers, Fred

Hi,

I need to read a file and sent it with a proxy. The file is on hte server

I therefore need to get the file content as an XString. I'm unable to make any code work for tatk.

Daniel

Edited by: Daniel Graversen on Aug 20, 2010 12:12 PM

4 REPLIES 4
Read only

fred_verheul
Active Contributor
0 Likes
2,790

Hi Daniel,

I'm not sure what requirement you exactly have, but would CL_FILE_SYSTEM_MANAGER->LOAD_FILE, followed by some string-to-xstring conversion (e.g. by function module SCMS_STRING_TO_XSTRING) help?

Cheers, Fred

Read only

DG
Active Contributor
0 Likes
2,789

I did solve it by


DATA:    begin of itab occurs 0,
         text(100) type c,
         end of itab.

" read the files
OPEN DATASET HEADERFILENAME FOR input in text MODE ENCODING default.

DO.
  READ DATASET HEADERFILENAME INTO itab.

  IF SY-SUBRC <> 0.
    EXIT.
  else.
    append itab.
    clear itab.
  ENDIF.
ENDDO.

CALL FUNCTION 'SCMS_TEXT_TO_XSTRING'
 IMPORTING
   BUFFER           = attach_xstring
  TABLES
    TEXT_TAB         =  itab
          .

Read only

0 Likes
2,789

Alternatively you can read the file as byte stream


OPEN DATASET HEADERFILENAME FOR input in BINARY MODE.
"then use FM 
SCMS_BINARY_TO_XSTRING

This way you avoid conversion to text while reading the file.

Regards

Marcin

Read only

DG
Active Contributor
0 Likes
2,789

I did manage to solve the problem