Search code examples
content-management-systemabapsap-basis

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 .


Solution

  • 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.