Screen display

效果

 

 源代码

program sap_picture_demo.

set screen 200.

TYPE-POOLS cndp.

************************************************************************
* CLASS    c_event_receiver
* DEFINITION
************************************************************************
class c_event_receiver definition.
* The class is used to test the events raised by the cl_gui_picture
* class
  public section.
    methods event_handler_picture_dblclick
            for event picture_dblclick of cl_gui_picture
            importing mouse_pos_x mouse_pos_y sender.
    methods event_handler_context_menu
            for event context_menu of cl_gui_picture
            importing sender.
    methods event_handler_context_menu_sel
            for event context_menu_selected of cl_gui_picture
            importing fcode sender.
  endclass.


************************************************************************
* DATA
************************************************************************
  data function like sy-ucomm.         " OK-Code field in screen 200
  data url  type cndp_url.                " URL-field in screen 200
  data url2 type cndp_url.               " URL-field in screen 200
  data picture_control_1 type ref to cl_gui_picture.
  data picture_control_2 type ref to cl_gui_picture.
  data container_1 type ref to cl_gui_custom_container.
  data container_2 type ref to cl_gui_custom_container.
  data event_receiver  type ref to c_event_receiver.
  data event_tab type cntl_simple_events.
  data event_tab_line type cntl_simple_event.
  data return type i.

************************************************************************
* PBO
* before_output
************************************************************************
module before_output output.
  set pf-status 'MAIN0001'.
  IF PICTURE_CONTROL_1 IS INITIAL.

* Create controls
    create object container_1
      exporting container_name = 'PICTURE_CONTROL_1'.
    create object container_2
      exporting container_name = 'PICTURE_CONTROL_2'.

    CREATE OBJECT PICTURE_CONTROL_1 exporting parent = container_1.
    CREATE OBJECT PICTURE_CONTROL_2 exporting parent = container_2.

* Register the events
    EVENT_TAB_LINE-EVENTID = CL_GUI_PICTURE=>EVENTID_PICTURE_DBLCLICK.
    append EVENT_TAB_LINE to EVENT_TAB.
    EVENT_TAB_LINE-EVENTID = CL_GUI_PICTURE=>EVENTID_CONTEXT_MENU.
    append EVENT_TAB_LINE to EVENT_TAB.
 EVENT_TAB_LINE-EVENTID = CL_GUI_PICTURE=>EVENTID_CONTEXT_MENU_SELECTED.
    append EVENT_TAB_LINE to EVENT_TAB.

    CALL METHOD PICTURE_CONTROL_1->SET_REGISTERED_EVENTS
      exporting
        EVENTS = event_tab.

    CALL METHOD PICTURE_CONTROL_2->SET_REGISTERED_EVENTS
      exporting
        EVENTS = event_tab.

* Create the event_receiver object and set the handlers for the events
* of the picture controls
    create object event_receiver.
    set handler event_receiver->event_handler_picture_dblclick
                FOR PICTURE_CONTROL_1.
    set handler event_receiver->event_handler_context_menu
                FOR PICTURE_CONTROL_1.
    set handler event_receiver->event_handler_context_menu_sel
                FOR PICTURE_CONTROL_1.
    set handler event_receiver->event_handler_picture_dblclick
                FOR PICTURE_CONTROL_2.
    set handler event_receiver->event_handler_context_menu
                FOR PICTURE_CONTROL_2.
    set handler event_receiver->event_handler_context_menu_sel
                FOR PICTURE_CONTROL_2.

* Set the display mode to 'normal' (0)
    CALL METHOD PICTURE_CONTROL_1->SET_DISPLAY_MODE
         EXPORTING DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_NORMAL.
    CALL METHOD PICTURE_CONTROL_2->SET_DISPLAY_MODE
         EXPORTING DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_NORMAL.

