‎2007 May 15 7:33 AM
Hi,
I have some data in my internal table.
Now my requirement is to read the table ITAB based on index as well as where clause.
So anybody will pls tell me how to code for the above requirement.
Pls tell me asap.
‎2007 May 15 7:40 AM
check whether it works...
read table itab index n.
if sy-subrc eq 0.
if itab-xxx = aaa.
.
.
else.
..
.
endif.
endif.
‎2007 May 15 7:39 AM
hi,
1.............
U can use the statement
READ ITAB INDEX 2.
Here 2 is the index for which u want to read the value in ITAB
2...........
go through this document & Syntaxes
Read an internal table
- READ TABLE itab. / READ TABLE itab INTO wa.
Read a list line
- READ LINE lin.
- READ LINE lin OF CURRENT PAGE.
- READ LINE lin OF PAGE pag.
- READ CURRENT LINE.
Read a program
- READ REPORT prog INTO itab.
Read text elements
- READ TEXTPOOL prog ...INTO itab ...LANGUAGE lg.
Read a file
- READ DATASET dsn INTO f.
Read a database table
- READ TABLE dbtab.
Determine calendar information
- In R/2: READ CALENDAR.
read table <Intenal Table Name> index <line number>.
pls reward if it helpful
Thanks
Vana
‎2007 May 15 7:39 AM
Hi Neha,
You cannot use both at a time. because when you give index you mean specific record ( position).
Ex for where:
READ TABLE html_viewer_tab
WITH KEY table_line->parent = container
INTO html_viewer.
Ex for index:
READ TABLE sflight_tab INDEX sy-index INTO sflight_wa.
Regds,
Younus
<b>Reward Helpful Answers!!!</b>
‎2007 May 15 7:39 AM
Hi,
You can directly pur your where condition while looping the itab.
see this:
Loop at itab where <Condition>. "So that only those records are looped.
........" Now read stmt.
READ TABLE itab INDEX sy-tabix.
.........
endloop.
Hope this info helps.
Regards,
Kumar.
‎2007 May 15 7:40 AM
check whether it works...
read table itab index n.
if sy-subrc eq 0.
if itab-xxx = aaa.
.
.
else.
..
.
endif.
endif.
‎2007 May 15 7:41 AM
You can loop if you need to read all the data from internal table
else if you need to fetch a particular row depending on the conditions then you can user READ statement
1.Loop at itab into wa.
write : wa.. " WA contains the data
endloop.
2.
READ table ITAB into wa with key f1 = 'xx'
you can read Table with either index or with some keys both are not possible..
as per your requirement..
READ TABLE ITAB into wa index 'N'.
if sy-subrc = 0.
Now you can compare your fields
if wa-matnr = 'xx'.
write: / wa
endif.
endif.
rewards if useful
regards
nazeer
Message was edited by:
nazeer shaik
‎2007 May 15 7:42 AM
‎2007 May 15 7:42 AM
hai neha ,
You can directly put your where condition while looping the itab.
‎2007 May 15 7:46 AM
you can do like this...
loop at itab where <..your where condition>.
if sy-tabix = <your value>.
<do something>
else.
continue.
endif.
endloop.
regards
shiba dutta
‎2007 May 15 7:52 AM
Hi Neha,
Refer this code :
Loop at itab where <condition>.
Read table itab index sy-tabix.
endloop.
Regards,
Hemant
‎2007 May 15 8:28 AM
hi neha,
Now my requirement is to read the table ITAB based on index as well as where clause.
So anybody will pls tell me how to code for the above requirement.
using read statement you can read data from internal table to work area as
read table [tablename] into [workarea] with index [indexno].
ex: read table itab into wa_itab
or
read table itab into wa_itab with key field = 'fieldname'
helpful reward some points.
with regards,
suresh babu aluri.