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: 

Add Image in ABAP Report

Former Member
0 Kudos
4,519

Hi All,

I want add image in ABAP Report.

Please let me know how it can be done?

Regards,

Jagdish More

1 ACCEPTED SOLUTION

Former Member
0 Kudos
1,278

Hi Jagdish,

You can do it only using SAP-SCRIPTS or SMARTFORMS.

There is the only way to add Image in your report.

Otherwise it is not possible.

Harish

12 REPLIES 12

Former Member
0 Kudos
1,279

Hi Jagdish,

You can do it only using SAP-SCRIPTS or SMARTFORMS.

There is the only way to add Image in your report.

Otherwise it is not possible.

Harish

Former Member
0 Kudos
1,278

Hi,

You can very well do that. There is a function Module REUSE_ALV_COMMENTARY_WRITE this will serve the logo or image to be displayed in the report. Call the FM and set the flag i_logo = 'X''. This will upload the image in the report.

Regards

Thiru

Former Member
0 Kudos
1,278

This message was moderated.

0 Kudos
1,278

Dear All,

Thanks for the replies.

I have already tried using the class 'CL_GUI_PICTURE'.

The issues I had face were:

1. Image is fixed at one position as per the parameters passed to method "set_position", though I scroll screen.

2. Image does not appear in print out.

Kindly let me know if there any other way out.

arpit_shah
Contributor
0 Kudos
1,278

Hi,

Pls check below code, may be it is help you.

MODULE show_pics OUTPUT.
  DATA: l_graphic_xstr TYPE xstring.
  DATA: l_graphic_conv TYPE i.
  DATA: l_graphic_offs TYPE i.

  CALL METHOD cl_gui_cfw=>flush.
  IF g_c_oper_rep IS INITIAL.
    CREATE OBJECT:
    g_c_oper_rep EXPORTING container_name = 'C_OPER_REP',
    g_oper_rep EXPORTING parent = g_c_oper_rep.


    CALL METHOD cl_ssf_xsf_utilities=>get_bds_graphic_as_bmp
      EXPORTING
        p_object       = 'graphics'
*        p_name         = 'COLORED_GRID4'
        p_name         = 'ZOPER'
        p_id           = 'BMAP'
        p_btype        = 'BCOL'
      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-msgv3.
    ENDIF.


    g_graphic_size = XSTRLEN( l_graphic_xstr ).
    l_graphic_conv = g_graphic_size.
    l_graphic_offs = 0.
    WHILE l_graphic_conv > 255.
      g_t_graphic_table-line = l_graphic_xstr+l_graphic_offs(255).
      APPEND g_t_graphic_table.
      l_graphic_offs = l_graphic_offs + 255.
      l_graphic_conv = l_graphic_conv - 255.
    ENDWHILE.

    g_t_graphic_table-line =
    l_graphic_xstr+l_graphic_offs(l_graphic_conv).
    APPEND g_t_graphic_table.

    CALL FUNCTION 'DP_CREATE_URL'
      EXPORTING
        type     = 'IMAGE'
        subtype  = 'X-UNKNOWN'
        size     = g_graphic_size
        lifetime = 'T'
      TABLES
        data     = g_t_graphic_table
      CHANGING
        url      = g_url.

    CALL METHOD g_oper_rep->load_picture_from_url
      EXPORTING
        url = g_url.

    CALL METHOD g_oper_rep->set_display_mode
      EXPORTING
        display_mode = g_oper_rep->display_mode_fit_center.
  ENDIF.

ENDMODULE.                 " SHOW_PICS  OUTPUT

Former Member
0 Kudos
1,278

I am facing the same issue

The issues I had face were:

1. Image is fixed at one position as per the parameters passed to method "set_position", though I scroll screen.

2. Image does not appear in print out

pls reply

former_member182040
Active Contributor
0 Kudos
1,278

check the standard report :- sap_picture_demo.

0 Kudos
1,278

Hi,

Thanks for the reply. We have already existing z-report available with us.

This report has been developed using the 'WRITE' statements. So we need to add small image at one fix position in the report generated screen '1000'.

We tried it using the cl_gui_picture class but eventuaaly it did not work due to following 2 reasons:

1. Image is fixed at one position (as per the parameters passed to method "set_position"), even though we scroll the screen.

2. Image does not appear in print out

Kindly suggest.

0 Kudos
1,278

Hi Jagdish,

to upload the image follow these steps.

1. Upload image in web repository.

Go to Transaction SMW0 to upload the image in SAP web Repository. elect second radiobutton u201DBinary data for WebRFC applicationsu201D and click on find.

