on 11-02-2010 7:16 AM
Dear Web Dynpro ABAP Specialists,
i want to create an ALV Table Display from a field-symbol-based Table named is defined as "TYPE STANDARD TABLE".
This is a dynamical table which needs to be displayed, but how to do this if it´s not possible
to use the output via the context-hierarchy?
Thanks a lot in advance for your input.
Best regards
Carsten Klatt
hi, Carsten Klatt.
You should use Dynamic Context Node, not Dynamic ALV.
Instead, you can declare one ALV component usage in your WD application.
Then, you make use of your field-symbol-based Table named <lt_output> to create one dynamic context node, then set this context node to bind to your alv (just use: set_data(context_node) ).
So, your requirement will be simple that how to create your dynamic context node using field-symbol-based Table named <lt_output>.
So, you must know the COLUMN or structure of your table, maybe you can use the CL_ABAP_typedecr or the relevant class to know the structure dynamically.
Then you should create the table dynamically.
A part EXAMPLE:
DATA: ls_comp TYPE LINE OF cl_abap_structdescr=>component_table,
lt_comp TYPE cl_abap_structdescr=>component_table,
ls_fieldcat TYPE LINE OF lvc_t_fcat,
struct_type TYPE REF TO cl_abap_structdescr.
* Loop to build lt_comp
LOOP AT it_fieldcat INTO ls_fieldcat.
ls_comp-name = ls_fieldcat-fieldname.
ls_comp-type ?= cl_abap_typedescr=>describe_by_name( 'string' ).
APPEND ls_comp TO lt_comp.
ENDLOOP.
* Create structure defined in lt_comp
struct_type = cl_abap_structdescr=>create( lt_comp ).
* Append dynamic node with name ( PAID )
co_dynnode_info = co_parent_node_info->add_new_child_node(
name = iv_paid
is_mandatory = abap_true
is_multiple = abap_true
static_element_rtti = struct_type
is_static = abap_false ).
I am not sure whether it can fit your requirement.Hope it can help you a little.
Best wishes.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi,
here, the above coding is just one example.
"co_dynnode_info" is the NODE INFO.
If you want to define your dynamic context node as the child of "WD_CONTEXT", you can use:
"get node info
co_dynnode_info = wd_context->get_node_info.
"create dynamic node
......
"bind your newly dynamically created node to ALV
lo_alv_it->set_data( lo_node ).
Hope it can help you a little.
Best wishes.
The below example shows, design of a database utility which displays data of any database table present in SAP system. User has to input the database table name and hit enter on keyboard. On user action the data will be displayed in Webdynpro ALV.
Below are the steps
Step 1: Declare usage of ALV component (SALV_WD_TABLE) in Consumer Component (Our Component: YDEMO_DYNPRO1) in the properties tab.
Step 2: Declare the usage of ALV in the properties tab of COMPONENTCONTROLLER of consumer component.
Step 3: Create proxy object of ALV in the DOINIT of COMPONENT CONTROLLER.
Code snippet
data lo_cmp_usage type ref to if_wd_component_usage.
lo_cmp_usage = wd_this->wd_cpuse_dynmaic_alv( ).
if lo_cmp_usage->has_active_component( ) is initial.
lo_cmp_usage->create_component( ).
endif.
Step 4: Go to main view and create context attribute TABNAME (type : TABNAME) under Root context node.
Step 5: Go to layout tab of the MAIN view and create below UI elements
Step 6: Create Enter action for the input field
Step 7: Go to properties of MAIN view and add usage of INTERFACECONTROLLER of the ALV.
Step 8: Go to ONACTIONENTER method of MAIN view and add below code
The code is built by using following concepts
Code Snippet
method ONACTIONENTER .
**Step 1: Find the table name from the screen
DATA lo_el_context TYPE REF TO if_wd_context_element.
DATA ls_context TYPE wd_this->Element_context.
DATA lv_tabname TYPE wd_this->Element_context-tabname.
lo_el_context = wd_context->get_element( ).
lo_el_context->get_attribute(
EXPORTING
name = `TABNAME`
IMPORTING
value = lv_tabname ).
**Step 2: Dynamic Internal table to hold data which comes from DB
data : dyntab type REF TO data.
FIELD-SYMBOLS : <table> type ANY TABLE.
CREATE DATA dyntab type TABLE OF (lv_tabname).
ASSIGN dyntab->* TO <table>.
SELECT * UP TO 20 ROWS FROM (lv_tabname) INTO TABLE <table>.
**Step 3: Dynamic context node
data : lv_table type string.
lv_table = lv_tabname.
wd_context->get_node_info( )->ADD_NEW_CHILD_NODE(
STATIC_ELEMENT_TYPE = lv_table
NAME = lv_table
).
wd_context->get_child_node( lv_table )->BIND_TABLE(
NEW_ITEMS = <table>
* SET_INITIAL_ELEMENTS = ABAP_TRUE
* INDEX =
).
**Step 4: Assign this context to ALV
DATA lo_INTERFACECONTROLLER TYPE REF TO IWCI_SALV_WD_TABLE .
lo_INTERFACECONTROLLER = wd_this->wd_cpifc_dynmaic_alv( ).
lo_interfacecontroller->set_data(
* only_if_new_descr = " wdy_boolean
r_node_data = wd_context->get_child_node( lv_table ) " ref to if_wd_context_node
).
endmethod.
Step 9: Go to display mode and activate all the entities together. Select Activate at component level.
Output:
Message was edited by: Anurag Bajaj
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 | |
10 | |
7 | |
6 | |
6 | |
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.