Quantcast
Channel: SCN: Message List - ABAP Connectivity
Viewing all articles
Browse latest Browse all 3125

first time image is not displayed in container

$
0
0

actual requirement is, to capture image from webcam then displayed it in module pool container.

 

for this, my approach as below

 

1. start webcam and take image.

 

CALL METHOD cl_gui_frontend_services=>directory_list_files
         EXPORTING
           directory                   = lv_dirname
           filter                      = '*.bmp'
           files_only                  = 'X'
*         directories_only            =
         CHANGING
           file_table                  = dl_files
           count                       = dl_cnt
         EXCEPTIONS
           cntl_error                  = 1
           directory_list_files_failed = 2
           wrong_parameter             = 3
           error_no_gui                = 4
           not_supported_by_gui        = 5
           OTHERS                      = 6.
       IF sy-subrc <> 0.
* Implement suitable error handling here
       ELSE.
         SORT dl_files BY createdate DESCENDING createtime DESCENDING .
         READ TABLE dl_files INTO ll_files INDEX 1.
         IF sy-subrc EQ 0.
           gi_filename = ll_files-filename.
           CONCATENATE lv_dirname  gi_filename INTO gi_filename.
           CONDENSE gi_filename.
         ENDIF.
       ENDIF.


2. upload image to sap


  gi_name = gv_driver-license."LS_TOKEN_DET-token.
   gi_object = 'GRAPHICS'.
   gi_id = 'BMAP'.
   gi_btype = 'BCOL'. "If u want black and white pass BMON
   gi_resident = ' '.
   gi_autoheight = ' '. "'X'.
   gi_bmcomp = 'X'.
*  gi_resolution = 200.
*l_width_pix = '400'. "'474'.
*l_height_pix = '400'. "'356'.
   l_extension = 'BMP'.

   PERFORM import_bitmap_bds IN PROGRAM saplstxbitmaps USING gi_filename
   gi_name
   gi_object
   gi_id
   gi_btype
   l_extension
   ' '
   gi_resident
   gi_autoheight
   gi_bmcomp
*l_width_pix
*l_height_pix
   CHANGING l_docid
   gi_resolution.


3. display image


CREATE OBJECT:
     container EXPORTING container_name = 'PIC10',
     picture EXPORTING parent = container.
     lv_obj gv_driver-license.

     CALL METHOD cl_ssf_xsf_utilities=>get_bds_graphic_as_bmp
       EXPORTING
         p_object       = 'GRAPHICS'
         p_name         = lv_obj
         p_id           = 'BMAP'
         p_btype        = 'BCOL'
       RECEIVING
         p_bmp          = l_graphic_xstr
       EXCEPTIONS
         not_found      = 1
         internal_error = 2
         OTHERS         = 3.
     IF sy-subrc EQ 0.
       graphic_size = xstrlen( l_graphic_xstr ).
       l_graphic_conv = graphic_size.
       l_graphic_offs = 0.
       WHILE l_graphic_conv > 255.
         graphic_table-line = l_graphic_xstr+l_graphic_offs(255).
         APPEND graphic_table.
         l_graphic_offs = l_graphic_offs + 255.
         l_graphic_conv = l_graphic_conv - 255.
       ENDWHILE.
       graphic_table-line = l_graphic_xstr+l_graphic_offs(l_graphic_conv).
       APPEND graphic_table.
       CALL FUNCTION 'DP_CREATE_URL'
         EXPORTING
           type     = 'IMAGE'
           subtype  = 'X-UNKNOWN'
           size     = graphic_size
           lifetime = 'T'
         TABLES
           data     = graphic_table
         CHANGING
           url      = url.
       CALL METHOD picture->load_picture_from_url
         EXPORTING
           url = url.
       CALL METHOD picture->set_display_mode
         EXPORTING
           display_mode = picture->display_mode_fit_center.

     ENDIF.
     CLEAR :url.

   ENDIF.


4. call picture_display in PBO

     

      PROCESS BEFORE OUTPUT.

       module picture_display.


here picture is displayed from second time onward, but first time picture not displayed. i have also check whether picture in uploaded before display, it uploaded (check it in SE78). please help its urgent.



Viewing all articles
Browse latest Browse all 3125

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>