‎2008 Jun 11 10:50 AM
Hi ,
Hope this query might seem very simple but I wanted to make it clear. I want to declare an itab with all the fields of the database table. There are many fields in db table.
Should I go for TYPES or DATA statement?
If I define with DATA , Is it "with occurs 0 with header line" or use separate work area. Pls suggest.
Thanks,
Rajani.
‎2008 Jun 11 11:20 AM
HI,
You can use both the TYPES and DATA no problem..
but it is always advisable that use separate work area just like this..
data:
begin of fs_structure,
f1 type xyz,
f2 type abc,
end of fs_structure.
data:
t_table like standard table of fs_structure.
it will be more efficient..
‎2008 Jun 11 10:56 AM
hiii,
if you want to use all the fields for internal table from DB table then you can use like below
DATA:
lt_files LIKE bapi_doc_files2 OCCURS 0 WITH HEADER LINE.
it will make your internal table with header line with all the fields.
for without header line table you need to define separate work area for it.like below.
DATA:
ls_excel TYPE alsmex_tabline.
" Work Area to hold Rows for Table
*"--------------------------------------------------------------------*
* Internal table to hold Rows for Table with Excel Data. *
*"--------------------------------------------------------------------*
DATA:
it_excel TYPE TABLE OF alsmex_tabline.performance will be same if you use with or without header line internal table.
thx
twinkal.
‎2008 Jun 11 10:56 AM
Hi,
You can declare a internal table either using data or types.
If you want to use data statement you need to use occurs 0 with header line. Or if you want to use types you need to declare internal table with or without header line and a work area.
Thanks,
Sriram Ponna.
‎2008 Jun 11 10:58 AM
Hello.
1 - If possible use types. If you have more than one internal tables of same type, if you want to change the type, with types, only one change that affects all tables.
TYPES: BEGIN OF ty_out,
field1 TYPE x,
field2 TYPE y,
END OF ty_out.
DATA: it_out TYPE STANDARD TABLE OF ty_out,
wa_out TYPE ty_out.
2 - Always use work area (instead of OCCURS 0). Work areas are faster (check Se30, tips&tricks), work in OO programing and OCCURS is an obsolete statement.
Regards.
Valter Oliveira.
‎2008 Jun 11 11:01 AM
Hi,
Create Structure if u want to use all the data of the table using DATA with OCCURS 0.
Regards,
Amit G.
‎2008 Jun 11 11:20 AM
HI,
You can use both the TYPES and DATA no problem..
but it is always advisable that use separate work area just like this..
data:
begin of fs_structure,
f1 type xyz,
f2 type abc,
end of fs_structure.
data:
t_table like standard table of fs_structure.
it will be more efficient..
‎2008 Jun 11 11:36 AM
Hi ,
This is also one of the best way to declare internal table for performance.
TYPES : BEGIN OF typ_itab,
f1,
f2,
,
fn,
END OF typ_itab.
DATA : it_itab TYPE STANDARD TABLE OF typ_itab INITIAL SIZE 1,
wa_itab TYPE typ_itab.
Regards,
Vishvesh