Application Development and Automation 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: 
Read only

uploadlogo to module pool

Former Member
0 Likes
1,635

Hi

When i upload sap icons its works fine but when i upload a image from my desktop,it doesn't show up.

please let me know if iam wrong anywhere

DATA: go_picture TYPE REF TO cl_gui_picture,

go_picture_container TYPE REF TO cl_gui_custom_container.

IF go_picture_container IS INITIAL.

CREATE OBJECT go_picture_container

EXPORTING

container_name = 'CONT'.

CREATE OBJECT go_picture

EXPORTING

parent = go_picture_container.

  • Set display mode (Stretching, original size etc.)

CALL METHOD go_picture->set_display_mode

EXPORTING

DISPLAY_MODE = CL_GUI_PICTURE=>display_mode_fit_center

EXCEPTIONS

ERROR = 1.

CALL METHOD GO_PICTURE->load_picture_from_url

EXPORTING

url = 'file://C:\Documents and Settings\gund\Desktop\UNTITLED.JPG'

  • IMPORTING

  • RESULT =

EXCEPTIONS

ERROR = 1

others = 2

.

  • CALL METHOD go_picture->load_picture_from_sap_icons

*

  • EXPORTING

  • icon = icon_delete

  • EXCEPTIONS error = 1.

*

ENDIF.

Please advice me

Thanks

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,599

Hi !

It should work...

Try to bring your picture to c:temp

then file://c:\temp\testpic.jpg should work.

What else can you do...

Have a look the the report SAP_PICTURE_DEMO.

Type ypur URL there and see if it works.

If not... The URL may not be correct or you may not have permission to read from the directory.

If it works in the SAP_PICTURE_DEMO, there may be an error in your report.

Just check out the SAP_PICTURE_DEMO it's a good example.

Regards

Rainer

Some points would be nice if that helped a bit.

Hi

When i upload sap icons its works fine but when i upload a image from my desktop,it doesn't show up.

please let me know if iam wrong anywhere

DATA: go_picture TYPE REF TO cl_gui_picture,

go_picture_container TYPE REF TO cl_gui_custom_container.

IF go_picture_container IS INITIAL.

CREATE OBJECT go_picture_container

EXPORTING

container_name = 'CONT'.

CREATE OBJECT go_picture

EXPORTING

parent = go_picture_container.

  • Set display mode (Stretching, original size etc.)

CALL METHOD go_picture->set_display_mode

EXPORTING

DISPLAY_MODE = CL_GUI_PICTURE=>display_mode_fit_center

EXCEPTIONS

ERROR = 1.

CALL METHOD GO_PICTURE->load_picture_from_url

EXPORTING

url = 'file://C:\Documents and Settings\gund\Desktop\UNTITLED.JPG'

  • IMPORTING

  • RESULT =

EXCEPTIONS

ERROR = 1

others = 2

.

  • CALL METHOD go_picture->load_picture_from_sap_icons

*

  • EXPORTING

  • icon = icon_delete

  • EXCEPTIONS error = 1.

*

ENDIF.

Please advice me

Thanks

16 REPLIES 16
Read only

Former Member
0 Likes
1,600

Hi !

It should work...

Try to bring your picture to c:temp

then file://c:\temp\testpic.jpg should work.

What else can you do...

Have a look the the report SAP_PICTURE_DEMO.

Type ypur URL there and see if it works.

If not... The URL may not be correct or you may not have permission to read from the directory.

If it works in the SAP_PICTURE_DEMO, there may be an error in your report.

Just check out the SAP_PICTURE_DEMO it's a good example.

Regards

Rainer

Some points would be nice if that helped a bit.

Read only

0 Likes
1,599

Hi Rainer and all,

I checked in sap_picture_demo .

it says error loading screen.

Any suggestions in order to acheve results

Thanks in advance

Read only

0 Likes
1,599

Hi,

I did something 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:\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.

Hope this helps!

Regards

Nishant

P.S. I might have missed some declaration but you can get an idea from this

Read only

Former Member
0 Likes
1,599

Hi !

If the SAP_PICTURE_DEMO cannot open the picture it's a problem with the path or the picture then !

The picture-control only can open BMP and JPG pictures.

It cannot open TIFF, for example.

So check out if your file is a propper jpg-file !

To check out you may download a jpg-file from the internet or soething else...

Check out the path and file permissions and the correct spelling of the path... then in shuld work...

Regards

Rainer

Read only

0 Likes
1,599

hi RAINER AND ALL,

can tell how to give the location of the image in sap_picture_demo or do i need to add any in front or end

I gave it as

C:\SAMPLE.JPG

this is the image that everybody has in their system

Thanks

Read only

0 Likes
1,599

Hi,

Give it like this

file://D:\mydata\Pictures\Misc_pics 1\fw1.jpg

It will work.

Make sure your file is there where you define

Regards

Nishant

Read only

0 Likes
1,599

Hi nishant,

I worked for me now in SAP_PICTURE_DEMO when i entered as

file://C:\pic1.bmp

i can see the image, but i gave in ur code i doesn't show in my module pool.

Please let me know wheter ur code works for bmp also

Thanks

Read only

0 Likes
1,599

Hi,

Yes, it will work for BMP also.

Define the custom control as 'IMG_CON'.

Regards

Nishant

Read only

0 Likes
1,599

hi Nishant and all,

can any one point out the problem for me

PROCESS BEFORE OUTPUT.

MODULE STATUS_9999.

*

PROCESS AFTER INPUT.

MODULE USER_COMMAND_9999.

MODULE STATUS_9999 OUTPUT.

SET PF-STATUS '9999'.

  • SET TITLEBAR 'xxx'.

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://C:\sample.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.

CALL METHOD my_pic->set_display_mode

EXPORTING display_mode = my_pic->display_mode_fit_center.

ENDMODULE. " STATUS_9999 OUTPUT

Read only

0 Likes
1,599

Hi,

Can you tell me what's the name of the control that you have created in Screen layout?

Regards

Nishant

Read only

0 Likes
1,599

Hi Nishant,

ITS IMG_ICON.

CAN YOU SEND UR EMAIL ID.

THANKS

Read only

0 Likes
1,599

SORRY ITS IMG_CON JUST AS I USED IN MY PROGRAM

Read only

0 Likes
1,599

hi,

Brother did u add the follwing lines!!

CLASS cl_gui_custom_container DEFINITION LOAD.

CLASS cl_gui_container DEFINITION LOAD.

CLASS cl_gui_picture DEFINITION LOAD.

These are needed to load the definition of the classes

Hope this helps

regards

Nishant

Read only

0 Likes
1,599

hi Nishant,

i haven't declared before .

But i have declared now in my top include but i don't see anything.

Can you give ur email id so that i can send you screen shots.

Thanks for valuable advice and help.

Read only

0 Likes
1,599

Hi all,

any suggestions

Thanks

Read only

Former Member
0 Likes
1,599

Hi Venki,

The reason why you are not seeing the image even after giving the source code correctly may be because you may not have activated your screens.

Just go to the screen and check if it is activated or not.If not, activate it. Sometimes, I also encountered the same problem.

Another important thing while using class methods and function modules is that always you should uncomment the Exceptions part of the methods or function modules so that you can identify the type of error, if an error occurs.

You can also execute the program in the debugging mode to find out the value of SY-SUBRC after each step is executed.

Your code looks correct to me assuming that the container name is CONT.

Also you can do one more thing. You can try loading the picture from another folder like 'file://D\temp\pic.jpg' .

.JPG and .BMP files can be uploaded using this method.

You can also refer this link for more details.

<u>Close the thread once the problem is solved.</u>

Regards,

SP.