on 07-18-2007 6:04 AM
Hi Experts,
I want to ask one simple question. What is the use of Bind and Invalidate in WD programs. For instance we write:
Bapi_abc xyz = new Bapi_abc();
wdContext.nodeBapi_abc().bind(xyz);
Why we write like as shown above? Suppose we have to initialize some parameters of Bapi_abc. Then should we write code like Case 1 or Case 2 as shown below:
Case 1
Bapi_abc xyz = new Bapi_abc();
wdContext.nodeBapi_abc().bind(xyz);
Initialize parameters here
Case 2
Bapi_abc xyz = new Bapi_abc();
Initialize parameters here
wdContext.nodeBapi_abc().bind(xyz);
When we have use invlidate? When we should not use invalidate? Should we use invalidate in Commit bapi as well.
Please let me know the answers of above queries.
Thanks in advance,
Brian
Hi Brain,
After executing the RFC model object to synchronize the data in the context with the data in the model you have to use invalidate()
Check ths code.
IWDMessageManager msg = wdComponentAPI.getMessageManager();
try {
Bapi_Employee_Getdata_Input input = new Bapi_Employee_Getdata_Input();
input.setEmployee_Id(empid);
wdContext.nodeBapi_Employee_Getdata_Input().bind(input);
// Calls remote function module BAPI_EMPLOYEE_GETDATA
wdContext.currentBapi_Employee_Getdata_InputElement().modelObject().execute();
// Synchronise the data in the context with the data in the model
wdContext.nodePersonal_Data().invalidate();
} catch (Exception e) {
// TODO Auto-generated catch block
msg.reportSuccess(e.getMessage());
e.printStackTrace();
}
Regards,
Mithu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
There seems to be alot of confusion about the invalidate() method.
When we're working with a model node, the context contains a referense pointing to the actual model object. See Mithus code with some additional comments
try {
//Create new model object
Bapi_Employee_Getdata_Input input = new Bapi_Employee_Getdata_Input();
// Set data on model object
input.setEmployee_Id(empid);
// Bind model object to context node, i.e. create reference from context node to model object
wdContext.nodeBapi_Employee_Getdata_Input().bind(input);
// Calls remote function module BAPI_EMPLOYEE_GETDATE. This call will create a new model object containing the response, the so called "Output"
wdContext.currentBapi_Employee_Getdata_InputElement().modelObject().execute();
//Tell the application that the current reference from our context node "Personal Data" is not valid. Thias will create a reference to the new output, containing the response from your bapi/rfm
wdContext.nodePersonal_Data().invalidate();
} catch (Exception e) {
// TODO Auto-generated catch block
msg.reportSuccess(e.getMessage());
e.printStackTrace();
}
See <a href="http://help.sap.com/saphelp_nw04/helpdata/en/66/8b3c413b456e24e10000000a155106/content.htm">http://help.sap.com/saphelp_nw04/helpdata/en/66/8b3c413b456e24e10000000a155106/content.htm</a> , it explains this in pretty good detail.
Regards
Mattias
go thtrogh dis link for binding
http://help.sap.com/saphelp_nw04s/helpdata/en/31/3bc041a1236724e10000000a1550b0/frameset.htm
we use invalidate to delete the elements of d node...........to reload values we use invalidate.....once bapi z commited we should nt use invalidate
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI Brian,
When u import an RFC, it's corresponding auxilliary java classes(Bapi_abc) will be created.
Initially, the model node that we map from model wont have any values
and will be null.
In order to initialize this model node, we are bind the object of auxiliary java class(xyz) to this node (ie.wdContext.nodeBapi_abc().bind(xyz);). NOw the model node can be used to pass the values.
Case 1 and 2 will work without any problem.
Invalidate as it's name indicates, invalidates the contents of a node.
So we will be using invalidate to delete all elements of a node.
In case of model node, we will be calling invalidate for output node.
It's because, if we r not invalidating the output node, the values will not be reloaded after the first output.
Regards
Fahad Hamsa
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
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.