* Set 3D Border
    CALL METHOD PICTURE_CONTROL_1->SET_3D_BORDER
       exporting border = 1.
    CALL METHOD PICTURE_CONTROL_2->SET_3D_BORDER
       exporting border = 1.


* new async implementation since 4.6C
CALL FUNCTION 'DP_PUBLISH_WWW_URL'
  EXPORTING
    OBJID                       = 'HTMLCNTL_TESTHTM2_SAP_AG'
    LIFETIME                    = cndp_lifetime_transaction
  IMPORTING
    URL                         = url
  EXCEPTIONS
    OTHERS                      = 1.

* Load the picture by using the url generated by the data provider.
    if sy-subrc = 0.
      CALL METHOD PICTURE_CONTROL_1->LOAD_PICTURE_FROM_URL_ASYNC
         exporting url = url.
    endif.

CALL FUNCTION 'DP_PUBLISH_WWW_URL'
  EXPORTING
    OBJID                       = 'DEMOWORD97SAPLOGO'
    LIFETIME                    = cndp_lifetime_transaction
  IMPORTING
    URL                         = url2
  EXCEPTIONS
    OTHERS                      = 1.

* load image
    if sy-subrc = 0.
      CALL METHOD PICTURE_CONTROL_2->LOAD_PICTURE_FROM_URL_async
         exporting url = url2.
    endif.

  endif.
endmodule.


************************************************************************
* PAI
* after_input
************************************************************************
module after_input input.
  case function.
* At the end of the program destroy the control
    when 'BACK'.
      CALL METHOD container_1->FREE.
      CALL METHOD container_2->FREE.
      leave to screen 0.

* Change the display mode
    when 'NORMAL'.
      CALL METHOD PICTURE_CONTROL_1->SET_DISPLAY_MODE
           EXPORTING DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_NORMAL.
      CALL METHOD PICTURE_CONTROL_2->SET_DISPLAY_MODE
           EXPORTING DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_NORMAL.
    when 'STRETCH'.
      CALL METHOD PICTURE_CONTROL_1->SET_DISPLAY_MODE
         EXPORTING DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_STRETCH.
      CALL METHOD PICTURE_CONTROL_2->SET_DISPLAY_MODE
         EXPORTING DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_STRETCH.
    when 'FIT'.
      CALL METHOD PICTURE_CONTROL_1->SET_DISPLAY_MODE
           EXPORTING DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_FIT.
      CALL METHOD PICTURE_CONTROL_2->SET_DISPLAY_MODE
           EXPORTING DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_FIT.
    when 'NORMAL_CTR'.
      CALL METHOD PICTURE_CONTROL_1->SET_DISPLAY_MODE
    EXPORTING DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_NORMAL_CENTER.
      CALL METHOD PICTURE_CONTROL_2->SET_DISPLAY_MODE
    EXPORTING DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_NORMAL_CENTER.
    when 'FIT_CTR'.
      CALL METHOD PICTURE_CONTROL_1->SET_DISPLAY_MODE
      EXPORTING DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_FIT_CENTER.
      CALL METHOD PICTURE_CONTROL_2->SET_DISPLAY_MODE
      EXPORTING DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_FIT_CENTER.

* Clear the picture
    when 'CLEAR'.
      CALL METHOD PICTURE_CONTROL_1->CLEAR_PICTURE.

* Load a new picture
    when space.
      CALL METHOD PICTURE_CONTROL_1->LOAD_PICTURE_FROM_URL
           exporting url = url
           importing result = return.
      call method cl_gui_cfw=>flush.
      if return = 0.
        url = text-000.
      endif.

  endcase.

  clear function.
endmodule.


************************************************************************
* CLASS   c_event_receiver
* IMPLEMENTATION
************************************************************************
CLASS C_event_receiver implementation.

************************************************************************
* CLASS   c_event_receiver
* METHOD  event_handler_picture_dblclick
************************************************************************
  METHOD EVENT_HANDLER_PICTURE_DBLCLICK.
