SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Insert image onto SAP screen



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Dialog Programming
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1640

PostPosted: Sun Oct 14, 2007 7:03 pm    Post subject: Insert image onto SAP screen Reply with quote

To version 4.6
This is very simple to do, first create a dialog program with one screen (any number i.e. 0100) and create a custom control called 'CUST_CONTROL'. Now use the below sections of code to create a top include and a PBO module/process. And then finally create a transaction code for it.

Code:

CONSTANTS: CNTL_TRUE  TYPE I VALUE 1,
      CNTL_FALSE type i value 0.
data:
   h_picture       type ref to cl_gui_picture,
   h_pic_container type ref to cl_gui_custom_container.
*   h_tree          type ref to cl_gui_list_tree,
*   h_docking       type ref to cl_gui_docking_container,
*   h_application   type ref to lcl_application.

data: graphic_url(255),
      graphic_refresh(1),
      g_result                     like cntl_true.

data: begin of graphic_table occurs 0,
        line(255) type x,
      end of graphic_table.

data: graphic_size type i.

       

data: g_stxbitmaps type STXBITMAPS,
      l_bytecount  type i,
      l_content   TYPE  standard table of bapiconten initial size 0.

g_stxbitmaps-tdobject = 'GRAPHICS'.
g_stxbitmaps-tdname = 'ENJOY'.
g_stxbitmaps-tdid = 'BMAP'.
g_stxbitmaps-tdbtype = 'BMON'.  "(BMON = black&white, BCOL = colour)

call function 'SAPSCRIPT_GET_GRAPHIC_BDS'
     exporting
          i_object       = g_stxbitmaps-tdobject
          i_name         = g_stxbitmaps-tdname
          i_id           = g_stxbitmaps-tdid
          i_btype        = g_stxbitmaps-tdbtype
     importing
          e_bytecount    = l_bytecount
     tables
          content        = l_content
     exceptions
          not_found      = 1
          bds_get_failed = 2
          bds_no_content = 3
          others         = 4.

call function 'SAPSCRIPT_CONVERT_BITMAP'
     exporting
          old_format               = 'BDS'
          new_format               = 'BMP'
          bitmap_file_bytecount_in = l_bytecount
     importing
          bitmap_file_bytecount  = graphic_size
     tables
          bds_bitmap_file        = l_content
          bitmap_file            = graphic_table
     exceptions
          others                 = 1.

call function 'DP_CREATE_URL'
     exporting
        type                 = 'image'            "#EC NOTEXT
        subtype              = cndp_sap_tab_unknown
        size                 = graphic_size
        lifetime             = cndp_lifetime_transaction
     tables
        data                 = graphic_table
     changing
        url                  = graphic_url
     exceptions
        others               = 4 .

create object h_pic_container
       exporting container_name =  'CUST_CONTROL'.

create object h_picture exporting parent = h_pic_container.

call method h_picture->set_display_mode
     exporting
          display_mode = cl_gui_picture=>display_mode_normal.

call method h_picture->load_picture_from_url
     exporting url    = graphic_url
     importing result = g_result.

endmodule.                 " STATUS_0100  OUTPUT


To version 4.7
This is very simple to do, first create a dialog program with one screen (any number i.e. 0100) and create a custom control called 'CUST_CONTROL'. Now use the below sections of code to create a top include and a PBO module/process. And then finally create a transaction code for it.

Code:

CONSTANTS: CNTL_TRUE  TYPE I VALUE 1,
      CNTL_FALSE type i value 0.
data:
   h_picture       type ref to cl_gui_picture,
   h_pic_container type ref to cl_gui_custom_container.
*   h_tree          type ref to cl_gui_list_tree,
*   h_docking       type ref to cl_gui_docking_container,
*   h_application   type ref to lcl_application.

data: graphic_url(255),
      graphic_refresh(1),
      g_result                     like cntl_true.

data: begin of graphic_table occurs 0,
        line(255) type x,
      end of graphic_table.

data: graphic_size type i.

       

*--------------------------------------------------------------------*
***INCLUDE ZDISPLAYIMAGEPBO .
*--------------------------------------------------------------------*
*&-------------------------------------------------------------------*
*&      Module  STATUS_0100  OUTPUT
*&-------------------------------------------------------------------*
*       text
*--------------------------------------------------------------------*
module STATUS_0100 output.
data: l_graphic_xstr type xstring,
      l_graphic_conv type i,
      l_graphic_offs type i.

  CALL METHOD cl_ssf_xsf_utilities=>get_bds_graphic_as_bmp
    EXPORTING
      p_object  = 'GRAPHICS'
      p_name    = 'ENJOY' "IMAGE NAME - Image name from SE78
      p_id      = 'BMAP'
      p_btype   = 'BMON'  "(BMON = black&white, BCOL = colour)
    RECEIVING
      p_bmp     = l_graphic_xstr
    EXCEPTIONS
      not_found = 1
      OTHERS    = 2.

*  IF sy-subrc = 1.
*    MESSAGE e287 WITH g_stxbitmaps-tdname.
*  ELSEIF sy-subrc <> 0.
*    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
*            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
*    EXIT.
*  ENDIF.

  graphic_size = XSTRLEN( l_graphic_xstr ).
  CHECK graphic_size > 0.

  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'               "#EC NOTEXT
          subtype              = cndp_sap_tab_unknown " 'X-UNKNOWN'
          size                 = graphic_size
          lifetime             = cndp_lifetime_transaction  "'T'
       TABLES
          data                 = graphic_table
       CHANGING
          url                  = graphic_url
       EXCEPTIONS
*           dp_invalid_parameter = 1
*           dp_error_put_table   = 2
*           dp_error_general     = 3
          OTHERS               = 4 .
  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.

   create object h_pic_container
          exporting container_name =  'CUST_CONTROL'.
   create object h_picture exporting parent = h_pic_container.

   call method h_picture->load_picture_from_url
        exporting url    = graphic_url
        importing result = g_result.

endmodule.                 " STATUS_0100  OUTPUT
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Dialog Programming All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.