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: 

CL_GUI_FRONTEND_SERVICES print and delete file

Former Member
0 Kudos

Hi,

I am using CL_GUI_FRONTEND_SERVICES->EXECUTE to execute adobe and print out a pdf form which is saved on my desktop. When the file is printed, the file should be deleted again from the desktop, for this I am using CL_GUI_FRONTEND_SERVICES->FILE_DELETE. But the printing does not work because the file gets deleted already before again. Is there a way to "Commit" the execute/print, so the file is not deleted already?


Thanks,

Tim

1 ACCEPTED SOLUTION

roberto_vacca2
Active Contributor
0 Kudos

Hi.

Execute method has a SYNCHRONOUS parameter that should work but it depends on your operating system. With a synchronous eq to space , you have your file opened in the application and you should DO file_delete until it's closed. (with a DO. ENDDO)..

Most Generally you could use an INPLACE control viewer using

i_oi_container_control class and parameters REGISTER_ON_CLOSE_EVENT.

This wait until operation from application side is closed.

Hope to help

Bye

7 REPLIES 7

roberto_vacca2
Active Contributor
0 Kudos

Hi.

Execute method has a SYNCHRONOUS parameter that should work but it depends on your operating system. With a synchronous eq to space , you have your file opened in the application and you should DO file_delete until it's closed. (with a DO. ENDDO)..

Most Generally you could use an INPLACE control viewer using

i_oi_container_control class and parameters REGISTER_ON_CLOSE_EVENT.

This wait until operation from application side is closed.

Hope to help

Bye

0 Kudos

Thanks for your comment. How can I check if the file is closed? I have also tried to use WAIT command, but still the file gets deleted and printing does not work.

Tim

0 Kudos

Hi.

You should post your main code to see some details.

0 Kudos

This is the part of the code where I first execute the adobe and print and afterwards I call the file_delete. This part I have commented out now because it does not work. I also tried WAIT before deletion but still not ok. Adobe opens an error message that file cannot be opened and therefore not printed.


Thanks,

Tim


*-- Prepare printing

     CONCATENATE  '/t' lv_path INTO zlv_parameter SEPARATED BY space.

     CALL METHOD cl_gui_frontend_services=>execute

       EXPORTING

         application            = zlv_program

         parameter              = zlv_parameter

         minimized              = 'X'

*        synchronous            = 'X'

*        operation              = ''

       EXCEPTIONS

         cntl_error             = 1

         error_no_gui           = 2

         bad_parameter          = 3

         file_not_found         = 4

         path_not_found         = 5

         file_extension_unknown = 6

         error_execute_failed   = 7

         synchronous_failed     = 8

         not_supported_by_gui   = 9

         OTHERS                 = 10.

*    lv_filename = lv_path.

**    WAIT UP TO 5 SECONDS.

** When file is printed delete from temporary store

*    IF sy-subrc = 0.

*      CALL METHOD cl_gui_frontend_services=>file_delete

*        EXPORTING

*          filename             = lv_filename

*        CHANGING

*          rc                   = lv_rc

*        EXCEPTIONS

*          file_delete_failed   = 1

0 Kudos

WAIT UP TO x SECONDS always sets sy-subrc to 0 !

But you wrote you added it later, so execute returned 0 and still did not print...

Does it print if you comment file deletion?

-- Tomas --

0 Kudos

yes, execute returned 0 and delete_file is executed, obviously before the printing can start/finish because the error message in Adobe is file cannot be opened. yes, it prints without the file deletion.

I have now create a separate program with the same logic and I use submit program and return for the file printing. When it returns, I do a commit and the delete_file and that works fine. So file is printed and the file is deleted afterwards.

So, thanks for your help!

rosenberg_eitan
Active Contributor
0 Kudos

Hi,

I did not try this but try using a batch (.bat) file that will call

adobe print and then delete the file .

Regards .