SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Показ картинки с локального диска.



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ABAP
View previous topic :: View next topic  
Author Message
corsair
Участник
Участник



Joined: 06 Feb 2008
Posts: 37

PostPosted: Tue Mar 18, 2008 2:14 pm    Post subject: Показ картинки с локального диска. Reply with quote

Привет!
Возможно ли показать на экране программы картинку, с локального диска. Например, пользователь выбрал изображение
c:\Temp\material1.jpg
нужно отобразить его на экране ниже поля с путем.
Back to top
View user's profile Send private message
John Doe
Модератор
Модератор


Age: 46
Joined: 05 Nov 2007
Posts: 725
Location: КраснАдар

PostPosted: Tue Mar 18, 2008 4:11 pm    Post subject: Reply with quote

К примеру:
Code:
DATA: CONT TYPE REF TO CL_GUI_DOCKING_CONTAINER,
      HTML TYPE REF TO CL_GUI_HTML_VIEWER,
      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 HTML
      EXPORTING
        PARENT = CONT.

    CONCATENATE
     'C:\Documents and Settings\All Users\Documents\My'
     'Pictures\Sample Pictures\Winter.jpg'
     INTO URL SEPARATED BY SPACE.
    CALL METHOD HTML->SHOW_URL
      EXPORTING
        URL                    = URL
        IN_PLACE               = ' X'
      EXCEPTIONS
        CNTL_ERROR             = 1
        CNHT_ERROR_NOT_ALLOWED = 2
        CNHT_ERROR_PARAMETER   = 3
        DP_ERROR_GENERAL       = 4
        OTHERS                 = 5
            .

  ENDIF.
Back to top
View user's profile Send private message Blog
corsair
Участник
Участник



Joined: 06 Feb 2008
Posts: 37

PostPosted: Thu Mar 20, 2008 12:16 pm    Post subject: Reply with quote

John Doe, ваш пример работает, спасибо!

Можно Вас спросить. Я нашел еще один код через 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 piccon
exporting
parent = my_piccon
container_name = 'IMG_CON'
* STYLE =
LIFETIME = lifetime_default
repid = sy-repid
dynnr = sy-dynnr
* NO_AUTODEF_PROGID_DYNNR =
exceptions
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
others = 6
.
if sy-subrc 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.

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.
Back to top
View user's profile Send private message
John Doe
Модератор
Модератор


Age: 46
Joined: 05 Nov 2007
Posts: 725
Location: КраснАдар

PostPosted: Thu Mar 20, 2008 1:09 pm    Post subject: Reply with quote

Можно и так:
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.

PARAMETERS: Z TYPE MATNR.

INITIALIZATION.
  G_REPID = SY-REPID.

AT SELECTION-SCREEN OUTPUT.
  IF CONT IS INITIAL.
    CREATE OBJECT CONT
      EXPORTING
        CONTAINER_NAME = 'IMG_CON'
        REPID = G_REPID
        DYNNR = '1000'
      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.
Back to top
View user's profile Send private message Blog
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ABAP All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
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.