on 06-24-2013 5:51 AM
Hi All,
My sup version is 2.2 sp02, I am to using the future Embedded Html.
Now i created a front end html page, in this page i need to call a MBO operation on button click.
Is it possible? if yes could u please share some knowledge.
Note:My requirement is to display multiple MBO screens in one screen.
through sup worksplace its not possible. Hence we are planing through Embedded Html.
Thanks in advance
suresh
"through sup workspace its not possible"
I assume by this you mean that the hybrid app designer doesn't support this, which I would agree with. Rather than still using the designer and utilizing the embedded HTML feature, you may find it easier to just create the entire app by hand.
"i need to call a MBO operation on button click.
Is it possible? if yes could u please share some knowledge."
I would recommend generating the JavaScript API for your MBOs, that will provide you with an API that will include the findAll function you need. The following samples/whitepapers include information how to generate and use this API:
https://cw.sdn.sap.com/cw/docs/DOC-152841
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi David,
thanks for your helping nature.
I generated the JavaScript API for my MBOs. In the embedded Html i imported a HTML file
having below code.
Here APIs is the folder generated through wizard,
i copied APIs and (used in embedded html) HTML file to path ....Generated Hybrid App\project_name\html
<html>
<head>
<script src="APIs/js/Callbacks.js"></script>
<script src="APIs/js/Camera.js"></script>
<script src="APIs/js/Certificate.js"></script>
<script src="APIs/js/datajs-1.0.3.js"></script>
<script src="APIs/js/ExternalResource.js"></script>
<script src="APIs/js/HybridApp.js"></script>
<script src="APIs/js/json2.js"></script>
<script src="APIs/js/SUPStorage.js"></script>
<script src="APIs/js/Timezone.js"></script>
<script src="APIs/js/WorkflowMessage.js"></script>
<script>
function findIbase() {
var v_mbo = new mbo5(); //MBO5 is the my MBO name
v_mbo.pks.put(P_LPNO_pkKey,Reg_no_input); "P_LPNO is the personalization key of MBO
mbo5_findAll(v_mbo,null,null); "funtion in the HybridApp.js file
}
</script>
</head>
<body>
<form>
<label for="VIN_no_output">VIN</label>
<div data-role="fieldcontain">
<label for="Reg_no_input">
Reg No.
</label>
<input name="Reg_no_input" id="Reg_no_input" placeholder="" value="" type="text"
data-mini="true">
</div>
<a id="GET_DATA" data-role="button" data-transition="none" href="#page1" onclick="findIbase()">
GET CUSTOMER
</a>
<div data-role="fieldcontain">
<label for="VIN_no_output">
VIN
</label>
<input name="VIN_no_output" id="VIN_no_output" placeholder="" value=""
type="text" data-mini="true">
</div>
</form>
</body>
</html>
if is displaying in the start screen perfectly when i click the GET CUSTOMER button nothing is happening.
Is anything i did wrong?
Thanks
Suresh
Hi Suresh,
First check if the findIbase() method is getting called or not? Put alert box inside findIbase().
function findIbase() {
alert("Hello");
var v_mbo = new mbo5(); //MBO5 is the my MBO name
v_mbo.pks.put(P_LPNO_pkKey,Reg_no_input); "P_LPNO is the personalization key of MBO
mbo5_findAll(v_mbo,null,null); "funtion in the HybridApp.js file
}
If an alert box doesn't pop out then something wrong in javascript code.
Hi Shashank,
Thanks for replay.
I copied same code in http://www.w3schools.com/html/tryit.asp?filename=tryhtml_intro
Here i am getting popup of hello, but in emulator i am not getting any popup,
Is anything wrong with JavaScript above,
Thanks in advance
suresh
This is the major problem of Javascript. If you have any error in the code then it won't show....
There is only one way to debug javascript is to comment some code and try executing....
If your findIbase() method is working fine then there must be problem in following includes.....
Put HTML comment around following tags and try.
eg.
<!-- <script src="APIs/js/Callbacks.js"></script> -->
<script src="APIs/js/Callbacks.js"></script>
<script src="APIs/js/Camera.js"></script>
<script src="APIs/js/Certificate.js"></script>
<script src="APIs/js/datajs-1.0.3.js"></script>
<script src="APIs/js/ExternalResource.js"></script>
<script src="APIs/js/HybridApp.js"></script>
<script src="APIs/js/json2.js"></script>
<script src="APIs/js/SUPStorage.js"></script>
<script src="APIs/js/Timezone.js"></script>
<script src="APIs/js/WorkflowMessage.js"></script>
If you have coded any java script file in the above includes then check its code first.
Hi Shshank,
Now alert box is coming
function findIbase() {
alert("Hello");
var v_mbo = new mbo5();
v_mbo.pks.put(P_VIN_pkKey,"yourValue");
v_mbo.pks.put(P_LPNO_pkKey,"123456789");
mbo5_findAll(v_mbo,null,null);
}
But if i change to
function findIbase() {
var v_mbo = new mbo5();
v_mbo.pks.put(P_VIN_pkKey,"yourValue");
v_mbo.pks.put(P_LPNO_pkKey,"123456789");
mbo5_findAll(v_mbo,null,null);
alert("Hello");
}
alert box is not coming.
Now the doubr is, how to call MBO's in java script?
This is the method in HybridApp.js file
function mbo5_findAll(mbo5Obj, credInfo , errorCallback)
Thanks in advance
suresh
Its throwing an exception. Try adding a try-catch-alert around your implementation of findlbase(), that should tell you where its having the problem.
Can you let us know what the MBO structure definitions in the generated HybridApp.js are? e.g.
Customer = makeClass( "Fname Lname ID Address City State Zip Phone", "" );
Hi David,
MBO5 = makeClass( "INSTANCE IBASE _surrogateKey", "" );
function mbo5_findAll(mbo5Obj, credInfo , errorCallback)
{
var keys = ["P_VIN_pkKey", "P_LPNO_pkKey"];
var types = ["string", "string"];
var objValues = [mbo5Obj.pks.P_VIN_pkKey, mbo5Obj.pks.P_LPNO_pkKey];
.
.
.
.}
Here "P_VIN_pkKey P ,_LPNO_pkKey are the Personalization keys mapped to the MBO attributes VIN , LPNO
INSTANCE, IBASE are the output parameters
i wrote my code as per
http://dcx.sybase.com/sup0220/en/com.sybase.infocenter.dc01853.0220/doc/html/vhu1349202936661.html link
2. If i successfully call the MBO how to get the MBO result.
Where i need to write the logic to get the data from MBO query.
Thanks
Suresh
Hi David,
Thanks for input. It Helped me.
<script>
function findIbase() {
var v_mbo = new MBO5();
alert("Hello end1");
v_mbo.pks.put(VinPK_pkKey,"");
alert("Hello end2");
var credInfo = "supusername=supAdmin&suppassword=********";
var reg_value = document.getElementById('Reg_no_input').value;
v_mbo.pks.put(LpnoPK_pkKey,reg_value );
alert(reg_value);
MBO5_findAll( v_mbo , credInfo , function(error){
alert("Hello end6");
alert(error);
});
alert("Hello end4");
hwc.processDataMessage = function (incomingDataMessageValue) {
alert("Hello end5");
if (incomingDataMessageValue.indexOf("<M>") != 0) {
alert("An error occurred! " + incomingDataMessageValue);
}
var workflowMessage = new
WorkflowMessage(incomingDataMessageValue);
var values = workflowMessage.getValues();
var empList = values.getData("MBO5");
var firstEmp = empList.value[0];
var firstName =
firstEmp.getData("MBO5_INSTANCE_attribKey").value;
alert("The name of the first employee is " + firstName);
} }
Now I am getting up-to alert("Hello end4");
alert("Hello end5"); popup is not coming
Note:Here MBO5_findAll method is correct ( if i changed to some other "alert("Hello end4"); " is not displaying.
Thanks in advance
Sureshb
Hi David,
I tried with both ways.
If i put both functions in separate
alert("Hello end5"); pop is not comming.
What i think is, we are not calling hwc.processDataMessage = function (incomingDataMessageValue) separately, hence i put it inside the onclick method findMBO( ).
Now also alert("Hello end5"); pop is not comming.
Hi Suresh,
We can call MBO methods using javascript. Please go through the following blog.
It may be helpful.....
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.