cancel
Showing results for 
Search instead for 
Did you mean: 

Upload the image

Former Member
0 Kudos

Hi Gurus,

My requirement was In Sales order screen in Item level we added one button if we click on that it should go directly to our own directory, so we have to create one directory path and also we need to upload images for particular sales order line item.

I tried with using class

  cl_gui_frontend_services=>directory_create  in that i getting Controller error Exception Please help on this issue.

Regards,

vishwanatha

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Vishwanatha,

  •      When OCA click call an event,say UPLOAD and use below code for uploading image into mime repository and also displaying

-----------------------------------------------------------------------------------------------------------

-----------------------------------------------------------------------------------------------------------

-----------------------------------------------------------------------------------------------------------

     DATA: lr_file TYPE REF TO cl_thtmlb_fileupload.

     DATA: lv_str TYPE xstring,

              lv_file_size TYPE sdok_fsize,

              lv_filepath TYPE string.

     DATA :mime_repository TYPE REF TO if_mr_api,

              content TYPE xstring,

              url TYPE string.

-----------------------------------------------------------------------------------------------------------

-----------------------------------------------------------------------------------------------------------

* Type cast server event to cl_htmlb_fileupload

          lr_file ?= htmlb_event_ex.

* Assign filepath and filesize to local variables

          lv_filepath = lr_file->file_name.

          lv_file_size = lr_file->file_length.

* Move content to file_content

          lv_str = lr_file->file_content.

 

          CLEAR url.

          CONCATENATE '/SAP/BC/BSP/SAP/MY_PICS/' lv_filepath INTO url.

          mime_repository = cl_mime_repository_api=>get_api( ).

    

     CALL METHOD mime_repository->put

         EXPORTING

             i_url = url

             i_content = lv_str

             i_check_authority = space

             i_dev_package = '$TMP'.

     IF sy-subrc = 0.

         gv_url = url.   

     ENDIF.

-----------------------------------------------------------------------------------------------------------

-----------------------------------------------------------------------------------------------------------

-----------------------------------------------------------------------------------------------------------

Regards

Rajarama U