You can add an image in a container and display that. In this article , I show how to specify clickable the image.
Step 1 Upload *BMP File
Step 2 Create program
STEP 1 Upload *BMP File – Upload Image
Go to SMW0 and upload image.
Choose Binary data for WebRFC applications and press enter key.
Give your package name and run(f8).
Click create button on the toolbar and give the image name and description.
Click import button and import your bmp image file.
STEP 2 Create program
Create container.
PBO :
* build button screen num – container name – image name
PERFORM set_button USING ‘100’ ‘B_PERSONEL’ ‘ZIMG_PERSONEL’ .
PAI : (Here set session break point and determine the w_int value. After you can use this functionality)
data : lv_1 type string.
data : lv_2 type string.
data : lv_3 type string.
w_int(4) TYPE c.
CLEAR : lv_1, lv_2 , lv_3 ,w_int.
SPLIT sy–ucomm AT ” INTO lv_1 lv_2 lv_3.
w_int = lv_2.
READ TABLE ole_control_map_table
INTO ole_control_map_wa WITH KEY shell_id = w_int.
IF syst–subrc = 0.
CASE syst–tabix.
WHEN 2. ” 2 can change according to place the container.
*** write your code when your button clicked
WHEN OTHERS.
CLEAR ok_code.
ENDCASE.
CHECK NOT ok_code IS INITIAL.
CALL FUNCTION ‘CONTROL_DISPATCH’
EXPORTING
fcode = ok_code.
ENDIF.
—————————————————————————————————————————————
Data declaritons :
DATA: pic_data LIKE w3mime OCCURS 0,
pic_size TYPE i,
repid LIKE sy–repid,
url(255) TYPE c,
ok_code LIKE sy–ucomm,
w_int(4) TYPE c.
DATA: query_table LIKE w3query OCCURS 1 WITH HEADER LINE,
html_table LIKE w3html OCCURS 1.
DATA: return_code LIKE w3param–ret_code,
content_type LIKE w3param–cont_type,
content_length LIKE w3param–cont_len.
data : pos_x type i,
pos_y type i,
w_init(1).
data gv_screen(3).
INCLUDE simagecontrolclassdef.
INCLUDE simagecontrolclassimpl.
DATA: button1 TYPE REF TO c_image_control,
button2 TYPE REF TO c_image_control,
button2_2 TYPE REF TO c_image_control,
button3 TYPE REF TO c_image_control,
button4 TYPE REF TO c_image_control.
data : lv_1 type string.
data : lv_2 type string.
data : lv_3 type string.
Class :
CLASS c_event_receiver DEFINITION.
PUBLIC SECTION.
METHODS event_handler_image_click
FOR EVENT image_click OF c_image_control
IMPORTING mouse_pos_x mouse_pos_y.
ENDCLASS.
DATA event_receiver TYPE REF TO c_event_receiver.
DATA event_receiver_kasa TYPE REF TO c_event_receiver.
DATA event_receiver_sevkiyat TYPE REF TO c_event_receiver.
*———————————————————————*
* CLASS c_event_receiver IMPLEMENTATION
*———————————————————————*
CLASS c_event_receiver IMPLEMENTATION.
METHOD event_handler_image_click.
pos_x = mouse_pos_x.
pos_y = mouse_pos_y.
ENDMETHOD.
ENDCLASS.
There is code set_button below.
FORM set_button USING value(p_0014)
value(p_0015)
value(p_0016).
clear : button1 , event_receiver.
CREATE OBJECT button1.
CALL METHOD button1->create_control
EXPORTING
dynnr = p_0014
repid = sy–repid
style = ws_dlgframe
container = p_0015.
CALL METHOD button1->register_event_image_click.
CREATE OBJECT event_receiver. “only need this line once
SET HANDLER event_receiver->event_handler_image_click
FOR button1.
CALL METHOD button1->set_display_mode
EXPORTING
display_mode = display_mode_fit_center.
PERFORM load_pic_from_db
TABLES pic_data
USING p_0016
CHANGING pic_size.
PERFORM call_function_url.
CALL METHOD button1->load_image_from_url
EXPORTING
url = url.
ENDFORM. ” SET_BUTTON
FORM load_pic_from_db TABLES pic_data
USING pic_name
CHANGING pic_size.
CLEAR: query_table[],
html_table,
return_code,
content_type,
content_length.
query_table–name = ‘_OBJECT_ID’.
query_table–value = pic_name.
APPEND query_table.
CALL FUNCTION ‘WWW_GET_MIME_OBJECT’
TABLES
query_string = query_table
html = html_table
mime = pic_data
CHANGING
return_code = return_code
content_type = content_type
content_length = content_length
EXCEPTIONS
OTHERS = 1.
IF sy–subrc = 0.
pic_size = content_length.
ENDIF.
ENDFORM. “load_pic_from_db
FORM call_function_url.
CALL FUNCTION ‘DP_CREATE_URL’
EXPORTING
type = ‘IMAGE’
subtype = ‘GIF’
size = pic_size
TABLES
data = pic_data
CHANGING
url = url.
ENDFORM. ” call_function_url
Secreen shot (Language = TR)

Uzun süredir paylaşım yapmıyorsunuz. Sizi özledik, lütfen değerli bilgilerinizi bizimle paylaşmaktan kaçınmayın.
LikeLike
I will do it soon 🙂
LikeLike