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

how to display a image in module pool program

0 Likes
8,795

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 =  '/tmp/Images/vehicle1.bmp'.

I used the above code.but the images are not getting displayed .then how i need to fetch the image which has been stored in sap server

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
4,553

Hi Madhusudan,

I have created a program according to your scenario.

Custom container is used to show the image.

Initially, go to  tcode SMW0 and choose Binary data for WebRFC applications and upload the image.

Here is the sample coding:

*--------------------------------------------------------------------*

* Initialization

*--------------------------------------------------------------------*

INITIALIZATION.

   CALL SCREEN 9000.

*&---------------------------------------------------------------------*

*&      Module  STATUS_9000  OUTPUT

*&---------------------------------------------------------------------*

*       text

*----------------------------------------------------------------------*

MODULE status_9000 OUTPUT.

   PERFORM show_pic.

ENDMODULE.                 " STATUS_9000  OUTPUT

*&-------------------------------------------------------------------

*& Form show_pic

*&-------------------------------------------------------------------

FORM show_pic.

   DATA: obj_custom TYPE REF TO cl_gui_custom_container,

         obj_picture TYPE REF TO cl_gui_picture,

         url TYPE char256,

         content_length TYPE w3contlen,

         lt_pic_data TYPE STANDARD TABLE OF w3mime.

   CREATE OBJECT obj_custom

     EXPORTING

       container_name              = 'CUSTOM'

     EXCEPTIONS

       cntl_error                  = 1

       cntl_system_error           = 2

       create_error                = 3

       lifetime_error              = 4

       lifetime_dynpro_dynpro_link = 5

       OTHERS                      = 6.

   IF sy-subrc <> 0.

     MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

   ENDIF.

   CREATE OBJECT obj_picture

     EXPORTING

       parent = obj_custom

     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.

   CHECK sy-subrc = 0.

   CALL METHOD obj_picture->set_3d_border

     EXPORTING

       border = 5

     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 obj_picture->set_display_mode

     EXPORTING

       display_mode = cl_gui_picture=>display_mode_stretch

     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.

   IF url IS INITIAL.

     CALL FUNCTION 'BC_TOOLS_FILE_GET_MIME_OBJECT'

       EXPORTING

         object_name    = 'ZSAP_LOGO'

       IMPORTING

         content_length = content_length

       TABLES

         mime           = lt_pic_data

       EXCEPTIONS

         invalid_table  = 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 FUNCTION 'DP_CREATE_URL'

       EXPORTING

         type                 = 'IMAGE'

         subtype              = cndp_sap_tab_unknown

         size                 = content_length

       TABLES

         data                 = lt_pic_data

       CHANGING

         url                  = url

       EXCEPTIONS

         dp_invalid_parameter = 1

         dp_error_put_table   = 2

         dp_error_general     = 3

         OTHERS               = 4.

     IF sy-subrc <> 0.

       MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

               WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

     ENDIF.

   ENDIF.

   CALL METHOD obj_picture->load_picture_from_url

     EXPORTING

       url    = url

     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.

ENDFORM.                    "show_pic

Thanks & Regards,

T. Prasanna Kumar


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 =  '/tmp/Images/vehicle1.bmp'.

I used the above code.but the images are not getting displayed .then how i need to fetch the image which has been stored in sap server

8 REPLIES 8
Read only

Former Member
0 Likes
4,553

1. Upload picture into SAP using the transaction SE78. Test picture


2: Create a custom screen section in the screen.

3. Code the following in the PBO.


MODULE STATUS_9000 OUTPUT.

  DATA: W_LINES TYPE I.
  TYPES PICT_LINE(256) TYPE C.
  DATA :
  CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
  EDITOR TYPE REF TO CL_GUI_TEXTEDIT,
  PICTURE TYPE REF TO CL_GUI_PICTURE,
  PICT_TAB TYPE TABLE OF PICT_LINE,
  URL(255) TYPE C.
  DATA: GRAPHIC_URL(255).

  DATA: BEGIN OF GRAPHIC_TABLE OCCURS 0,
          LINE(255) TYPE X,
        END OF GRAPHIC_TABLE.
  DATA: L_GRAPHIC_CONV TYPE I.
  DATA: L_GRAPHIC_OFFS TYPE I.
  DATA: GRAPHIC_SIZE TYPE I.
  DATA: L_GRAPHIC_XSTR TYPE XSTRING.
  .

  CALL METHOD CL_GUI_CFW=>FLUSH.

  CREATE OBJECT:
  CONTAINER EXPORTING CONTAINER_NAME = 'PICTURE_CONTAINER',
  PICTURE EXPORTING PARENT = CONTAINER.

  CALL METHOD CL_SSF_XSF_UTILITIES=>GET_BDS_GRAPHIC_AS_BMP
    EXPORTING
      P_OBJECT       = 'GRAPHICS'
      P_NAME         = 'WINNY'
      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-MSGV4.
  ENDIF.

  GRAPHIC_SIZE = XSTRLEN( L_GRAPHIC_XSTR ).
  L_GRAPHIC_CONV = GRAPHIC_SIZE.
  L_GRAPHIC_OFFS = 0.

  WHILE L_GRAPHIC_CONV > 255.
    GRAPHIC_TABLE-LINE = L_GRAPHIC_XSTR+L_GRAPHIC_OFFS(255).
    APPEND GRAPHIC_TABLE.
    L_GRAPHIC_OFFS = L_GRAPHIC_OFFS + 255.
    L_GRAPHIC_CONV = L_GRAPHIC_CONV - 255.
  ENDWHILE.
  GRAPHIC_TABLE-LINE = L_GRAPHIC_XSTR+L_GRAPHIC_OFFS(L_GRAPHIC_CONV).

  APPEND GRAPHIC_TABLE.

  CALL FUNCTION 'DP_CREATE_URL'
    EXPORTING
      TYPE     = 'IMAGE'
      SUBTYPE  = 'X-UNKNOWN'
      SIZE     = GRAPHIC_SIZE
      LIFETIME = 'T'
    TABLES
      DATA     = GRAPHIC_TABLE
    CHANGING
      URL      = URL.

  CALL METHOD PICTURE->LOAD_PICTURE_FROM_URL
    EXPORTING
      URL = URL.
  CALL METHOD PICTURE->SET_DISPLAY_MODE
    EXPORTING
      DISPLAY_MODE = PICTURE->DISPLAY_MODE_FIT_CENTER.

