Application Development and Automation 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: 
Read only

How to open a picture?

Former Member
0 Kudos
397

Hi,

I want to open a picture while program is running. While program is running user need to open a picture, then user will browse a picture which is in computer. Then (s)he will open it.

Is is possible to implement this program?

Thanks.

2 REPLIES 2
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos
328

This may not solve your problem, but maybe give you some ideas. This is a sample program which uses the HTML container to throw up a webpage, this can also be used to view a network directory, not sure that it works for local drives. If you "picture" resides on a network server, then you will be able to use this sample.

Network server address like
ServerName\Folder

If pictures are on local drive, then your URL will be
computername. You will need to "share out" the local drive to make it visiable.

Rememeber, this is a quick a dirty way. There are better ways.

Regards

Rich Heilman

Read only

0 Kudos
328

Here is another sample that may help you.

User can select any folder, program will write the files to list display, then user can click on the file to open it up.



report zrich_0003.

data: gui_fs type ref to cl_gui_frontend_services.

data: dir_tab type standard table of file_info.
data: directory_folder type string.
data: count type i.

data: begin of list occurs 0,
      file(50) type c,
      end of list.

start-of-selection.

  create object gui_fs.

  perform select_read_directory.


at line-selection.

  perform execute_application using directory_folder
                                    list-file.


************************************************************************
*  Form  EXECUTE_APPLICATION
************************************************************************
form execute_application using directory_folder
                               file.

  data: file_path type string.

  concatenate directory_folder '' file into file_path.
  condense file_path.

  call method gui_fs->execute
    exporting
      document               = file_path
      maximized              = 'X'
      synchronous            = 'X'
    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
      others                 = 8.

  if sy-subrc <> 0.
  endif.

endform.

************************************************************************
*  Form  SELECT_READ_DIRECTORY
************************************************************************
form select_read_directory.

  call method gui_fs->directory_browse
    exporting
      window_title    = 'Select Directory'
      initial_folder  = 'c:'
    changing
      selected_folder = directory_folder
    exceptions
      cntl_error      = 1
      error_no_gui    = 2
      others          = 3.

  if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  endif.

  call method cl_gui_cfw=>flush
       exceptions
          cntl_system_error = 1
          cntl_error        = 2.
  if sy-subrc <> 0.
    message e324(sbds).
  endif.

  call method gui_fs->directory_list_files
    exporting
      directory                   = directory_folder
*    FILTER                      = '*.*'
     files_only                  = 'X'
*    DIRECTORIES_ONLY            =
    changing
      file_table                  = dir_tab
      count                       = count
    exceptions
      cntl_error                  = 1
      directory_list_files_failed = 2
      wrong_parameter             = 3
      error_no_gui                = 4
      others                      = 5.

  if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  endif.

  list[] = dir_tab[].

  loop at list.
    write:/ list-file. hide list-file.
  endloop.

endform.

Regards,

Rich Heilman