on 02-03-2011 8:20 AM
Hi all,
can any one tell me how to display data in a table when user click on a button. i have created a node with a set of fields from different tables now how to write the logic to display data in that table.
Thanks & Regards,
Naveen
Hi
In the eventhandler of the button's action.
create an internal table of structure similar to the node structure and then
fill this internal table using the select statement ( using corresponding fields )
ater that bind the node to the internal table using the statement BInd_table.
Here is the sample code for the same.
my node name is dealer1 and i am filling it from a table Zdealer
DATA lo_nd_dealer1 TYPE REF TO if_wd_context_node.
DATA lt_dealer1 TYPE wd_this->elements_dealer1. "internal table
* navigate from <CONTEXT> to <DEALER1> via lead selection
lo_nd_dealer1 = wd_context->get_child_node( name = wd_this->wdctx_dealer1 ).
select * from zdealer into table lt_dealer1.
lo_nd_dealer1->bind_table( lt_dealer1 ).
thanks
sarbjeet singh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sarbjeet can u tell me why u have this syntax
when we have to use this syntax?
DATA lt_dealer1 TYPE wd_this->elements_dealer1.
when we have to use this syntax?
lo_nd_dealer1 = wd_context->get_child_node( name = wd_this->wdctx_dealer1 ).
when we have to use this syntax?
lo_nd_dealer1->bind_table( lt_dealer1 ).
DATA lt_dealer1 TYPE wd_this->elements_dealer1.
this statement is creating one internal table with structure same as the node dealer1.
it will have all the context attribute as the fields in this table.
dealer1 has attribute like A, B , C, D
then it will create one table with all the fields a, b, c, d
lo_nd_dealer1 = wd_context->get_child_node( name = wd_this->wdctx_dealer1 ).
here we are setting the value in the variable of type node.
lo_nd_Dealer intially we create a variable of type if_wd_context_node.
then we are assigning some node to it.
you can also use thi statement like this.
lo_nd_dealer1 = wd_context->get_child_node( 'DEALER1' ).
here we are using the reference to the main context node using wd_context and then calling the method get_child_node
to access the child node by passing the parameter (child node 's name ) which is 'Dealer1'
lo_nd_dealer1->bind_table( lt_dealer1 ).
this particular statement calls the function bind_table to create elements for the node
this is useful when you fill a table first then bind it to node to create the elements.
then ssame numbe of rows will be created in the table bound to the node.
let me know if you need assistance in anything else.
Regards,
Sarbjeet singh
Hi Naveen,
when we have to use this syntax?
DATA lt_dealer1 TYPE wd_this->elements_dealer1.
The above statement is used to declare internal table as same as your context node.
Suppose if u want to create structre of same type use this, Instead of elements_dealer1 use element_dealer1.
DATA ls_dealer1 TYPE wd_this->element_dealer1.
lo_nd_dealer1 = wd_context->get_child_node( name = wd_this->wdctx_dealer1 ).
Above statement is used , using context reference getting child node.
lo_nd_dealer1->bind_table( lt_dealer1 ).
Above statement is used bind table with modified data. you are selecting data from ztable to this local table and binding this new table. Now you get populate data in table.
Thanks,
Kris.
Edited by: kissnas on Feb 3, 2011 10:24 AM
Hi naveen,
There are a few things you need to understand.
Here in web dynpro we are using class instance and there method to implement almost every thing.
Like you have created a context node. So now to work with this you need to instantiate this and after that you can use
any method under this.
So your context node is of type IF_WD_CONTEXT_NODE.
Now go to se24 and check that interface , what are the method you have there.
WD_THIS :- this is a referrence to the local interface. in particular view it act as a referrence of that view
ELEMENTS means that it a table of the type of that node.
ELEMENT means it like work area of that table or a structure.
When you declare :-
navigate from <CONTEXT> to <CTX_VN_STOCK> via lead selection
LO_ND_CTX_VN_STOCK = WD_CONTEXT->GET_CHILD_NODE( NAME = WD_THIS->WDCTX_CTX_VN_STOCK ).
WD_CONTEXT :- It is a referrence to the controller context of type IF_WD-CONTEXT_NODE.
WDCTX :- fro every node you created in context of a controller a constant with name WDCTX < node name > is automatically created.
In this line you are using the get child method of interface IF_WD_CONTEXT_NODE and you are inatansiating your declared
LO_ND_CTX_VN_STOCK.
Now you are able to use LO_ND_CTX_VN_STOCK.
LO_ND_CTX_VN_STOCK->BIND_TABLE( LT_CTX_VN_STOCK ).
In the above table you are binding the table with node. by doing this you are keeping data. In web dynpro you can only keep data in any node.
Reply in case of any issue.
All the best.
Thanks & Regards,
Monishankar C
hi naveen,
in web dynpro abap the data transfer from the screen and the data base is done via context node/attribute....so since you want to display the table with data ...
you will have a table in layout and corresponding node with which data will be given to be displayed..rite?
now since you will need a context node for displaying a data you will read that node as table operation....
once you read that node you will get all the data in the internal table now you will have to show this in layout do achieve this goal you will have to bind the internal table using bind_table...
hope this information may be helpfull to you.
regards,
sahai.s
Hi Sarbjeet,
i have taken one example that i have created one structure which contains the fields from vbaak and vbap
from vbak i have taken the fields vbeln erdat ernam
from vbap i have taken the fields posnr matnr
now i have created a structure with the fields and i have created a node and perform contex binding to table.
now i have created a button and action.
now my requirement is when user click on the button it should display data in the table.
can u tell me how to write logic in the action.
Thanks & Regards,
Naveen
Hi,
i have taken one example that i have created one structure which contains the fields from vbaak and vbap
from vbak i have taken the fields vbeln erdat ernam
from vbap i have taken the fields posnr matnr
now i have created a structure with the fields and i have created a node and perform contex binding to table.
now i have created a button and action.
now my requirement is when user click on the button it should display data in the table.
can u tell me how to write logic in the action.
Thanks & Regards,
Naveen
HI
suppose your node name is VBKP having the fields as attributes with same names i.e. vblen, erdat,ernam, etc.
then in the eventhandler of the button you can write the following code.
DATA lo_nd_vbkp TYPE REF TO if_wd_context_node.
DATA lt_vbkp TYPE wd_this->Elements_vbkp.
* navigate from <CONTEXT> to <VBKP> via lead selection
lo_nd_vbkp = wd_context->get_child_node( name = wd_this->wdctx_vbkp ).
select vbak~vblen vbak~erdat vbak~ernam vbap~posnr vbap~matnr into table lt_vbkp from vbak join vbap
on vbak~vblen = vbap~vblen.
lo_nd_vbkp->bind_table( new_items = lt_vbkp set_initial_elements = abap_false ).
Thanks
Sarbjeet SIngh
HI,
HERE YOU WILL BE NEEDING JOIN QUERY TO SELECT DATA AND REMEMBER THAT JOIN QUERY CAN ONLY BE IMPLEMENTED IF BOTH THE TABLES HAVE ATLEAST ONE FIELD IN COMMON IN YOU CASE THAT FIELD IS VBLEN
NOW AS YOU TOLD YOU HAVE CREATED THE NODE NAME SAY IT IS NODE1.
suppose your node name is VBKP having the fields as attributes with same names i.e. vblen, erdat,ernam, etc.
then in the eventhandler of the button you can write the following code.
DATA lo_nd_NODE1 TYPE REF TO if_wd_context_node.
DATA lt_NODE1 TYPE wd_this->Elements_NODE1.
* navigate from <CONTEXT> to <NODE1> via lead selection
lo_nd_NODE1 = wd_context->get_child_node( name = wd_this->wdctx_NODE1 ).
*SELECTING THE FIELDS FROM BOTH THE TABLES ALSO NO=TE HERE ADDITIONAL FIELD VBLEN IS USED AS IT IS PRESENT IN BOTH THE TABLES.
select vbak~vblen vbak~erdat vbak~ernam vbap~posnr vbap~matnr into table lt_NODE1 from vbak join vbap
on vbak~vblen = vbap~vblen.
lo_nd_NODE1->bind_table( new_items = lt_NODE1 set_initial_elements = abap_false ).
THANKS AND REGARDS,
SAHAI.S
Hi sahai,
this is the table name /BIC/AGLDCPRTS00 in BW system.
i have created one button in that action i have implemented the following code.
and i have kept the cc-0.n sc -0.1. but when i am performing action on the button it is not displaying data can u check what is the wrong in the code.
DATA lo_nd_professionaltable TYPE REF TO if_wd_context_node.
DATA lo_el_professionaltable TYPE REF TO if_wd_context_element.
DATA ls_professionaltable TYPE wd_this->ElementS_professionaltable. " declaring internaltable
navigate from <CONTEXT> to <PROFESSIONALTABLE> via lead selection
lo_nd_professionaltable = wd_context->get_child_node( name = wd_this->wdctx_professionaltable ).
get element via lead selection
lo_el_professionaltable = lo_nd_professionaltable->get_element( ).
@TODO handle not set lead selection
IF lo_el_professionaltable IS INITIAL.
ENDIF.
get all declared attributes
lo_el_professionaltable->get_static_attributes(
IMPORTING
static_attributes = ls_professionaltable ).
SELECT /BIC/WRATEGRP /BIC/WPCSLEVEL DATEFROM DATETO /BIC/WSTRATE /BIC/WOHRTE1 /BIC/WOHRTE2 /BIC/WOHRTE3 FROM /BIC/AGLDCPRTS00 INTO TABLE ls_professionaltable.
lo_nd_professionaltable->bind_table( new_items = ls_professionaltable set_initial_elements = abap_false ). " binding the table
Hi sarbajeet,
this is the table name /BIC/AGLDCPRTS00 in BW system.
i have created one button in that action i have implemented the following code.
and i have kept the cc-0.n sc -0.1. but when i am performing action on the button it is not displaying data can u check what is the wrong in the code.
DATA lo_nd_professionaltable TYPE REF TO if_wd_context_node.
DATA lo_el_professionaltable TYPE REF TO if_wd_context_element.
DATA ls_professionaltable TYPE wd_this->ElementS_professionaltable. " declaring internaltable
navigate from <CONTEXT> to <PROFESSIONALTABLE> via lead selection
lo_nd_professionaltable = wd_context->get_child_node( name = wd_this->wdctx_professionaltable ).
get element via lead selection
lo_el_professionaltable = lo_nd_professionaltable->get_element( ).
@TODO handle not set lead selection
IF lo_el_professionaltable IS INITIAL.
ENDIF.
get all declared attributes
lo_el_professionaltable->get_static_attributes(
IMPORTING
static_attributes = ls_professionaltable ).
SELECT /BIC/WRATEGRP /BIC/WPCSLEVEL DATEFROM DATETO /BIC/WSTRATE /BIC/WOHRTE1 /BIC/WOHRTE2 /BIC/WOHRTE3 FROM /BIC/AGLDCPRTS00 INTO TABLE ls_professionaltable.
lo_nd_professionaltable->bind_table( new_items = ls_professionaltable set_initial_elements = abap_false ). " binding the table
Hi monishankar,
this is the table name /BIC/AGLDCPRTS00 in BW system.
i have created one button in that action i have implemented the following code.
and i have kept the cc-0.n sc -0.1. but when i am performing action on the button it is not displaying data can u check what is the wrong in the code.
DATA lo_nd_professionaltable TYPE REF TO if_wd_context_node.
DATA lo_el_professionaltable TYPE REF TO if_wd_context_element.
DATA ls_professionaltable TYPE wd_this->ElementS_professionaltable. " declaring internaltable
navigate from <CONTEXT> to <PROFESSIONALTABLE> via lead selection
lo_nd_professionaltable = wd_context->get_child_node( name = wd_this->wdctx_professionaltable ).
get element via lead selection
lo_el_professionaltable = lo_nd_professionaltable->get_element( ).
@TODO handle not set lead selection
IF lo_el_professionaltable IS INITIAL.
ENDIF.
get all declared attributes
lo_el_professionaltable->get_static_attributes(
IMPORTING
static_attributes = ls_professionaltable ).
SELECT /BIC/WRATEGRP /BIC/WPCSLEVEL DATEFROM DATETO /BIC/WSTRATE /BIC/WOHRTE1 /BIC/WOHRTE2 /BIC/WOHRTE3 FROM /BIC/AGLDCPRTS00 INTO TABLE ls_professionaltable.
lo_nd_professionaltable->bind_table( new_items = ls_professionaltable set_initial_elements = abap_false ). " binding the table
Hi
1. Your node professionaltable should have all these attributes means there types should be same to these fields.
/BIC/WRATEGRP /BIC/WPCSLEVEL DATEFROM DATETO /BIC/WSTRATE /BIC/WOHRTE1 /BIC/WOHRTE2 /BIC/WOHRTE3
2.
put a creak point at the selct statement and check in teh debugging mode,
is your internal table is gettign any values.
Thanks
sarbjeet singh
SELECT /BIC/WRATEGRP /BIC/WPCSLEVEL DATEFROM DATETO /BIC/WSTRATE /BIC/WOHRTE1 /BIC/WOHRTE2 /BIC/WOHRTE3 FROM /BIC/AGLDCPRTS00 INTO TABLE ls_professionaltable.
firstly
/BIC/AGLDCPRTS00 ....check whether this has value or not in db?
secondly
just tell after debugging that ls_professionaltable table has how many fields and what are they?
regards,
sahai.s
DATA lo_nd_professionaltable TYPE REF TO if_wd_context_node.
DATA lo_el_professionaltable TYPE REF TO if_wd_context_element.
DATA ls_professionaltable TYPE wd_this->ElementS_professionaltable. "internaltable
TYPES: BEGIN OF TY_PFTAB,
RATEGROUP TYPE /BIC/OIWRATEGRP,
LEVEL TYPE /BIC/OIWPCSLEVEL,
FROMDATE TYPE /BI0/OIDATEFROM,
FROMTO TYPE /BI0/OIDATETO,
STANDARD TYPE /BIC/OIWSTRATE,
OVERHEAD1 TYPE /BIC/OIWOHRTE1,
OVERHEAD2 TYPE /BIC/OIWOHRTE2,
OVERHEAD3 TYPE /BIC/OIWOHRTE3,
EXCEPTIONFLAG TYPE /BIC/OIMSECFILER,
END OF TY_PFTAB.
DATA : IT_PFTABLE TYPE STANDARD TABLE OF TY_PFTAB,
WA_PFTAB TYPE TY_PFTAB.
SELECT /BIC/WRATEGRP /BIC/WPCSLEVEL DATEFROM DATETO /BIC/WSTRATE /BIC/WOHRTE1 /BIC/WOHRTE2 /BIC/WOHRTE3
FROM /BIC/AGLDCPRTS00 INTO TABLE IT_PFTABLE.
*TYPES : BEGIN OF TY_EXCEPTION,
EXCEPTIONFLAG TYPE /BIC/OIMSECFILER,
END OF TY_EXCEPTION.
*
*DATA : IT_EXTABLE TYPE STANDARD TABLE OF TY_EXCEPTION,
WA_EXTABLE TYPE IT_EXTABLE.
*
*SELECT /BIC/MSECFILER FROM /BIC/AGLDCLMLT00 INTO TABLE IT_EXTABLE.
navigate from <CONTEXT> to <PROFESSIONALTABLE> via lead selection
lo_nd_professionaltable = wd_context->get_child_node( name = wd_this->wdctx_professionaltable ).
*
*
get element via lead selection
lo_el_professionaltable = lo_nd_professionaltable->get_element( ).
*
@TODO handle not set lead selection
IF lo_el_professionaltable IS INITIAL.
ENDIF.
*
get all declared attributes
lo_el_professionaltable->get_static_attributes(
IMPORTING
static_attributes = ls_professionaltable ).
lo_nd_professionaltable->bind_table( new_items = IT_PFTABLE set_initial_elements = abap_false ).
>
> hi sarbjeet,
> with the code i am able to display data in the table .
>
> can u tell me the debugging steps how to debug a webdynpro component.
>
> Thanks & Regards,
> Naveen
means your problem is solved and now it is showing the data in the table.
if not then as i told you check the types of all the attributes in the node.
and as far as debugging a wd comp is concerned it is similar to debugging a abap report.
put the breakpoint (external break point) on any line in the code . here in your case on the line with select statement.
then just run the applciation and it wil stop there
then use F5 to procedd step by step.
thanks
sarbjeet singh
Hi Naveen,
See if this fits your need to create table from node Dynamically.
cl_wd_dynamic_tool=>create_table_from_node( )
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
In order to display the data in the table on click of a button , u need to code in the event handler of the button.
we need to populate your node and bind it to the table.
eg.(here main is my node and zhr_main is my table)
DATA node_main TYPE REF TO if_wd_context_node.
DATA lo_el_main TYPE REF TO if_wd_context_element.
DATA: lt_stru_main TYPE TABLE OF zhr_main .//define a structure of type of your table
navigate from <CONTEXT> to <MAIN> via lead selection
node_main = wd_context->get_child_node( name = wd_this->wdctx_main ).
@TODO handle non existant child
IF node_main IS INITIAL.
ENDIF.
get element via lead selection
lo_el_main = node_main->get_element( ).
@TODO handle not set lead selection
IF lo_el_main IS INITIAL.
ENDIF.
CALL METHOD node_main->get_static_attributes_table
EXPORTING
FROM = 1
TO = 2147483647
IMPORTING
table = lt_stru_main
.
//populate your lt_stru_main
select * from zhr_main into lt_stru_main.
//bind it to the table
call method node_main->bind_table
exporting
new_items = lt_stru_main.
SET_INITIAL_ELEMENTS = ABAP_TRUE
INDEX =
.
Regards,
Mayank
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey naveen ,
To implement this wht you need to do is simply in the action of your button you have to populate the table .
Check inn your node cardinality = 0..n.
Go to the action of your button. ;-
Here you need to two thing.
1. Declare a internal table of your node and indtantiate this and fill values in this.
2. bind the internal table with your node.
for 1. Go to code wizard ( magic wand button ).
Select your node and check option of as a table .
It will automatically generate some code like.
DATA LO_ND_CTX_VN_STOCK TYPE REF TO IF_WD_CONTEXT_NODE. " nose CTX_VN_STOCK
DATA LT_CTX_VN_STOCK TYPE WD_THIS->ELEMENTS_CTX_VN_STOCK. "internal table
navigate from <CONTEXT> to <CTX_VN_STOCK> via lead selection
LO_ND_CTX_VN_STOCK = WD_CONTEXT->GET_CHILD_NODE( NAME = WD_THIS->WDCTX_CTX_VN_STOCK ).
after that populate internal table with values.
select * from your db table or any other into table LT_CTX_VN_STOCK .
for 2. Just you bind the table with the appropriate node.
LO_ND_CTX_VN_STOCK->BIND_TABLE( LT_CTX_VN_STOCK ).
it will do as you required ...
I am assuming you have taken a table in your view layout and crate a binding with your required node.
Thanks & Regards,
Monishankar C
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
9 | |
7 | |
7 | |
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.