cancel
Showing results for 
Search instead for 
Did you mean: 

Upload an Image from Mobile to SAP

former_member184247
Participant
0 Kudos

Hello Experts,

I want upload an image  using mobile camera or gallery to SAP system.

Regards

Sumeet S

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member184247
Participant
0 Kudos

Hello Midhun

I have created one custom RFC for testing purpose is as shown below. For IMPORTING value I am passing "base64" type as STRING.

Source Code is:

FUNCTION Z_IMG_UPLOAD.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     VALUE(IM_DATA) TYPE  STRING OPTIONAL
*"  EXPORTING
*"     VALUE(EX_MSG) TYPE  CHAR1
*"----------------------------------------------------------------------

DATA: lr_mime_rep TYPE REF TO if_mr_api.

DATA: lv_content  TYPE xstring.
DATA: lv_length   TYPE i.
DATA: lv_rc TYPE sy-subrc.

DATA: lt_data TYPE STANDARD TABLE OF x255,
p_path
TYPE string VALUE 'SAP/public/test1.jpg'.   "<<-- Mime path, save to path


lr_mime_rep
= cl_mime_repository_api=>if_mr_api~get_api( ).

CALL FUNCTION 'SSFC_BASE64_DECODE'
EXPORTING
b64data
= im_data
IMPORTING
bindata
= lv_content
EXCEPTIONS
OTHERS  = 8.

lr_mime_rep
->put(
EXPORTING
i_url                    
= p_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 ).

if sy-subrc = 0.
ex_msg
= '0'.
endif.

ENDFUNCTION.

Then I have created MBO as shown below

MBO

Then created one Personalization KEY.

Assigned Load Argument with

and generated code for android.

After this What to do???

Am I on right path???

Regards

Sumeet S

midhun_vp
Active Contributor
0 Kudos

Sending image from the native app will be an operation of the MBO.

In that case you need keep the load parameter of the RFC as the Xstring. And there is no need to create a personalization key to map it to the load parameter. Instead you need to call the operation as given below and pass the binary data as argument.

MBO_test.sendImage("binary_string");

Where sendImage is the operation in the MBO.

- Midhun VP

Former Member
0 Kudos

Hi Midhun,

Even I'm getting the same problem, I'm new to SAP Mobility just 2 days I'm not able to find the operation(sendimage) inside MBO. In which MBO can I find it?

It would be really helpful if you could share some screen shots or document.

Regards,

Pratheek

midhun_vp
Active Contributor
0 Kudos

You need to create an operation inside the MBO. Once you import the generated code to the project you can use that operation as I mentioned.

SendImage is a name I given as an example.

What you are trying to do. Can you please explain.

- Midhun VP

Former Member
0 Kudos

Hi Midhun,

Thanks a Lot for your time.

What I'am trying to do is,

I have an Android app using PhoneGap now When I take a Picture with the camera, I want that Picture to be send to SAP. For this I have created an RFC and Used an MBO for the same. Now I dont know how to send my photo from this html file in Phonegap to the SAP system, can you please guide me.

Regards,

Pratheek

midhun_vp
Active Contributor
0 Kudos

Are you gonna send the image from a native app of HWC?

- Midhun VP

former_member184247
Participant
0 Kudos

Yes.

midhun_vp
Active Contributor
0 Kudos

You need to have an RFC with input parameter to accept the binary data ( image ). The data type of that input parameter will be Xstring.

In the MBO the datatype of that field will be BigBinary. The image has to be send as a binary file from the device.

I believe that you can send the image from device through the use of PhoneGap.

- Midhun VP