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: 

Insert picture in selection screen.

Former Member
0 Kudos

Hi,

Can some one suggest how to insert picture in selection screen?

Thanks

Deep

16 REPLIES 16

Former Member
0 Kudos

Look at this program <b>RSDEMO_CUSTOM_CONTROL</b> and also check the class <b>CL_GUI_PICTURE</b> and the method <b>load_picture_from_url</b>.

I am not sure if this works for selection screen, but you can give it a try.

Regards,

Subramanian V.

Message was edited by: Subramanian Venkateswaran

0 Kudos

Yes it can be done in selection screen.

at selection-screen output event create a docking container and create cl_gui_picture with parent docking container use method LOAD_PICTURE_FROM_URL to load the picture.

If this explanation is not clear do let me know, i will post code sample.

Regards

Raja

0 Kudos

Yes if u could please show the sample code, that would be very helpful.......

Regards,

Deepti

0 Kudos

Here is the sample code.


REPORT y_pic_show .

DATA:
docking TYPE REF TO cl_gui_docking_container,
picture_control_1 TYPE REF TO cl_gui_picture,
url(256) TYPE c .

PARAMETERS: p_dummy TYPE c  .

AT SELECTION-SCREEN OUTPUT.
  PERFORM show_pic.

START-OF-SELECTION.


*&---------------------------------------------------------------------*
*& Form show_pic
*&---------------------------------------------------------------------*
FORM show_pic.

  DATA: repid LIKE sy-repid.
  DATA: file_name LIKE sapb-sapfiles,
  file_type LIKE bdn_con-mimetype.

  repid = sy-repid.
  IF docking IS INITIAL .
    CREATE OBJECT docking
    EXPORTING
    repid = repid
    dynnr = sy-dynnr
    side = cl_gui_docking_container=>dock_at_right
    extension = '200'
    EXCEPTIONS
    cntl_error = 1
    cntl_system_error = 2
    create_error = 3
    lifetime_error = 4
    lifetime_dynpro_dynpro_link = 5.



    CREATE OBJECT picture_control_1 EXPORTING parent = docking.

    CHECK sy-subrc = 0.
    CALL METHOD picture_control_1->set_3d_border
      EXPORTING
        border = 0.

    CALL FUNCTION 'DP_PUBLISH_WWW_URL'
      EXPORTING
        objid    = 'HTMLCNTL_TESTHTM2_SAP_AG'
        lifetime = 'T'
      IMPORTING
        url      = url
      EXCEPTIONS
        OTHERS   = 1.

* Load the picture by using the url generated by the data provider.
    IF sy-subrc = 0.
      CALL METHOD picture_control_1->load_picture_from_url_async
        EXPORTING
          url = url.
    ENDIF.
  ENDIF .

ENDFORM.                    "show_pic

More on controls demo at transaction <b>DWDM</b>

Hope this helps.

Regards

Raja

0 Kudos

Thanks for this code Raja. It work fine.

Do you know if something similar can be implemented with cl_gui_custom_container & cl_gui_picture instead of cl_gui_docking_container?

Tried but couldn't manage to make it work:-(

Thanks,

Peter

0 Kudos

You cannot do that using cl_gui_custom_container in report selection screen, because cl_gui_custom_container requires a custom container on the screen defined.

There may some other way available to do the same in selection screen. i will check it out and post the results here.

Regards

Raja

0 Kudos

You could make your selection screen a subscreen. You then design a regular screen in the screen painter. You carve out an area on the screen for the subscreen area and the custom container.

0 Kudos

The code given is working fine to display the picture on the screen. It is displaying an existing picture form the repository . Can I know the way to upload custom photo so that I can use it to display it on the screen

0 Kudos

Use transaction SMW0 to load the picture and give it a name and replace <b>"HTMLCNTL_TESTHTM2_SAP_AG"</b> with your object name.

Raja

0 Kudos

Hi Durairaj Athavan Raja ,

can you please send a sample code how to display LOGO in the secondary list in the interactive report.

Thanks&Regards,

Praveen Kumar.A

0 Kudos

But like this...... the image is over lapping on to the next out-put

0 Kudos

But like this...... the image is over lapping on to the next out-put

Former Member
0 Kudos

I tried to create an object using transaction SMW0 but the program does not upload the picture. Can you please explain the whole procedure in more detail (Regarding creation of pnew picture ID)?

0 Kudos

Can you post it as a new thread as what you are asking is not part of the thread topic.

This would enable people to search the forum better and easy.

Regards

Raj

Former Member
0 Kudos

Can u guide me as to why it is giving me error in smw0 while importing picture for $tmp pacakge

The error is foreign objects not allowed

Former Member

Hi,

I have inserted a picture in my classical report. According to the position where you want can be adjusted. If you know how to upload Logo in SMW0 then upload and just copy paste the code that i have shown will display the image.

DATA: docking TYPE REF TO cl_gui_docking_container,
picture_control_1 TYPE REF TO cl_gui_picture,
url(256) TYPE c .

DATA: query_table LIKE w3query OCCURS 1 WITH HEADER LINE,
html_table LIKE w3html OCCURS 1,
return_code LIKE w3param-ret_code,
content_type LIKE w3param-cont_type,
content_length LIKE w3param-cont_len,
pic_data LIKE w3mime OCCURS 0,
pic_size TYPE i.
* END OF DO NOT CHANGE----------------------*
FORMAT HOTSPOT ON.

DATA : sum(4) , num1(4) , num2(4).
PARAMETERS: A(4) DEFAULT '4' .
PARAMETERS: B(4) DEFAULT '5' .
DATA: ANSWER TYPE I.
ANSWER = A + B.

WRITE:/ ANSWER.


AT SELECTION-SCREEN OUTPUT.
PERFORM show_pic.
* PERFORM show_pic1.



START-OF-SELECTION.
*&-------------------------------------------------------------------
*& Form show_pic
*&-------------------------------------------------------------------
FORM show_pic.
DATA: repid LIKE sy-repid.
repid = sy-repid.

CREATE OBJECT picture_control_1 EXPORTING parent = docking.
CHECK sy-subrc = 0.

CALL METHOD picture_control_1->set_3d_border
EXPORTING
border = 5.

CALL METHOD picture_control_1->set_display_mode
EXPORTING
display_mode = cl_gui_picture=>display_mode_stretch.

CALL METHOD picture_control_1->set_position
EXPORTING
height = 90
left = 40
top = 30
width = 190.
*CHANGE POSITION AND SIZE ABOVE*****************

IF url IS INITIAL.
REFRESH query_table.
query_table-name = '_OBJECT_ID'.

*CHANGE IMAGE NAME BELOW UPLOADED IN SWO0******************

query_table-value = 'YREDDY'. "name which u have given in SMW0
APPEND query_table.

query_table-value = 'YLOGO'.
APPEND query_table.


*FORMAT HOTSPOT ON.

CALL FUNCTION 'WWW_GET_MIME_OBJECT'
TABLES
query_string = query_table
html = html_table
mime = pic_data
CHANGING
return_code = return_code
content_type = content_type
content_length = content_length
EXCEPTIONS
object_not_found = 1
parameter_not_found = 2
OTHERS = 3.
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 FUNCTION 'DP_CREATE_URL'
EXPORTING
type = 'image'
subtype = cndp_sap_tab_unknown
size = pic_size
lifetime = cndp_lifetime_transaction
TABLES
data = pic_data
CHANGING
url = url
EXCEPTIONS
OTHERS = 1.
ENDIF.
CALL METHOD picture_control_1->load_picture_from_url
EXPORTING
url = url.

FORMAT HOTSPOT OFF.
ENDFORM.