*        for event picture_dblclick of c_picture_control
*        importing mouse_pos_x mouse_pos_y.
    DATA pos_x(5) type c.
    DATA pos_y(5) type c.
    pos_x = mouse_pos_x.
    pos_y = mouse_pos_y.

    IF SENDER = PICTURE_CONTROL_1.
      MESSAGE I000(0K) WITH
        'DoubleClick' 'Upper Picture' POS_X POS_Y. "#EC NOTEXT
    else.
      MESSAGE I000(0K) WITH
        'DoubleClick' 'Lower Picture' POS_X POS_Y. "#EC NOTEXT
    endif.
  endmethod.

************************************************************************
* CLASS   c_event_receiver
* METHOD  event_handler_context_menu
************************************************************************
  METHOD EVENT_HANDLER_CONTEXT_MENU.
    data menu type ref to cl_ctmenu.
    create object menu.
    call method menu->ADD_FUNCTION exporting
      fcode = text-001
      TEXT = TEXT-001.
    call method menu->ADD_FUNCTION exporting
      FCODE = TEXT-002
      TEXT = TEXT-002.
    call method menu->ADD_FUNCTION exporting
      FCODE = TEXT-003
      TEXT = TEXT-003.
    call method menu->ADD_FUNCTION exporting
      FCODE = TEXT-004
      TEXT = TEXT-004.
    call method menu->ADD_FUNCTION exporting
      FCODE = TEXT-005
      TEXT = TEXT-005.

    CALL METHOD SENDER->DISPLAY_CONTEXT_MENU
      EXPORTING CONTEXT_MENU = MENU.
  endmethod.

************************************************************************
* CLASS   c_event_receiver
* METHOD  event_handler_context_menu_sel
************************************************************************
  METHOD EVENT_HANDLER_CONTEXT_MENU_sel.
    DATA DISPLAY_MODE TYPE I.
    IF FCODE = TEXT-001.
      DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_NORMAL.
    ENDIF.
    IF FCODE = TEXT-002.
      DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_STRETCH.
    ENDIF.
    IF FCODE = TEXT-003.
      DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_FIT.
    ENDIF.
    IF FCODE = TEXT-004.
      DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_NORMAL_CENTER.
    ENDIF.
    IF FCODE = TEXT-005.
      DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_FIT_CENTER.
    ENDIF.
    CALL METHOD SENDER->SET_DISPLAY_MODE
         EXPORTING DISPLAY_MODE = DISPLAY_MODE.

  endmethod.

endclass.

屏幕

 

 

program sap_picture_demo_icon.

set screen 200.

TYPE-POOLS cndp.

************************************************************************
* CLASS    c_event_receiver
* DEFINITION
************************************************************************
class c_event_receiver definition.
* The class is used to test the events raised by the cl_gui_picture
* class
  public section.
  methods event_handler_control_click
          for event control_click of cl_gui_picture
          importing mouse_pos_x mouse_pos_y.
  methods event_handler_control_dblclick
          for event control_dblclick of cl_gui_picture
          importing mouse_pos_x mouse_pos_y.
endclass.


************************************************************************
* DATA
************************************************************************
data function like sy-ucomm.           " OK-Code field in screen 200
data event1(255) type c.
data picture_control_1 type ref to cl_gui_picture.
data picture_control_2 type ref to cl_gui_picture.
data container_1 type ref to cl_gui_custom_container.
data container_2 type ref to cl_gui_custom_container.
data event_receiver  type ref to c_event_receiver.
data event_tab type cntl_simple_events.
data event type cntl_simple_event.


************************************************************************
* PBO
* before_output
************************************************************************
module before_output output.
  set pf-status 'MAIN0001'.
  IF PICTURE_CONTROL_1 IS INITIAL.

