You are on page 1of 5

HOW TO DISPLAY PICTURES IN MODULE POOL PROGRAMMING

STEPS
1.
2.
3.
4.
5.
6.

UPLOAD THE PICTURE THROUGH SE78 TRANSACTION


CREATE MODULE POOL PROGRAM
CREATE A SCREEN FOR THE PROGRAM
CREATE CUSTOM CONTROL IN SCREEN
PUT THE CODE PBO OF SCREEN
GIVE THE PICTURE & CUSTOM CONTROL NAME IN THE PROGRAM AS YOU
HAVE CREATED/*

CODE 1:

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.

data: g_stxbmaps type STXBITMAPS,


l_bytecnt

type i,

l_content

TYPE

standard table of bapiconten initial size 0.

g_stxbmaps-tdobject = 'GRAPHICS'.
g_stxbmaps-tdname = 'ENJOY'.
g_stxbmaps-tdid = 'BMAP'.
g_stxbmaps-tdbtype = 'BCOL'.

CALL FUNCTION 'SAPSCRIPT_GET_GRAPHIC_BDS'


EXPORTING
i_object
= g_stxbmaps-tdobject
i_name
= g_stxbmaps-tdname
i_id
= g_stxbmaps-tdid
i_btype
= g_stxbmaps-tdbtype
IMPORTING
e_bytecount
= l_bytecnt
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_bytecnt
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'
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 = 'PIC_DISP'.
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_1000

OUTPUT

CODE 2 :
MODULE STATUS_1000 OUTPUT.
* SET PF-STATUS 'xxxxxxxx'.
* SET TITLEBAR 'xxx'.

DATA: w_lines TYPE i.


TYPES pict_line(256) TYPE c.
DATA: container TYPE REF TO cl_gui_custom_container,

editor TYPE REF TO cl_gui_textedit,


picture TYPE REF TO cl_gui_picture,
pict_tab TYPE TABLE OF pict_line,
url(255) TYPE c.
DATA: graphic_url(255).
DATA: BEGIN OF graphic_table OCCURS 0,
line(255) TYPE x,
END OF graphic_table.
DATA: l_graphic_conv TYPE i.
DATA: l_graphic_offs TYPE i.
DATA: graphic_size TYPE i.
DATA: l_graphic_xstr TYPE xstring.
CALL METHOD cl_gui_cfw=>flush.
CREATE OBJECT:
container EXPORTING container_name = 'PIC_DISP ',
picture EXPORTING parent = container.
*Method which takes the object "ENJOY" - uploaded through SE78
*into the ABAP memory. Change name to object to be displayed in
*screen.
CALL METHOD cl_ssf_xsf_utilities=>get_bds_graphic_as_bmp
EXPORTING
p_object = 'GRAPHICS'
p_name
= 'ENJOY'
p_id
= 'BMAP'
p_btype = 'BCOL'
RECEIVING
p_bmp
= l_graphic_xstr.
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.

ENDMODULE.

" STATUS_1000

OUTPUT

You might also like