Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

select options

Former Member
0 Likes
1,166

hi !

why do we need to declare the table with TABLES statement before using select-options?

why do we use internal table without headerline instead of internal table with headerline?

points will be given

4 REPLIES 4
Read only

Former Member
0 Likes
763

Hi,

1) SELECT-OPTIONS you don't have declare TABLES..You can use a variable..

ex..

DATA: V_MATNR TYPE MARA-MATNR.

SELECT-OPTIONS SO_MATNR FOR V_MATNR.

2) ABAP OO doesn't allow internal tables to be created with HEADER LINE.

Thanks,

Naren

Read only

Former Member
0 Likes
763

you create select options by referencing them to a particualr column in database table. You can do this by declaring a variable in your program and then create select options against that and the other way is by using TABLES <tab_name> - this will allow you to reference to any coulmn on the table while declaring the select options.

its SAPs recommendation to use internal tables without header lines. In case of OO ABAP its already restricted and you will not be allowed to create internal tables with header lines.

Cheers

Read only

Clemenss
Active Contributor
0 Likes
763

Hi,

already explained.

Just an addition: Select-options needs a reference on a dictionary type.

TABLES is an outdated obsolete statement which is the same as i.e.

DATA: MARA TYPE MARA.

For select-options, also non-database-types can be used. In dictionary, you can have structures with fields and dataelements as well. So

DATA: lv_matnr type mara-matnr.

select-options: s_matnr for lv_matnr.

is OK.

Internal tables with header lines are confusing for the ABAP processor because the same name is used for the header line and the internal table itself.

LOOP at ITAB.

is the same as

LOOP AT ITAB INTO ITAB.

For every loop the contents of the table row is copied to the implicit header line.

In ABAP OO there are no implicit declarations and thus no tables with header line.

Anyway you are much better in terms of performance, using internal tables without header line and looping using field-symbol assignment.

Confusing only when you start with it, but get used to it quick and will never forget a MODIFY statement. MODIFY copies the header line into the actual table row.

<pre>

DATA: lt_mara TYPE TABLE OF mara.

  • declares internal table of structure MARA without header line

FIELD-SYMBOLS: <mara> TYPE mara.

  • declares pointer for structure MARA

LOOP AT lt_mara ASSIGNING <mara>.

  • in each loop, table row is assigned to <mara>

  • <mara> is the actual record of the internal table

  • Nothing copied, ultra-fast assignment only

<mara>-laeng = 50.

  • allrecords: Field LAENG set to 50

  • no MODIFY needed because accessed directly - very fast

ENDLOOP.

</pre>

This is just an example. If you get used to it, you will never need a header line again.

Regards,

Clemens

Read only

Former Member
0 Likes
763

Hi~~

Addition for the internal table delaring with header lines.

This kind of internal table have structure with the same name of the table.

That is why some of codes just select~ from in_table.

Sometime, it can be confusing to codes readers.

Linette