on 04-15-2009 11:29 AM
Hi,
I am trying to build a check box in the ALV grid and capture the values of the user input . I have the following error saying Null Reference . The check box column is 'Position' . Can any one let me know where i am going wrong .
*************************************************************************************************************************
data: lr_column type ref to cl_salv_wd_column,
lr_checkbox type ref to cl_salv_wd_uie_checkbox.
data l_value type ref to cl_salv_wd_config_table.
data it_form_jobs type standard table of zform_jobs.
data lt_context_node type ref to IF_WD_CONTEXT_NODE.
data lt_context_elements type ref to if_wd_context_element.
select * from z_jobs into table it_form_jobs.
lt_context_node = wd_context->get_child_node( name = wd_this->wdctx_node_alv ).
lt_context_node->get_elements( ).
***- Its going to dump while executing the code saying Null reference .
lr_column = l_value->if_salv_wd_column_settings~get_column( 'POSITION' ).
***- Its going to dump while executing the code
create object lr_checkbox
EXPORTING
checked_fieldname = 'POSITION'.
lr_checkbox->set_enabled( abap_true ).
lr_column->set_cell_editor( lr_checkbox ).
if not it_form_jobs is initial.
lt_context_node = wd_context->get_child_node( name = wd_this->wdctx_node_alv ).
lt_context_node->bind_table( it_form_jobs ).
endif.
Thanks,
Kumar.
Hi,
Check wether the model object is intitial or not.
***- Its going to dump while executing the code saying Null reference .
if l_value is not initial.
lr_column = l_value->if_salv_wd_column_settings~get_column( 'POSITION' ).
endif.
Check in the deubugging for the columns that you have.
I think you didnt get the column reference for the Position.
Try to pass the correct name for the coulmn. check the L_value for the columns in debugging.
And also check the lr_column is initial or not before creating a check box.
That is a good pratice.
Regards,
Lekha.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
>lr_column = l_value->if_salv_wd_column_settings~get_column( 'POSITION' ).
I would say that you don't have a column named POSITION. You have to be careful with these calls because the column name is supplied as a literal, it isn't checked by the complier. You won't know if you supply an incorrect column or mispell something until it dumps at runtime. You should really surround this entire block of code with a TRY...ENDTRY and catch the object exception and report a graceful error.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Thomas ,
I placed the below code in the 'WDDOMODIFYVIEW' and able to run the application , but the problem is its not creating a check box in the column of the ALV grid any reasons for this please .
Code :
******************************************************************
DATA: lr_column type ref to cl_salv_wd_column,
lr_checkbox type ref to cl_salv_wd_uie_checkbox.
DATA: lr_column_settings TYPE REF TO if_salv_wd_column_settings,
lr_INTERFACECONTROLLER TYPE REF TO IWCI_SALV_WD_TABLE,
l_VALUE type ref to Cl_Salv_Wd_Config_Table.
DATA it_form_jobs type standard table of zform_jobs.
DATA lt_context_node type ref to IF_WD_CONTEXT_NODE.
DATA lt_context_elements type ref to if_wd_context_element.
lr_INTERFACECONTROLLER = wd_This->wd_cpifc_alv_comp( ).
l_VALUE = lr_INTERFACECONTROLLER->Get_Model( ).
lr_column_settings ?= l_value.
if not l_value is initial.
lr_column = l_value->if_salv_wd_column_settings~get_column( 'POSITION' ).
endif.
create object lr_checkbox
EXPORTING
checked_fieldname = 'POSITION'.
lr_checkbox->set_enabled( abap_true ).
lr_column->set_cell_editor( lr_checkbox ).
Thanks,
Kumar
Hi,
I am using the following code to create a check box in ALV grid , but the check box is not is editable mode to check and uncheck any suggestions would be helpfull.
method WDDOMODIFYVIEW .
DATA: lr_column type ref to cl_salv_wd_column,
lr_checkbox type ref to cl_salv_wd_uie_checkbox.
DATA: lr_column_settings TYPE REF TO if_salv_wd_column_settings,
lr_INTERFACECONTROLLER TYPE REF TO IWCI_SALV_WD_TABLE,
l_VALUE type ref to Cl_Salv_Wd_Config_Table.
lr_INTERFACECONTROLLER = wd_This->wd_cpifc_alv_comp( ).
l_VALUE = lr_INTERFACECONTROLLER->Get_Model( ).
lr_column_settings ?= l_value.
if not l_value is initial.
lr_column = l_value->if_salv_wd_column_settings~get_column( 'STATUS' ).
endif.
create object lr_checkbox
EXPORTING
checked_fieldname = 'STATUS'.
lr_checkbox->set_enabled( abap_true ).
lr_column->set_cell_editor( lr_checkbox ).
endmethod.
Thanks,
Kumar.
Hi,
In the node that you are binding to ALV, create a conetxt attribute of type char1(SELECT).
Fill the table for char1 field as 'X' or space for all the rows.
loop at lt_table into ls_table.
lv_tabix = sy-tabix.
ls_table-select = 'X'.
modify lt-table..... index lv_tabix transporting select.
endif.
Now in the lr_checkbox object use the method SET_CHECKED_FIELDNAME and pass this context attribute(char1) field name.
* create object lr_check
* EXPORTING
* checked_fieldname = 'SELECT'.
X means checked, space means unchecked.
Please try this way.
Regards,
Lekha.
User | Count |
---|---|
98 | |
11 | |
11 | |
10 | |
10 | |
8 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.