* Create controls
    create object container_1
      exporting container_name = 'PICTURE_CONTROL_1'.
    create object container_2
      exporting container_name = 'PICTURE_CONTROL_2'.

    CREATE OBJECT PICTURE_CONTROL_1 exporting parent = container_1.
    CREATE OBJECT PICTURE_CONTROL_2 exporting parent = container_2.

* Register the events
    EVENT-eventid = CL_GUI_PICTURE=>EVENTID_CONTROL_DBLCLICK.
    append event to EVENT_TAB.
    CALL METHOD PICTURE_CONTROL_1->SET_REGISTERED_EVENTS
      exporting
        EVENTS = event_tab.
    clear event_tab.
    EVENT-EVENTID = CL_GUI_PICTURE=>EVENTID_CONTROL_CLICK.
    append event to EVENT_TAB.
    CALL METHOD PICTURE_CONTROL_2->SET_REGISTERED_EVENTS
      exporting
        EVENTS = event_tab.

* Create the event_receiver object and set the handlers for the events
* of the picture controls
    create object event_receiver.
    set handler event_receiver->event_handler_control_dblclick
                FOR PICTURE_CONTROL_1.
    set handler event_receiver->event_handler_control_dblclick
                FOR PICTURE_CONTROL_2.
    set handler event_receiver->event_handler_control_click
                FOR PICTURE_CONTROL_1.
    set handler event_receiver->event_handler_control_click
                FOR PICTURE_CONTROL_2.

    CALL METHOD PICTURE_CONTROL_1->SET_DISPLAY_MODE
      EXPORTING DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_FIT_CENTER.
    CALL METHOD PICTURE_CONTROL_2->SET_DISPLAY_MODE
      EXPORTING DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_FIT_CENTER.

    CALL METHOD PICTURE_CONTROL_1->LOAD_PICTURE_FROM_SAP_ICONS
       exporting icon = '@01@'.
    CALL METHOD PICTURE_CONTROL_2->LOAD_PICTURE_FROM_SAP_ICONS
       exporting icon = '@02@'.

  endif.
endmodule.


************************************************************************
* PAI
* after_input
************************************************************************
module after_input input.
  case function.
* At the end of the program destroy the control
    when 'BACK'.
      CALL METHOD PICTURE_CONTROL_1->FREE.
      CALL METHOD PICTURE_CONTROL_2->FREE.
      CALL METHOD container_1->FREE.
      CALL METHOD container_2->FREE.
      leave to screen 0.

* Change the display mode
    when 'NORMAL'.
      CALL METHOD PICTURE_CONTROL_1->SET_DISPLAY_MODE
           EXPORTING DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_NORMAL.
      CALL METHOD PICTURE_CONTROL_2->SET_DISPLAY_MODE
           EXPORTING DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_NORMAL.
    when 'STRETCH'.
      CALL METHOD PICTURE_CONTROL_1->SET_DISPLAY_MODE
         EXPORTING DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_STRETCH.
      CALL METHOD PICTURE_CONTROL_2->SET_DISPLAY_MODE
         EXPORTING DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_STRETCH.
    when 'FIT'.
      CALL METHOD PICTURE_CONTROL_1->SET_DISPLAY_MODE
           EXPORTING DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_FIT.
      CALL METHOD PICTURE_CONTROL_2->SET_DISPLAY_MODE
           EXPORTING DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_FIT.
    when 'NORMAL_CTR'.
      CALL METHOD PICTURE_CONTROL_1->SET_DISPLAY_MODE
    EXPORTING DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_NORMAL_CENTER.
      CALL METHOD PICTURE_CONTROL_2->SET_DISPLAY_MODE
    EXPORTING DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_NORMAL_CENTER.
    when 'FIT_CTR'.
      CALL METHOD PICTURE_CONTROL_1->SET_DISPLAY_MODE
      EXPORTING DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_FIT_CENTER.
      CALL METHOD PICTURE_CONTROL_2->SET_DISPLAY_MODE
      EXPORTING DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_FIT_CENTER.

