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 logo in Module pool

Former Member
0 Kudos

hi,

i want ot upload my company logo in Module pool progrma kindly help me for that .

thanks in advance.

6 REPLIES 6

Former Member
0 Kudos

Hi

U need to use a container in order to upload an image on a screen, u can see the demo program like SAP_PICTURE_DEMO

Max

Former Member
0 Kudos

This message was moderated.

Former Member
0 Kudos

Hi,

1.upload image through txn code-smw0

2. create a conatiner in the screen

3.

DATA: CONTAINER_PIC TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
      PICTURE TYPE REF TO CL_GUI_PICTURE,
      URL(256) TYPE C .

 CREATE OBJECT CONTAINER_PIC
    EXPORTING
      CONTAINER_NAME              =                             " name of the container
			.

  CREATE OBJECT PICTURE
    EXPORTING
      PARENT = CONTAINER_PIC
      .

  PERFORM LOAD_PIC_FROM_DB CHANGING URL.

*load picture
  CALL METHOD PICTURE->LOAD_PICTURE_FROM_URL
    EXPORTING
      URL = URL.

  CALL METHOD CL_GUI_CFW=>FLUSH
    EXCEPTIONS
      CNTL_SYSTEM_ERROR = 1
      CNTL_ERROR        = 2.
  IF SY-SUBRC <> 0.
*error handling
  ENDIF.


FORM LOAD_PIC_FROM_DB  CHANGING P_URL.

*---local variables

  DATA QUERY_TABLE TYPE W3QUERY OCCURS 1 WITH HEADER LINE.
  DATA HTML_TABLE TYPE W3HTML OCCURS 1.
  DATA RETURN_CODE TYPE  W3PARAM-RET_CODE.
  DATA CONTENT_TYPE TYPE  W3PARAM-CONT_TYPE.
  DATA CONTENT_LENGTH TYPE  W3PARAM-CONT_LEN.
  DATA PIC_DATA TYPE W3MIME OCCURS 0.
  DATA PIC_SIZE TYPE I.

  REFRESH QUERY_TABLE.
  QUERY_TABLE-NAME = '_OBJECT_ID'.
  QUERY_TABLE-VALUE =                    .         "  name assignment
  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

regards

Gaurav

0 Kudos

hi,

this wil help you

{

}
1.	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.
  
4.	Image is Successfully got uploaded in Web Repository.

2.	Creating Module Pool Program
1.	Go to transaction SE80 or SE38 and create a module pool program.i have named it as u2018ZUploadImageu2019.
2.	Create a Screen.Go to Layout and create Custom Control.I have named it as u2018CONTAINERu2019.
 
3.	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).
4.	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.
5.	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.

6.	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.
7.	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.
8.	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.
{

}

Thanks

Tanmaya

Former Member
0 Kudos

hi Ankita,

INCLUDE ZUPLOADIMAGETOP                         .    " global Data

INCLUDE ZUPLOADIMAGEO01                         .  " PBO-Modules
INCLUDE ZUPLOADIMAGEF01                         .  " FORM-Routines
*&---------------------------------------------------------------------*
*& Include ZUPLOADIMAGETOP                                   Module Pool      ZUPLOADIMAGE
*&
*&---------------------------------------------------------------------*

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

Please check this full code.I have done this before.this will surely help you

Thanks

tanmaya

0 Kudos

Hi Tanmaya,

thanks for the rply i tryed same way which you have written but no image is coming please help me for that.