cancel
Showing results for 
Search instead for 
Did you mean: 

reg:DISPlay code in wdabap

Former Member
0 Kudos

Hi Experts

How are you?Hope all are doing great and fine.

Actually i am very new to wdabap coding but working on that technology where i have designed an wdabap application in that there is a button named display when i click on that button all the UI elements what ever i have used in the application should be displayed in non-editable mode ,means just it should display in inactive state.

could you please share your knowledge regarding coding.

Thanks in Advance.

Regards

Deepika

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hello deepika,

Create a context attribute of type WDY_BOOLEAN. And bind the readOnly property of all the UI elements which you want to be in display mode to that context attribute.

Initially if you want all those to be in editable mode, then you can set that attribute value to abap_false.

And in the event handler of your button, set that attribute to abap_true so that all the UI elements will becom readonly.

Hope this helps!

Regards,

Srilatha

Former Member
0 Kudos

Hi Srilatha

Thanks for your quick response

But please can give elaborately what your explaining. here i am having some doubts

1) bind the read Only property of all the UI elements which you want to be in display mode to that context attribute :

when i do this all are in non editable mode but this should happen when i click on display button only.but when i test the application all are in non edit mode if i do above procedure.

can please give me the coding how to write in

2)Initially if you want all those to be in editable mode, then you can set that attribute value to abap_false:

Is this should be written in wddoint method of the application.

3)event handler of your button, set that attribute to abap_true so that all the UI elements will becom readonly:

Is this should be written in display button action.

can please clarify this along with the coding.

Thanks & Regards

Deepika

Former Member
0 Kudos

Hi deepika,

>>when i do this all are in non editable mode but this should happen when i click on display button only.but when i test the application all are in non edit mode if i do above procedure.

The reason could be that the value of the context attribute was set to true. Initially i mean, in wddoinit method of the view, you can set that to false.

>>Is this should be written in wddoint method of the application.

you have to write it in WDDOINIT of the corresponding view

>>Is this should be written in display button action.

Yes you are right.

you can use the web dynpro code wizard to set the value of context attribute.

Here is the sample code to set the context attribute:


    DATA lo_node TYPE REF TO if_wd_context_node.

    DATA lo_el_node TYPE REF TO if_wd_context_element.
    DATA ls_node_flighttab TYPE wd_this->element_node_flighttab.
   

*   navigate from <CONTEXT> to <NODE_FLIGHTTAB> via lead selection
    lo_node = wd_context->get_child_node( name = wd_this->wdctx_node_flighttab ).

*   get element via lead selection
    lo_el_node  =  lo_node->get_element( ).

*   set single attribute
    lo_el_node->set_attribute(
      name =  'CHECKED'
      value = abap_false ). 

Former Member
0 Kudos

Hi srilatha

That code should we write in component DOINT( ) method or view controller DOINT( )

Actually when i write in component controller

DATA LO_ND_LECI_EVENT TYPE REF TO IF_WD_CONTEXT_NODE.

DATA LO_EL_LECI_EVENT TYPE REF TO IF_WD_CONTEXT_ELEMENT.

DATA LS_LECI_EVENT TYPE WD_THIS->ELEMENT_LECI_EVENT.

DATA LV_PASS_NUMB TYPE WD_THIS->ELEMENT_LECI_EVENT-PASS_NUMB.

  • navigate from <CONTEXT> to <LECI_EVENT> via lead selection

LO_ND_LECI_EVENT = WD_CONTEXT->GET_CHILD_NODE( NAME = WD_THIS->WDCTX_LECI_EVENT ).

  • @TODO handle non existant child

  • IF lo_nd_leci_event IS INITIAL.

  • ENDIF.

  • get element via lead selection

LO_EL_LECI_EVENT = LO_ND_LECI_EVENT->GET_ELEMENT( ).

  • @TODO handle not set lead selection

IF LO_EL_LECI_EVENT IS INITIAL.

ENDIF.

  • get single attribute

LO_EL_LECI_EVENT->SET_ATTRIBUTE(

NAME = `PASS_NUMB`

I

VALUE = abap_false ).

it is giving VALUE not expected .

Can you clarify why the problem is coming

Thanks & Regards

Deepika

Former Member
0 Kudos

hi,

it is giving VALUE not expected

have u mapped ur Component controller context to the view . for this just drag and drop the context node.

That code should we write in component DOINT( ) method or view controller DOINT( )

u shud write the coding in the OnAction of the button in ur view..

as alrady replied in preious thread , there is Action property of ur button UI .. so right click and create a action for ur button.

then in the OnAction method u can write the coding to inactive ur screen UI ..

regards,

Amit

Former Member
0 Kudos

Hi Srilatha

congrats for being in top contributor list.

could please reply for my Query ASAP .

Thanks in advance

Deepika

Former Member
0 Kudos

hi

do not use IMPORTING parameter for set_attribute method .. map ur component controller context nodes to view and disable the fields in the event handler ..

1) bind the read Only property of all the UI elements which you want to be in display mode to that context attribute :

when i do this all are in non editable mode but this should happen when i click on display button only.but when i test the application all are in non edit mode if i do above procedure.

yes , this is why u need to create a action for ur button .. u can find a Action property for ur button UI .. create a action and then write the code for enable/disable of the fields in this method

can please give me the coding how to write in

refer to my earler post ..

one correction ..

set the value to ' ' for disable and 'X' for enable .. instead of '01' and '02' ... use the set_attribute method

