cancel
Showing results for 
Search instead for 
Did you mean: 

Use of Binding and invalidate in Web Dynpro

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (3)

Answers (3)

former_member751941
Active Contributor
0 Kudos

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();

}

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/355b9c90-0201-0010-d2a8-89f...

Regards,

Mithu

Mattias
Active Participant
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

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