Code template for redefinition of /IWBEP/IF_MGW_APPL_SRV_RUNTIME~CREATE_STREAM

πŸ“Ÿ create_attachment

Placeholder function – replace with the relevant business logic

πŸ“Ÿ check_msg_and_raise_exceptions

Take a look atΒ Generic Exception handling (BAPIRET2) in OData

  METHOD /iwbep/if_mgw_appl_srv_runtime~create_stream.
    DATA: lv_entity_type TYPE string.
    DATA: lo_message_container TYPE REF TO /iwbep/if_message_container.
    DATA: ls_attachment TYPE z_structure.
    DATA: lt_return TYPE bapiret2_t.
    DATA: lv_filename_esc TYPE string.
    DATA: lv_filename TYPE string.
    DATA: lv_parameter TYPE string.


*--- Basic requirements
    lv_entity_type = io_tech_request_context->get_entity_type_name( ).
    lo_message_container = mo_context->get_message_container( ).

    CASE lv_entity_type.

*--- When EntityType XYZ do the following
      WHEN zcl_..._mpc=>gc_xyz.


*-- read slug
        ##TODO: " replace the seperator '~' with the seperator you are using
        SPLIT iv_slug AT '~' INTO lv_filename_esc lv_parameter.
        lv_filename = cl_http_utility=>if_http_utility~unescape_url( lv_filename_esc ). "decode filename


*-- create attachment - execute business logic
        create_attachment(
          EXPORTING
            i_parameter    = lv_parameter
            i_file_name    = lv_filename
            i_xstring      = is_media_resource-value
            i_mime_type    = is_media_resource-mime_type
          IMPORTING
            e_attachment   = ls_attachment
            et_return      = lt_return
        ).

*-- check errors
        check_msg_and_raise_exceptions(
          EXPORTING
            it_messages         = lt_return
            i_message_container = lo_message_container
        ).

*-- copy data to ref
        copy_data_to_ref( EXPORTING is_data = ls_attachment
                          CHANGING  cr_data = er_entity ).


      WHEN OTHERS.
        super->/iwbep/if_mgw_appl_srv_runtime~create_stream(
          EXPORTING
            iv_entity_name          = iv_entity_name
            iv_entity_set_name      = iv_entity_set_name
            iv_source_name          = iv_source_name
            is_media_resource       = is_media_resource
            it_key_tab              = it_key_tab
            it_navigation_path      = it_navigation_path
            iv_slug                 = iv_slug
            io_tech_request_context = io_tech_request_context
          IMPORTING
            er_entity               = er_entity
        ).
    ENDCASE.
  ENDMETHOD.

Leave a Reply

Your email address will not be published. Required fields are marked *