Skip to Content
avatar image
Former Member

Uploading Mime image into BDS

Hi,

I am trying to use almost similar algorithim to store an image into BDS. But in my case the image is stored in MIME. The content of the image is TYPE xstring. This Xstring content is all I have to store the image into BDS.

I am having problem in converting the image to BDS BMP format using :

CALL FUNCTION 'SAPSCRIPT_CONVERT_BITMAP_BDS'
  EXPORTING
    color                    = 'X'
    format                   = 'BMP'
    resident                 = p_resident
    bitmap_bytecount         = l_bytecount
    compress_bitmap          = 'X'
  IMPORTING
    bds_bytecount            = l_bds_bytecount
  TABLES
    bitmap_file              = l_bitmap
    bitmap_file_bds          = l_bds_content.

I am not passing anything in the l_bds_bytecount. l_bitmap is defined as-

DATA: BEGIN OF l_bitmap OCCURS 0,
        l(64) TYPE x,
      END OF l_bitmap.

mr = cl_mime_repository_api=>if_mr_api~get_api( ).
mr->get(
  EXPORTING
    i_url                  = lv_path
  IMPORTING
    e_content              = lv_content ).

l_bitmap-l = lv_content.

Could anybody help me out how to get the converted BMP using this function?

Many Thanks,

Rajib Shome

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • Jul 02, 2009 at 05:21 PM

    Here is a program that shows how to upload a file in binary to the MIME.

    REPORT  zrich_0001.
    
    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.
    
    PARAMETERS: p_path TYPE string
                 DEFAULT 'SAP/PUBLIC/Test.jpg'.   "<<-- Mime path, save to path
    
    
    cl_gui_frontend_services=>file_open_dialog(
      CHANGING
        file_table              =  lt_file  " Table Holding Selected Files
        rc                      =  lv_rc  ). " Return Code, Number of Files or -1 If Error Occurred
    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
        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 ).

    Regards,

    Rich Heilman

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 16, 2009 at 08:33 PM

    Hello Rich, Thanks a lot for your reply.

    But I had already found that sample program and tried with that. it works well when I select a image file. but in this case I am have the image content as hex-string which I am passing to be uploaded.

    So my question is - How to pass the image-content received from cl_mime_repository_api=>if_mr_api~get_api->get() to the BDS upload function 'SAPSCRIPT_CONVERT_BITMAP_BDS' ?

    If anything solved the problem in case like this, kindly share with me.

    Thanks and Best regards, Rajib

    Add comment
    10|10000 characters needed characters exceeded