* Clear the picture
    when 'CLEAR'.
      CALL METHOD PICTURE_CONTROL_1->CLEAR_PICTURE.

* Load a new picture
    when space.
      CALL METHOD PICTURE_CONTROL_1->LOAD_PICTURE_FROM_SAP_ICONS
           exporting icon = event1.

  endcase.

  clear function.
endmodule.


************************************************************************
* CLASS   c_event_receiver
* IMPLEMENTATION
************************************************************************
CLASS C_event_receiver implementation.


************************************************************************
* CLASS   c_event_receiver
* METHOD  event_handler_control_click
************************************************************************
  method event_handler_control_click.
*        for event control_click of c_picture_control
*        importing mouse_pos_x mouse_pos_y.
    DATA pos_x(5) type c.
    DATA pos_y(5) type c.
    pos_x = mouse_pos_x.
    pos_y = mouse_pos_y.

    MESSAGE I000(0K) WITH
      'Click' 'Lower Picture' POS_X POS_Y. "#EC NOTEXT
  endmethod.

************************************************************************
* CLASS   c_event_receiver
* METHOD  event_handler_control_dblclick
************************************************************************
  method event_handler_control_dblclick.
*        for event control_dblclick of c_picture_control
*        importing mouse_pos_x mouse_pos_y.
    DATA pos_x(5) type c.
    DATA pos_y(5) type c.
    pos_x = mouse_pos_x.
    pos_y = mouse_pos_y.

    MESSAGE I000(0K) WITH
      'DoubleClick' 'Upper Picture' POS_X POS_Y. "#EC NOTEXT
  endmethod.

endclass.
*&---------------------------------------------------------------------*
*& Report  RSDEMO_PICTURE_CONTROL                                      *
*&                                                                     *
*&---------------------------------------------------------------------*
*&                                                                     *
*&                                                                     *
*&---------------------------------------------------------------------*

REPORT  rsdemo_picture_control        .
include <icon>.
DATA container TYPE REF TO cl_gui_custom_container.
DATA picture TYPE REF TO cl_gui_picture.
DATA init.
DATA  ok_code TYPE sy-ucomm.
DATA save_ok TYPE sy-ucomm.
TYPE-POOLS cndp.

##CLASS_FINAL
CLASS lcl_event_receiver DEFINITION.

  PUBLIC SECTION.
    METHODS contextmenurequest
            FOR EVENT context_menu OF cl_gui_picture.
    METHODS contextmenuselected
            FOR EVENT context_menu_selected OF cl_gui_picture
                IMPORTING fcode.
  ENDCLASS.
  DATA event_receiver TYPE REF TO lcl_event_receiver.
  DATA events TYPE cntl_simple_events.
  DATA wa_events TYPE  cntl_simple_event.

  SET SCREEN 100.

  CLASS lcl_event_receiver IMPLEMENTATION.
    METHOD contextmenurequest.
      DATA menu TYPE REF TO cl_ctmenu.
      CREATE OBJECT menu.
      CALL METHOD menu->load_gui_status
                  EXPORTING  program    = 'RSDEMO_PICTURE_CONTROL'
                             status     = 'CONTEXT'
                             menu       = menu
                  EXCEPTIONS read_error = 1.
##NEEDED
      IF sy-subrc ne 0.
* Fehlerbehandlung
      ENDIF.
      CALL METHOD picture->display_context_menu
            EXPORTING context_menu = menu
            EXCEPTIONS error = 1.
##NEEDED
      IF sy-subrc ne 0.
* Fehlerbehandlung
      ENDIF.
* <weiterer Aufbau des Kontext Menüs>
    ENDMETHOD.
    METHOD contextmenuselected.

      MESSAGE i300(eu) WITH fcode.  "#EC NOTEXT

    ENDMETHOD.
  ENDCLASS.



*&---------------------------------------------------------------------*
*&      Module  STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
  SET PF-STATUS 'STATUS'.
