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: 

Custom Container

Former Member
0 Kudos

Hi all

I am doing new image with customer container program.

but i have taken function module then

I want about what is code for put the image?

reply me soon,

thx,

s.suresh

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

in this example the picture has an URL placement:

data: picture TYPE REF TO cl_gui_picture,

g_pic_url TYPE saeuri.

CALL METHOD picture->set_display_mode

EXPORTING

display_mode = picture->display_mode_fit

EXCEPTIONS

error = 1

OTHERS = 2.

CALL METHOD picture->load_picture_from_url_async

EXPORTING

url = g_pic_url

EXCEPTIONS

error = 1.

This works for me 🐵

Regards Tom.

2 REPLIES 2

Former Member
0 Kudos

I paste here the example program to display IMAGE.

program name SAPMZATTMENU_C

& Module pool       SAPMZATTMENU                                      *
*&                                                                     *
*&---------------------------------------------------------------------*
*&                                                                     *
*&                                                                     *
*&---------------------------------------------------------------------*


INCLUDE MZATTMENU_CTOP.
Data

INCLUDE MZATTMENU_CO01.
Modules     *
INCLUDE MZATTMENU_CI01.
Modules     *
INCLUDE MZATTMENU_CF01.
Routines   *

TOP coding MZATTMENU_CTOP

*&---------------------------------------------------------------------*
*& Include MZATTMENUTOP                                      Module poo*
*&                                                                     *
*&---------------------------------------------------------------------*

PROGRAM  SAPMZATTMENU                                                .

data: logo_container type ref to cl_gui_custom_container,
      logo           type ref to cl_gui_picture.

data: sf_homepage(255)     type c.
data: url(255) type c.
constants: true(1)   type c value 'X',       " TRUE
           false(1)  type c value ' '.       " FALSE
constants: screen_on(1)  type c value '1',
           screen_off(1) type c value '0'.

define screen_display.
  loop at screen.
    check screen-name = &1.
    screen-input     = screen_off.
    modify screen.
  endloop.
end-of-definition.
*
define screen_invisible.
  loop at screen.
    check screen-name = &1.
    screen-invisible  = screen_on.
    screen-input      = screen_off.
    modify screen.
  endloop.
end-of-definition.

include : MZATTMENU_CO01

*&---------------------------------------------------------------------*
*&  Include           MZATTMENUO01                                     *
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*&      Module  STATUS_9000  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module STATUS_9000 output.
  SET PF-STATUS 'MAINSCR'.
*  SET TITLEBAR 'xxx'.
data: partner_flag like trpari-s_checked.
 sf_homepage = 'Tafe Chennai Home Page'.
call function 'TR_GET_PARTNER_PROJECTS'
     importing  we_partner_flag = partner_flag
     exceptions others          = 1.
  if sy-subrc ne 0 or partner_flag eq false.
    screen_invisible 'SF_HOMEPAGE'.
  endif.


endmodule.                 " STATUS_9000  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  zinit_picture_control  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module zinit_picture_control output.
data: query_table like w3query occurs 1 with header line,
      html_table like w3html occurs 1,
      return_code like  w3param-ret_code,
      content_type like  w3param-cont_type,
      content_length like  w3param-cont_len,
      pic_data like w3mime occurs 0,
      pic_size type i.

  if url is initial.

    if logo_container is initial.
      create object logo_container
             exporting  container_name = 'LOGO_CONTAINER'
             exceptions others         = 1.
      if sy-subrc ne 0.
        exit.
      endif.
    endif.

    if logo is initial.
      create object logo
             exporting  parent = logo_container
             exceptions others = 1.
      if sy-subrc ne 0.
        exit.
      endif.
    endif.

    refresh query_table.
    query_table-name  = '_OBJECT_ID'.                "#EC NOTEXT
             "#EC NOTEXT
    query_table-value = 'ENJOY'.        "#EC NOTEXT
*    query_table-value = 'ZTAFELOGO2'.   "#EC NOTEXT

    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.

    call method logo->load_picture_from_url
         exporting url     = url
         exceptions others = 1.

  endif.
endmodule.                 " zinit_picture_control  OUTPUT

include : MZATTMENU_CI01

*&---------------------------------------------------------------------*
*&  Include           MZATTMENUI01                                     *
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_9000  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module USER_COMMAND_9000 input.
data: l_fieldname type scrfname,
      l_fcode_old like sy-ucomm.

case sy-ucomm.
  when 'PICK'.
*    get cursor field l_fieldname.
*    if l_fieldname eq 'SF_HOMEPAGE'.
*      call function 'CALL_BROWSER'
*           exporting   url    = 'http://tafechannel.com'
*           exceptions others  = 1.
*    endif.

endcase.

endmodule.                 " USER_COMMAND_9000  INPUT

include MZATTMENU_CF01

No coding.

SCREEN 900 Logic

PROCESS BEFORE OUTPUT.
 MODULE STATUS_9000.
 module zinit_picture_control.

*
PROCESS AFTER INPUT.
MODULE USER_COMMAND_9000.

In the SCreen create a Custom Container named 'LOGO_CONTAINER'.

Try this out .

Regards,

Balakumar.G

Reward Points if helpful.

Former Member
0 Kudos

Hi,

in this example the picture has an URL placement:

data: picture TYPE REF TO cl_gui_picture,

g_pic_url TYPE saeuri.

CALL METHOD picture->set_display_mode

EXPORTING

display_mode = picture->display_mode_fit

EXCEPTIONS

error = 1

OTHERS = 2.

CALL METHOD picture->load_picture_from_url_async

EXPORTING

url = g_pic_url

EXCEPTIONS

error = 1.

This works for me 🐵

Regards Tom.