on 09-25-2008 10:17 AM
HI,
When i am declaring node and its element i am not getting proper reference. so when i use that element to access any method , it give null pointer error.
like,
my context got through service call , is like:
ZBAPI_FORWARD_WOR_1->node
IMPORTING_1 ->node
PERNR -> attribute
CHANGING_1 ->node
TT_WWID ->node
wi_id -> attribute
TT_WWID is table in bapi having cardianality 0..N
when i declare in code:
DATA:
NODE_ZBAPI_FORWARD_WOR_1 TYPE REF TO IF_WD_CONTEXT_NODE,
NODE_CHANGING_1 TYPE REF TO IF_WD_CONTEXT_NODE,
NODE_TT_WIID TYPE REF TO IF_WD_CONTEXT_NODE,
ELEM_TT_WIID TYPE REF TO IF_WD_CONTEXT_ELEMENT,
STRU_TT_WIID TYPE IF_MAIN=>ELEMENT_TT_WIID .
NODE_ZBAPI_FORWARD_WOR_1 =
WD_CONTEXT->GET_CHILD_NODE( NAME = IF_MAIN=>WDCTX_ZBAPI_FORWARD_WOR_1 ).
NODE_CHANGING_1 =
NODE_ZBAPI_FORWARD_WOR_1->GET_CHILD_NODE( NAME = IF_MAIN=>WDCTX_CHANGING_1 ).
NODE_TT_WIID =
NODE_CHANGING_1-GET_CHILD_NODE( NAME = IF_MAIN=>WDCTX_TT_WIID ).
ELEM_TT_WIID = NODE_TT_WIID->GET_ELEMENT( ).
CALL METHOD ELEM_TT_WIID->SET_ATTRIBUTE
EXPORTING
VALUE = ITEM_WI_ID
NAME = 'WI_ID'.
I am not getting any refrence in elem_tt_wiid.....so i am getting error when access method set_attribute......
any idea?
thanks,
saurin shah.
by self
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi saurin,
Since u made the cardinality 0..n, the element will not be instantiated. So use create element method instead of get_element. First create a element and try to set the value to the created element.
Regards...
Arun.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi arun,
i did as u said.
Very helpful u r answer was...
will u tell me one thing pleaze , when i am having table with selection mode - multi . and the context node which binds to table having property , Cardinality 0...N & Selection 0...N to have multi selection on table.. but when i execute application, i can make multiple selection and data also comes to table bt it doesnt disply on table. at the end of table it shows no. of rows, there it shows how many data r there... so is there any idea........
Thanks,
saurin
HI ARUN,
METHOD EXECUTE_ZBAPI_CREATE_WORKITEML .
declarations for context navigation
DATA:
NODE_ZBAPI_CREATE_WORKITE TYPE REF TO IF_WD_CONTEXT_NODE.
DATA:
NODE_CHANGING TYPE REF TO IF_WD_CONTEXT_NODE.
DATA:
NODE_WORKITEM TYPE REF TO IF_WD_CONTEXT_NODE.
DATA:
NODE_IMPORTING TYPE REF TO IF_WD_CONTEXT_NODE.
DATA:
LRI_ELEMENT TYPE REF TO IF_WD_CONTEXT_ELEMENT,
LOA_ELEMENTS TYPE WDR_CONTEXT_ELEMENT_SET.
declarations for fuba parameters
DATA:
ATTR_PERNR TYPE PA0001-PERNR.
DATA:
COPY_C_WORKITEM TYPE IF_COMPONENTCONTROLLER=>ELEMENTS_WORKITEM,
STRU_C_WORKITEM TYPE IF_COMPONENTCONTROLLER=>ELEMENTS_WORKITEM,
ITAB_C_WORKITEM LIKE LINE OF STRU_C_WORKITEM.
get all involved child nodes
NODE_ZBAPI_CREATE_WORKITE = WD_CONTEXT->GET_CHILD_NODE( `ZBAPI_CREATE_WORKITE` ).
NODE_CHANGING = NODE_ZBAPI_CREATE_WORKITE->GET_CHILD_NODE( `CHANGING` ).
NODE_WORKITEM = NODE_CHANGING->GET_CHILD_NODE( `WORKITEM` ).
NODE_IMPORTING = NODE_ZBAPI_CREATE_WORKITE->GET_CHILD_NODE( `IMPORTING` ).
CLEAR LOA_ELEMENTS. REFRESH LOA_ELEMENTS.
get input from context
NODE_IMPORTING->GET_ATTRIBUTE(
EXPORTING
NAME = `PERNR`
IMPORTING
VALUE = ATTR_PERNR ).
******THIS IS MY BAPI GIVE ME OUTPUT************
CALL FUNCTION 'ZBAPI_CREATE_WORKITEMLIST'
EXPORTING
PERNR = ATTR_PERNR
TABLES
WORKITEM = STRU_C_WORKITEM .
NODE_WORKITEM->BIND_TABLE( STRU_C_WORKITEM[] ).
ENDMETHOD.
THANKS,
SAURIN SHAH
Hi Saurin,
NODE_ZBAPI_FORWARD_WOR_1 =
WD_CONTEXT->GET_CHILD_NODE( NAME = IF_MAIN=>WDCTX_ZBAPI_FORWARD_WOR_1 ).
instead writing like ablove you can use node name directly.
NODE_ZBAPI_FORWARD_WOR_1 =
WD_CONTEXT->GET_CHILD_NODE( ' ZBAPI_FORWARD_WOR_1' ).
if you want to read the sub node tt_wid directly you can use this method.
NODE_TT_WIID = wd_context->path_get_node('NODE_ZBAPI_FORWARD_WOR_1.NODE_CHANGING_1.NODE_TT_WIID').
thanks
Suman
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Saurin,
ELEM_TT_WIID = NODE_TT_WIID->GET_ELEMENT( ).
CALL METHOD ELEM_TT_WIID->SET_ATTRIBUTE
EXPORTING
VALUE = ITEM_WI_ID
NAME = 'WI_ID'.
your code is correct nothing wrong there.I want to know how many attributes you have under the node node_tt_wiid.
you can also write like this ...
if you want to set the value to first attribute of node.
ELEM_TT_WIID = NODE_TT_WIID->GET_ELEMENT( 1 ).
CALL METHOD ELEM_TT_WIID->SET_ATTRIBUTE
EXPORTING
VALUE = ITEM_WI_ID
NAME = 'WI_ID'.
( OR )
l_node = wd_context->get_child_node( 'NODE1' ).
l_node->set_static_attributes( static_attributes = l_my_struc ).
thanks
Suman
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
6 | |
6 | |
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.