‎2008 Aug 22 7:55 AM
for selection of all the fields in table using perticular condition,.how to declare the itab? plz,explain with example.
‎2008 Aug 22 8:09 AM
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
‎2008 Aug 22 7:57 AM
tables:mara.
DATA: it_final TYPE mara OCCURS 0 WITH HEADER LINE.
select single * from mara into it_final where.......
‎2008 Aug 22 8:10 AM
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.
‎2008 Aug 22 8:28 AM
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
‎2008 Aug 22 9:25 AM
>
> 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
‎2008 Aug 22 8:00 AM
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
‎2008 Aug 22 8:09 AM
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