cancel
Showing results for 
Search instead for 
Did you mean: 

Checkbox unchecked : How to check ?

Former Member
0 Kudos

Hello,

I am a ABAP & Web Dynpro beginner , and I try to modify a checkbox unchecked by default when the opening of a window.

This window contains two tabs, the first tab contains various information and fields with my checkbox, and the other tab contains other information.

So I have my box which is not checked 'IS_CNCT_PERSON_FLG' in my first tab.

I have made the code below:

ZSET_IS_CNCT_PERSON_FLG method.
    TYPE REF TO DATA lo_nd_cp_basic_data if_wd_context_node.

    TYPE REF TO DATA lo_el_cp_basic_data if_wd_context_element.
    DATA TYPE ls_cp_basic_data wd_this-> Element_cp_basic_data.
    DATA TYPE lv_is_cnct_person_flg wd_this-> Element_cp_basic_data-is_cnct_person_flg.

* Navigate from to via lead selection
    lo_nd_cp_basic_data = wd_context-> get_child_node (name = wd_this-> wdctx_cp_basic_data).

* @ TODO handle non existent child
* IF lo_nd_cp_basic_data IS INITIAL.
* ENDIF.

* Get element via lead selection
    lo_el_cp_basic_data = lo_nd_cp_basic_data-> get_element ().

* Alternative access via index
* = Lo_el_cp_basic_data lo_nd_cp_basic_data-> get_element (index = 1).

* @ TODO handle not set lead selection
    IF IS INITIAL lo_el_cp_basic_data.
    ENDIF.

* @ TODO fill attribute
Lv_is_cnct_person_flg * = 1.


* Set attribute single
    lo_el_cp_basic_data-> set_attribute (
      name = `` IS_CNCT_PERSON_FLG
      value = i_is_selected).

EndMethod.

I call this method: WDDOMODIFYVIEW post-exit :

IF = first_time abap_true.
    wd_this-> ZSET_IS_CNCT_PERSON_FLG (abap_true).
  ENDIF.

Then, I open my window and my box is checked, except that when I click the second tab and I go back to the first, the checkbox is unchecked again.

I don't know if you need more info :).

Can you give me a solution to resolve my problem.

Thank you in advance!

Vincent

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member199125
Active Contributor
0 Kudos

Hi vincet,

You want to set check box by default all the time?

If yes, please call your method in wddoinit method. Wddomodifyview will trigger for each and every action. When it executes 2nd time it wll clear the attributes.

Regards

Srinivas

Former Member
0 Kudos

Hi sanasrinivas,

I have already test in WDDOINIT method, but I had an error :

OBJECTS_OBJREF_NOT_ASSIGNED_NO

Access via 'NULL' object reference not possible.

Method: ZSET_IS_CNCT_PERSON_FLG of program /1BCWDY/51AE06KQDH8STUCI7DHL==CP

Method: IF_V_BD_OIF_BASIC_DATA~ZSET_IS_CNCT_PERSON_FLG of program /1BCWDY/51AE06KQDH8STUCI7DHL==CP

Method: PRE007PKSSCNUFQG630JDXNYTOIJ of program /1BCWDY/51AE06KQDH8STUCI7DHL==CP

Method: IF_WDR_VIEW_DELEGATE~WD_DO_INIT of program /1BCWDY/51AE06KQDH8STUCI7DHL==CP

Method: DO_INIT of program CL_WDR_DELEGATING_VIEW========CP

Method: INIT_CONTROLLER of program CL_WDR_CONTROLLER=============CP

Method: INIT_CONTROLLER of program CL_WDR_VIEW===================CP

Method: INIT of program CL_WDR_CONTROLLER=============CP

Method: GET_VIEW of program CL_WDR_VIEW_MANAGER===========CP

Method: BIND_ROOT of program CL_WDR_VIEW_MANAGER===========CP

And I don't know how to resolve the problem.

To be sure, you confirm me the WDDOMODIFYVIEW method is not the solution ?

Thanks

saravanan_narayanan
Active Contributor
0 Kudos

Hello Vincent,

you can call your method in Modifyview. Its not a problem. In the ModifyView for the first time, you are setting the value of check box to checked. and if you come back to first tab (after navigating to second tab), the check box is unchecked. this means there is some piece of code which is unsetting the check box. So instead of calling the method ZSET_IS_CNCT_PERSON_FLG only for the FIRST_TIME, always call this method and check. If its still not working then you need to identify which method is unsetting the check box and in that method's post exit you need to call this method.

Hope this helps.

BR, Saravanan

former_member199125
Active Contributor
0 Kudos

Hi vincet,

yes you can use wddomodify view method, but as sarvanan said dont write your code in first time = true condition.

just check where exactly you called your method in wddomodifyview method.

And about your access null object error , just check ST22 transaction and identify the exact error line code and analyze.

Regards

Srinivas

Former Member
0 Kudos

Hello Saravanan,

So instead of calling the method ZSET_IS_CNCT_PERSON_FLG only for the FIRST_TIME, always call this method and check

It is working when I always call the method ZSET_IS_CNCT_PERSON_FLG, so I'll search the method which is unsetting the check box however I think it is too difficult for me :s .

Thank you both