on 12-31-2008 11:45 AM
Hi
Im working on Web Dynpro for ABAP Application where Im using dynamic programming.
I've created node and attributes dynamically (using ADD_NEW_CHILD_NODE & ADD_ATTRIBUTE methods resp.) & bound the dynamically created Textedit UI elements to those attributes. The application is running fine upto this.
Now I want to get the text entered in textedit field from the context. For this I'm using GET_ATTRIBUTE method. Here Im getting dump with error message 'Could not find attribute V_TEST.1.CN_INPUT.1.ATTR11 '. When I debug the GET_ATTRIBUTE method, I found out that the internal table DYNAMIC_ATTRIBUTES is initial. The internal table ATTRIBUTES->* is getting populated in the metod ADD_ATTRIBUTE.
Pls suggest the solution or any alternative method for this.
Hi ,
this is happening because the attributes are added dynamically . to get the attribute value at runtime u have to follow the below procedure .
DATA : LR_ROOT_INFO TYPE REF TO IF_WD_CONTEXT_NODE_INFO ,
LR_NODE_INFO TYPE REF TO IF_WD_CONTEXT_NODE_INFO,
LR_STRUCTDESCR TYPE REF TO CL_ABAP_STRUCTDESCR ,
LS_COMPONENT TYPE CL_ABAP_STRUCTDESCR=>COMPONENT,
LT_COMPONENTS TYPE CL_ABAP_STRUCTDESCR=>COMPONENT_TABLE,
LR_TYPE TYPE REF TO CL_ABAP_DATADESCR .
LR_TYPE ?= cl_abap_TYPEdescr=>describe_by_name( p_name = 'MATNR' ).
LS_COMPONENT-NAME = 'MATNR'.
LS_COMPONENT-TYPE = LR_TYPE .
APPEND LS_COMPONENT TO LT_COMPONENTS.
LR_TYPE ?= cl_abap_TYPEdescr=>describe_by_name( p_name = 'MAKTX' ).
LS_COMPONENT-NAME = 'MAKTX'.
LS_COMPONENT-TYPE = LR_TYPE .
APPEND LS_COMPONENT TO LT_COMPONENTS.
CALL METHOD cl_abap_structdescr=>create
EXPORTING
p_components = LT_COMPONENTS
receiving
p_result = LR_STRUCTDESCR
.
CATCH cx_sy_struct_creation .
*ENDTRY.
LR_ROOT_INFO = WD_CONTEXT->GET_NODE_INFO( ).
CALL METHOD lr_root_info->add_new_child_node
498 EXPORTING
499 * supply_method =
500 * supply_object =
501 * dispose_method =
502 * dispose_object =
503 * static_element_type =
504 name = 'DATA' " NODE NAME
505 * is_mandatory = ABAP_FALSE
506 * is_mandatory_selection = ABAP_FALSE
507 * is_multiple = ABAP_TRUE
508 * is_multiple_selection = ABAP_TRUE
509 * is_singleton = ABAP_FALSE
510 is_initialize_lead_selection = ABAP_false
511 static_element_rtti = LR_STRUCTDESCR
512 * is_static = ABAP_TRUE " ADD ATTRIBUTE AS STATIC
513 * attributes =
514 receiving
515 child_node_info = LR_NODE_INFO .
Regards
Yash
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Yash,
First of all thank you very much for your reply.....
I tried the code given by you. After creating node (DATA) & attibute (MATNR & MAKTX) dynamically, I dynamically created one text edit with following code:
LR_TEXT_EDIT = CL_WD_TEXT_EDIT=>NEW_TEXT_EDIT( BIND_VALUE = 'DATA.MATNR' ).
CL_WD_MATRIX_HEAD_DATA=>NEW_MATRIX_HEAD_DATA( ELEMENT = LR_TEXT_EDIT ).
LR_CONTAINER->ADD_CHILD( THE_CHILD = LR_TEXT_EDIT ).
& then tried to get the value of attribute MATNR with following code:
LR_NODE = WD_CONTEXT->GET_CHILD_NODE( NAME = 'DATA' ).
LR_ELEMENT = LR_NODE->GET_ELEMENT( ).
LR_ELEMENT->GET_ATTRIBUTE(
EXPORTING
NAME = 'MATNR'
IMPORTING
VALUE = CONTENT ).
It gave me following error at runtime:
'Access via 'NULL' object reference not possible.'
Then I commented following code
LR_NODE = WD_CONTEXT->GET_CHILD_NODE( NAME = 'DATA' ).
LR_ELEMENT = LR_NODE->GET_ELEMENT( ).
LR_ELEMENT->GET_ATTRIBUTE(
EXPORTING
NAME = 'MATNR'
IMPORTING
VALUE = CONTENT ).
This time it gave me following error at runtime:
'The lead selection has not been set. V_TEST'
(V_TEST this is the name of the view)
I tried some combinations for the following
IS_MANDATORY = ABAP_FALSE
IS_MANDATORY_SELECTION = ABAP_FALSE
IS_MULTIPLE = ABAP_TRUE
IS_MULTIPLE_SELECTION = ABAP_FALSE
IS_INITIALIZE_LEAD_SELECTION = ABAP_TRUE
it didnt work......
Pls suggest the solution.......
Regards,
Saket.
User | Count |
---|---|
84 | |
24 | |
11 | |
9 | |
7 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.