cancel
Showing results for 
Search instead for 
Did you mean: 

mapping from view to controller

Former Member
0 Kudos

Hello Friends,

I have one inputfield and value attribute in view, now I have extended my controller, add a new value attribute with the same name, and mapped them, when I run the applicatin, got the following exceptin :

must not modify the datatype of a mapped attribute

Any idea what I am doing wrong

PS: Both have type string...

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Hello Murtuza,

Unfortunately, this did not worked out for me,

Nevertheless, I have passed the inputfield value in method parameter in controller, ....so for time being it has solved the issue...

Regards, ( points awarded for your kind help and supprot ....

former_member485701
Active Participant
0 Kudos

Hi,

"must not modify the datatype of a mapped attribute ", this error comes in following cases.

(1) You are making your inputfield as valuehelp field by creating SVS or EVS.

Solution: Move all calculation to component controller.

(2) DataType Problem: Like java.util.Date and java.sql.date both refer's to date

Solution:Check the import Packeges in such case.

Regards,

Praveen

Former Member
0 Kudos

Hello Praveen,

Thanks for your input,...

Yes the input field is with f4 help, and the value of this input field I want to handover to my controller, and therefore i did bindng, and encountered the exception:

You mentioned by I have to shift the calculation to controller, ( right now my all coading for f4 help on inputfield is in doModifyInit.... what do u mean by calculation to move to controller ?

Seconldy, is there anyother way to fix this issue ?

Regards,

Former Member
0 Kudos

Hello Kalyan ,

Could you please re-explain your suggestion, I do not understand what do you mean there....

Regards,

Former Member
0 Kudos

In doinit of view, I have following code:

( varname is the inputfield, and the value of this inputfield I want to bind with value attribute of the controller...)

IWDAttributeInfo attribute_var = wdContext.getNodeInfo().getAttribute("varname");

ISimpleTypeModifiable fileName_var = attribute_var.getModifiableSimpleType();

What I can do to fix this issue ?

Regards,

Former Member
0 Kudos

Hi,

move this code to the doinit of the controller.

Regards

Ayyapparaj

Former Member
0 Kudos

hi this is all code in wdinit of view:

fileName_var.setFieldLabel("varname");

IModifiableSimpleValueSet valueSet2 = fileName_var.getSVServices().getModifiableSimpleValueSet();

for (int i = 0; i < wdContext.nodeVartab().size(); i++)

{

valueSet2.put(wdContext.nodeVartab().getVartabElementAt(i).getVarname(), "Variant: " + wdContext.nodeVartab().getVartabElementAt(i).getVarname());

}

valueSet2.sort(true, true , true);

.... the thing is the nodeVartab is not avaiable in that custom controller, ( as I have two custom controller )....

Former Member
0 Kudos

Hi,

Where is this "fileName_var" attribute created?

Is this a maapped attribute from one of your controller?

Regards

Ayyapparaj.

Former Member
0 Kudos

is it possible to access the node of one custom controller, in another custome controller ?

Regards,

Former Member
0 Kudos

Hi,

Just map the node from controller1 to controller 2 and then access them

Regards

Ayyapparaj

Former Member
0 Kudos

Hello,

I have shifted the code from view to the custom controller, the problem is solved, i.e I am not getting anymore the exception, but the new problem is that the f4 help is not avaiable to my input filed...

looks like the inputfiled is not recognize in the custome controller ....

pls help....

Regards,

PS: if its helpful I can paste my code.....

Message was edited by:

Shah H

Former Member
0 Kudos

Hi,

Check the attribute which is mapped to the <b>value</b> property of the inputfield.

Check for the code which creates the F4, is that accessing the same attribute or not.

Regards

Ayyapparaj

Former Member
0 Kudos

IWDAttributeInfo attribute_var = wdContext.getNodeInfo().getAttribute("varname");

ISimpleTypeModifiable fileName_var = attribute_var.getModifiableSimpleType();

this above code I have shifted from view to my custom controller, now the thing is varname is the attribute which I have in view and also in controller ( which I want to mapped from view to controller )

so pls suggestn, how I can manage to bring the varname here from view ?

IWDAttributeInfo attribute_var = wdContext..(context from view)..getNodeInfo().getAttribute("varname");

how I can access the context from view here ?

Regards,

Former Member
0 Kudos

Hi,

Create an attribute with the same name and type in your controller and then in your data modeller just link the 2 attributes (left to right).

Regards,

Murtuza

Former Member
0 Kudos

Hello Murtuza,

This what I am doing, but my inputfield has no f4 help any more ?

Any idea, what I am doing wrong ?

Regards,

Former Member
0 Kudos

Hi,

It seems that you have not changed the type of your context attribute in controller to the simple type defined. Change the type of the component controller'a context attribute to the one that you have in your view's context attribute.

Warm Regards,

Murtuza

Former Member
0 Kudos

Okey, here I will let you know what I have done uptill now:

(I have couple of views with two custome controllers and 4 models:)

The following code was in my view first.

IWDAttributeInfo attribute_var = wdContext.getNodeInfo().getAttribute("varname");

ISimpleTypeModifiable fileName_var = attribute_var.getModifiableSimpleType();

Zport_Get_Variant_Input variant_input = new Zport_Get_Variant_Input();

wdContext.nodeZport_Get_Variant_Input().bind(variant_input);

variant_input.setClient(wdContext.currentContextElement().getClient());

variant_input.setPuser(wdContext.nodeZport_Get_Fields_Input().getZport_Get_Fields_InputElementAt(0).getUname());

//variant_input.setRpttype(wdContext.currentContextElement().get.getReportType() );

variant_input.setTabname(wdContext.currentContextElement().getTabname());

try {

wdContext.nodeZport_Get_Variant_Input().currentZport_Get_Variant_InputElement().modelObject().execute();

wdContext.nodeVartab().invalidate();

} catch (Exception e ) {

}

fileName_var.setFieldLabel("varname");

IModifiableSimpleValueSet valueSet2 = fileName_var.getSVServices().getModifiableSimpleValueSet();

for (int i = 0; i < wdContext.nodeVartab().size(); i++)

{

valueSet2.put(wdContext.nodeVartab().getVartabElementAt(i).getVarname(), "Variant: " + wdContext.nodeVartab().getVartabElementAt(i).getVarname());

}

valueSet2.sort(true, true , true);

Which I then moved to my one custome controller : before doing that, I have created a value attribute varname in controller to be mapped with varname of my view ( which takes the values from inputfiled ) by doing so I got the exception, which was fixed when I moved the above mentioned code from view to controller.

Now the new issue is f4 help is not visible in inputfield. you mentioed something with type ? but my both context attributes are of type string...

Former Member
0 Kudos

Hi,

Create a simple type of type String in your local dictionary and set the type of your varname in both controller and view to that simple type.

Regards,

Murtuza

Former Member
0 Kudos

Can I edit the type of varname ? or I have to create a new value attribute ( because I cant see the way to edit the type of value attribute ?

Regards,

Former Member
0 Kudos

Murtuza, one thing more, if i do so ( like create a new simpletype and assign it to both value attributes ) then I can revert the changes made too or ? that my simpletype coading back to view ??

Regards,

Former Member
0 Kudos

Yes, you can edit it directly. It would be disabled because you have mapped it to your controller too.

Do one thing. Remove both the context from view as well as from the controller and create new one in your <b>controller</b> with the same name that you gave previously. Specify the type to the Simple Type. Now map the same to your view too.

Regards,

Murtuza

Former Member
0 Kudos

I have delete the mapping, but still I cant edit it,,,,

Okey, I will create two new and assign them to simpletype, and then bind them again,

let see... get back to you ....

Thanks regards,

Former Member
0 Kudos

Hi,

Don't create 2 different.

Just create one in component controller. Bind it to your simple type and map the same context to your view from data modeller. So that view's context will take the same properties that of your component controller's context.

Regards,

Murtuza

Former Member
0 Kudos

hi

After executing RFC try to add this code

IWDAttributeInfo[] ovsStartUpAttributes =

{ wdContext.nodeUser_Input_Node().getNodeInfo().getAttribute("varname")};

IWDOVSContextNotificationListener listener =

wdThis.wd<UR>CompController().getListener();

WDValueServices.addOVSExtension("Var Name",

// not used yet by the current OVS Service

ovsStartUpAttributes,

// fields bound to startup attributes will be ovs-enabled

wdThis.wd<UR>CompController().getInputNode(),

wdThis.wd<UR>CompController().getOutputNode(),

listener);

Write getListener() getInputNode () and getOutputNode() methos in component controller.

Former Member
0 Kudos

hello Murtuza,

What do u mean, by saying "remove both from context" , by that I think you mean remove both value attribute from my view and controller ? right...

Former Member
0 Kudos

Yes exactly.

1. Remove the varname from view as well as from the controller.

2. save your metadata

3. create varname in your component controller.

4. set its type to the simple type defined.

5. map varname from component controller to view.

Regards,

Murtuza

Former Member
0 Kudos

one last confusion :

While doing point 5: I have to first create the value attribute (varname )in view, assign it to my inputfield and then I can mapped it with my custom controller ? right ...

and while creating varname in view I will create it of type simpletype, created first....

secondly, by doing so, I do not need to shift my all code form view to controller ( for creating f4 help )...

Regards,

Former Member
0 Kudos

No.

Create it in your component controller and set its type to Simple type and then map this to your view and then bind it to your input field.

Regards,

Murtuza

Former Member
0 Kudos

okey, will try it...

Regards,

Message was edited by:

Shah H

Former Member
0 Kudos

Still getting the following exception:

com.sap.tc.webdynpro.progmodel.context.ContextException: MappedAttributeInfo(SelectView.varname): must not modify the datatype of a mapped attribute

I have not created the value attribute of type simpletype in customcontroller, mapped it to view, and inputfield, ( the coading for creating f4 help is in view ),

PLS help, how I can fix the issue, without moving the code creating f4help in custom controller ? ( because while do so, I fell in further issues )

Regards,

Former Member
0 Kudos

If you are writing this in view then there is no need to mapping it to the controller.

Remove the mapping between view and controller.

Set the type of the view as SimpleType

Try executing it now.

Regards,

Murtuza

Former Member
0 Kudos

then how I will get the value of inputfield in my custom controller ?, .... its getting tricky,

PS: both value attributes in view and controller has the same name... okey, will give it a shot... brb..

Regards,

Former Member
0 Kudos

unfortunately, the value from inputfield is not given over to the controller ?

MAN, i did not estimate that it could be so difficult...

Regards,

Former Member
0 Kudos

Hi,

What I understood is :

You have an input field in your view binded to a context(not model context) of simple type and thus acting as F4 in your view.

You are getting the values from your back-end R/3 system.

You are dynamically adding those values to your simple type enumeration from your model nodes.

If this is the scenario then you don't have to map the context binded to input field to your custom controller.

If my understanding is wrong then point me whereever there are changes.

Regards,

Murtuza

Former Member
0 Kudos

Hello Murtuza,

Thanks for your help ; but I am still facing the issue to give over the value of my inputfield to the custom controller, ( now both the value attributes are of simpletype )

or let me ask in other way, how I can access the context of view in my custom controller ?

right now I am trying following to access the varname in controller:

wdContext.currentContextElement().getVarname()

Any idea....

Regards,

Former Member
0 Kudos

<b>You are dynamically adding those values to your simple type enumeration from your model nodes.</b>

Apart of this all is okey, ...

After getting the userinput in inputfield, I want to give over this value to the controller, .....so I just want to know how I can handover the inputfield value to custom controller...

Regards,

Former Member
0 Kudos

If you need to access your view context in your custom controller then there needs to be a mapping between your view and controller.

Once you map it to your custom controller, you will be able to access it using:

wdContext.currentContextElement().getVarname()

Regards,

Murtuza

Former Member
0 Kudos

<b>wdContext.currentContextElement().getVarname()</b>

but in controller, currentContextElement() will refer the context of controller, and I want to access the context of view....

Seconly, should I create a value attribute of type simpletype in controller ( same name as varname ) ?

Regards,

Former Member
0 Kudos

If there is mapping between view and controller then the same context is used in both view as well as controller.

Regards,

Murtuza

Former Member
0 Kudos

<b>If you need to access your view context in your custom controller then there needs to be a mapping between your view and controller.

Once you map it to your custom controller, you will be able to access it using:

wdContext.currentContextElement().getVarname()</b>

This is the problem i.e. when I do mapping, I got the exception as said earlier...

com.sap.tc.webdynpro.progmodel.context.ContextException: MappedAttributeInfo(SelectView.varname): must not modify the datatype of a mapped attribute

Regards,

Message was edited by:

Shah H

Message was edited by:

Shah H

Former Member
0 Kudos

Hello Murtuza ,

Any suggestion for me, ?

Regards,

Former Member
0 Kudos

Ok,

I got your problem.

You write the code to insert the values in the value set to your simple type in component controller instead of view.

Regards,

Murtuza

Former Member
0 Kudos

You mean, code for creating f4 help in custome controller ?

I tried this too, but then I was not getting the f4 help ( as the inputfields to whom I have to assign the f4 help was not reachable in custome controller )...

is there any other way to do the same ?

Regards,

Former Member
0 Kudos

Hi,

I tried to write the same code in component controller and was getting the values for the input box successfully.

The only thing is you need to map the view and component controller but the code for populating the values to the simple type will be written in component controller instead of the view.

I tried this and is working for me.

Regards,

Murtuza

Former Member
0 Kudos

I do not have any component controller, can the same be done in custome controller ?

What code you have place in controller ? ( can you pls paste here as well ) ?

Regards,

Former Member
0 Kudos

Yes for you it would be custom controller.

I created a context attribute called Comp of Simple type String.

This is the code I placed in the custom controller's method.

IWDAttributeInfo attr = wdContext.getNodeInfo().getAttribute("Comp");

ISimpleTypeModifiable sim = attr.getModifiableSimpleType();

IModifiableSimpleValueSet vs = sim.getSVServices().getModifiableSimpleValueSet();

vs.put("Value1","Key_1");

vs.put("Value2","Key_2");

Regards,

Murtuza

Former Member
0 Kudos

okey, here is what I am doing:

This is the code in view which is used to create the f4 help, ( now I moved this to doinit of custome controller )

IWDAttributeInfo attribute_var = wdContext.getNodeInfo().getAttribute("varname");

ISimpleTypeModifiable fileName_var = attribute_var.getModifiableSimpleType();

Zport_Get_Variant_Input variant_input = new Zport_Get_Variant_Input();

wdContext.nodeZport_Get_Variant_Input().bind(variant_input);

variant_input.setClient(wdContext.currentContextElement().getClient());

variant_input.setPuser(wdContext.nodeZport_Get_Fields_Input().getZport_Get_Fields_InputElementAt(0).getUname());

variant_input.setTabname(wdContext.currentContextElement().getTabname());

try {

wdContext.nodeZport_Get_Variant_Input().currentZport_Get_Variant_InputElement().modelObject().execute();

wdContext.nodeVartab().invalidate();

} catch (Exception e ) {

}

fileName_var.setFieldLabel("varname");

IModifiableSimpleValueSet valueSet2 = fileName_var.getSVServices().getModifiableSimpleValueSet();

for (int i = 0; i < wdContext.nodeVartab().size(); i++)

{

valueSet2.put(wdContext.nodeVartab().getVartabElementAt(i).getVarname(), "Variant: " + wdContext.nodeVartab().getVartabElementAt(i).getVarname());

}

valueSet2.sort(true, true , true);

But still the f4 help is not there, ......

PS: the varname is avaiable twice 1) in view with simpletype string, and 2) in custom controller with simpletype string ?

Dont know what I am doing wrong....

have u also created the comp in view and in controller ?

Regards,

Former Member
0 Kudos

I created Comp in Custom Controller and mapped the same to view too.

So you first delete varname from view as well as custom controller and then create one in custom controller and map the same to view.

Write the following code in custom controller and I think you should find luck this time.

Regards,

Murtuza

Former Member
0 Kudos

Okey, let me try this now ....

Regards

venkatakalyan_karanam
Active Contributor
0 Kudos

Hi Shaw

You can not modify the mapped Attribute which is binded to the Input field.

Create One more Attr dont map with the component controller Attr.Bind this to input field.

Populate the data from this Attr to the one Which you binded with Comp Controller.

Note :you can not modify the mapped Attr in Webdynpro like modifying into Simple type to use it as EVS or SVS.

Regards

Kalyan

Former Member
0 Kudos

Did you write some code that modifies the DDIC type of the attribute in the view controller? If yes, move that code to the component controller and modify the original attribute.

Armin

Former Member
0 Kudos

No I have not write such stuff in view controller,

The thing is other value fields from view are mapped on the same way to controller, but now when I try to add another mapping, it gives me the exception,...

Regards,

Former Member
0 Kudos

Any idea / suggestions, why I am getting this exception ?

Regards,

Former Member
0 Kudos

Hi

Shah

This error comes when string is of different type

in java string is in two classes

1.java.lang

2.java.sql.

So check whether at both place imported package is same.

Regards

Sunny Shah.