cancel
Showing results for 
Search instead for 
Did you mean: 

How to retrieve the image from mssql back end to the ATE or to mobile device?

former_member197782
Participant
0 Kudos

Hi all,

     I have a field "image" in the object level with string property and same in transaction also. I added this field to the add transaction detail screen with  "Edit type" as "Image capture" as well as to the list screen to display image field.

     Here when I am adding image from ATE it is storing image path. In back end also I took the image field as nvarchar so it is also storing the path.

     When I take the image datatype as varbinary(max) in back end it is showing the following error.

          "Implicit conversion from data type varchar to varbinary(max) is not allowed. Use the CONVERT function to run this query."

How to write convert function for this. And how can i upload image from the mobile device and how to update it to the back end and also how to retrieve the image back to the mobile device.

Suggest me the solution.

Thanks,

Swaroopa.

Accepted Solutions (1)

Accepted Solutions (1)

bill_froelich
Product and Topic Expert
Product and Topic Expert
0 Kudos

There are also some links for tutorials on this at the following link.

Agentry - Tutorials - SAP Mobility - SCN Wikihttp://wiki.scn.sap.com/wiki/display/SAPMOB/Agentry+-+Tutorials

former_member197782
Participant
0 Kudos

Hi Bill,

   The links you sent are very useful.

   By following the below link I succeed up to uploading the image to the "UploadedFiles" folder which in agentry "ServerDev" folder.

Attach Documentation - Uploading files to the Agentry Server - SAP Mobility - SCN Wiki

But I struck to copy the image from "C:\Syclo-Nonsap\ServerDev\UploadedFiles\ to My path

i.e, D:\Doclinks\Attachments.

How to achieve this please provide the Dos ".bat file copy command" to do this.

Another problem in this is, I uploaded the image file name with <<transaction.ImageID>> property.

I wrote a rule to update that ImageID value automatically. When I add an image it is updating like 1.jpg and the image is copied to the "UploadedFiles" with 1.jpg.

For single xmit there is no problem. But when I reset the entire test client the image is again starting with 1.jpg as per my rule. In this case when I Xmit the ATE the previous image with 1.jpg is over written by the recent 1.jpg.

Here I am providing my rule also. Please have a look.

How to solve these problems. Anyone help me resolve these things.

bill_froelich
Product and Topic Expert
Product and Topic Expert
0 Kudos

Swaroopa,

I'm glad you got the image upload working to the Agentry server.  In answer to your next question about copying the file to the D:\Doclinks\Attachments location you can simply add a second step to the upload transaction that does the copy.

In my case I created a step called "CopyAttachmentToDownloadLocation".  It uses the File Backend connection type and in my case executes the following command on the Agentry Server renaming it as part of the process.

move /Y <<FileAttachments.UploadedAttachments>>\<<transaction.documentid>>_<<transaction.FileName>> <<FileAttachments.DownloadLocation>>\<<local.DocID>>_<<transaction.FileName>>

You will of course need to decide on a naming convention for your uploaded items.  Are the associated to something on the client (like a workorder for example) where you could use that as part of the filename?  or you could always use that combined with a date time stamp to make sure the names are unique.  There is no single right answer here it will depend on your application and what you are doing with the images uploaded.

In terms of the rule question, we frequently do something similar to generate local id values on the client which are then replaced with a unique id from the backend when the transaction is processed.  So in my case when I attach the first image it gets an imageid of LOCAL_1 and the next one will get LOCAL_2, etc.  When I upload to the server I also generate a record in the database with a unique id that will then replace the id of the object on the client moving forward.  This same id could also be used in the file name.

--Bill

former_member197782
Participant
0 Kudos

Hi Bill,

    Thanks for all your support. I successfully copied the images to my path which was defined by me.

I placed the step in transaction update steps.

In your move command you updated with globals. But here I updated with the hard coded path.

My move command is:


move  C:\Syclo-NonSAP\ServerDev\UploadedFiles\<<local.realID>><<AttachImageFormat.AgentryUploadImage>> D:\Doclinks\Attachments\

Now I need to download the image to the mobile device. I followed the following link to do the downloading.

Attach Documentation - Downloading files to the mobile client - SAP Mobility - SCN Wiki

But I didn't get the clear idea where it is being downloaded in mobile device path or the system path.

Can you explain more on this. Which path should I pass in application level.

Thanks,

Swaroopa.

Answers (2)

Answers (2)

bill_froelich
Product and Topic Expert
Product and Topic Expert
0 Kudos

Swaroopa,

When downloading files or images to the client you need to have an object with a property of type External Data.  This will be the property that will hold the reference to the downloaded file on the client device.  On the File Locations tab of the External Data property you can specify the default location on the various client types where the files will be stored.

Once you have this in place it is time to populate it.  Typically with attached documents there is a collection that contains the attachment details (including the external data property) that is populated during a fetch with the other details about the file.  Then we use a read step to Run Once per Collection Object and download the actual files using a File System Document Management step to the client.

Then once we have both the object reference and the actual file we can view them on the client.  The vewing process on the client will vary based on the type of client you are using.  For example, on iOS devices we can view most files simply by referencing the external data property in an HTML control.  On Android, Windows or WinCE we can usually only view a few types (graphics, text) in the HTML control and must have another application to view other files types (pdf, doc, xls, etc).

In my case I download the path of the file on the server along with the file name into my Attachment object on the client.  Then the File System Document Management step can simply execute the Type command to read the file down to the client mapping it into the External Data property (named Data in my example).

I hope this helps clarify it a bit more.

--Bill

bill_froelich
Product and Topic Expert
Product and Topic Expert
0 Kudos

Swaroopa,

Which direction are you trying to go?  From the backend to the client (per your summary) or from the client back to the server (the description).

Typically we upload files back to the server using an update step on the transaction of type File System Document Management step.  This step maps the captured data to a physical file on the Agentry Server.  Once the file is on the Agentry server subsequent update steps can move the file or do additional processing on it.

--Bill

former_member197782
Participant
0 Kudos

Hi Froelish,

    Thanks for the reply & sharing very useful documents they are really helpful.

Now in my application I want to do the both. Upload image from front end to back end as well as download from back end to front end.

When uploading my image from front end through file system it is storing the path of the image in back end and also in front end to.

In both front end and back end I took the image field as String datatype. Is there any restriction in case of datatypes. Please let me know.

Thanks,

Swaroopa.