cancel
Showing results for 
Search instead for 
Did you mean: 

Action for button

Former Member
0 Kudos

Hi Experts,

I am new to ABAP and and have never worked on BSP also I have a webdynpro application which needs a 'edit' button to be added, I need the code to execute the same. I got the sample code for cancel button, what more information needs to be added here...

method ONACTIONEDITTREE .

DATA lr_node_info TYPE REF TO if_wd_context_node_info.

DATA lt_value_set TYPE wdy_key_value_table.

DATA lo_el_context TYPE REF TO if_wd_context_element.

clear lt_value_set.

*----- Retrieve node

lr_node_info = wd_context->get_node_info( ).

*----- Set attribute info

lr_node_info->set_attribute_value_set( name = 'TYPE'

value_set = lt_value_set ).

  • get element via lead selection

lo_el_context = wd_context->get_element( ).

  • set single attribute

lo_el_context->set_attribute(

name = `ISBUTENABLE`

value = abap_false ).

  • set single attribute

lo_el_context->set_attribute(

name = `ISTYPE`

value = abap_true ).

  • set single attribute

lo_el_context->set_attribute(

name = `ISNEW`

value = abap_true ).

  • set single attribute

lo_el_context->set_attribute(

name = `CANDELETE_TOPIC`

value = abap_true ).

  • set single attribute

lo_el_context->set_attribute(

name = `CANDO_TOPIC`

value = abap_true ).

  • set single attribute

lo_el_context->set_attribute(

name = `CANDO_HEADING`

value = abap_true ).

  • set single attribute

lo_el_context->set_attribute(

name = `INPUT`

value = ' ' ).

  • set single attribute

lo_el_context->set_attribute(

name = `TYPE`

value = ' ' ).

endmethod.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

hi ,

I have created a context node cn_node and a context attribute ca_attribute under it ,

if u want ur Button to be visible / invisible , create this attribute of type WDUI_VISIBILITY

if u want ur Button to be enable /disable , create this attribute of type WDY_BOOLEAN

and like wise ..

now bind the value property with this context attribute .

using get_attribute method , we can get the value which user has entered

using set_attribute method , we can set the value which we want to give for our field


DATA lo_nd_cn_node TYPE REF TO if_wd_context_node.
    DATA lo_el_cn_node TYPE REF TO if_wd_context_element.
    DATA ls_cn_node TYPE wd_this->element_cn_node .
    DATA lv_attr  LIKE ls_city-ca_attr.
*   navigate from <CONTEXT> to <CN_NODEE> via lead selection
    lo_nd_node = wd_context->get_child_node( name = wd_this->wdctx_ca_attr).
 
*   get element via lead selection
    lo_el_cn_node = lo_nd_cn_node->get_element(  ).
 

*   get single attribute
    lo_el_cn_node->get_attribute(
      EXPORTING
        name =  `CA_ATTR`
      IMPORTING
        value = lv_attr ).

*   Set single attribute
    lo_el_cn_node-Set_attribute(
      EXPORTING
        name =  `CA_ATTR`
        value = lv_attr ).

the code is automatically generated when u press control +f7 and choose read/set context node/attribute and choose the attribute

regards,

amit

Former Member
0 Kudos

Thanks a lot Amit..the problem here is it is not generating the code when I press control+f7..it is popping a template gallery..which has again three components..screen form table...did I miss out anything..?

Edited by: rakshita hegde on Jan 18, 2010 8:45 AM

Former Member
0 Kudos

Hi ,

U go to the method where u wish to place ur code

Now press CONTROL+F7 , u wud be directed to a control wizard

Now choose the radio button read context node/attribute

Now press F4 and choose the context attribute and press enter , the code shud be automatically generated

Regards,

amit

Former Member
0 Kudos

hi

Go to context tab , right click on context and choose create node and give it a Name

Create a context attribute under it , choose its type as string

Go to layout tab , right click on the root element container and choose insert element

Choose Button UI .. now it is placed

In the TEXT property , write EDIT and there is a property OnAction , right click on that

Create a Event , now in OnActionEvent method , u have to write the coding

Bind Value property with this context attrtibute

Press control +f7 ( code wizard) and choose read context node/attribute .the code will be auto generate

And u can play with get_attribute and set_attribute method

regards,

amit