on 08-08-2011 8:47 AM
Hi All,
I am having task. I should create a normal table( Through Coding) in SAP Web dynpro, is this possible? If this is possible pls let me know immediately.
Edited by: csekrishnan on Aug 8, 2011 9:48 AM
hello Krishnan,
You can dynamically create table via coding. here is the code snippet to create a table with one column under the RootUIelementcontainer
data lo_container type ref to cl_wd_transparent_container.
data lo_table type ref to cl_wd_table.
data lo_flow_data type ref to cl_wd_flow_data.
data lo_column type ref to cl_wd_table_column.
data lo_text_view type ref to cl_wd_text_view.
data lo_header type ref to cl_wd_caption.
"Get the container Element
lo_container ?= view->get_element( 'ROOTUIELEMENTCONTAINER' ).
"Create new Table
lo_table = cl_wd_table=>new_table(
bind_data_source = 'ALV_TABLE' "context node path
view = view ).
"Setting flow data for the table
lo_flow_data = cl_wd_flow_data=>new_flow_data( lo_table ).
lo_table->set_layout_data( the_layout_data = lo_flow_data ).
"Creating Table column
lo_column = cl_wd_table_column=>new_table_column( view = view ).
"Creating table cell editor
lo_text_view = cl_wd_text_view=>new_text_view(
bind_text = 'ALV_TABLE.A1' "Path of the context attribute
view = view ).
"creating header for the table column
lo_header = cl_wd_caption=>new_caption(
text = 'Header'
view = view ).
"Setting cell editor and header for the column
lo_column->set_table_cell_editor( lo_text_view ).
lo_column->set_header( lo_header ).
"Adding the column to the table
lo_table->add_column( the_column = lo_column ).
"Adding the table to the container
lo_container->add_child( the_child = lo_table ).
BR, Saravanan.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Saravanan,
Your code is working fine. Now i have another requirement, dynamically column should get displayed.
Ex: In VBAK Table, there are so many columns i should displayed as same as in database table. It should be displayed in Normal table not in ALV.
Kindly let know as soon as possible.
Hello Krishnan,
do you want to dynamically create the context as well? If you want to dynamically create the context then go through this e-Learning session
http://www.sdn.sap.com/irj/scn/elearn?rid=/library/uuid/201ddd3b-b4ce-2b10-8883-880ae8147f89
Once the context available, then you read the attributes in the context via node info and then create the columns dynamically based on the attributes in the context
data lo_node type ref to if_wd_context_node.
data lo_node_info type ref to if_wd_context_node_info.
lo_node = wd_context->get_child_node( <node_name> ).
lo_node_info = lo_node->get_node_info( ).
data lt_attributes type WDR_CONTEXT_ATTR_INFO_MAP.
lt_attributes = lo_node_info->get_attributes( ).
"loop thru lt_attributes and create the table columns.
BR, Saravanan
PS. Please you one thread for one questions. you can start a new thread for new questions.
Hi csekrishnan,
why not?
Sure you can create a dynamic internal table with as many columns as you have rows in the original. Then transpose the values.
Question: As in each column, you may get mixed types, you will need to use a geberic, i.e. string type for all columns. The original column headres may become first column of transpose table.
Or what is the exact requirement, have an example?
Regards
Clemens
Hi Clemens,
Thanks for your reply. My requirement is different scenario.
Requirement:
In Employee Master, pls follow the below table.
In first internal table, the entries will be like this;
Client Employee Id Employee Name
100 01 Krishnan
100 02 Bala
100 03 Pradeep
While converting to another internal table the entries should be
Krishnan Bala Pradeep
100 100 100
01 02 03
Is this possible? <<Personal contact information removed>>
Note: In first internal table, the rows can be increamented to number of rows.
Edited by: csekrishnan on Aug 16, 2011 6:26 AM
Edited by: Matt on Aug 16, 2011 3:53 PM
yes krtishnan,
exactly what I said: As ALV and ABAP allow exactly one data type per column in an internal table and/or an ALV grid/list, you will have to use pure char or string type in the second table. This will have as many columns as row count in first table.
So what are your search result, what is existing code and where did you get stuck?
If you want a private answer to your private mail account, this will help nobody except you. If you want my account number to send an initial transfer, please ask for this.
Regards
Clemens
Hi Krishnan,
right now I have to system access and time to check it out, probably its similar as in CL_SALV
METHOD set_columns.
*
*...Get all the Columns
DATA: lo_cols TYPE REF TO cl_salv_columns.
lo_cols = o_alv->get_columns( ).
*
* set the Column optimization
lo_cols->set_optimize( 'X' ).
*
*...Process individual columns
DATA: lo_column TYPE REF TO cl_salv_column.
*
* Change the properties of the Columns KUNNR
TRY.
lo_column = lo_cols->get_column( 'KUNNR' ).
lo_column->set_long_text( 'Sold-To Party' ).
lo_column->set_medium_text( 'Sold-To Party' ).
lo_column->set_short_text( 'Sold-To' ).
lo_column->set_output_length( 10 ).
CATCH cx_salv_not_found. "#EC NO_HANDLER
ENDTRY.
*
ENDMETHOD. "SET_COLUMNS
In web dynpro, names are like CL_SALV_WD_COLUMN, the rest should be almost the same. Let me know if you can use it to set column headers.
Regards
Clemens
User | Count |
---|---|
88 | |
23 | |
11 | |
9 | |
8 | |
5 | |
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.