Archiv der Kategorie: Geschüttelt und Gerührt

If you can dream it …

WD4A Message Area Configuration

 METHOD init_message_area .
 
 * API Window Controller
   DATAlr_api_window TYPE REF TO if_wd_window_controller.
 * Message area
   DATAlr_wd_message_area TYPE REF TO if_wd_message_area.
 * Get the API
   lr_api_window ?= wd_this->wd_get_api).
 * Get the Message Area
   lr_wd_message_area lr_api_window->get_message_area).
 * Configure the message are
   CALL METHOD lr_wd_message_area->set_display_attributes
     EXPORTING
       i_show_only_current abap_false "Show message protocol
       i_msg_lines_visible '-1'
       i_use_toggle_area   abap_true "Show old design
       i_for_all_instances abap_false.
 
 ENDMETHOD.

In Place Media Visualization for SAPUI5

Intro

This short instruction explains all the components which are used for displaying media data based on an oData service and an SAP UI5 application.

Step-by-Step

Service
  1. First you need an object, s.a. a image or a pdf document. Let’s call it Media Object.
  2. Then you need an oData service to deliver the data for the Media Object.
    1. Just create a plain oData service
    2. Create an entity type.
    3. Check the MEDIA  check box for the entity type (oData Project->Data Model->Entity Types, double click your enttiy type, the attributes are shown on the right hand side)
    4. Switch to the …DPC_EXT class (oData Project->Runtime Artifacts)
    5. Use context menu->Goto ABAP Workbench
    6. Redefine the /IWBEP/IF_MGW_APPL_SRV_RUNTIME~GET_STREAM method (see sample code Appendix)
  3. Once you want to call the media service you have to at the $value at the end of the query, e.g. <Service URL>/$value
SAP UI5

View:

<core:HTML id=“pdfContainer“ ></core:HTML>

Controller:

var oContainer = this.getView().byId(„pdfContainer“);
var oContent = „<iframe src='“+ <Service URL>/$value +“‚
+ „style=’width:600px; height:500px;‘ frameborder=’0′></iframe>“;

Transactions

Transaction Explanation
SEGW SAP Gateway Service Builder

Appendix

METHOD /iwbep/if_mgw_appl_srv_runtime~get_stream.
DATA:
 ld_mypdf TYPE xstring,
 ls_stream TYPE ty_s_media_resource,
 ls_header TYPE ihttpnvp.

* Create the media data
 * ld_mypdf = ...

* Set the MIME type and the value and create data ref
 ls_stream-mime_type = 'application/pdf'.
 ls_stream-value = ld_mypdf.
 copy_data_to_ref( 
   EXPORTING is_data = ls_stream
   CHANGING cr_data = er_stream ).

* In order to display the media data in place you have to set the 
* following
 ls_header-name = 'content-disposition'.
 ls_header-value = 'inline; filename=MyPDF.pdf'.
 /iwbep/if_mgw_conv_srv_runtime~set_header( ls_header ).
ENDMETHOD.