on 05-04-2011 10:35 AM
Hello Experts,
I am trying the below mentioned code to generate input field and its label dynamiclly in WDDOMOFIYVIEW method
data lr_label1 type ref to cl_wd_label.
data input1 type ref to cl_wd_input_field.
DATA GRID_DATA TYPE REF TO CL_WD_GRID_DATA.
data lcr type ref to cl_wd_transparent_container.
lcr ?= view->get_element( 'MAIN_CONTAINER' ).
input1 = cl_wd_input_field=>new_input_field( id = 'INP1'
).
GRID_DATA = CL_WD_GRID_DATA=>NEW_GRID_DATA( input1 ).
input1->set_layout_data( GRID_DATA ).
LR_LABEL1 = CL_WD_LABEL=>NEW_LABEL(
ID = 'LB1'
LABEL_FOR = 'INP1'
TEXT = 'LABEL1'
).
GRID_DATA = CL_WD_GRID_DATA=>NEW_GRID_DATA( lr_label1 ).
LR_LABEL1->set_layout_data( GRID_DATA ).
LCR->ADD_CHILD( LR_LABEL1 ).
LCR->ADD_CHILD( input1 ).
But this gives OBJECTS_OBJREF_NOT_ASSIGNED dump.
This is what it shows in ST22
Information on where terminated
Termination occurred in the ABAP program "/1WDA/C0STANDARD==============CP" -
in "IF_NW7_VIEW_ELEMENT_ADAPTER~SET_CONTENT".
The main program was "SAPMHTTP ".
In the source code you have the termination point in line 8623
of the (Include) program "/1WDA/C0STANDARD==============CCIMP".
I Checked the standard code where the exception is trigered.
This is the code
if ifur_nw7_inputfield~align = ifur_nw7=>horizontalalign_enum.
case mv_value_info-rtti->type_kind. <---This becomes initial when the class is called 3rd time
when cl_abap_typedescr=>typekind_packed or
cl_abap_typedescr=>typekind_int or
cl_abap_typedescr=>typekind_int1 or
cl_abap_typedescr=>typekind_int2 or
cl_abap_typedescr=>typekind_float.
ifur_nw7_inputfield~align = ifur_nw7=>horizontalalign_right.
when others.
ifur_nw7_inputfield~align = ifur_nw7=>horizontalalign_left.
endcase.
endif.
Again if I change a small code as shown below
LR_LABEL1 = CL_WD_LABEL=>NEW_LABEL(
ID = 'LB1'
LABEL_FOR = 'INP1'
TEXT = 'LABEL1'
).
GRID_DATA = CL_WD_GRID_DATA=>NEW_GRID_DATA( input1 ).<---THIS WAS LR_LABEL1 ORIGINALLY
LR_LABEL1->set_layout_data( GRID_DATA ).
there is no runtime error but in UI it shows only 2 lables instead of one label and one inputfield.
The class where exception is trigered is called only 2 times.
What am I doing wrong here?
Thanks,
Anubhav
HI,
You will have to bind the input field to a context attribute.
DATA lr_label1 TYPE REF TO cl_wd_label.
DATA input1 TYPE REF TO cl_wd_input_field.
DATA grid_data TYPE REF TO cl_wd_grid_data.
DATA lcr TYPE REF TO cl_wd_transparent_container.
lcr ?= view->get_element( 'ROOTUIELEMENTCONTAINER' ).
input1 = cl_wd_input_field=>new_input_field( id = 'INP1'
BIND_VALUE = 'NODE4.ATT4' ). "This is where you have to add the binding code
grid_data = cl_wd_grid_data=>new_grid_data( input1 ).
input1->set_layout_data( grid_data ).
lr_label1 = cl_wd_label=>new_label(
id = 'LB1'
label_for = 'INP1'
text = 'LABEL1'
).
grid_data = cl_wd_grid_data=>new_grid_data( lr_label1 ).
lr_label1->set_layout_data( grid_data ).
lcr->add_child( lr_label1 ).
lcr->add_child( input1 ).
Thanks,
Aditya.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.