cancel
Showing results for 
Search instead for 
Did you mean: 

Recommendation on how to set column inputField attribute readonly

Former Member
0 Kudos

Hi,

I have a table that is built against a result of a RFC execution that fills a context node, I have a requirement to set a column input field to readonly if a context attribute is equal to cero.

do you have any recommendations on how to set this readonly atribute when a specific context atribute value for that row is equal to cero?

the easiest way for me is that the RFC contains a new column in the table and bind the property readonly of the cell against it and then change the value in the context depending on the other attribute been cero or not, but I don´t know if it is a good aproach.

Hope somebody have some recomendations.

kind Regards,

Gerardo J

Accepted Solutions (0)

Answers (1)

Answers (1)

gill367
Active Contributor
0 Kudos

Hello,

In the context you can add one more attribute with type wdy_boolean and give it some name say state.

bind this UI element to the property read only of the input field you want to make read only or read write on some condition.

then after filling the node wirte the code to modify the internal table used to fill the node

modify the table like that when the value is 0 then set state attribute for that element equal to 'X' and in other cases ' '.

and then fill the node once again.

and you will get the desired output.

here is some sample code for modifying the table.

in the where clause you can write your condition to check for the value equal to 0 or not.

** data declaration
  DATA lt_zdealer3 TYPE wd_this->Elements_zdealer3.
  DATA ls_zdealer3 LIKE LINE OF lt_zdealer3.
** @TODO compute values
** e.g. call a data providing FuBa
*
  select * into corresponding fields of table lt_zdealer3 from zdealer.
    ls_zdealer3-state = ' '.
   MODIFY lt_zdealer3 FROM ls_zdealer3 TRANSPORTING state
WHERE status = '1'  .
   ls_zdealer3-state = 'X'.
MODIFY lt_zdealer3 FROM ls_zdealer3 TRANSPORTING state
WHERE status ne '1'  .

** bind all the elements
 node->bind_table(
   new_items            =  lt_zdealer3
    set_initial_elements = abap_true ).

thanks

sarbjeet singh

Former Member
0 Kudos

Hi Sarbjeet,

Thanx alot for your answer, I tried adding an attribute to the Node and it is not allowing me, I created this Controller from a Service Call to the RFC and it built automatically the Structure with nodes and attributes and is not allowing me to create a new attribute in to the node, how can that be achieved?

Thanx again!

kind Regards,

Gerardo J

Former Member
0 Kudos

Hi Sarbjeet,

I did something and is working.

I have the atribute that if value = 0 then I have to set the InputField property to ReadOnly(now I set it in Enabled instead).

What I did is to bind the desired attribute of the inputField not with the option to "Bind directly to the Selected Attribute" but with the other option "Bind to the Property of the selected Attribute" and selected the Enabled Property.

Then in my coding I´m changing the property Enabled of the attribute in the Context node and this is getting the desired effect, here a piece of code :

  • get single attribute

LO_EL_I_ELEMENTPC->GET_ATTRIBUTE(

EXPORTING

NAME = `MONMAXI`

IMPORTING

VALUE = LV_MONMAXI ).

if LV_MONMAXI = 0.

  • set attribute property

LO_EL_I_ELEMENTPC->SET_ATTRIBUTE_PROPERTY(

EXPORTING

ATTRIBUTE_NAME = 'MONMAXI'

PROPERTY = 4

VALUE = abap_false ).

ENDIF.

What do you think? Hope I can get your advice.

Kind Regards,

Gerardo J

gill367
Active Contributor
0 Kudos

Yup its fine.

directly also you can change the attribute proeprties.

i guess if you try to change the property readonly dynamically in the code. it wont reflect in the output.

if it is working with the enabled property , its well and good.

thanks

sarbjeet singh

Former Member
0 Kudos

Thanx Alot for the help!

Actually the Attribute Property that I change is not the inputField one but the context Attribute Property directly and then I bind the inputField property Enabled against the Enabled property of the context Attribute instead of the attribute itself.

Does it sound like a good aproach to you?

Kind Regards,

Gerardo J

gill367
Active Contributor
0 Kudos

>

> then I bind the inputField property Enabled against the Enabled property of the context Attribute instead of the attribute itself.

>

how did u do that?

Former Member
0 Kudos

When you select to bind the Enabled attribute of the inputField it opens the Context of the View and you can see the nodes and the attributes, then I selected the Attribute 'MONMAXI' and you have the option to Bind directly to the selected attribute or to bind to a property of the selected attribute, I clicken on the radio button of the second one and in the property combobox I selected Enabled.

After that with the codign I changes the Node attribute property Enabled to true or false accordingly.

Thats is what I did, what do you think?

Thanx for the patience,

Kind Regards,

Gerardo J

gill367
Active Contributor
0 Kudos

Ohk

actually i was not aware of this option.

thanks for the explanation.

regards,

sarb

Former Member
0 Kudos

Cool! nice to know that at least I could contribute with a small piece. :O)

Really apreciate the help you have already given to me in this and other threads.

Kind Regards,

Gerardo J

Former Member
0 Kudos

Hi Sarbjeet,

I have a new similar Requirement and looking for information about it, thanx God I found this link that talks about the aproach mentioned of using the node attribute properties :O) , here I post the link:

http://help.sap.com/saphelp_nw04s/helpdata/en/45/d44e0cdff073b1e10000000a11466f/content.htm

Also I opened a new thread about the other issue I´m facing regarding a cell color change, hope you could help on that one too.

Kind Regards,

Gerardo J

Edited by: Gerardo Jiménez on Jan 13, 2011 12:26 PM