cancel
Showing results for 
Search instead for 
Did you mean: 

Get the current view to draw dynamically check boxes

Former Member
0 Kudos

Hello,

I need to draw check boxes in my view dynamically depending on an sql query result.

The problem is how to get the current view to use its method get_element.

My source code is below

thanks.

<Code>

LOOP AT lt_benef_list_node INTO ls_benef_list_node.

*Create Node

lr_view_controller = wd_this->wd_get_api( ).

CALL METHOD view->get_element EXPORTING id = 'OPTIONS_CTR' RECEIVING element = lr_root_node.

lr_container ?= lr_root_node.

lr_context_node_info = wd_context->get_node_info( ).

CONCATENATE 'Check_' counter into AttributID.

MOVE ls_benef_list_node-nodenameext TO AttributTxt.

st_contxt_attr-name = AttributID.

st_contxt_attr-type_name = 'WDY_BOOLEAN'.

*Create CheckBox

CALL METHOD cl_wd_checkbox=>new_checkbox

RECEIVING

control = lr_check_box.

*Bind checkbox to Node

lr_check_box->bind_checked( path = AttributID ).

lr_check_box->set_text( value = AttributTxt ).

cl_wd_matrix_head_data=>new_matrix_head_data( element = lr_check_box ).

lr_container->add_child( lr_check_box ).

AttributID = ''.

ENDLOOP.

</Code>

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

done by my self.

gill367
Active Contributor
0 Kudos

HI

view is available in wddomodify generally.

you can make it availabale in all the methods by creating an attriubte of type if_wd_view.

say its name as view1.

then in wddomodify

set it in view1

wd_this->view1 = view.

and use it in any method by fetching it

data view1 type ref to if_Wd_view.
view1 = wd_this->view1.

then use get element 
CALL METHOD view1->get_element
EXPORTING
id = 'OPTIONS_CTR'
RECEIVING
element = lr_root_node.

Former Member
0 Kudos

I switched to on modify and now i can get the "view".

But now i have an error when i try to use bind_cheked it tels me that 'atributID' is not compatible with formal parameter path.

I cheked the method and the type of the path parameter is string as my atributID.

lr_checkbox->bind_checked( PATH = AttributID ).

Edited by: Achref zaidi on Feb 17, 2011 12:09 PM

Former Member
0 Kudos

HI ,

Please post the value you are passing to the method.

What does attribID have??

You will have to pass somthing like

lr_checkbox->bind_checked( PATH = NODE_NAME.ATTRIBUTE_NAME ).

Thanks,

Aditya.

Former Member
0 Kudos

actually it will contain : check1, check2 ...

Former Member
0 Kudos

Hi ,

Try passing the value as ,

lr_checkbox->bind_checked( PATH = NODE_NAME.check1 ).

Thanks,

Aditya.

gill367
Active Contributor
0 Kudos

Paste your code for wddomodify.

in the variable attribute id

you need to pass the value like 'NODENAME.ATTRIBUTE'

if attribute is directly under main context nodethen

just 'ATTRIBUTE' is enough

thanks

sarbjeet

Former Member
0 Kudos

This my code.

I still get that error:

LOOP AT lt_benef_list_node INTO ls_benef_list_node.

*Create Node

lr_view_controller = wd_this->wd_get_api( ).

CALL METHOD view->get_element

EXPORTING

id = 'OPTIONS_CTR'

RECEIVING

element = lr_root_node.

lr_container ?= lr_root_node.

lr_context_node_info = wd_context->get_node_info( ).

move counter to counters.

CONCATENATE 'OPTIONS_NODE.Check_' counters into AttributID.

MOVE ls_benef_list_node-nodenameext TO AttributTxt.

st_contxt_attr-name = AttributID.

st_contxt_attr-type_name = 'WDY_BOOLEAN'.

*Create CheckBox

CALL METHOD cl_wd_checkbox=>new_checkbox

RECEIVING

control = lr_checkbox.

*Bind checkbox to Node

lr_checkbox->bind_checked( PATH = AttributID ).

lr_checkbox->set_text( value = AttributTxt ).

cl_wd_matrix_head_data=>new_matrix_head_data( element = lr_checkbox ).

lr_container->add_child( lr_checkbox ).

AttributID = ''.

ENDLOOP.

Edited by: Achref zaidi on Feb 17, 2011 1:09 PM

gill367
Active Contributor
0 Kudos

Try this

LOOP AT lt_benef_list_node INTO ls_benef_list_node.
*Create Node
lr_view_controller = wd_this->wd_get_api( ).
CALL METHOD view->get_element
EXPORTING
id = 'OPTIONS_CTR'
RECEIVING
element = lr_root_node.
lr_container ?= lr_root_node.
lr_context_node_info = wd_context->get_node_info( ).

move counter to counters.
CONCATENATE 'OPTIONS_NODE.CHECK_' counters into AttributID. 
CONDENSE AttributID.
MOVE ls_benef_list_node-nodenameext TO AttributTxt.
st_contxt_attr-name = AttributID.
st_contxt_attr-type_name = 'WDY_BOOLEAN'.

*Create CheckBox
CALL METHOD cl_wd_checkbox=>new_checkbox
RECEIVING
control = lr_checkbox.

*Bind checkbox to Node
lr_checkbox->bind_checked( PATH = AttributID ).
lr_checkbox->set_text( value = AttributTxt ).
cl_wd_matrix_head_data=>new_matrix_head_data( element = lr_checkbox ).
lr_container->add_child( lr_checkbox ).
AttributID = ''.

Former Member
0 Kudos

I got this now :

Attribut Check_0 konnte nicht gefunden werden.

it means that it could'nt find my attribut.

i cheked my sy-subrc after each action and it is always 0.

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

>view is available in wddomodify generally.

>you can make it availabale in all the methods by creating an attriubte of type if_wd_view.

>say its name as view1.

This is extremely bad advice and you should never actually do this. Accessing the view in any other step of the phase model than WDDOMODIFYVIEW can result in unpredicatble behavior and is not supported by SAP.

Instead set flags within the other event handlers and then evaluate these flags within the WDDOMODIFYVIEW.

Former Member
0 Kudos

done by my self.

gill367
Active Contributor
0 Kudos

>

> >view is available in wddomodify generally.

> >you can make it availabale in all the methods by creating an attriubte of type if_wd_view.

> >say its name as view1.

>

> This is extremely bad advice and you should never actually do this. Accessing the view in any other step of the phase model than WDDOMODIFYVIEW can result in unpredicatble behavior and is not supported by SAP.

>

> Instead set flags within the other event handlers and then evaluate these flags within the WDDOMODIFYVIEW.

OOPs is it so.

actually i also havenot used it anywher.

thanks for pointing out thomas.

thanks

Former Member
0 Kudos

Hi ,

This kind of code can be written in the WDDOMODIFY method of the view.

In this method it is available.

Thanks,

Aditya.