cancel
Showing results for 
Search instead for 
Did you mean: 

How to remove an element which is added because of model binding?

Former Member
0 Kudos

Hi May I know how do I do that? To empty the element that appears in the node because of model binding?

Because I am unable to execute the model as the model requires some of the element's attributes to be filled up.

Accepted Solutions (1)

Accepted Solutions (1)

pravesh_verma
Active Contributor
0 Kudos

Hi Jackson,

You can use invalidate before the model execution.

node.invalidate();

Check these links:

1)

2)

I hope this solves the issue.

Thanks and Regards,

Pravesh

Former Member
0 Kudos

I tried to remove the element SA_ITEM3, but it is not being removed.. it is still there..

wdComponentAPI.getMessageManager().reportException("" + wdContext.nodeSa_Item3().size(), true);

wdContext.nodeSa_Item3().invalidate();

wdComponentAPI.getMessageManager().reportException("" + wdContext.nodeSa_Item3().size(), true);

Former Member
0 Kudos

just to clarify.. i want to remove the element.. not just to empty it.. is it possible for binded node?

Former Member
0 Kudos

The scenario is like this.. I have an order form with items in a table.. so lets say if there is no item, I could not execute the model with the empty element.. therefore I am trying to delete this existing element in the model node.

former_member185086
Active Contributor
0 Kudos

Hi

Better solution is dont bind/take it during mapping .

what I mean is : A bapi/rfc node structure contain some hierarchy first is for request (which actually require to execute the model ) and Some response (which contain the information after execuation like data ,message etc )

It seems that u don't want message node there , so when u bind the model node to component controller --select only those node in which u want to work (request and returnNode )and leave others

Best Regards

Satish Kumar

Former Member
0 Kudos

Hi Thanks Satish,

I see. but as what I have explained previously.. the Item node MAY have element and MAYNOT have element depending on if the users delete them.. therefore I still need to have it binded am I right?

The question is how to not delete the empty element (remove the element) so that execution will be successful?

former_member185086
Active Contributor
0 Kudos

Oh.... jackson

If u remember i have given some clarification about Model Node and Value Node in some previous question.

The scenario is like this.. I have an order form with items in a table.. so lets say if there is no item, I could not execute the model with the empty element.. therefore I am trying to delete this existing element in the model node.

tell me one thing as you mentioned u r trying to delete this existing element in the model node How it possible dear.

Model node is just a representation of the stuff which is there in database, for doing some modification/operations with the help of these node .

You again welcome with questions.

Best Regards

Satish Kumar

Former Member
0 Kudos

Hi

If there are no ITEMS in the table , table will eventually be null ,

so irrespective of ITEMS present in the table or not

do one thing , after you bind the model node to the table ,

catch the size of the table .

if(tablesize==0)

{

IprivateViewname.I<ContextElementName> abc = wdcontext.node<NodeName>.createElement(new class());

wdcontext.node<NodeName>.removeElement(abc);

hope this should help you .

Former Member
0 Kudos

As what satish has said, I think it can't be done..

I tried anyway and it gives:

model object must not be null

Answers (1)

Answers (1)

p_2_5_6_9_6_0
Active Participant
0 Kudos

Hi,

Just wanted to put in my 2 cents worth as well. Maybe it will help.

When I want to remove unnecessary model context attributes that I dont want / need on the UI - I use a Faceless component in between the UI and the Model Components.

UI <------ Faceless Comp <---- Model

The model has a Public Part used inside the faceless component. All the unnecessay parameters are filled in with default / initial / garbage values inside the faceless component.

Finally, the faceless component exposes a Public Part with just the required context to the UI component.

You could also make use of "Component Usage" via the Component Interface Controller - i guess.

It''s an SAP Best Practice. And illustrated by Chris Whealy's best practices e-learning segments.

Hope the information is useful.

Thanks.

p256960.