on 11-30-2020 11:49 AM
Hi comunitiy
While I tested my code for a case where I do not have rights to save file, I tried to save a file to C:\WINDOWS folder, and discovered that method cl_gui_frontend_services=>gui_download do return sy-subrc = 0, but actually do not save file. Or at least I can't access with any other program other than SAP. What's even stranger is when I close all my sessions and SAP Logon, and then I start again SAP Logon pad and run program where I only read same file it is working perfectly! I read with cl_gui_frontend_services=>gui_upload. Still I can't find my file via Windows Explorer or Total Commander in C:\WINDOWS folder. Of course checked System and Hidden files. I also tried with CMD.EXE as administrator.
Here is the example code for writing some content to file TEMP.TXT in C:\WINDOWS folder.
report znem_windows_write.
* File path
data(gv_filepath) = conv string( 'c:\windows\temp.txt' ).
* Content
data: gt_content_write type standard table of string.
append conv string( 'abc' ) to gt_content_write.
* Write
cl_gui_frontend_services=>gui_download(
exporting
filename = gv_filepath
filetype = 'ASC'
changing
data_tab = gt_content_write
).
Here is the example code for reading content from TEMP.TXT from C:\WINDOWS folder.
report znem_windows_read.
* File path
data(gv_filepath) = conv string( 'c:\windows\temp.txt' ).
* Content
data: gt_content_write type standard table of string.
append conv string( 'abc' ) to gt_content_write.
* Read
data: gt_content_read type standard table of string.
cl_gui_frontend_services=>gui_upload(
exporting
filename = gv_filepath
filetype = 'ASC'
changing
data_tab = gt_content_read
).
* Compare
try.
cl_abap_unit_assert=>assert_equals(
exporting
act = gt_content_read
exp = gt_content_write
).
write 'Are equal.'.
catch cx_root into data(gr_ex).
write 'Not equal.'.
endtry.
Appreciate any hint! 🙂
Update: Question is how can I trust sy-subrc or how can I access that file with another application?
Regards,
Nemanja
Hi all,
I found the what is happening! 🙂 I must admit, I didn't know that windows is having this kind of feature.
Here's the thing. Windows introduced feature to protect original installed files by virtualizing certain folders like "C:\Windows" or "C:\Program Files". Any files written by applications other than system are stored in folder "%userprofile%\appdata\local\virtualstore". Read the "Background" section on this link for slightly more info.
In my example I can find my TEMP.TXT file with command:
dir %userprofile%\appdata\local\virtualstore\temp.txt /s
I can see that is located in folder:
C:\Users\<my_username>\appdata\local\virtualstore\Windows
This issue is not due to SAP GUI saving under mysterious premissions, but due to Windows User Access Control (UAC) and its VirtualStore feature. Of course c5e08e0478aa4727abc4482f5be390b2 was right in did when he said that SY-SUBRC is returning valid value. Because file do exists. Thanks everyone for your interest. 🙂
Regards,
Nemanja
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I suggest you to close the question, accepting your own answer 🙂
And thanks for sharing this feature i wasn't aware of!
Hello nemanja.simovic.avnet ,
Have you checked if you have read/write permissions for that directory at the user level?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.