‎2007 Jul 31 7:33 AM
Hi Friends,
Please can u explain me what is the use of this READ statement, and why we use INDEX here.
READ TABLE z_tlines INDEX 1
Thank you,
Shreekant
‎2007 Jul 31 7:33 AM
hi,
Read table with index 1 will read the first record from ur internal table.... index denotes the row of ur internal table....
<b>reward points if useful...</b>
regards,
raksha
‎2007 Jul 31 7:33 AM
hi,
Read table with index 1 will read the first record from ur internal table.... index denotes the row of ur internal table....
<b>reward points if useful...</b>
regards,
raksha
‎2007 Jul 31 7:35 AM
hi,
<u>READ TABLE z_tlines INDEX 1</u>
It reads only one record...Either by index or key.
READ TABLE MY_TAB INDEX 1.
READ TABLE MY_TAB WITH KEY CODE = 'ATG'.
when we use the INDEX 1, it reads the 1st record of the table.
Reading records with keys
http://help.sap.com/saphelp_47x200/helpdata/en/fc/eb35f8358411d1829f0000e829fbfe/content.htm
Reading lines with Index
http://help.sap.com/saphelp_47x200/helpdata/en/fc/eb3730358411d1829f0000e829fbfe/content.htm
Rgds
Reshma
‎2007 Jul 31 7:40 AM
Hi
Read table statement is used for Reading a particular internala table or a field it is used for selecting a single record.
READ TABLE sets SY-TABIX to the index of the table line read. If you use a binary search, and the system does not find a line, SY-TABIX contains the total number of lines, or one more than the total number of lines. SY-INDEX is undefined if a linear search fails to return an entry.
Check this sample code
READ TABLE itab INTO wa WITH KEY field1 = X.
IF sy-subrc <> 0.
READ TABLE itab INTO wa WITH KEY field2 = Y.
IF sy-subrc <> 0.
READ TABLE itab INTO wa WITH KEY field3 = Z.
ENDIF.
ENDIF.
CHECK sy-subrc = 0. "Or an IF, of course
Reward all helpfull answers
Regards
Pavan
‎2007 Jul 31 7:35 AM
Hi,
If you need only the first record in the table you can use like this
‎2007 Jul 31 7:35 AM
Hi,
Read table is used when you want to read the contents of the internal table Z_tlines.
The option INDEX 1 is used to read the first line of the internal table.
Shruthi R
‎2007 Jul 31 7:37 AM
Hi,
If I want to read all the lines from the internal table what should I do.
Pls. reply me.
Thanks,
Shreekant
‎2007 Jul 31 7:38 AM
Hi,
If u want to read all the lines either u just use the same table for the purpose of usage or just loop at this table and put it onto a wrk area and use the record for further processing
<b>reward points if useful</b>
‎2007 Jul 31 7:37 AM
Hi,
READ TABLE isused to read from internal tables.
And INDEX can only be used with STANDARD and SORTED tables. INDEX can be used only with ORDERED and INDEXED tables like STADARD and SORTED tables.
This is to read from certain position.
Regards,
Sesh
‎2007 Jul 31 7:37 AM
hi,
Read table will get the first record that saitisfies the condition specified in the with key statement into the header.
if an itab contains the following data:
field1 field2
1 one
2 two
3 three
4 four
5 five
And if you read the itab like this:
read table itab into WA with key field1 = '3'.
if sy-subrc = 0.
write:/ wa.
endif.
The output will be
3 three.
The sy-tabix will hold the value of index of the current record.
<b>REWARDS POINT</b>
Regards,
ASHOK
‎2007 Jul 31 7:40 AM
hi,
read table st is used to read a record from internal table into workarea. with read statement we can do in 2 ways
1. using index
2. using key fields of the record
for ex:
loop at itab.
read table itab with index sy-tabix.
endloop.
reads all records of internal table with respect to index. here index is also used to read particular record it its given outside loop.
as similar usingkey field also we can read a record.
if helpful reward some points.
with regards,
Suresh Aluri.
‎2020 Mar 31 2:56 PM
Read table is used to read the record from your internal table "z_tlines" and if you mention the INDEX 1 with it then it means it will read the First record.