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

OPEN DATASET write to root folder

Former Member
0 Likes
6,670

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

1 ACCEPTED SOLUTION
Read only

Former Member
4,741

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

9 REPLIES 9
Read only

Former Member
4,741

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'

Read only

Former Member
4,742

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

Read only

0 Likes
4,741

root.pnghi,

thanks for the reply. I have tried below as path and it works fine

'/usr/sap/tmp/po.xml'

I want to place the file po.xml in "home" directory under root node. I tried '/home/po.xml' but it is dumping.. I have attached the screen shots of AL11. please suggest.

home.png

Read only

0 Likes
4,741

Then this is most likely an autorization issue on the OS level. The <sid>adm user probably does not have write access in the /home/ directory. If there is where the files should be placed, the system administrator of the server need to grant access for that user to the /home directory.

Read only

0 Likes
4,741

Ok. so you think there is nothing wrong in the way I am providing the file name /home/po.xml. Is there anyway I can check in SAP that authorisation is failing

Read only

0 Likes
4,741

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 ). 
Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
4,741

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

Read only

RaymondGiuseppi
Active Contributor
0 Likes
4,741

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?

Read only

retired_member
Product and Topic Expert
Product and Topic Expert