2. Click on Execute.

3. Click on Create and give the obj.name and description and click on import.

once the image gets uploaded.in your program do the following

1. Create a Screen.Go to Layout and create Custom Control.I have named it as u2018CONTAINERu2019.

2. Declare container(Custom Control name),picture(child of Container) and url in Top of the program.

data container type ref to cl_gui_custom_container.

data picture type ref to cl_gui_picture.

data url(256).

3. Now create the object Container and Picture.

create object container

exporting container_name = 'CONTAINER'.//name of the custom control

create object picture

exporting parent = container

exceptions error = 1.

4. Now we have to load the picture from the database which we have uploaded. For this we need to declare the following:-

data query_table like w3query occurs 1 with header line.

data html_table like w3html occurs 1.

data return_code like w3param-ret_code.

data content_type like w3param-cont_type.

data content_length like w3param-cont_len.

data pic_data like w3mime occurs 0.

data pic_size type i.

5. Refresh the Query table and give the name of Query table as u2018_OBJECT_ID_u2019 and value as the name of logo/Image which u have uploaded.Append the value in the Query Table.

refresh query_table.

query_table-name = '_OBJECT_ID'.

query_table-value = 'ZLOGO.GIF'."name of logo

append query_table.

6. Now call the function WWW_GET_MIME_OBJECT to get the logo/image which u have uploaded and call the function DP_CREATE_URL to create the url where the image is present.

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.

pic_size = content_length.

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.

7. Finally we have to upload the image from the URL, this can be done by calling the method: picture->load_picture_from_url

call method picture->load_picture_from_url

exporting

url = url.

Now Save,Activate and Execute the Program , Image/Logo got successfully uploaded.

I have already done this program and uploaded the image...

this will surely help you

Thanks and regards,

Tanmaya

Former Member
0 Kudos
1,278

hi,

sneding you the whole code ..try it hope it will help you


PROGRAM  ZUPLOADIMAGE.


DATA CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER.
DATA PICTURE TYPE REF TO CL_GUI_PICTURE.
DATA URL(256).
*&---------------------------------------------------------------------*
*&  Include           ZUPLOADIMAGEO01
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*&      Module  STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module STATUS_0100 output.
*  SET PF-STATUS 'xxxxxxxx'.
*  SET TITLEBAR 'xxx'.
    CREATE OBJECT CONTAINER
       EXPORTING CONTAINER_NAME = 'CONTAINER'.
    CREATE OBJECT PICTURE
       EXPORTING  PARENT = CONTAINER
       EXCEPTIONS ERROR = 1.

 CLEAR url.
    PERFORM load_pic_from_db CHANGING url.

CALL METHOD picture->load_picture_from_url
EXPORTING
url = url.

endmodule.                 " STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*&  Include           ZUPLOADIMAGEF01
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*&      Form  LOAD_PIC_FROM_DB
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      <--P_URL  text
*----------------------------------------------------------------------*
form LOAD_PIC_FROM_DB  changing p_url.

  DATA query_table LIKE w3query OCCURS 1 WITH HEADER LINE.
  DATA html_table LIKE w3html OCCURS 1.
  DATA return_code LIKE  w3param-ret_code.
  DATA content_type LIKE  w3param-cont_type.
  DATA content_length LIKE  w3param-cont_len.
  DATA pic_data LIKE w3mime OCCURS 0.
  DATA pic_size TYPE i.
  REFRESH query_table.
  query_table-name = '_OBJECT_ID'.
  query_table-value = 'ZLOGO.GIF'."name of logo
  APPEND query_table.
  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.
    pic_size = content_length.
  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.
ENDFORM.                    " LOAD_PIC_FROM_DB

hope this will help you in solving your query....

Thanks and Regards,

Tanmaya

Former Member
0 Kudos
1,278

Hi,

You first have to import the logo from desktop using se78 transaction.

Then use the below function module in alv program,



CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = IT_LISTHEADER
I_LOGO = 'TEST_UPLOAD'
* I_END_OF_LIST_GRID =
* I_ALV_FORM =.

Hope it helps

Regards

Mansi

Former Member
0 Kudos
1,278

Hi,

What type of report you are using. IS it ALV report. If yes then you need to activate 'TOP_OF_PAGE' event of function module 'REUSE_ALV_GRID_DISPLAY'. After that you need create Form of TOP-OF-PAGE. In that You need use function module 'REUSE_ALV_COMENTARY_WRITE'.

Thanks,

Padmakar