Skip to Content
0
Nov 30, 2020 at 11:49 AM

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

139 Views Last edit Nov 30, 2020 at 01:34 PM 2 rev

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