Application Development 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: 

OPEN DATASET write to root folder

former_member184741
Active Contributor
0 Kudos

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

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

Former Member

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'

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

0 Kudos

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

0 Kudos

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.

0 Kudos

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

0 Kudos

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

SuhaSaha
Advisor
Advisor

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

raymond_giuseppi
Active Contributor
0 Kudos

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?