on 05-29-2007 5:12 PM
All,
Im setting the context variable "POS_NUM" in Component controller:
wdThis.wdGetFormController().wdGetContext().getCurrentElement().setAttributeValue( "c_pos_num", pos_num);
* In View controller im reading the component controller value & passing into BAPI..
Here im getting error :Can not be converted".
String val = wdThis.toString( wdContext.getCurrentElement().getAttributeValue( "c_pos_num") );
bapiInput.setI_Pos_Num( val );
can anyone tell me how to read the value of context variable..
BM
Hi Bharathi,
Even more simpler:
Set values in your controller set values as:
wdContext.currentContextElement().setC_pos_num(<value>);
In view controller,
If c_pos_num value in context is of type String then simply get value using following statement:
wdContext.currentContextElement().getC_pos_num();
If it is type of int, then use following statement.
String value = new String(wdContext.currentContextElement().getC_pos_num());
Regards,
Bhavik
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI Bharathi,
Have you created this context attribute under root context or under any context node.
If you have created under root context then you should get setter and getter methods.
If it is available under context node then you can get by following statement:
wdcontext.current<context node>Element().getC_pos_num();
Regards,
Bhavik
Assuming that the context variable is only in component controller
Setting the value in component controller
wdContext.currentContextElement.setPOS_NUM(pos_num);
Getting the value in view controller
wdContext.wdGetComponentController.wdGetContext.getPOS_NUM();
if you map the context to view context then
Setting the value in component controller
wdContext.currentContextElement.setPOS_NUM(pos_num);
Getting the value in view controller
wdContext.currentContextElement.getPOS_NUM();
the return type depends on the 'type' of context attribute POS_NUM.
When you set it to the BAPI variable I_Pos_Num the POS_NUM value data type should be
same as I_Pos_Num.
Hi Bharathi,
First open ur the interfaceView from ComponentInterface>InterfaceViews> <WindowName>InterfaceView. Take the properties Tab and in Required Controllers, add the Component Controller using the add button provided. Then save all metadata. After this, u can assign a value from interface view to the component controller's context variable by
wdThis.wdGet<ComponentController>().wdGetContext().currentContextElement().set<attribute>("Value");
Regards
Fahad Hamsa
Hi Bharathi,
If you want to access variable onr context attribute defined in Component controller then you have to follow this:
Create a global variable in component controller. Define it in between following section at the end of the file:
// Begin others
public String data;
// End others
Make sure, scope of this variable is public.
Now, from interfaceView, you can access value as,
wdthis.Wdget<compoent controller>().data;
Regards,
Bhavik
Nothing helpfu...
I'm setting the value in InterfaceView as follows:
wdThis.wdGetRequisitionFormController().wdGetContext().currentContextElement().set_pos_num("125");
When I debugged the pos_num is initial here.
In Componenet controller I'm reading the value as follows:
String value = wdContext.currentContextElement().getTemp_pos_num();
Here value is initial.
Could anyone suggest me pls.
BM
Hi Bharathi,
I guess, You have confirmed that you are checking values for Temp_pos_num after setting it from view controller.
One more check:
Right click on this context atrribute and select properties.
In properties, check whether read only property is false or not. If it is true then make it false.
Regards,
Bhavik
<i>In properties, check whether read only property is false or not. If it is true then make it false.</i>
Its already false...
Actually I'm transfering variable from one component to another component via Event parameter,
When I set the value to the target component Context variable, its not setting up..Even i hardcoded & checked also..
Pls help me..
BM
Hi Bharathi,
Have you tried printing message with this value on the screen using message manger?
Print message right after setting value in this context attributes.
It must work atleast when you have tried with hardcoding.
For, event parameter, make sure, value is passing properly or not.
regards,
Bhavik
Hi,
For cross component use server side eventing.
Go through the tutorial to cehck how you can pass values from one component to another.
<a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/e8d7cd90-0201-0010-4a8c-dd22fa16ca0a">Server Side eventing</a>
HI Bharathi
U can acess the node in the context of component controller from the interface view but before that u need to go to the properties of interface view and add the component controller as the <b>required controller</b> for the Interface view
and then u can acess the context of component controller by following line
<b>wdThis.wdGetFormController().wdGetContext().currentNodeElement().setAttributenameValue(value)</b>
Regards
Asif
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Bharathi,
Check the datatype of the argument of the function "setI_Pos_Num".I think it is of type "int".You are passing the value of type "String".Thats why you are getting the exception.
Try this.
try {
String val = wdThis.toString( wdContext.getCurrentElement().getAttributeValue( "c_pos_num") );
bapiInput.setI_Pos_Num(Integer.parseInt(val));
}
catch (ParseException e)
{
// TODO Auto-generated catch block
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 Bharathi,
Instead of using wdThis.wdGetFormController().wdGetContext().<b>getCurrentElement()</b>.setAttributeValue( "c_pos_num", pos_num);
Use
wdThis.wdGetFormController().wdGetContext().<b>currentContextElement()</b>.setAttributeValue( "c_pos_num", pos_num);
if the variable is in the Context
OR
wdThis.wdGetFormController().wdGetContext().<b>current<Node>Element()</b>.setAttributeValue( "c_pos_num", pos_num);
if the variable is in a node
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.
If u want getter and setter methods for context value attribute.u go to the particular attribute property and set "calculated" as true then u will get that methods.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Instead of
String val = wdThis.toString( wdContext.getCurrentElement().getAttributeValue( "c_pos_num") );
Do :
String val = wdContext.getCurrentElement().getAttributeAsText( "c_pos_num") ;
The way to read context attribute is correct i.e wdContext.getCurrentElement().getAttributeValue( "c_pos_num").But it returns Object.
getAttributeAsText( "c_pos_num") returns String so you need not do any casting.
Regards,
Ashwani Kr Sharma
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
82 | |
10 | |
10 | |
9 | |
6 | |
6 | |
5 | |
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.