Veralteten Baustein WWW_GET_MIME_OBJECT ersetzen
In einer alten Programmierung habe ich den folgenden Code verwendet, um ein Bild aus dem MIME-Repository (Transaktion SMW0) zu laden und anzuzeigen:
CLASS pic DEFINITION. PUBLIC SECTION. DATA mo_picture TYPE REF TO cl_gui_picture . METHODS display IMPORTING name TYPE clike container TYPE REF TO cl_gui_container disp_mode TYPE i DEFAULT cl_gui_picture=>display_mode_fit_center . PROTECTED SECTION. PRIVATE SECTION. ENDCLASS. CLASS pic IMPLEMENTATION. METHOD display. DATA query_table TYPE STANDARD TABLE OF w3query. DATA query_line TYPE w3query. DATA html_table TYPE STANDARD TABLE OF w3html . DATA html_line TYPE w3html . 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 STANDARD TABLE OF w3mime . DATA url TYPE c LENGTH 1000. query_line-name = '_OBJECT_ID'. query_line-value = name. APPEND query_line TO 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. CALL FUNCTION 'DP_CREATE_URL' EXPORTING type = 'image' subtype = cndp_sap_tab_unknown size = content_length lifetime = cndp_lifetime_transaction TABLES data = pic_data CHANGING url = url EXCEPTIONS OTHERS = 1. mo_picture = NEW #( container ). mo_picture->load_picture_from_url( url ). mo_picture->set_display_mode( disp_mode ). ENDMETHOD. ENDCLASS. PARAMETERS dummy. INITIALIZATION. DATA(docker) = NEW cl_gui_docking_container( ratio = 50 side = cl_gui_docking_container=>dock_at_bottom ). NEW pic( )->display( name = 'ENJOYSAP_LOGO' container = docker disp_mode = cl_gui_picture=>display_mode_fit_center ).
Leider hat sich der ATC-Check darüber beschwert, dass der Funktionsbaustein WWW_GET_MIME_OBJECT obsolet ist und nicht mehr verwendet werden soll.
Lösung
Der Funktionsbaustein WWW_GET_MIME_OBJECT muss ersetzt werden durch Baustein DP_PUBLISH_WWW_URL. Dadurch wird der Code auch deutlich schlanker:
METHOD display. DATA url TYPE cndp_url. DATA objid TYPE w3objid. objid = name. CALL FUNCTION 'DP_PUBLISH_WWW_URL' EXPORTING objid = objid lifetime = cndp_lifetime_transaction IMPORTING url = url EXCEPTIONS OTHERS = 1. IF sy-subrc = 0. mo_picture = NEW #( parent = container ). mo_picture->load_picture_from_url( url ). mo_picture->set_display_mode( disp_mode ). ENDIF. ENDMETHOD
Letzte Artikel von Enno Wulff (Alle anzeigen)
- Meine Eclipse-Plugins - 22. November 2024
- Interview mit Björn Schulz (Software-Heroes.com) - 3. September 2024
- Daten aus ALV ermitteln - 3. September 2024