Quantcast
Channel: SCN : All Content - SAP NetWeaver Gateway Developer Center
Viewing all articles
Browse latest Browse all 750

MIME Image OData Post Exception

$
0
0

Hello Experts,

 

I am trying to save an Image in MIME Repository using Function module,code as given below. Passing Source file image as local file and Destination path as MIME path. And i am able to Save the image successfully using the Function Module. And defined an OData Post method using that function module. But when it comes to OData Post method execution using REST Client, it is throwing Dump as Exception Condition "Not Supported by GUI" raised. A raise statement in the program "CL_GUI_FRONTEND_SERVICES=>GUI_UPLOAD" raised the exception.

 

Termination occurred in  "File_Exist" Method.

*-check if valid GUI is available----------------------------------

   IF IS_VALID_HANDLE( ) NE 0 AND cl_gui_control=>www_active IS INITIAL.

     RAISE NOT_SUPPORTED_BY_GUI.

   ENDIF.


Function Module Code:


DATA: lr_mime_rep TYPE REF TO if_mr_api.

 

   DATA: lv_filename TYPE string.

   DATA: lv_path     TYPE string.

   DATA: lv_fullpath TYPE string.

   DATA: lv_content  TYPE xstring.

   DATA: lv_length   TYPE i.

   DATA: lv_rc TYPE sy-subrc.

 

   DATA: lt_file TYPE filetable.

   DATA: ls_file LIKE LINE OF lt_file.

 

   DATA: lt_data TYPE STANDARD TABLE OF x255.

 

ls_file-filename = im_data. "im_data is the local image file ".jpg"

append ls_file to lt_file.

 

READ TABLE lt_file INTO ls_file INDEX 1.

IF sy-subrc = 0.

   lv_filename = ls_file-filename.

ENDIF.

 

cl_gui_frontend_services=>gui_upload(

   EXPORTING

     filename                = lv_filename    " Name of file

     filetype                = 'BIN'

   IMPORTING

     filelength              lv_length   " File length

   CHANGING

     data_tab                = lt_data    " Transfer table for file contents

   EXCEPTIONS

     OTHERS                  = 19 ).

 

CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'

   EXPORTING

     input_length = lv_length

*    first_line   = 0

*    last_line    = 0

   IMPORTING

     buffer       = lv_content

   TABLES

     binary_tab   = lt_data

   EXCEPTIONS

     failed       = 1

     OTHERS       = 2.

 

   lr_mime_rep = cl_mime_repository_api=>if_mr_api~get_api( ).

 

   lr_mime_rep->put(

     EXPORTING

       i_url                     = p_path  "P_Path is the Mime Path

       i_content                 = lv_content

       i_dev_package             = '$TMP'

     EXCEPTIONS

       parameter_missing         = 1

       error_occured                 = 2

       cancelled                       = 3

       permission_failure           = 4

       data_inconsistency         = 5

       new_loio_already_exists  = 6

       is_folder                         = 7

       OTHERS                       = 8 ).


Importing Parameters:

im_data type string(local file for .jpg)

p_path type string(MIME Path)



Could you please suggest how to handle the exception occurred and Do we need to make any changes/configs in defining the Post method.


Appreciate your help.


Thanks.


Viewing all articles
Browse latest Browse all 750

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>