cancel
Showing results for 
Search instead for 
Did you mean: 

Button in Table view

Former Member
0 Kudos

Hi Gurus,

I have two columns(date and status) in table view in WDP for Abap application. In the corresponding source table, if date is 00/00/0000, then I need to populate an approve button in the status column of table view, otherwise the actual date has to be populated from the table. After populating the approve button, if its clicked the system date should be displayed in the date column and the approve button should be disappeared.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

You have not mentioned what you want in the button column when the date is some valid date. I assume you dont want anything in that case. Do some minor changes if that is not the case.

In your context node, have two attributes, date of type DATS and visible type char01. With the help of your API, get the node data in an internal table. Loop through this, and when date = 00/00/0000, set the visible attribute to true, else set it to false. So your button will be visible only if the date is initial.

In your UI, create a table with the date column bound to the date attribute. Create another column with the button as cell editor, and bind the 'visible' property of the button to the Visible context attribute. Statically define the button text as 'Approve'. In the onClick event of the button, use the following code:

data: lr_element type ref to if_wd_context_element.

lr_element = wdevent->get_context_element( 'CONTEXT_ELEMENT' ).

lr_element->set_attribute( name = 'DATE' value = sy-datum ).

lr_element->set_attribute( name = 'DATE' value = abap_false ).

This will set the date field to the current date and also make the button invisible.

Hope this helps.

Regards

Nithya

Former Member
0 Kudos

Hi Nithya,

Many thanks for your quick response. I have a question in your solution.

How can I set the visible attribute to true or false? Dont I have to declare the visible attribute as WDUI_VISIBILITY. Please explain me in detail.

Thanks,

David.

Former Member
0 Kudos

Hi David,

The visible attribute can be of type wdui_visibility or simply char01. If it is of type wdui_visibility, you should set it to '01' or '02' depending on whether you want to make it visible or invisible. If it is of type char01, just set to abap_true or abap_false. Both will work.

Regards

Nithya

Former Member
0 Kudos

Hi Nithya,

first am trying to set the visible to true for all rows, but,I'm getting an error "Access via 'NULL' object reference not possible" in the below code. Please suggest me how to fix it. I have declared wdevent as type ref to CL_WD_CUSTOM_EVENT. Is that true?

Here is the code.

data:

Node_Plan type ref to If_Wd_Context_Node,

Elem_Plan type ref to If_Wd_Context_Element,

Stru_Plan type If_View_Plan_Table=>Element_Plan ,

wdevent type ref to CL_WD_CUSTOM_EVENT,

Item_VISIBLE like Stru_Plan-VISIBLE.

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

Node_Plan = wd_Context->get_Child_Node( Name = IF_VIEW_PLAN_TABLE=>wdctx_Plan ).

  • @TODO handle not set lead selection

if ( Node_Plan is initial ).

endif.

  • get element via lead selection

Elem_Plan = Node_Plan->get_Element( ).

  • @TODO handle not set lead selection

if ( Elem_Plan is initial ).

endif.

Elem_Plan = wdevent->get_context_element( 'CONTEXT_ELEMENT' ).

  • get single attribute

Elem_Plan->set_attribute(

  • exporting

Name = `VISIBLE`

Value = abap_true ).

Thanks,

David.

Former Member
0 Kudos

Hello David,

You do not need to <i>declare</i> WDEVENT. It is available as an importing parameter in your action handler. You should use that as it is.

Regards,

Neha

Answers (0)