Posted: Tue Mar 18, 2008 2:14 pm Post subject: Показ картинки с локального диска.
Привет!
Возможно ли показать на экране программы картинку, с локального диска. Например, пользователь выбрал изображение
c:\Temp\material1.jpg
нужно отобразить его на экране ниже поля с путем.
Можно Вас спросить. Я нашел еще один код через google.
В аннотации написано, что нужно создать контейнер с именем 'IMG_CON', но у меня ничего не показывается?
You'll have to create a custom control for this and perform coding like this:
Code:
data piccon type ref to cl_gui_custom_container.
data my_piccon type ref to cl_gui_container.
data my_pic type ref to cl_gui_picture.
data my_container type ref to cl_gui_container.
invoking the static attribute of the class.
my_container = cl_gui_container=>default_screen.
create object my_pic
exporting
* LIFETIME =
* SHELLSTYLE =
parent = piccon
* NAME =
exceptions
error = 1
others = 2
.
if sy-subrc 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
Can be used to load the picture from the presentation server.
call method my_pic->load_picture_from_url
exporting
url = 'file://D:\mydata\Pictures\Misc_pics 1\fw1.jpg'
IMPORTING
* RESULT =
exceptions
error = 1
others = 2
.
if sy-subrc 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
Age: 46 Joined: 05 Nov 2007 Posts: 725 Location: КраснАдар
Posted: Thu Mar 20, 2008 1:09 pm Post subject:
Можно и так:
Code:
DATA: CONT TYPE REF TO CL_GUI_DOCKING_CONTAINER,
MY_PIC TYPE REF TO CL_GUI_PICTURE,
URL TYPE TEXT255,
G_REPID TYPE REPID.
PARAMETERS: Z TYPE MATNR.
INITIALIZATION.
G_REPID = SY-REPID.
AT SELECTION-SCREEN OUTPUT.
IF CONT IS INITIAL.
CREATE OBJECT CONT
EXPORTING
REPID = G_REPID
DYNNR = '1000'
SIDE = CL_GUI_DOCKING_CONTAINER=>DOCK_AT_BOTTOM
RATIO = '50'
EXCEPTIONS
CNTL_ERROR = 1
CNTL_SYSTEM_ERROR = 2
CREATE_ERROR = 3
LIFETIME_ERROR = 4
LIFETIME_DYNPRO_DYNPRO_LINK = 5.
CREATE OBJECT MY_PIC
EXPORTING
PARENT = CONT
EXCEPTIONS
ERROR = 1
OTHERS = 2 .
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CONCATENATE
'file://C:\Documents and Settings\All Users\Documents\My'
'Pictures\Sample Pictures\Winter.jpg'
INTO URL SEPARATED BY SPACE.
* CAN BE USED TO LOAD THE PICTURE FROM THE PRESENTATION SERVER.
CALL METHOD MY_PIC->LOAD_PICTURE_FROM_URL
EXPORTING
URL = URL
EXCEPTIONS
ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDIF.
А еще можно контейнер с названием IMG_CON прямо на селекционном экране нарисовать (только при изменении он стирается)... Тогда можно так написать:
Code:
DATA: CONT TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
MY_PIC TYPE REF TO CL_GUI_PICTURE,
URL TYPE TEXT255,
G_REPID TYPE REPID.
CREATE OBJECT MY_PIC
EXPORTING
PARENT = CONT
EXCEPTIONS
ERROR = 1
OTHERS = 2 .
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CONCATENATE
'file://C:\Documents and Settings\All Users\Documents\My'
'Pictures\Sample Pictures\Winter.jpg'
INTO URL SEPARATED BY SPACE.
* CAN BE USED TO LOAD THE PICTURE FROM THE PRESENTATION SERVER.
CALL METHOD MY_PIC->LOAD_PICTURE_FROM_URL
EXPORTING
URL = URL
EXCEPTIONS
ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDIF.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.