2)Initially if you want all those to be in editable mode, then you can set that attribute value to abap_false:

Is this should be written in wddoint method of the application.

by default the fields are in the enable mode. if u wish them to be disable mode, u can write the coding in WDDOINIT method..

u can accordingly change them to enable/disable them in the onAction method of ur button UI

3)event handler of your button, set that attribute to abap_true so that all the UI elements will becom readonly:

Is this should be written in display button action.

if u set the attribute in the event handler to 'X' or 'ABAP_TRUE' fields will be in enable mode

if set to ' ' or 'ABAP_FALSE' vice versa ..

regards,

Amit

Former Member
0 Kudos

HI Amit

The answer which you have sent is very helpfull to me.But there is one problem when assigning field of data type WDY_boolean to one of the inputfield it is taking by default X value in the inputfield which i have used that X for edit mode in wddoint()

DATA LO_EL_CONTEXT TYPE REF TO IF_WD_CONTEXT_ELEMENT.

DATA LS_CONTEXT TYPE WD_THIS->ELEMENT_CONTEXT.

DATA LV_DISPLAYMODE TYPE WD_THIS->ELEMENT_CONTEXT-DISPLAYMODE.

  • get element via lead selection

LO_EL_CONTEXT = WD_CONTEXT->GET_ELEMENT( ).

  • @TODO handle not set lead selection

IF LO_EL_CONTEXT IS INITIAL.

ENDIF.

  • get single attribute

LO_EL_CONTEXT->sET_ATTRIBUTE(

EXPORTING

NAME = `DISPLAYMODE`

VALUE = 'X' ).

this value X is getting displayed in the first inputfield how to avoid this and can you please explain me what might be the problem

Thanks & Regards

Deepika

Former Member
0 Kudos

Hello Deepika,

>>this value X is getting displayed in the first inputfield

Did you bind the value property of input field to the attribute "DISPLAYMODE" by any chance?

Regards,

Srilatha

Former Member
0 Kudos

hi,

this value X is getting displayed in the first inputfield how to avoid this and can you please explain me what might be the problem

when we bind the Value property of our input field to a context attribute of type WDY_BOOLEAN .. we can set the field in

editable or display mode by using the set_attribute method..

1) if we set the attribute to 'X' .. the input field will be displayed in editable mode

2) if we set the attribute to ' ' .. the input field will be displayed in display mode ..

By default , if you do not bind the context attribute , the input field will be displayed in the EDIT mode ..

I have tried to explain a bit of this in my earlier post , let me frgment my previous reply in two peces .. so that u can be better able to understand that ..

regards,

Amit

Former Member
0 Kudos

hi,

PFB the previous reply to ur post:

do not use IMPORTING parameter for set_attribute method .. map ur component controller context nodes to view and disable the fields in the event handler ..

1) bind the read Only property of all the UI elements which you want to be in display mode to that context attribute : when i do this all are in non editable mode but this should happen when i click on display button only.but when i test the application all are in non edit mode if i do above procedure.

yes , this is why u need to create a action for ur button .. u can find a Action property for ur button UI .. create a action and then write the code for enable/disable of the fields in this method

can please give me the coding how to write in

refer to my earler post .. one correction .. set the value to ' ' for disable and 'X' for enable .. instead of '01' and '02' ... use the set_attribute method

Former Member
0 Kudos

2)Initially if you want all those to be in editable mode, then you can set that attribute value to abap_false: Is this should be written in wddoint method of the application.

by default the fields are in the enable mode. if u wish them to be disable mode, u can write the coding in WDDOINIT method.. u can accordingly change them to enable/disable them in the onAction method of ur button UI

3)event handler of your button, set that attribute to abap_true so that all the UI elements will becom readonly: Is this should be written in display button action.

if u set the attribute in the event handler to 'X' or 'ABAP_TRUE' fields will be in enable mode if set to ' ' or 'ABAP_FALSE' vice versa ..

regards,

Amit

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Deepika,

Please check the below link.

[Webdynpro ABAP - Sample Code|http://wiki.sdn.sap.com/wiki/display/WDABAP/SimpleapplicationtochangepropertiesofUIElementsduringruntimeinWebDynpro+ABAP]

It will give you the step by step procedure in using the visibility and enable property.

Former Member
0 Kudos

hi deepika,

1)Bind ur fields with the context attribute of type WDY_BOOLEAN. There is a value propery of ur field. Bind that property.

2) Now create a action for ur button . In the method OnAction of the button , u need to set the attribute , to '01' or ABAP_FALSE to make the field non editable

3) for this, u can go to code wizard. press control+f7. choose the radio button to read/set the attribute


  DATA lo_nd_cn_editable TYPE REF TO if_wd_context_node.
  DATA lo_el_cn_editable TYPE REF TO if_wd_context_element.
 
* navigate from <CONTEXT> to <CN_EDITABLE> via lead selection
  lo_nd_cn_editable = wd_context->get_child_node(
  name = wd_this->wdctx_cn_editable ).
 
* get element via lead selection
  lo_el_cn_editable = lo_nd_cn_visiblesuper->get_element(  ).
 
* set single attribute
  lo_el_cn_editable->set_attribute(
    EXPORTING
      name =  `CA_EDITABLE`
*    IMPORTING
      value = '01' ).
// context attribute ca_editable under the context node cn_editable
// set the attribute to '01' for dispaly mode

please revert back in case of any doubts

regards,

Amit