Skip to Content
-4

OPEN DATASET write to root folder

Hi Exprets,

I would like to store data in application server in the following directory.

the directory ( lets say folder name is "Folder1" is created under 'root' node in AL11. Now how do i write my OPEN dataset statemnet

what should lv_file shoud have?

OPEN DATESET lv_file .....

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

5 Answers

  • Best Answer
    Nov 22, 2017 at 11:37 AM

    The OPEN DATASET command expects a real physical file name, and the format depends on the operating system of the current app server. For instance on a LINUX os this mig be '/Folder1/filename' if that folder is placed directly in the root.

    If the path is identical across all application servers and the system landscape, you don't need the root node in AL11 for this, but of course you can use Logical file names as well. (Then use transactions AL11, FILE, SF01 and then use function module FILE_GET_NAME to get the actual file name to use in you call to OPEN DATASET).

    Add comment
    10|10000 characters needed characters exceeded

    • Yes, its in the documentation provided by Suhas Saha as well... This will give you the error message:

      data lv_message type string.
      open dataset '/home/po.xml' for output in text mode encoding default message lv_message.
      cl_demo_output=>display( lv_message ). 
  • Nov 22, 2017 at 02:20 PM

    Everything you want to know is listed in the ABAP(F1) Documentation.

    https://help.sap.com/doc/abapdocu_751_index_htm/7.51/en-US/index.htm?file=abapopen_dataset.htm

    Add comment
    10|10000 characters needed characters exceeded

  • Nov 23, 2017 at 12:12 PM
    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Nov 22, 2017 at 11:34 AM

    if you want to write data in AL11 then:

    OPEN DATASET lv_file for OUTPUT in <mode>.

    Just write open dataset in ABAP editor and click F1 on OPEN, you will get all the required details.

    Let me know if you still stuck

    LV_file should be of LOCALFILE type and should have the full path like '/usr/local/bin/test.txt'

    Add comment
    10|10000 characters needed characters exceeded

  • Nov 23, 2017 at 10:35 AM

    To insure correct behavior of your program you should first check authorization at SAP level

        CALL FUNCTION 'AUTHORITY_CHECK_DATASET'
             EXPORTING                       
               ACTIVITY             = 'WRITE'
               FILENAME             = filename
             EXCEPTIONS                      
               NO_AUTHORITY         = 1      
               OTHERS               = 4. 
    

    But, of course, you should also CATCH handleable exceptions like CX_SY_FILE_AUTHORITY (list can be found with F1 or online help) for error raised by actual server.

    Also most Admins I know, wont allow you to put your data in root folder, bad practice indeed?

    Add comment
    10|10000 characters needed characters exceeded