Skip to Content
0
Sep 02, 2020 at 09:24 AM

How to display a large size image in a custom container?

129 Views

I am trying to display image from an external system. The images of small size like 50KB - 700KB are being displayed just fine, but when i try to display an image of large size like 3mb - 4mb the image does not show. is there any way to upload an image of larger size. below is my code:

MODULE get_images OUTPUT.

DATA: lv_pic_result TYPE i,
pic_data LIKE w3mime OCCURS 0,
pic_size TYPE i.

CLEAR: gv_file, pic_size, pic_data, lv_pic_result .

CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = l_string
filetype = 'BIN'
IMPORTING
filelength = pic_size
TABLES
data_tab = pic_data
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_READ_ERROR = 2
NO_BATCH = 3
GUI_REFUSE_FILETRANSFER = 4
INVALID_TYPE = 5
OTHERS = 20
.

IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

CALL FUNCTION 'DP_CREATE_URL'
EXPORTING
type = 'image'
subtype = cndp_sap_tab_unknown
size = pic_size
lifetime = cndp_lifetime_transaction
TABLES
data = pic_data
CHANGING
url = gv_file
EXCEPTIONS
OTHERS = 1.




"free control object
IF gr_cc_pic IS NOT INITIAL.
gr_cc_pic->free( ).
FREE gr_cc_pic.
ENDIF.


CALL METHOD cl_gui_cfw=>flush.

"create custom container in dynpro 9003
IF gr_cc_pic IS INITIAL.
CREATE OBJECT gr_cc_pic
EXPORTING
container_name = 'IMAGES'
repid = sy-repid
dynnr = sy-dynnr.
ENDIF.

"create picture
IF gr_pic IS INITIAL.
CREATE OBJECT gr_pic
EXPORTING
parent = gr_cc_pic.
ENDIF.

gr_pic->load_picture_from_url(
EXPORTING
url = gv_file
IMPORTING
result = lv_pic_result
EXCEPTIONS
error = 1 ).

CALL METHOD gr_pic->set_3d_border(
EXPORTING
border = 5
EXCEPTIONS
error = 1 ).

gr_pic->set_display_mode(
EXPORTING
display_mode = cl_gui_picture=>display_mode_fit
EXCEPTIONS
error = 1 ).

CALL METHOD cl_gui_control=>set_focus
EXPORTING
control = gr_cc_pic.

CALL METHOD cl_gui_cfw=>flush.

ENDMODULE.