Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 8902

Re: Saving image using mobile into sap R/3

$
0
0

Hi Nilesh ,

  I had a scenario to attach image to pr05 transaction from mobile, so that when click view attachment button in pr05 i can see the image . My code is based on that .

 

it is the function module with import parameter base64 string and filename ,last three letters of the file name proceeding the . is the extension

 

 

in your case you need to create custom object type instead of  BUS2089 .

Do research regarding that ..


-->Local Workare declaration.
   DATA : ls_fol_id   TYPE soodk,
          ls_obj_id   TYPE soodk,
          ls_obj_data TYPE sood1,
          ls_content  TYPE soli,
          ls_folmem_k TYPE sofmk,
          ls_note     TYPE borident,
          ls_object   TYPE borident.

**--> Local internal table declaration.
   DATA : lt_content   TYPE STANDARD TABLE OF soli,
          lt_url_tab   TYPE STANDARD TABLE OF so_url,
          lt_objhead   TYPE STANDARD TABLE OF soli.

**--> Local variable declaration.
   DATA : lv_filename            TYPE string,
          lv_file_name_with_path TYPE chkfile,
          lv_stripped_name       TYPE string,
          lv_name                TYPE char30,
          lv_url_tab_size        TYPE sytabix,
          lv_ep_note             TYPE borident-objkey.


   ls_object-objtype = 'BUS2089'.
   ls_object-objkey  = '001095510000020022'.
   ls_obj_data-objdes = I_FILE_NAME.
   ls_obj_data-file_ext = I_FILE_EXT.


   CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
     EXPORTING
       buffer     = I_FILE
     TABLES
       binary_tab = lt_content.

   CALL FUNCTION 'SO_CONVERT_CONTENTS_BIN'
     EXPORTING
       it_contents_bin = lt_content[]
     IMPORTING
       et_contents_bin = lt_content[].

**--> Getting folder ID to save data
   CALL FUNCTION 'SO_FOLDER_ROOT_ID_GET'
     EXPORTING
       region                = 'B'
     IMPORTING
       folder_id             = ls_fol_id
     EXCEPTIONS
       communication_failure = 1
       owner_not_exist       = 2
       system_failure        = 3
       x_error               = 4
       OTHERS                = 5.
   IF sy-subrc = 0.

     ls_obj_data-objsns = 'O'.
     ls_obj_data-objla = sy-langu.
     ls_obj_data-objlen = LINES( lt_content ) * 255.

     CLEAR ls_content.
     CONCATENATE '&SO_FILENAME=' I_FILE_NAME '.' I_FILE_EXT INTO ls_content.
     APPEND ls_content TO lt_objhead.

**-->To Create an Object and Move to a Folder
     CALL FUNCTION 'SO_OBJECT_INSERT'
       EXPORTING
         folder_id                  = ls_fol_id
         object_hd_change           = ls_obj_data
         object_type                = 'EXT'
       IMPORTING
         object_id                  = ls_obj_id
       TABLES
         objcont                    = lt_content
         objhead                    = lt_objhead
       EXCEPTIONS
         active_user_not_exist      = 1
         communication_failure      = 2
         component_not_available    = 3
         dl_name_exist              = 4
         folder_not_exist           = 5
         folder_no_authorization    = 6
         object_type_not_exist      = 7
         operation_no_authorization = 8
         owner_not_exist            = 9
         parameter_error            = 10
         substitute_not_active      = 11
         substitute_not_defined     = 12
         system_failure             = 13
         x_error                    = 14
         OTHERS                     = 15.

     IF sy-subrc = 0 AND ls_object-objkey IS NOT INITIAL.
*            COMMIT WORK AND WAIT.
       ls_folmem_k-foltp = ls_fol_id-objtp.
       ls_folmem_k-folyr = ls_fol_id-objyr.
       ls_folmem_k-folno = ls_fol_id-objno.
       ls_folmem_k-doctp = ls_obj_id-objtp.
       ls_folmem_k-docyr = ls_obj_id-objyr.
       ls_folmem_k-docno = ls_obj_id-objno.
       lv_ep_note = ls_folmem_k.
       ls_note-objtype = 'MESSAGE'.
       ls_note-objkey = lv_ep_note.

**-->Link the object ID to trip No.
       CALL FUNCTION 'BINARY_RELATION_CREATE_COMMIT'
         EXPORTING
           obj_rolea      = ls_object
           obj_roleb      = ls_note
           relationtype   = 'ATTA'
         EXCEPTIONS
           no_model       = 1
           internal_error = 2
           unknown        = 3
           OTHERS         = 4.
       IF sy-subrc = 0.
*            COMMIT WORK AND WAIT.
       ENDIF.
     ENDIF.   " SO_OBJECT_INSERT
   ENDIF.       " SO_FOLDER_ROOT_ID_GET



ENDFUNCTION.


Viewing all articles
Browse latest Browse all 8902

Trending Articles



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