‎2008 Feb 08 3:21 AM
HI ,
1.can we change the internal table field names in dynamic .
for ex : in ITAB i defind filed1,field2,
but in program i have to change the name of these fields .
2.HOw to create dummy fields in internal table and how to assign data to it .
THX
‎2008 Feb 08 3:41 AM
Hi Chaaya,
Not sure why you need to change the Field name dynamically.
But yes you can achieve alomost near to your requirement by creating Dynamic Internal table as per the input table/structure.
Sample code below:
parameter p_table type tabname.
field-symbols <tab> type table.
field-symbols <tab1> type any.
types: begin of itab,
t_name type tabname,
t_ref type ref to data,
end of itab.
data itab1 type table of itab with non-unique key t_name.
perform fetch_data using p_table.
perform print_table using p_table.
&----
*& Form fetch_data
&----
text
----
-->P_P_TABLE text
----
FORM fetch_data USING P_TABLE1 type tabname.
data itab2 type itab.
itab2-t_name = p_table1.
create data itab2-t_ref type table of (itab2-t_name) .
assign itab2-t_ref->* to <tab>.
append itab2 to itab1.
select * from (p_table1) up to 25 rows into corresponding fields of table <tab>.
ENDFORM. " fetch_data
<b>Reward points if this helps.
Manish</b>
‎2008 Feb 08 4:09 AM
Hi
you can create dummy fields in your program.
create local field names.
and then select from your itab into your local table and say move corresponding fields.
code:
suppose your itab has field1 and field2.
data: l_field1 type (your itab field1)
l_field2 type (your itab field2)
l_table type table of itab
select * from itab where <condition> into corresponding fields of l_table.
<do your logic>
endselect.
regards,
chithra