abap display the logo

*- GET BMP image *-
  call method cl_ssf_xsf_utilities=>get_bds_graphic_as_bmp
    exporting
      p_object  = 'GRAPHICS'
      p_name    = lv_pic_name
      p_id      = 'BMAP'
      p_btype   = 'BCOL' "(BMON = black&white, BCOL = colour)
    receiving
      p_bmp     = lv_graphic_xstr
    exceptions
      not_found = 1
      others    = 2.

  lv_graphic_size = xstrlen( lv_graphic_xstr ).
  check lv_graphic_size > 0.                  "check whether image exists

  lv_graphic_conv = lv_graphic_size.
  lv_graphic_offs = 0.

*- prepare the image as data table *-
  while lv_graphic_conv > 255.
    ls_pict_tab-line = lv_graphic_xstr+lv_graphic_offs(255).
    append ls_pict_tab to lt_pict_tab.
    lv_graphic_offs = lv_graphic_offs + 255.
    lv_graphic_conv = lv_graphic_conv - 255.
  endwhile.

*- append rest of the lines of the image *-
  ls_pict_tab-line = lv_graphic_xstr+lv_graphic_offs(lv_graphic_conv).
  append ls_pict_tab to lt_pict_tab .
  clear ls_pict_tab.

*- create URL for the image *-
  call function 'DP_CREATE_URL'
    exporting
      type     = 'IMAGE'
      subtype  = co_sap_tab_unknown " 'X-UNKNOWN'
      size     = lv_graphic_size
      lifetime = co_lifetime_transaction "'T'
    tables
      data     = lt_pict_tab
    changing
      url      = lv_url.
  if sy-subrc <> 0.
    message id sy-msgid type sy-msgty number sy-msgno
    with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    exit.
  endif.
<!--StartFragment -->  lv_container type scrfname value 'LOGO_90_CONT'.screen create container 
                                                                                                    for picture display
  if go_pic_container is initial.

*- create picture container *-
    create object go_pic_container
      exporting
        container_name = lv_container.

*- create picture control *-
    create object go_picture_control
      exporting
        parent = go_pic_container.


*- display image from URL *-
    call method go_picture_control->load_picture_from_url_async
      exporting
        url = lv_url.


  else.

    call method go_picture_control->clear_picture.

*- display image from URL *-
    call method go_picture_control->load_picture_from_url_async
      exporting
        url = lv_url.

  endif.

endform.

猜你喜欢

转载自mahone.iteye.com/blog/1217041