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: 

how to upload picture on dialog screen

0 Kudos
370

hi All

can anny body tell me how to upload a picture on a dialog screen , my picture is residing on the presentation server(desktop), what all i need to do ?

2 REPLIES 2

Former Member
0 Kudos
122

HI,

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>.

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 DWDM

Hope this helps.

Regards

Sudheer

ashok_kumar24
Contributor
0 Kudos
122

Hi Ritesh,

Good Check these programs !!!!

RSDEMO_PICTURE_CONTROL

SAP_PICTURE_DEMO

DEMO_PICTURE_CONTROL

or check this for same requirement

data container_top TYPE REF TO cl_gui_container,

create the container

CREATE OBJECT picture

EXPORTING parent = container_top.

METHOD fill_picture.

TYPES ty_graphic_line(255) TYPE x.

DATA graphic_table TYPE TABLE OF ty_graphic_line.

DATA graphic_line TYPE ty_graphic_line.

DATA: l_graphic_xstr TYPE xstring,

l_graphic_conv TYPE i,

l_graphic_offs TYPE i,

graphic_url(255),

graphic_size TYPE i,

graphic_refresh(1).

CALL METHOD cl_ssf_xsf_utilities=>get_bds_graphic_as_bmp

EXPORTING

p_object = 'GRAPHICS'

p_name = 'Z200000AD901'

"p_name is any bmp available in SE78

p_id = 'BMAP'

p_btype = 'BCOL' "BMON if monochrome

RECEIVING

p_bmp = l_graphic_xstr

EXCEPTIONS

not_found = 1

internal_error = 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.

graphic_size = XSTRLEN( l_graphic_xstr ).

CHECK graphic_size > 0.

l_graphic_conv = graphic_size.

l_graphic_offs = 0.

WHILE l_graphic_conv > 255.

graphic_line = l_graphic_xstr+l_graphic_offs(255).

APPEND graphic_line TO graphic_table.

l_graphic_offs = l_graphic_offs + 255.

l_graphic_conv = l_graphic_conv - 255.

ENDWHILE.

graphic_line = l_graphic_xstr+l_graphic_offs(l_graphic_conv).

APPEND graphic_line TO graphic_table.

CALL FUNCTION 'DP_CREATE_URL'

EXPORTING

type = 'IMAGE'

subtype = 'GIF'

TABLES

data = graphic_table

CHANGING

url = graphic_url.

CALL METHOD picture->load_picture_from_url

EXPORTING

url = graphic_url.

CALL METHOD picture->set_display_mode

EXPORTING

display_mode = picture->display_mode_fit_center.

ENDMETHOD. "FILL_PICTURE

You can attach the picture using picture control.For a dialog screen,make sure that when you create the screen,you choose MODAL DIALOG BOX in SCREEN TYPE.

Now make a cusom container in the screen layout and name it as CONTAINER.Use the sample code below:

REPORT SAMPLE.

DATA: picture type ref to cl_gui_picture,

cont type ref to cl_gui_custom_container.

DATA:

OK_CODE TYPE SY-UCOMM,

p_url type cndp_url.

START-OF-SELECTION.

call screen 100.

&----


*& Module STATUS_0100 OUTPUT

&----


  • text

----


MODULE STATUS_0100 OUTPUT.

SET PF-STATUS 'GUI'.

  • SET TITLEBAR 'xxx'.

if cont is initial.

CREATE OBJECT CONT

EXPORTING

CONTAINER_NAME = 'CONTAINER'.

CREATE OBJECT PICTURE

EXPORTING

  • LIFETIME =

  • SHELLSTYLE =

PARENT = cont

  • 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.

CALL METHOD PICTURE->SET_3D_BORDER

EXPORTING

BORDER = 1.

CALL FUNCTION 'DP_PUBLISH_WWW_URL'

EXPORTING

OBJID = 'HTMLCNTL_TESTHTM2_SAP_AG'

LIFETIME = cndp_lifetime_transaction

IMPORTING

URL = p_url

.

IF SY-SUBRC = 0.

CALL METHOD PICTURE->LOAD_PICTURE_FROM_URL_ASYNC

EXPORTING

URL = p_url.

ENDIF.

endif.

ENDMODULE. " STATUS_0100 OUTPUT

&----


*& Module USER_COMMAND_0100 INPUT

&----


  • text

----


MODULE USER_COMMAND_0100 INPUT.

CASE OK_CODE.

WHEN 'BACK'.

LEAVE PROGRAM.

CALL METHOD CL_GUI_CFW=>FLUSH.

endcase.

endmodule.

Also check demo program:RSDEMO_PICTURE_CONTROL

TO GET PICTURES:

Refer this link

1... create a logo using paint shop and save it as tifffile then using RSTXLDMC (is a program name) used to upload logo

2.....create a logo using paint shop and save it as bmpfile then using SE78 you can do this.

http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCCIIMAGE/BCCIIMAGE.pdf

http://www.sap-img.com/human/linking-employee-photos-using-sap-archive-link.htm

Transaction OAOR,

- OAOR (Business Document Navigator)

Give Class Name - PICTURES Class Type - OT..... then Execute

It will show you the list, then select ENJOYSAP_LOGO.

On that list, you will find one control with a "create" tab.

Click std. doc types.

Select SCREEN and double-click.

It will push FILE selection screen.

Select your company logo (.gif) and press OK.

It will ask for a description- for instance: "company logo".

It will let you know your doc has been stored successfully.

You can find your logo under ENJOYSAP_LOGO->Screen->company logo.

Just run your ALV program, you should find your company logo in place of the EnjoySAP logo.

Good Luck and thanks

AK