on 12-16-2011 10:02 AM
Hi,
I've made a method in an ABAP Web Dynpro that returns a table taken from the database via a SELECT statement.
The table that is returned by the method is of TYPE ZTESTTABLE.
I've created in my context a node with the wizard Attributes from Component of Structure passing ZTESTTABLE as the structure.
Now I've tried to get the context node filled with values with the BIND_TABLE method on the context node, but I get a type mismatch error.
Can someone help me?
Thank you,
Pietro
Have you selected all the feilds of that structure or only a few fields are selected?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In that case..When you read the context there will be an Internal table gets declared as ELEMENTS->NODENAME.
You got another internal table from the some method of that ztest.. right..
Now...
ITAB is of type the table that has data returnd from your method and ITAB1 is of CONTEXTNODE internal table type.
You need to explicity fill the Node related internal table as you have used only a some of the columns.
LOOP AT ITAB into WA_TAB.
move-corresponding fields of WA_TAB to WA_TAB1.
append WA_TAB1 to IT_TAB1.
ENDLOOP.
lo_node->bind_table( IT_TAB1 ).
Regards,
Lekha.
Hi Lekha,
thank you for your suggestion. Unfortunately, I'm still having troubles (bear in mind that I'm a beginner to ABAP since I've only made Java Web Dynpros).
This is the code snippet that gets the data from the assistance class and map it to the context:
DATA : lo_nd_richieste_prov_ec TYPE REF TO if_wd_context_node,
richieste_prov_ctx TYPE wd_this->elements_richieste_prov_ec,
richieste_prov_tab TYPE zhr_pa_han_rich.
lo_nd_richieste_prov_ec = wd_context->get_child_node( name = wd_this->wdctx_richieste_prov_ec ).
richieste_prov_tab = wd_assist->retrieve_richieste_provvidenza( ).
????? (richieste_prov_tab >>> richieste_prov_ctx)
lo_nd_richieste_prov_ec->bind_table( new_items = richieste_prov_ctx set_initial_elements = abap_true ).
I've tried using your LOOP AT code in the middle part (?????) but the problem is that I get the error that richieste_prov_tab is not an internal table. Is there a way to copy values from richieste_prov_tab to richieste_prov_ctx without having to declare additional variables?
Thank you again,
Pietro
DATA :
lo_nd_richieste_prov_ec TYPE REF TO if_wd_context_node,
richieste_prov_ctx TYPE wd_this->elements_richieste_prov_ec, "internal table of node type
richieste_prov_ctx_wa TYPE wd_this->element_richieste_prov_ec, "structure of node type
richieste_prov_tab TYPE zhr_pa_han_rich. u201CIs this a table type
richieste_prov_tab_wa TYPE zhr_pa_han_rich_XXX. u201CGIVE the structure type of
that table type
lo_nd_richieste_prov_ec = wd_context->get_child_node( name = wd_this->wdctx_richieste_prov_ec ).
richieste_prov_tab = wd_assist->retrieve_richieste_provvidenza( ).
LOOP at richieste_prov_tab into richieste_prov_tab_wa.
Move-corresponding field s of richieste_prov_tab_wa to richieste_prov_ctx_wa .
Append richieste_prov_ctx_wa to richieste_prov_ctx.
Clear: richieste_prov_ctx_wa , richieste_prov_tab_wa.
ENDLOOP.
lo_nd_richieste_prov_ec->bind_table( new_items = richieste_prov_ctx set_initial_elements = abap_true ).
Is zhr_pa_han_rich a table type. If yes then the variable decalred using this acts as an internal table , If it is a structure, then it doesnot act as an internal table. Please clarify this so that the code can be changed accordingly.
Regards,
Lekha.
I've managed to make it work.
I've declared a custom type in the public section of my assistance class of TYPE STANDARD TABLE OF zhr_pa_han_rich WITH KEY key1 key2 key3
I was wondering if there could be a way to avoid specifying the table keys in order to avoid to change the code if the table zhr_pa_han_rich is changed.
If you know that the method always returns a single record then it is better to make it as a structure.. if you want to return the internal table data either import or export to a method, in that case it will always take a table type. Create a table type using that structure either in SE11 or using the way you declared at class public section level.
Regards,
Lekha.
User | Count |
---|---|
83 | |
24 | |
12 | |
9 | |
7 | |
6 | |
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.