cancel
Showing results for 
Search instead for 
Did you mean: 

How to delete and update records in an OFFLINE hybrid web container application?

Former Member
0 Kudos

Hello everyone

           I have developed a simple application using SMP 2.3 that performs the basic CRUD operations. I am able to perform all the four operations successfully in the on line mode. I am also able to read and create new records in the offline mode. But I am not able to delete and update records in the offline mode. Can anyone help me out? I have tried multiple times but no success. I tried after enabling the on device caching option also but no success.

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Osama

We managed to create a fully offline capable HWC app....but we wrote all the functionality from scratch using javascript.

We create custom databases locally where data can be created, updated and deleted (using JayData to allow any device database).

We created an offline submission queue object that allows users to submit transactions when the device is offline and will send the submission if the device comes back online or is restarted.

We use a single generic MBO that is just a proxy for submitting AJAX requests, we then handle the back end functionality ourselves, if the ajax request fails it is placed into the offline queue for processing later (timer based).

With regards your problems, the only way I can see you achieving this is if you override functions in the custom.js file and then update and delete using your own code as in the thread mentioned by Jitendra above.

Thanks

Andrew

Former Member
0 Kudos

Hello Andrew,

           I am just new to all this so can you please guide me in which approach to follow to create a fully functional offline HWC app using javascript?

     According to my knowledge one way to work with javascript is to export the app and then to the changes and secondly by making changes in the app using the pre provided JS editor in SMP. If you can briefly tell me the steps to follow it would be really great. many thanks

Regards

Osama Misbah

Former Member
0 Kudos

http://scn.sap.com/thread/3446274

http://scn.sap.com/thread/3405801

Hi Osama

We took an approach where we built all the offline functionality ourselves using javascript.

We create the databases in our javascript and create, read, update and delete data using our own javascript framework as well as the offline submission process. It was a lengthy process.

We then created a single MBO in a package that acts as a proxy for submission of data, all ajax calls in our apps run through this single MBO.

The MBO is generic and it is hooked into an RFC function in SAP which then acts as a proxy to BSP pages that create, update, delete etc.

We create the workflow API javascript files from the above package and use this in all our HTML5 apps.

We then take our html, javascript, mimes, SMP javascript API files, WorkflowClient.xml, etc and use the SMP packaging tool to create a zip file (the app).

We then deploy the app.

With regards your problems, you have taken a different approach.

Have you checked out the thread suggested by Jitendra above?

Thanks Andrew

Former Member
0 Kudos

Hello Andrew,

      I am trying to follow the approach explained by Naresh in the URLs provided by you. But I am confused about what to write in the case where  we are client-initiated and are offline in Custom.js. Do we need to change the type of the menu item from online request or something else? I have attached the image of my delete screen also. What I actually want to do is that when we press the delete menuitem in offline mode, the respective record should be deleted as the device goes online.

It would be really great if you can guide me with this. you can see the type of delete menu item in the above picture is set to "online Request". is it the right way or it should be something else?

Thanks

Osama Misbah

Former Member
0 Kudos

http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.infocenter.dc01218.0210/doc/html/vhu12...

Hi Osama

Check out the above, it explains how to do it, the type should be selected as "Submit Workflow". You are setting the "Key" to online_request also.

Creating a Submit Workflow Menu Item

A Submit Workflow menu item, allows the user to update, delete, or create data even when not connected to the network. When the user connects, data is automatically sent and received.

The submit menu item of the first screen in a mobile workflow form must be associated with a mobile business object (MBO) operation or an object query.

If the user has multiple screens open at the time of the submit execution, and one of the underlying screens fails validation, the user is prompted with the configured warning message and the submit process stops.

1.From the palette on the Screen Design page, click Menuitem, then click the Menu box.

2.From the Properties view, select the menu item for which to configure the properties.

3.In the Properties view, configure the properties for the submit menu item:

Name Enter a valid name for the menu item. Note: To avoid wrapping of menu item names on Apple iOS devices, keep the name length to 10 or fewer characters.

Key Select the key with which to bind the submit menu item.

Default Select to display the menu item prominently on the screen.

Type Select Submit Workflow.

4.If the menu item is an operation associated with a mobile business object, you can configure these properties in Details:

Mobile business object The MBO with which the menu item is associated. Click Search to locate the MBO.

Invoke parent update No changes are made to the parent MBO, but the appropriate operations (create, update, delete) are performed on its descendants.

Invoke operation Invoke the selected MBO operation with which the menu item is associated. Select the operation from the list, which is populated when you select the MBO.

Invoke object query Invoke the object query from the menu item.

Submit confirmation message (Optional) Enter text to show in a message box on the screen when the submit operation finishes successfully.

Resubmit confirmation message (Optional) Enter text to show in a message box on the screen when the submit was not successful and thus must be resubmitted.

5.Select File > Save.

Former Member
0 Kudos

Hello Andrew,

     I have tried what you are telling me but still not successful. I am a little confused about what do you mean by :

         

"The submit menu item of the first screen in a mobile workflow form must be associated with a mobile business object (MBO) operation or an object query.

If the user has multiple screens open at the time of the submit execution, and one of the underlying screens fails validation, the user is prompted with the configured warning message and the submit process stops."

     I have created the MBO on a web service and my server receives the delete request but gives illegal Argument exception. I am sharing a few screen shots of my application.

This is my first screen, it has an online request type.

This is my whole scenario and the next screen shot shows the settings for the delete menuItem. That is the actual control from where I am trying to delete

Waiting for your response. Thanks

Regards

Osama Misbah

Former Member
0 Kudos

Hi Osama

If you change the delete menu item type to online request does it work correctly?

Do you get an illegal argument exception when the submit is online?

Cheers

Andrew

Former Member
0 Kudos

Hello Andrew,

   When I change the type from submit hybrid app to Online Request , It works perfectly fine.

Regards

Osama

Former Member
0 Kudos

Hello Andrew..

          I was trying to do so but could not do it yet. Any update from your side so far?. Looking forward to it.

Thanks

Osama Misbah

Answers (1)

Answers (1)

Jitendra_Kansal
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi

I believe HWC provides a HTML/JS development framework for developing apps which are platform independent. This apporach has been recommended for lightweight online apps. As you mentioned, from SUP 2.2 there is one new functionality has been added for showing/viewing the data even if the device is offline. But doing other operation like CUD still a challenging option.

Just have a look at this

Note: On device caching option is only for viewing/showing the data in case device is offline.

Rgrds,

Jitendra

Former Member
0 Kudos

Thanks Jitendra for your reply. I have created records in offline mode , they are syncd with the back end as soon as internet connection is available. The problem is in update and delete operations. I guess there is some way of doing it by javascript. Will try to do it using javascript and will surely update it.

Thanks

Osama Misbah