‎2008 Oct 30 6:22 AM
hai how can we load our own picture into a custom control .
i tried using CL_GUI_PICTURE.
method :LOAD_PICTURE_FROM_URL
for this i have to pass url.
how can i get url name for our own picture.
Edited by: sudheer b on Oct 30, 2008 7:22 AM
‎2008 Oct 30 6:30 AM
Hi,
See This link [loading picture|http://www.erpgenie.com/component/content/article/55-abap/425-picture-control]
Best Regards
swamy
‎2008 Oct 30 6:30 AM
Hi,
See This link [loading picture|http://www.erpgenie.com/component/content/article/55-abap/425-picture-control]
Best Regards
swamy
‎2008 Oct 30 6:54 AM
‎2008 Oct 30 7:32 AM
Hi Sudheer,
We have to create a url.
If the File is in presentation server, upload it into an int table and create url.
If the File is in application server, read it into an int table and create url.
Check the below example for reference.
Screen flow logic
PROCESS BEFORE OUTPUT.
MODULE pbo.
PROCESS AFTER INPUT.
MODULE pai AT EXIT-COMMAND.I have used the whole screen-100 as container so no custom container in screen
Program
DATA : go_pic TYPE REF TO cl_gui_picture,
gt_picbin TYPE solix_tab,
gt_filetable TYPE filetable,
gv_filename TYPE string,
gv_url TYPE char255,
gv_filesize TYPE i,
gv_return TYPE i,
gv_useraction TYPE i.
CALL SCREEN 100.
*&---------------------------------------------------------------------*
MODULE pbo OUTPUT.
SET PF-STATUS 'BASIC'. " just a BACK button with application type 'E'.
PERFORM upload_file.
PERFORM create_url.
CREATE OBJECT go_pic EXPORTING parent = cl_gui_container=>default_screen.
go_pic->load_picture_from_url( EXPORTING url = gv_url
IMPORTING result = gv_return ).
ENDMODULE. " pbo OUTPUT
*&---------------------------------------------------------------------*
MODULE pai INPUT.
SET SCREEN 0. LEAVE SCREEN.
ENDMODULE. " pai INPUT
*&--------------------------------------------------------------------*
FORM upload_file.
*File Open Dialog
cl_gui_frontend_services=>file_open_dialog( CHANGING file_table = gt_filetable
rc = gv_return
user_action = gv_useraction ).
CHECK gv_return GT cl_gui_frontend_services=>action_ok AND
gv_useraction EQ cl_gui_frontend_services=>action_ok.
READ TABLE gt_filetable INTO gv_filename INDEX 1.
*File Upload
cl_gui_frontend_services=>gui_upload( EXPORTING filename = gv_filename
filetype = 'BIN'
IMPORTING filelength = gv_filesize
CHANGING data_tab = gt_picbin
EXCEPTIONS OTHERS = 4 ).
CHECK sy-subrc = 4.
MESSAGE 'Exception occured' TYPE 'I'.
ENDFORM. "upload_file
*&--------------------------------------------------------------------*
FORM create_url.
CALL FUNCTION 'DP_CREATE_URL'
EXPORTING
type = 'image'
subtype = 'X-UNKNOWN'
TABLES
data = gt_picbin
CHANGING
url = gv_url
EXCEPTIONS
OTHERS = 4.
CHECK sy-subrc = 4.
MESSAGE 'Exception occured' TYPE 'I'.
ENDFORM. "create_urlalso search PICTUREDEMO* in SE38 for std examples.
Cheers,
Jose.
‎2008 Oct 30 6:59 AM
Specify the full path of the location where the picture is located along with the picture name and extension to the parameter URL of the method.
E.G:
For local system
C:\My folder\picture.jpg
For application server
/usr/sap/tmp/picture.jpg