ENDMODULE.                 " STATUS_9000  OUTPUT

Check this doc

http://abap-explorer.blogspot.ae/2008/10/how-to-display-picture-in-screen.html

Read only

0 Likes
4,553

Thank u sooo much ...it worked.

BUT i have another doubt.

If the images are stored in server then how can i access it.

see 1 example

*** if the images are stored in my computer then

   CALL METHOD

     picture_control_1->load_picture_from_url

     EXPORTING

       url =  'file://C:\Documents and Settings\madhusajjan\Desktop\crm lcv image\vehi1.bmp'.

*** if the images are stored in GOOGLE image

   CALL METHOD

     picture_control_1->load_picture_from_url

     EXPORTING

       url =  'fhttp://google/googleimage/vehicle1.bmp'.

**if it is in local host ,i mean if it is sap server ,then how to acess it

???????

Message was edited by: Madhusudan sajjan

Read only

0 Likes
4,553

Check this link. Hope it helps.

http://scn.sap.com/thread/1598579

Read only

former_member213275
Contributor
Read only

Sijin_Chandran
Active Contributor
0 Likes
4,553

Hello Madhusudan ,

Apart from the solutions above  , Implementing the code mentioned in below thread for your MPP should also work ,

http://scn.sap.com/docs/DOC-43540

Implement your Logic in PBO and it should work .

Read only

Former Member
0 Likes
4,554

Hi Madhusudan,

I have created a program according to your scenario.

Custom container is used to show the image.

Initially, go to  tcode SMW0 and choose Binary data for WebRFC applications and upload the image.

Here is the sample coding:

*--------------------------------------------------------------------*

* Initialization

*--------------------------------------------------------------------*

INITIALIZATION.

   CALL SCREEN 9000.

*&---------------------------------------------------------------------*

*&      Module  STATUS_9000  OUTPUT

*&---------------------------------------------------------------------*

*       text

*----------------------------------------------------------------------*

MODULE status_9000 OUTPUT.

   PERFORM show_pic.

ENDMODULE.                 " STATUS_9000  OUTPUT

*&-------------------------------------------------------------------

*& Form show_pic

*&-------------------------------------------------------------------

FORM show_pic.

   DATA: obj_custom TYPE REF TO cl_gui_custom_container,

         obj_picture TYPE REF TO cl_gui_picture,

         url TYPE char256,

         content_length TYPE w3contlen,

         lt_pic_data TYPE STANDARD TABLE OF w3mime.

   CREATE OBJECT obj_custom

     EXPORTING

       container_name              = 'CUSTOM'

     EXCEPTIONS

       cntl_error                  = 1

       cntl_system_error           = 2

       create_error                = 3

       lifetime_error              = 4

       lifetime_dynpro_dynpro_link = 5

       OTHERS                      = 6.

   IF sy-subrc <> 0.

     MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

   ENDIF.

   CREATE OBJECT obj_picture

     EXPORTING

       parent = obj_custom

     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.

   CHECK sy-subrc = 0.

   CALL METHOD obj_picture->set_3d_border

     EXPORTING

       border = 5

     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 obj_picture->set_display_mode

     EXPORTING

       display_mode = cl_gui_picture=>display_mode_stretch

     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.

   IF url IS INITIAL.

     CALL FUNCTION 'BC_TOOLS_FILE_GET_MIME_OBJECT'

       EXPORTING

         object_name    = 'ZSAP_LOGO'

       IMPORTING

         content_length = content_length

       TABLES

         mime           = lt_pic_data

       EXCEPTIONS

         invalid_table  = 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 FUNCTION 'DP_CREATE_URL'

       EXPORTING

         type                 = 'IMAGE'

         subtype              = cndp_sap_tab_unknown

         size                 = content_length

       TABLES

         data                 = lt_pic_data

       CHANGING

         url                  = url

       EXCEPTIONS

         dp_invalid_parameter = 1

         dp_error_put_table   = 2

         dp_error_general     = 3

         OTHERS               = 4.

     IF sy-subrc <> 0.

       MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

               WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

     ENDIF.

   ENDIF.

   CALL METHOD obj_picture->load_picture_from_url

     EXPORTING

       url    = url

     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.

ENDFORM.                    "show_pic

Thanks & Regards,

T. Prasanna Kumar


Read only

former_member209120
Active Contributor
Read only

0 Likes
4,553

i want to get the image which has been stored in sap server...how to fetch?