how to read text files from content repository in sap abap

不问归期 提交于 2019-12-12 02:16:33

问题


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 .


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/30634939/how-to-read-text-files-from-content-repository-in-sap-abap

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!