cancel
Showing results for 
Search instead for 
Did you mean: 

File do not exists in C:\WINDOWS folder after saving with cl_gui_frontend_services=>gui_download

NemanjaSimovic
Participant

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

abo
Active Contributor
0 Kudos

An exception implies subrc other than 0, right?

mateuszadamus
Active Contributor
0 Kudos

Yes, but only if these are handled. If not, then SY-SUBRC is not changed.

Kind regards,
Mateusz
abo
Active Contributor

Basically, your questions boils down to "can I trust the return code?" and the answer is yes, based on your own testing (reading the file back).

Still, I'm following the question out of curiosity, I'm going to try it later.

abo
Active Contributor
0 Kudos

Shouldn't an unhandled exception terminate the program?

mateuszadamus
Active Contributor
0 Kudos

Damn, you're right. I'm not thinking straight today...

I will remove my bollocks answer.


Kind regards,
Mateusz
NemanjaSimovic
Participant

Hi Andrea,


You are right. I didn't drop a formal question, but it will sound like you wrote.

Accepted Solutions (1)

Accepted Solutions (1)

NemanjaSimovic
Participant

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

SimoneMilesi
Active Contributor

I suggest you to close the question, accepting your own answer 🙂
And thanks for sharing this feature i wasn't aware of!

Answers (1)

Answers (1)

nishant12
Participant
0 Kudos

Hello nemanja.simovic.avnet ,

Have you checked if you have read/write permissions for that directory at the user level?

NemanjaSimovic
Participant
0 Kudos

Hi nishant ,

I started File Explorer, Total Commander and CMD.EXE as administraotr and I was not able to locate the file. I believe group Administrators have Full access.