您的位置:首页 > 其它

ABAP屏幕开发-屏幕插入图片

2013-10-05 14:31 375 查看
相关T-CODE

SE78:维护需要在屏幕上插入的图片

SE80:画屏幕&Coding

*&-------------------------------------------------------------------*

*&    定义变量

*&-------------------------------------------------------------------* 

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.

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.

*&-------------------------------------------------------------------*

*&      Module  STATUS_0100  OUTPUT

*&-------------------------------------------------------------------*

*       PBO

*--------------------------------------------------------------------*

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' "图片名称(SE78中维护)

      p_id      = 'BMAP'

      p_btype   = 'BMON'  "(BMON = black&white, BCOL = colour)

    RECEIVING

      p_bmp     = l_graphic_xstr

    EXCEPTIONS

      not_found = 1

      OTHERS    = 2.

  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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息