Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Display Image from Local path "c:\image.gif"

former_member196601
Active Participant
0 Kudos

Hi Experts,

Is there anyway to display an image from local path i.e "c:\img.jpg".

I need to display an image from the path in Dialog(Screen) programming.

I need to do it using program not any other way...

Can anyone suggest me a method please.

Thanks

Regards

Naveen

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Check if this thread helps -

ashish

PS: This helps to display image in ALV, you can create a subscreen in your dialog program screen, create a small program and call that program in this subscreen to display the image.

Message was edited by:

Ashish Gundawar

8 REPLIES 8

Former Member
0 Kudos

Hi,

Check if this thread helps -

ashish

PS: This helps to display image in ALV, you can create a subscreen in your dialog program screen, create a small program and call that program in this subscreen to display the image.

Message was edited by:

Ashish Gundawar

0 Kudos

Here you are just getting image from SAP database, or we are fetching it using business navigator but i don't need that...

My requirement is to display image using programming....

but my requirement is to get it from its local path i.e. "c:/folder/img.gif".

Is there anyway to achieve it...

Thanks

Regards

Naveen

0 Kudos

Hi,

Here is a sample code to upload picture to SAP -

CALL METHOD PIC_OBJ->LOAD_PICTURE_FROM_URL

EXPORTING

URL = 'file://C:FINALMain.BMP'

  • 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

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/74164792-0601-0010-1ca2-c61...

Hope this helps.

ashish

Message was edited by:

Ashish Gundawar

0 Kudos

Hi Naveen,

You'll have to create a custom control for this and perform coding like this:


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:mydataPicturesMisc_pics 1fw1.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.


0 Kudos

Hi Nishant

I tried your way but still I am not able to display the image, what can be done???

Please help...

Thanks

Regards

Naveen

0 Kudos

Hi,

I have tested this code and this displays image that I have stored in my D drive.

Have you created a custom control . The name of the control should be 'IMG_CON'

If the control name is not correct this will not work.

I believe you'll have to do some customization of the code as per your declarations.

It could also be that the object is not getting created at the right time.

Let me know what is the issue you are facing. Are you getting a blank screen? Dump? Any error messages?

Regards

Nishant

0 Kudos

Hey i apologize for that..

Its working for me..

Thanks a lot.

But can you suggest me a way to load picture from application server???

0 Kudos

I try to run your code it is not showing any and not raising any exception too. All i changed is file path. Am i missing anything?