11-22-2017 10:45 AM
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 .....
11-22-2017 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).
11-22-2017 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'
11-22-2017 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).
11-22-2017 12:30 PM
11-22-2017 12:38 PM
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.
11-22-2017 2:11 PM
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
11-23-2017 8:39 AM
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 ).
11-22-2017 2: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
11-23-2017 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?
11-23-2017 12:12 PM