cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple File Attachments upload via Odata Service Call in GOS

former_member214928
Participant
0 Kudos

Hi Experts,

We have a requirement where we need to attach multiple files with different file extensions via Odata Service Call in GOS (no Z-table).

I know that we need to redefine method CREATE_STREAM to upload files.

Has anyone implemented such kind of a service where multiple files attached on UI side are read in a single service call and the files are uploaded in GOS?

From U5 side we are using Upload Collection Entity.

SAPUI5 Explored

Accepted Solutions (0)

Answers (1)

Answers (1)

0 Kudos

Hi Rahul,

             For saving files in GOS ,we have SAP standard Class methods which need to be used. Is your question related to the backend filesave using GOS or the Gateway part how to.

Arka

former_member214928
Participant
0 Kudos

I know we have standard class methods to save files in GOS.

We will upload multiple files from UI side and those need to be stored in GOS, so that these can be read later.

0 Kudos

Hi Rahul,

             Assuming you are seeking information on the gateway part, you can check the following steps:

  • Redefine the "DEFINE" method in your MPC_EXT and put the below code there:

super->define( ).

     DATA:

       lo_entity   TYPE REF TO /iwbep/if_mgw_odata_entity_typ,

       lo_property TYPE REF TO /iwbep/if_mgw_odata_property.

     lo_entity = model->get_entity_type( iv_entity_name = <Your Entity Name> ).

     IF lo_entity IS BOUND.

       lo_property = lo_entity->get_property( iv_property_name = 'Mimetype' ).

       lo_property->set_as_content_type( ).

     ENDIF.

  • As you have mentioned redefine the CREATE_STREAM method in your DPC_EXT and put the following code

CASE iv_entity_name.

       WHEN <Your Entity>.

         ls_upload-mimetype = is_media_resource-mime_type.

         ls_upload-filename = iv_slug.

         ls_upload-value = is_media_resource-value.

        Call the GOS method here to save the attachment. LS_UPLOAD used here is a local structure with only the below fields.

FILENAME - CHAR200

VALUE       - XSTRINGVAL

MIMETYPE- CHAR100

LS_FILE used here is of type your entity.

         <your entity>set_get_entity(

           EXPORTING

             iv_entity_name     = iv_entity_name

             iv_entity_set_name = iv_entity_set_name

             iv_source_name     = iv_source_name

             it_key_tab         = it_key_tab

             it_navigation_path = it_navigation_path

           IMPORTING

             er_entity          = ls_file ).

         copy_data_to_ref( EXPORTING is_data = ls_upload

                           CHANGING  cr_data = ER_ENTITY ).

     ENDCASE.

From UI pass the attachements one by one by calling the entity set (method "POST") and passing the filename in the slug parameter of the http request.


Hope this helps.

Arka