*  SET TITLEBAR 'xxx'.
  IF init is initial.
    CREATE OBJECT container
       EXPORTING container_name = 'CUSTOM_CONTAINER'.
    CREATE OBJECT picture
       EXPORTING  parent = container
       EXCEPTIONS error = 1.
##NEEDED
    IF sy-subrc ne 0.
* Fehlerbehandlung
    ENDIF.

    wa_events-eventid = picture->eventid_context_menu.
    wa_events-appl_event = ' '.
    APPEND wa_events TO events.
    wa_events-eventid = picture->eventid_context_menu_selected.
    wa_events-appl_event = ' '.
    APPEND wa_events TO events.
    CALL METHOD picture->set_registered_events
          EXPORTING  events                    = events
          EXCEPTIONS cntl_error                = 1
                     cntl_system_error         = 2
                     illegal_event_combination = 3.
##NEEDED
    IF sy-subrc ne 0.
* Fehlerbehandlung
    ENDIF.

    CREATE OBJECT event_receiver.
    SET HANDLER event_receiver->contextmenurequest FOR picture.
    SET HANDLER event_receiver->contextmenuselected FOR picture.
    init = 'X'.
  ENDIF.
ENDMODULE.                             " STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
  save_ok = ok_code.
  CLEAR ok_code.
  CASE save_ok.
    WHEN 'LOAD_PICTURE'.
* Request an URL from the data provider by exporting the pic_data.
##DECL_MODUL
    DATA url(255).
    CLEAR url.
    PERFORM load_pic_from_db CHANGING url.

* load picture
    CALL METHOD picture->load_picture_from_url
        EXPORTING url = url.
##NEEDED
      IF sy-subrc ne 0.
* Fehlerbehandlung
      ENDIF.
    WHEN 'DELETE'.
      CALL METHOD picture->clear_picture
           EXCEPTIONS error = 1.
##NEEDED
      IF sy-subrc ne 0.
* Fehlerbehandlung
      ENDIF.
    WHEN 'STRETCH'.
      CALL METHOD picture->set_display_mode
           EXPORTING display_mode = picture->display_mode_stretch
           EXCEPTIONS error = 1.
##NEEDED
      IF sy-subrc ne 0.
* Fehlerbehandlung
      ENDIF.
    WHEN 'NORMAL'.
      CALL METHOD picture->set_display_mode
           EXPORTING display_mode = picture->display_mode_normal
           EXCEPTIONS error = 1.
##NEEDED
      IF sy-subrc ne 0.
* Fehlerbehandlung
      ENDIF.
    WHEN 'LOAD_ICON'.
      CALL METHOD picture->load_picture_from_sap_icons
            EXPORTING icon = '@00@'
            EXCEPTIONS error = 1.
##NEEDED
      IF sy-subrc ne 0.
* Fehlerbehandlung
      ENDIF.

  ENDCASE.
ENDMODULE.                             " USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
*&      Module  EXIT  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE exit INPUT.
  CALL METHOD picture->free.
  CALL METHOD container->free.
  LEAVE PROGRAM.
ENDMODULE.                             " EXIT  INPUT
*&---------------------------------------------------------------------*
*&      Form  LOAD_PIC_FROM_DB
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
##PERF_NO_TYPE
FORM load_pic_from_db CHANGING 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 = 'ENJOYSAP_LOGO'.
  APPEND query_table.

##FM_OLDED
  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
##NO_TEXT
            type     = 'image'
            subtype  = cndp_sap_tab_unknown
            size     = pic_size
            lifetime = cndp_lifetime_transaction
       TABLES
            data     = pic_data
       CHANGING
            url      = url
##FM_SUBRC_OK
       EXCEPTIONS
            OTHERS   = 1.


ENDFORM.                               " LOAD_PIC_FROM_DB

 

posted on 2021-04-02 09:59  姬如千泷  阅读(225)  评论(0编辑  收藏  举报