03-24-2009 1:00 PM
Hi folks,
I have defined one parameter of a method signature as 'ANY TABLE', as the table structure differs. The implementation of this methods works fine, but if i copy the result to the exporting table parameter there will be only the first character of each table line.
What can i do, to copy the result lines without leaving structure information?
03-24-2009 1:36 PM
Can you show us your implementation and full signature of the method?
Regards,
Naimesh Patel
03-24-2009 1:36 PM
Can you show us your implementation and full signature of the method?
Regards,
Naimesh Patel
03-24-2009 1:44 PM
Of course:
Signature
E_FILE_TABLE TYPE ANY TABLE
Implementation
FIELD-SYMBOLS: [...]
<lt_table> TYPE STANDARD TABLE.
[...]
CREATE DATA lw_result_tab TYPE HANDLE lo_table_line.
ASSIGN lw_result_tab->* TO <wa_table> CASTING
TYPE HANDLE lo_table_line.
CREATE DATA lt_result_tab LIKE TABLE OF <wa_table>.
ASSIGN lt_result_tab->* TO <lt_table>.
[...]
INSERT LINES OF <lt_table> INTO TABLE E_FILE_TABLE.
03-24-2009 2:05 PM
I tried to replicate the error, but the code is working good for me.
Check this code of method:
*@79\QExporting@ ET_ANY_TAB TYPE ANY TABLE
*@79\QExporting@ ET_2ND_TAB TYPE REF TO DATA
FIELD-SYMBOLS: <lt_table> TYPE STANDARD TABLE.
DATA: struct_type TYPE REF TO cl_abap_structdescr,
comp_tab TYPE cl_abap_structdescr=>component_table,
comp LIKE LINE OF comp_tab,
dref TYPE REF TO data.
FIELD-SYMBOLS: <wa_table> TYPE ANY,
<comp> TYPE ANY.
comp-name = 'MATNR'.
comp-type = cl_abap_elemdescr=>get_c( 18 ).
APPEND comp TO comp_tab.
comp-name = 'MTART'.
comp-type = cl_abap_elemdescr=>get_c( 4 ).
APPEND comp TO comp_tab.
struct_type = cl_abap_structdescr=>create( comp_tab ).
CREATE DATA dref TYPE HANDLE struct_type.
ASSIGN dref->* TO <wa_table>
CASTING
TYPE HANDLE struct_type.
CREATE DATA et_2nd_tab LIKE TABLE OF <wa_table>.
ASSIGN et_2nd_Tab->* TO <lt_table>.
select matnr mtart
from mara
into table <lt_table>
up to 10 rows.
INSERT LINES OF <lt_table> INTO TABLE et_any_tab.
Testing program:
types: begin of ty_tab,
matnr type mara-matnr,
mtart type mara-mtart,
end of ty_tab.
data: lt_tab type standard table of ty_Tab.
data: lt_2nd_tab type ref to data.
zcl_test_Text=>GIVE_ANY_TAB(
importing
et_any_Tab = lt_Tab
et_2nd_Tab = lt_2nd_Tab ).
write: 'Test'.
I would suggest you to try without using the CASTING in the field-symbol.
Regards,
Naimesh Patel
03-24-2009 3:28 PM
When you call a method with an exporting parameter of type ANY TABLE, the structure of the table is controlled by the calling code, not the method.
Set a breakpoint at "INSERT LINE OF" in your method, and look at the structure of <lt_table> and e_file_table in debugger. From what you report, I'd guess e_file_table is somehow defined as a table with record type C length 1.
matt
03-25-2009 10:05 AM
Hi Matt,
You're completely right. I had missed to assign an internal table at method call.
Thanks for your help!