08-24-2006 4:27 PM
Hi Experts,
I am using this..
data:itab like mara occurs.....
here mara can be replaced by any table name which i get frm the selection screen parameter. Also the same variable shud be passed to a FM. Is there any way tht i can do it??
Thanks
Sony
08-24-2006 4:39 PM
Sony you can try this also.
field-symbols :<fs_newtab> type table.
data : v_tabname type dntab-tabname.
move p_name to v_tabname.
*-- Getting the field names of the input table
call function 'NAMETAB_GET'
exporting
langu = sy-langu
tabname = v_tabname
tables
nametab = t_dyntab.
select * from (t_dyntab-tabname) into table <fs_newtab>
where vkorg in s_vkorg and
kschl in s_kschl and
datbi >= p_datab and
datab <= p_datbi.
-Anu
08-24-2006 4:30 PM
Hi Sony,
Try this.
DATA wa TYPE scarr.
DATA name(10) TYPE c VALUE 'SCARR'.
SELECT *
INTO wa
FROM (name) CLIENT SPECIFIED
WHERE mandt = '000'.
WRITE: / wa-carrid, wa-carrname.
ENDSELECT.
08-24-2006 4:37 PM
You need a dynamic internal table.
This sample may be helpful.
report zrich_0002.
type-pools: slis.
field-symbols: <dyn_table> type standard table,
<dyn_wa>,
<dyn_field>.
data: alv_fldcat type slis_t_fieldcat_alv,
it_fldcat type lvc_t_fcat.
type-pools : abap.
data : it_details type abap_compdescr_tab,
wa_details type abap_compdescr.
data : ref_descr type ref to cl_abap_structdescr.
data: new_table type ref to data,
new_line type ref to data,
wa_it_fldcat type lvc_s_fcat.
selection-screen begin of block b1 with frame title text .
parameters: p_table(30) type c.
selection-screen end of block b1.
* Get the structure of the table.
ref_descr ?= cl_abap_typedescr=>describe_by_name( p_table ).
it_details[] = ref_descr->components[].
loop at it_details into wa_details.
clear wa_it_fldcat.
wa_it_fldcat-fieldname = wa_details-name .
wa_it_fldcat-datatype = wa_details-type_kind.
wa_it_fldcat-inttype = wa_details-type_kind.
wa_it_fldcat-intlen = wa_details-length.
wa_it_fldcat-decimals = wa_details-decimals.
append wa_it_fldcat to it_fldcat .
endloop.
* Create dynamic internal table and assign to FS
call method cl_alv_table_create=>create_dynamic_table
exporting
it_fieldcatalog = it_fldcat
importing
ep_table = new_table.
assign new_table->* to <dyn_table>.
* Create dynamic work area and assign to FS
create data new_line like line of <dyn_table>.
assign new_line->* to <dyn_wa>.
* Select Data from table.
select * into corresponding fields of table <dyn_table>
from (p_table).
* Write out data from table.
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.
Regards,
Rich Heilman
08-24-2006 4:55 PM
Hey Rich,
Thats helping me a lot..not 100% but i can manage the rest...thanks a lot...
Anupama thanks to u too.
Regards
Sony
08-24-2006 4:39 PM
Sony you can try this also.
field-symbols :<fs_newtab> type table.
data : v_tabname type dntab-tabname.
move p_name to v_tabname.
*-- Getting the field names of the input table
call function 'NAMETAB_GET'
exporting
langu = sy-langu
tabname = v_tabname
tables
nametab = t_dyntab.
select * from (t_dyntab-tabname) into table <fs_newtab>
where vkorg in s_vkorg and
kschl in s_kschl and
datbi >= p_datab and
datab <= p_datbi.
-Anu