08-11-2005 9:50 AM
Hello,
I am a beginner in ABAP and I have a question for you:
I have selected some data into an internal table (ex: IT_MAT ). Now I need to select again the data from IT_MAT to make some calculations, but I get the error
"IT_MAT" is not defined in the ABAP Dictionary as a table, projection view or database view.
What can I do to run a select like Select * from IT_MAT . ?
08-11-2005 11:12 AM
Thank you for your answers !
Can you please tell me how can I know when I am on the last line of an internal table in a loop ?
08-11-2005 9:51 AM
08-11-2005 9:55 AM
report Z_STOC_0_RAION no standard page heading line-size 92 .
data: begin of IT_ARTICOLE occurs 128 ,
MATNR like MARA-MATNR,
MAKTX like MAKT-MAKTX,
EKGRP like MARC-EKGRP,
EKNAM like T024-EKNAM,
WERKS like MARD-WERKS,
LABST like MARD-LABST,
MSTAE like MARA-MSTAE,
LVORM like MARA-LVORM,
LIFNR like EINA-LIFNR,
SPERQ like LFA1-SPERQ,
end of IT_ARTICOLE .
data: N type I .
selection-screen begin of block MATNR with frame title text-111.
select-options MATERIAL for IT_ARTICOLE-MATNR obligatory.
selection-screen end of block MATNR.
Start-of-selection.
select distinct
A~MATNR
B~MAKTX
C~WERKS
C~LABST
A~MSTAE
G~EKGRP
H~EKNAM
into corresponding fields
of table IT_ARTICOLE from MARA as A
join MAKT as B on AMATNR = BMATNR
join MARD as C on AMATNR = CMATNR
join MARD as D on AMATNR = DMATNR
join EINA as E on AMATNR = EMATNR
join LFA1 as F on ELIFNR = FLIFNR
join MARC as G on AMATNR = GMATNR and G~WERKS = 'HY01'
join T024 as H on GEKGRP = HEKNAM
where A~MATNR in MATERIAL
and A~MSTAE not in ('01','02','03')
and c~werks = 'HY01'
and C~LABST = 0
and A~LVORM <> 'X'
and f~sperq not in ('01','02','03')
and f~sperm <> 'X' .
select count(*) from IT_ARTICOLE group by it_articole-EKGRP.
08-11-2005 10:14 AM
Hi,
You can use
<b>data : itab type standard table of it_articole,
ln type i.
itab[] = it_articole[].
sort itab by ekgrp.
delete adjacent duplicates from itab comparing ekgrp.
describe table itab lines ln.</b>
instead of the line
select count(*) from IT_ARTICOLE group by it_articole-EKGRP.
Because in ABAP, you cannot use select statements in internal table.
If you want to get data from internal table,you can use <b>read or loop</b> statements.
Kindly reward points if it is useful.If you need clarifications,get back.
08-11-2005 9:56 AM
Select query from internal table is not possible.It is for abap Dictionary only.
Use abap statement Read table <internal table> with key...
Regds
gv
08-11-2005 9:57 AM
for select count(*) from IT_ARTICOLE group by it_articole-EKGRP
use abap statement describe table.
Regards
gv
08-11-2005 10:17 AM
with internal tables you can use only
loop at itab (from) (at)(where)
endloop
or
read table itab with index n.
read table itab with key <condition one> <condition two>...
or
describe ........
regards
08-11-2005 10:24 AM
If you just want to know the number of records in your i table, you can use the following statment :
data : w_nb_line type i.
...
Describe table i_tab lines w_nb_line.
regards,
Erwan.
08-11-2005 10:27 AM
if you want to learn more about loop.. enloop, read..., describe... just take the cursor to that keyword and press F1.
and if you want to learn how data flows, use debugging.
regards
08-11-2005 11:12 AM
Thank you for your answers !
Can you please tell me how can I know when I am on the last line of an internal table in a loop ?
08-11-2005 11:17 AM
Hi,
Within a loop use:
at last.
....
endat.
AT LAST.
Effect
Executes the relevant series of statements just once - either on the first loop pass (with AT FIRST) or on the last loop pass (with AT LAST).
Svetlin
Message was edited by: Svetlin Rusev
08-11-2005 11:19 AM
Hi,
After describing the table as I told in my previous reply,you will have the count in the variable ln.
loop at itab into wa.
...
if sy-tabix = ln.
...this is the last line.
endif.
endloop.
Here is the sample.
data itab type standard table of mara.
data ln type i.
data w type mara.
select * from mara into table itab.
describe table itab lines ln.
loop at itab into w.
if sy-tabix = ln.
write ln.
endif.
endloop.
Please reward points by clciking the star on the left side of the reply for useful answers.
Message was edited by: Jayanthi Jayaraman