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

loading picture

Former Member
0 Likes
607

hai how can we load our own picture into a custom control .

i tried using CL_GUI_PICTURE.

method :LOAD_PICTURE_FROM_URL

for this i have to pass url.

how can i get url name for our own picture.

Edited by: sudheer b on Oct 30, 2008 7:22 AM

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
537

Hi,

See This link [loading picture|http://www.erpgenie.com/component/content/article/55-abap/425-picture-control]

Best Regards

swamy

4 REPLIES 4
Read only

Former Member
0 Likes
538

Hi,

See This link [loading picture|http://www.erpgenie.com/component/content/article/55-abap/425-picture-control]

Best Regards

swamy

Read only

0 Likes
537

thank u but i want picture.

Read only

0 Likes
537

Hi Sudheer,

We have to create a url.

If the File is in presentation server, upload it into an int table and create url.

If the File is in application server, read it into an int table and create url.

Check the below example for reference.

Screen flow logic

PROCESS BEFORE OUTPUT.
  MODULE pbo.

PROCESS AFTER INPUT.
  MODULE pai AT EXIT-COMMAND.

I have used the whole screen-100 as container so no custom container in screen

Program

DATA : go_pic             TYPE REF TO cl_gui_picture,
       gt_picbin          TYPE solix_tab,
       gt_filetable       TYPE filetable,
       gv_filename        TYPE string,
       gv_url             TYPE char255,
       gv_filesize        TYPE i,
       gv_return          TYPE i,
       gv_useraction      TYPE i.

CALL SCREEN 100.

*&---------------------------------------------------------------------*
MODULE pbo OUTPUT.
  SET PF-STATUS 'BASIC'.  " just a BACK button with application type 'E'.
  PERFORM upload_file.
  PERFORM create_url.
  CREATE OBJECT go_pic EXPORTING parent = cl_gui_container=>default_screen.
  go_pic->load_picture_from_url( EXPORTING url    = gv_url
                                 IMPORTING result = gv_return ).
ENDMODULE.                 " pbo  OUTPUT
*&---------------------------------------------------------------------*
MODULE pai INPUT.
  SET SCREEN 0. LEAVE SCREEN.
ENDMODULE.                 " pai  INPUT

*&--------------------------------------------------------------------*
FORM upload_file.
*File Open Dialog
  cl_gui_frontend_services=>file_open_dialog( CHANGING file_table  = gt_filetable
                                                       rc          = gv_return
                                                       user_action = gv_useraction ).
  CHECK gv_return     GT cl_gui_frontend_services=>action_ok AND
        gv_useraction EQ cl_gui_frontend_services=>action_ok.
  READ TABLE gt_filetable INTO gv_filename INDEX 1.
*File Upload
  cl_gui_frontend_services=>gui_upload( EXPORTING  filename   = gv_filename
                                                   filetype   = 'BIN'
                                        IMPORTING  filelength = gv_filesize
                                        CHANGING   data_tab   = gt_picbin
                                        EXCEPTIONS OTHERS     = 4 ).
  CHECK sy-subrc = 4.
  MESSAGE 'Exception occured' TYPE 'I'.
ENDFORM.                    "upload_file

*&--------------------------------------------------------------------*
FORM create_url.
  CALL FUNCTION 'DP_CREATE_URL'
    EXPORTING
      type    = 'image'
      subtype = 'X-UNKNOWN'
    TABLES
      data    = gt_picbin
    CHANGING
      url     = gv_url
    EXCEPTIONS
      OTHERS  = 4.
  CHECK sy-subrc = 4.
  MESSAGE 'Exception occured' TYPE 'I'.
ENDFORM.                    "create_url

also search PICTUREDEMO* in SE38 for std examples.

Cheers,

Jose.

Read only

Former Member
0 Likes
537

Specify the full path of the location where the picture is located along with the picture name and extension to the parameter URL of the method.

E.G:

For local system

C:\My folder\picture.jpg

For application server

/usr/sap/tmp/picture.jpg