简体   繁体   中英

how to read text files from content repository

My requirement is read text files from content repository in sap abap.I used SCMS_DOC_READ FM to read image file and creating url DP_CREATE_URL for creating image url but SCMS_DOC_READ not working for text.

Can any one suggest some code, FM or class .

You can easily find the answer there: http://scn.sap.com/thread/525075

If you want the short answer, you should use this(Note: I am not the author of this part):

CALL FUNCTION 'GUI_UPLOAD'
  EXPORTING
    FILENAME                     = "File path"
    FILETYPE                     = 'ASC'
   HAS_FIELD_SEPARATOR           = 'X'

TABLES
    DATA_TAB                     = IT.

Note : Internal table structure should be same as text File.

There are two options based on your requirement:

Option 1: Use READ DATASET to read file.

DATA : FNAME(60) type c VALUE 'myfile.txt',
       TEXT2(5) type c.

       OPEN DATASET FNAME FOR INPUT IN TEXT MODE.

       DO.
        READ DATASET FNAME INTO TEXT2 LENGTH LENG.
        WRITE: / SY-SUBRC, TEXT2.
         IF SY-SUBRC <> 0.
             EXIT.
         ENDIF.
      ENDDO.

     CLOSE DATASET FNAME.

Option 2: Use Class CL_ABAP_CONV_IN_CE to read file.

Refer this tutorial page to get more information on this class.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM