‎2007 Apr 11 1:28 PM
hai all,
i want to display the values of table dynamically..
i found some code but it's going to dump pls correct the error
DUMP SAYING***********88
The types of operands "dbtab" and "itab" cannot be converted into one another.
In a Unicode system, the type of the operand "dbtab" must be convertible
into that of the operand "itab" for the statement "SELECT * FROM dbtab INTO
TABLE itab". Regardless of the
length of a Unicode character, both operands must have the same
structure layout.
In this case, this condition has not been met.
*******************************************************************************
code:
type-pools : abap.
field-symbols: <dyn_table> type standard table,
<dyn_wa>,
<dyn_field>.
data: dy_table type ref to data,
dy_line type ref to data,
xfc type lvc_s_fcat,
ifc type lvc_t_fcat.
data : dy_db type ref to data.
selection-screen begin of block b1 with frame.
parameters: p_table LIKE dd02l-tabname.
selection-screen end of block b1.
start-of-selection.
TRANSLATE p_table TO UPPER CASE.
perform get_structure.
perform create_dynamic_itab.
perform get_data.
perform write_out.
*Write out data from table.
form write_out.
loop at <dyn_table> into <dyn_wa>.
do.
assign component sy-index
of structure <dyn_wa> to <dyn_field>.
if sy-subrc <> 0.
exit.
endif.
if sy-index = 1.
write:/ <dyn_field>.
else.
write: <dyn_field>.
endif.
enddo.
endloop.
endform.
form get_structure.
data : idetails type abap_compdescr_tab,
xdetails type abap_compdescr.
data : ref_table_des type ref to cl_abap_structdescr.
Get the structure of the table.
ref_table_des ?=
cl_abap_typedescr=>describe_by_name( p_table ).
idetails[] = ref_table_des->components[].
loop at idetails into xdetails.
clear xfc.
xfc-fieldname = xdetails-name .
xfc-datatype = xdetails-type_kind.
xfc-inttype = xdetails-type_kind.
xfc-intlen = xdetails-length.
xfc-decimals = xdetails-decimals.
append xfc to ifc.
endloop.
endform.
form create_dynamic_itab.
Create dynamic internal table and assign to FS
call method cl_alv_table_create=>create_dynamic_table
exporting
it_fieldcatalog = ifc
importing
ep_table = dy_table.
assign dy_table->* to <dyn_table>.
Create dynamic work area and assign to FS
create data dy_line like line of <dyn_table>.
assign dy_line->* to <dyn_wa>.
endform.
form get_data.
Select Data from table.
select * into table <dyn_table>
from (p_table). "/BIC/AZCRM_O0100.
endform.
THANKS,
laxmi
‎2007 Apr 11 1:37 PM
Here in unicode system, the Source and the target should be of the same type. When we use field symbols, the fields are generally interpreted as character type fields. If the database table contains CURRENCY, QUantity fields, we will face such errors
‎2007 Apr 13 6:53 AM
Hi Laxmi,
Just click on the below link.........
" http://www.saptechnical.com/Tutorials/ABAP/DynamicInternaltable/DynamicInternalTable.htm "
Here you can see the complete details of HOW TO CREATE DYANMIC INTERNAL TABLE. It is Crystal Clear.
<b>Hope you can understand it easily.
Reward if helpful.</b>
Regards,
V.Raghavender.