Display Picture in ABAP Program

Bagaimana menampilkan gambar pada program ABAP (SE38) dengan screen painter, seperti gambar di bawah ini :

1. Check what extensions are allowed in table “MIMITYPES” in Tcode SMW0 : Setting > Maintain MIME types.

2. Upload html & picture using TCode SMW0.

3. Create program Z dengan SE38. Create juga screen pada program tersebut dan tambahkan custom control pada screen.

4. Pada PBO, tambahkan coding berikut :

*&---------------------------------------------------------------------*
*&      Module  STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
* create screen dan buat custom control dengan nama 'html_banner'
  DATA: html_banner  TYPE REF TO cl_gui_html_viewer,
        my_container TYPE REF TO cl_gui_custom_container,
        prog_repid LIKE sy-repid.

  IF my_container IS INITIAL.
    CREATE OBJECT my_container
      EXPORTING
        container_name = 'HTML_BANNER'.
    CASE sy-subrc.
      WHEN 0.
      WHEN OTHERS.
        RAISE cntl_error.
    ENDCASE.
  ENDIF.

  IF html_banner IS INITIAL.
    prog_repid = sy-repid.

    CREATE OBJECT html_banner
      EXPORTING
        parent = my_container.
    IF sy-subrc NE 0.
      RAISE cntl_error.
    ENDIF.

    PERFORM f_load_mime USING 'ZLOGOXXX' 'LogoXXX.jpg'.
    PERFORM f_load_html USING 'ZBANNERXXX'.
  ENDIF.
ENDMODULE.                 " STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*&      Form  f_load_mime
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_MIMEID   text
*      -->P_MIMEURL  text
*----------------------------------------------------------------------*
FORM f_load_mime USING p_mimeid
                       p_mimeurl.

  CALL METHOD html_banner->load_mime_object
    EXPORTING
      object_id  = p_mimeid
      object_url = p_mimeurl
    EXCEPTIONS
      OTHERS     = 1.

ENDFORM.                    " f_load_mime
*&---------------------------------------------------------------------*
*&      Form  f_load_html
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_HTML     text
*----------------------------------------------------------------------*
FORM f_load_html USING p_html.

  DATA: doc_url(80).

  CALL METHOD html_banner->load_html_document
    EXPORTING
      document_id  = p_html
    IMPORTING
      assigned_url = doc_url
    EXCEPTIONS
      OTHERS       = 1.
  IF sy-subrc EQ 0.
    CALL METHOD html_banner->show_url
      EXPORTING
        url = doc_url.
  ENDIF.

ENDFORM.                    " f_load_html
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s