cancel
Showing results for 
Search instead for 
Did you mean: 

How to upload file to mime without selecting any Transport request

Former Member
0 Kudos
375

Hi experts,

My Function Module is like billow.. It is asking Transport request for every file....


FUNCTION ZBAPI_FM_UPLOAD_IMAGES_TO_MIME.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     VALUE(PATH) TYPE  STRING DEFAULT 'SAP/PUBLIC/VIJAY/'
*"  EXPORTING
*"     VALUE(RETURN) TYPE  BAPIRET2
*"---------------------------------------
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 subrc type sy-subrc VALUE 0.

DATA: lt_data TYPE STANDARD TABLE OF x255.

DATA:  l_fname TYPE string.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
  EXPORTING
    window_title            =  'Select Multiple Files to Upload'
    default_extension       = ' '
*    default_filename        =
*    file_filter             =   'Photos (*.jpg) | *.jpg | *.png | *.bmp '
*    with_encoding           =
*    initial_directory       =
    multiselection          = 'X'
  CHANGING
    file_table              = lt_file
    rc                      = lv_rc
*    user_action             =
*    file_encoding           =
  EXCEPTIONS
    file_open_dialog_failed = 1
    cntl_error              = 2
    error_no_gui            = 3
    not_supported_by_gui    = 4
    others                  = 5
        .




  LOOP AT lt_file INTO ls_file.
    CLEAR: lv_filename,l_fname.
    lv_filename = ls_file-filename.
    CALL FUNCTION '/SAPDMC/LSM_PATH_FILE_SPLIT'
      EXPORTING
        pathfile       = lv_filename
     IMPORTING
*     PATHNAME       =
       filename       = l_fname
              .
    CONCATENATE path l_fname INTO l_fname RESPECTING BLANKS.

    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 ).
    if sy-subrc = 0.

    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                     = l_fname
        i_content                 = lv_content
      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 ).

    commit work.
ELSE.
subrc = 1.
ENDIF.
ENDLOOP.
endfunction.

Please reply with any answers have..

thanks and regards

Vijay

Accepted Solutions (0)

Answers (1)

Answers (1)

0 Kudos

Hi Vijay,

Provide names in the customer namespace starting with Z*.

Regards

Leon

Former Member
0 Kudos

Sorry Lion,

I am not getting, what you are saying.

Where i have to provide names as z* ?

Please explain it..

regards

VIJAY

0 Kudos

Hi Vijay,

Is it not possible for you to upload to the mime repository through transaction se80?

Regards

Leon

Former Member
0 Kudos

Thanks Leon,

My problem is solved, I was doing mistake now I have added one line of code and now it is working perfectly.


lr_mime_rep->put(
      EXPORTING
        i_url                     = l_fname
        i_content                 = lv_content
        i_dev_package             = '$TMP' "Here i add package name as temp
      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 ).

Thanks & regards

VIJAY

Edited by: VIJAY4vision on Feb 1, 2012 8:24 AM

0 Kudos

Correct. You should save it in the customer/local namespace which is the temp package.

Regards

Leon