How To Master Media Handling with SAP OData Part 20


Code detail :- 

class ZCL_ZMEDIA_MPC_EXT definition

public

inheriting from ZCL_ZMEDIA_MPC

create public .


public section.

METHODS: define REDEFINITION.

protected section.

private section.

ENDCLASS.




CLASS ZCL_ZMEDIA_MPC_EXT IMPLEMENTATION.

METHOD DEFINE.

super->define( ).

* CATCH /iwbep/cx_mgw_med_exception.


model->get_entity_type( iv_entity_name = 'Media'

)->get_property( iv_property_name = 'Mimetype'

)->set_as_content_type( ).

* CATCH /iwbep/cx_mgw_med_exception..

* CATCH /iwbep/cx_mgw_med_exception..

* CATCH /iwbep/cx_mgw_med_exception.


ENDMETHOD.


ENDCLASS.



**************************************************************

CLASS zcl_zmedia_dpc_ext DEFINITION

PUBLIC

INHERITING FROM zcl_zmedia_dpc

CREATE PUBLIC .


PUBLIC SECTION.

METHODS : /iwbep/if_mgw_appl_srv_runtime~create_stream REDEFINITION.

METHODS : /iwbep/if_mgw_appl_srv_runtime~get_stream REDEFINITION.

METHODS : /iwbep/if_mgw_appl_srv_runtime~update_stream REDEFINITION.

METHODS : /iwbep/if_mgw_appl_srv_runtime~delete_stream REDEFINITION.

PROTECTED SECTION.

PRIVATE SECTION.

ENDCLASS.




CLASS zcl_zmedia_dpc_ext IMPLEMENTATION.

METHOD /iwbep/if_mgw_appl_srv_runtime~create_stream.

DATA(ls_media_ram) = VALUE zcl_zmedia_mpc=>ts_media(

client = sy-mandt

filename = iv_slug

mimetype = is_media_resource-mime_type

value = is_media_resource-value ).


INSERT zmedia_ram FROM @ls_media_ram.


IF sy-subrc IS INITIAL.

copy_data_to_ref(

EXPORTING

is_data = ls_media_ram

CHANGING

cr_data = er_entity

).

ENDIF.


ENDMETHOD.



METHOD /iwbep/if_mgw_appl_srv_runtime~get_stream.


DATA(it_keys) = io_tech_request_context->get_keys( ).


DATA(lv_key) = VALUE #( it_keys[ 1 ]-value OPTIONAL ).


IF lv_key IS NOT INITIAL.

SELECT SINGLE *

FROM zmedia_ram

INTO @DATA(ls_zmedia_ram)

WHERE filename = @lv_key.

IF sy-subrc IS INITIAL.

DATA(ls_s_media_resource) = VALUE ty_s_media_resource( mime_type = ls_zmedia_ram-mimetype

value = ls_zmedia_ram-value ).


copy_data_to_ref(

EXPORTING

is_data = ls_s_media_resource

CHANGING

cr_data = er_stream

).

ENDIF.



ENDIF.

ENDMETHOD.


METHOD /iwbep/if_mgw_appl_srv_runtime~update_stream.

DATA(it_keys) = io_tech_request_context->get_keys( ).


DATA(lv_key) = VALUE #( it_keys[ 1 ]-value OPTIONAL ).



DATA(ls_zmedia_ram) = VALUE zcl_zmedia_mpc=>ts_media( client = sy-mandt

filename = VALUE #( it_keys[ 1 ]-value OPTIONAL )

mimetype = is_media_resource-mime_type

value = is_media_resource-value ).


MODIFY zmedia_ram FROM ls_zmedia_ram.



ENDMETHOD.


METHOD /iwbep/if_mgw_appl_srv_runtime~delete_stream.


DATA(it_keys) = io_tech_request_context->get_keys( ).


DELETE FROM zmedia_ram WHERE filename = @( VALUE #( it_keys[ 1 ]-value OPTIONAL ) ).


ENDMETHOD.


ENDCLASS.

Comments

Post a Comment

Popular posts from this blog

AMDP ( ABAP Managed Database Procedure ) Part - 1

Backup all ADT Objects & Other queries RAP Part 10.1

SAP CDS Introduction Part 2 - ABAP on HANA Course