on 01-19-2011 7:30 AM
Hi All,
I am new to dynpro, please help in this...
I have one table with tool bar buttons. Initial i want to display empty table with toolbar buttons only. when i click button i want to add one record. how to do this. any helping code pelase..
thanks,
Madhan.
hello madhan,
in a the table ui element must be binded to the node for populating values in it....because the flow of value in web dynpro abap is maintained through the context.
now coming to your case...
the table is to display one row everytime a button is clicked rite...so when i click it for first time the first data is diplayed and when i click it for the second time second row is to be displayed..rite?
to show the data in the table we always bind an internal table with it rite.
so to achieve this you will have to play the trick here.
*1) you just fetch the data into an internal table say int1 generally we will bind this and whole data will be seen in the table but you dnt bind it instead you make a similar internal table say int2 and populate int2 from int1 using work area so that one row will reach at a time in int2.*
2) while bindin you bind int2 to the table so that first record can be shown....similarly you can use loop .....endloop to populate the entire int1 to int2...
do remember that you keep the code in modify_view so that the table will be refreshed and filled again.
hope you may solve you problem using the above logic as i have used it and it worked fr me.
thanks and regards,
sahai.s
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I hope you already created context node with some attributed and binded this node to the table datasource property.
1. Create action on toolbar button click from the properties.
2. In the Event handler write the following code.
data: lr_node type ref to if_wd_context_node,
ls_struc type if_<view_name>=>element_<node_name>.
lr_node = wd_context->get_child_node( if_<view_name>=>wdctx_<Node_name> ).
lr_node->bind_element( new_data = ls_struct set_initial_elements = abap_false ).
View_name is the your view name and Node_name is the node name which is binded to the table datasource property.
Abhi
hi madhan,
i hope you are using text_edit ui element as your cell editor in table ...so that user can enter the value now you just read the node with which you have binded your table ui element as as table opertaion (check out when you move to code wizard you will find a checkbox below the radio buttons)when you read the node you will be getting a code like
DATA LO_ND_CTX_VN_ALV_TABLE TYPE REF TO IF_WD_CONTEXT_NODE.
DATA LO_EL_CTX_VN_ALV_TABLE TYPE REF TO IF_WD_CONTEXT_ELEMENT.
DATA LS_CTX_VN_ALV_TABLE TYPE WD_THIS->ELEMENT_CTX_VN_ALV_TABLE.
DATA LT_CTX_VN_ALV_TABLE TYPE IF_SECOND_V=>ELEMENTS_CTX_VN_NODE1.
* navigate from <CONTEXT> to <ctx_vn_alv_table> via lead selection
LO_ND_CTX_VN_ALV_TABLE = WD_CONTEXT->GET_CHILD_NODE( NAME = WD_THIS->WDCTX_CTX_VN_ALV_TABLE ).
CALL METHOD LO_ND_CTX_VN_ALV_TABLE->GET_STATIC_ATTRIBUTES_TABLE
* EXPORTING
* FROM = 1
* TO = 2147483647
IMPORTING
TABLE = LT_CTX_VN_ALV_TABLE.
no w to update the database you use the following
MODIFY DATABASE_TABLE FROM TABLE LT_CTX_VN_ALV_TABLE.
also you can display an error message if something ges wrong like below
IF SY-SUBRC = 0.
DATA: L_CURRENT_CONTROLLER TYPE REF TO IF_WD_CONTROLLER.
DATA: L_MESSAGE_MANAGER TYPE REF TO IF_WD_MESSAGE_MANAGER.
L_CURRENT_CONTROLLER ?= WD_THIS->WD_GET_API( ).
CALL METHOD L_CURRENT_CONTROLLER->GET_MESSAGE_MANAGER
RECEIVING
MESSAGE_MANAGER = L_MESSAGE_MANAGER.
CALL METHOD L_MESSAGE_MANAGER->REPORT_SUCCESS
EXPORTING
MESSAGE_TEXT = 'DATA WAS SUCCESSFULLY SAVED'.
ELSE.
* get message manager
DATA LO_API_CONTROLLER TYPE REF TO IF_WD_CONTROLLER.
DATA LO_MESSAGE_MANAGER TYPE REF TO IF_WD_MESSAGE_MANAGER.
LO_API_CONTROLLER ?= WD_THIS->WD_GET_API( ).
CALL METHOD LO_API_CONTROLLER->GET_MESSAGE_MANAGER
RECEIVING
MESSAGE_MANAGER = LO_MESSAGE_MANAGER.
* report message
CALL METHOD LO_MESSAGE_MANAGER->REPORT_WARNING
EXPORTING
MESSAGE_TEXT = 'Data Not Saved Due to Some Error'.
ENDIF.
Hi Abhimanyu,
Thanks for your reply,
your code is for adding new record right. i want initially no records, i.e. empty table. i changed some properties to do this, but i am getting one record initially. but i dont want that record also. when i click add button then only i have to add record to the table..
or ( initialy that record in display mode, after clicking button that should be in edit mode....)
any help.. to get this
thanks,
madhan.
Edited by: MadhanSAP on Jan 19, 2011 11:22 AM
Hi,
Bind a table UI , datasource property to the context node. Obviously your context node does not have element.
So your table will be empty. There are properties for table to display empty rows yes or no.
Create a toolbar and buttons. When you press a button to add, Just insert a context_element to the context node.
This will automatically insert a row in a table.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
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.