on 04-01-2014 6:52 AM
I am new to SAP and trying ot create an MBO based Hybrid app which takes data from REST service. The REST service accepts an HTTP POST input.
I have seen tutorials of creating MBO from REST service which is an HTTP GET endpoint. Please suggest me with a tutorial.
You can check this video SUP 2.0 (8) Create an MBO from RESTful Service in SUP - YouTube
Rgrds,
Jitendra
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jitendra
Thanks for the reply.
Now If I need to get the data from the user, I would do it as demonstrated in the following tutorial
SUP 1.x Weather WebService Workflow (Part 1 of 2) - YouTube
I am using a webservice which takes data as POST body instead of appending it in the url. I gave the request xsd and created the MBO successfully. I could preview it.
How can I take the input from the user , form the xml and give it to the webservice using MBO ?
You need to create Query in the MBO (Right click on MBO>properties). You can call this query to get data in the app. If you are developing a HWC app once you map the query to a button or menuitem the parameters will be filled with parameters you used while creating query. You can map this parameters with input of user. If you are new to HWC development you can have a look at this,
And if you are developing native app after synchronization you can query the ultraliteDB similar to a method, ex. findByLastMonth("value"); If you are new to native development this might help you,
Sample Queries:
SELECT x.* FROM Sales_order_items_Scheduled x WHERE x.ship_date > DATEADD(month, -1, '1998-11-26') and x.ship_date < '1998-11-26' ORDER BY x.ship_date;
SELECT x.* FROM Sales_order_items_Scheduled x WHERE x.ship_date > DATEADD(year, -1, '1998-11-26') and x.ship_date < '1998-11-26' ORDER BY x.ship_date;
SELECT x.* FROM Sales_order_items_Scheduled x WHERE x.ship_date >= :sDate AND x.ship_date <= :eDate ORDER BY x.ship_date;
In the query tab it will write query automatically if you select the fields (MBO>properties>Object Query>Add).
Midhun VP
The following is my post data format given to the REST service as the body
<Root>
<User>
<parameter name="id" value="abcd"/>
<parameter name="password" value="23"/>
</User>
</Root>
and the following is the load argument of the MBO generated by giving the request xsd
If the parameters in the load arguments did not have the child tags, I could have added it to Attributes and created an object query.
The number of the argument 'parameter' will come more than 1 time as shown in the request xml.
Is it possible to create an object query in this situation ?
If you want to do an authentication before fetching the data you need to add credentials request screen to the application. After that you need to create a new security profile in SCC and deploy the MBO package to this security profile instead of the admin profile (admin is default). You have different options for authentications.
http://scn.sap.com/thread/3454963
Even without passing the credentials it works using the credentials you saved in the REST services connection profile in Sybase workspace.
Midhun VP
The example mentioned in this thread help you,http://scn.sap.com/thread/3338213
Midhun VP
Since you have a load parameter similar to structure you can't the personlization key you are creating can't be used in HWC since HWC will not support PK with structure. You can modify the inout type of the service in this case to solve the issue. Regarding the object query, you can use findAll query.
Midhun VP
Hi Midhun
Thanks Midhun.
Is the following scenario possible
1. User selects a button in the screen
2. Inside the Custom.js file, I could manually take the data from the editboxes.(I dont know the function)
3. Form the request xml.
4. Set the xml(the string) as the value of the key mapped to the Personalization key.
If possible I would like to know how to set the value of the key.
Here I can use a Personalization key of string type.
Also I would like to know if the native app supports the PK with structure.
Can't you create PKs for name, value and content if these values will be always a single set? Then map these values from HWC to solve this issue instead of setting values from custom.js.
To answer your questions,
It is possible to get the data from editbox using below code:
if(screenKey === "Detail")
{
var form = document.forms[screenKey + "Form"];
if(form){
var Number = form.Number_attribKey.value;// Number_attribKey is the key of editbox
}
}
You can set the PK from custom.js too: Add a key in the screen (click on screen>select keys>add) then map the key to the PK using the below code:
Inside method customBeforeSubmit,
if(screenKey =="Start" && actionName == "Create"){
var myNewValue = new MessageValue();
myNewValue.setKey("PK_Value");
myNewValue.setText("TEXT");
var mvc = workflowMessageToSend.getValues();
if(mvc){
mvc.add(myNewValue.getKey(), myNewValue);
}
Midhun VP
Midhun
There are three sets of name, value pairs.
I could not try the code mentioned as I was having the following problem "java.lang.RuntimeException:the messageListener is null of mbo:"
I then tried to redeploy the Hybrid app. Then I got the following error
An error occurred deploying the package, .pkg to server, MobieServer (Exception Deploy error: runtime_error: -- Unknown error in server runtime: java.lang.reflect.InvocationTargetException).
Let me try resolving these errors. Then I will update on passing values to the REST service.
User | Count |
---|---|
84 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.