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

itab

Former Member
0 Likes
944

for selection of all the fields in table using perticular condition,.how to declare the itab? plz,explain with example.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
923

Hi ,

Intenal tables are declared on

(a) what data we need

(b) the structure of the table from where we are obtaining

(c) the output we want to display

eg: consider table VBAP

case(1)

imagine we need all the fields for data processing based on field Ebelen

tables : vbap.

data: itab type table of vbap.

select-options: s_ebeln for vbap-ebeln.

select * from vbap into table itab where

ebeln in s_ebelp.

case(2)

imagine we need 2 fields only ebeln,ebelp for data processing based on field Ebelen

so we declare a strucutre or internal table with these 2 fields only

so we have

tables vbap.

data : begin of itab occurs 0,

ebeln type vbap-ebeln,

ebelp type vbap-ebelp,

end of itab.

select-options: s_ebeln for vbap-ebeln.

select ebeln ebelp from vbap into table itab where

ebeln in s_ebelp.

so if we have multiple selection fields

like s_ebelp in case(1) we write

select-options: s_ebeln for vbap-ebeln.

select-options: s_ebelp for vbap-ebelp.

select * from vbap into table itab where

ebeln in s_ebelp and

ebelp in s_ebelp.

Hope it helps,

Pls check and revert

Regards

Byju

6 REPLIES 6
Read only

Former Member
0 Likes
923
tables:mara.
DATA:  it_final TYPE mara OCCURS 0 WITH HEADER LINE.
select single * from mara into it_final where.......
Read only

0 Likes
923
tables:mara.
DATA:  it_final TYPE mara OCCURS 0 WITH HEADER LINE.
select single * from mara into it_final where.......

Don't use TABLES and WITH HEADER LINE statements. That's old school and not up to date (I hate it because so many old programs contains this type of code and I have to work with it)...

Instead of that use internal tables with field symbols due to performance reasons. And try to avoid using * in the select. Select only the fields you need to have:

DATA:
  lt_mara       TYPE STANDARD TABLE OF mara.

FIELD-SYMBOLS:
  <fs_mara>   TYPE mara.

SELECT SINGLE matnr FROM mara INTO TABLE lt_mara
  WHERE
    matnr = '123' AND...
    ...

READ lt_mara ASSIGNING <fs_mara> INDEX 1.
IF sy-subrc IS INITIAL.
  WRITE <fs_mara>-matnr.
ENDIF.

Read only

0 Likes
923

Don't use TABLES and WITH HEADER LINE statements. That's old school and not up to date (I hate it because so many old programs contains this type of code and I have to work with it)...

Instead of that use internal tables with field symbols due to performance reasons. And try to avoid using * in the select. Select only the fields you need to have:

Thanks for useful info.

though i just gave qustionire some glimpse.Am not writing a report for me.

Amit.l

Read only

matt
Active Contributor
0 Likes
923

>

> Don't use TABLES and WITH HEADER LINE statements. That's old school and not up to date (I hate it because so many old programs contains this type of code and I have to work with it)...

> Instead of that use internal tables with field symbols due to performance reasons. And try to avoid using * in the select. Select only the fields you need to have:

Absolutely! Sometimes I think I'm the only person advising this!

Additionally, I'd add - tables with header lines introduce an ambiguity, and are therefore bad programming pracice.

Also, sometimes you have to use a work area rather than a field-symbol. But in those cases, you should still define the work area seperately from the table.

matt

Read only

Former Member
0 Likes
923

Hi,

Suppose you have select All fields of table SFLIGHT based on the Input CARRID in Selection Screen.

For this-

Tables:sflight.

Select-options:s_carrid for sflight-carrid.

DATA: itab type table of sflight,

wa type sflight.

Select * from sflight into table itab where carrid in S_carrid.

Loop at itab into wa.

write:wa-carrid,

..........

............

Endloop.

Regards,

Sujit

Read only

Former Member
0 Likes
924

Hi ,

Intenal tables are declared on

(a) what data we need

(b) the structure of the table from where we are obtaining

(c) the output we want to display

eg: consider table VBAP

case(1)

imagine we need all the fields for data processing based on field Ebelen

tables : vbap.

data: itab type table of vbap.

select-options: s_ebeln for vbap-ebeln.

select * from vbap into table itab where

ebeln in s_ebelp.

case(2)

imagine we need 2 fields only ebeln,ebelp for data processing based on field Ebelen

so we declare a strucutre or internal table with these 2 fields only

so we have

tables vbap.

data : begin of itab occurs 0,

ebeln type vbap-ebeln,

ebelp type vbap-ebelp,

end of itab.

select-options: s_ebeln for vbap-ebeln.

select ebeln ebelp from vbap into table itab where

ebeln in s_ebelp.

so if we have multiple selection fields

like s_ebelp in case(1) we write

select-options: s_ebeln for vbap-ebeln.

select-options: s_ebelp for vbap-ebelp.

select * from vbap into table itab where

ebeln in s_ebelp and

ebelp in s_ebelp.

Hope it helps,

Pls check and revert

Regards

Byju