‎2007 Dec 20 4:13 AM
‎2007 Dec 20 4:23 AM
Hi Ganapathi,
Read Table <body of itab> into <workarea> with key <keyfiled> = < > .
Read Table <body of itab> into <workarea>.
Regards,
sana.
‎2007 Dec 20 4:16 AM
Read a Single Row in a Table:
READ TABLE <itab> WITH KEY <col 1> = <value> <col 2> = <value> <col n> = <value>.
READ TABLE <itab> INDEX <possition>.
Read Multiple Rwos of a Table:
LOOP AT <itab> WHERE <condition>.
ENDLOOP.
Reward points if useful.
‎2007 Dec 20 4:18 AM
Hi,
in ABAP only one Read statment is available..
But we read the internal table data using read statment, using loop at statement...
if u want to read the data from database we can use select statement....
if u want syntax and programs let me know.
if it useful reward with ponis...
‎2007 Dec 20 4:18 AM
Hi,
Read an internal table
- READ TABLE itab FROM wa [additions].
- READ TABLE itab WITH TABLE KEY k1 = v1 ...kn = vn [additions].
- READ TABLE itab WITH KEY k1 = v1 ...kn = vn [BINARY SEARCH] [additions].
- READ TABLE itab INDEX i [additions].
- Obsolete Variants
Read a program
- READ REPORT prog INTO itab.
Read text elements
- READ TEXTPOOL prog ...INTO itab ...LANGUAGE lg.
Read from a file
- READ DATASET dsn INTO f.
Read a database table
- READ TABLE dbtab.
press f1 on read statement u will get all the details
‎2007 Dec 20 4:21 AM
hi ,
Reading Lines of Tables
To read a single line of any table, use the statement:
READ TABLE <itab> <key> <result>.
For the statement to be valid for any kind of table, you must specify the entry using the key and not the index. You specify the key in the <key> part of the statement. The <result> part can specify a further processing option for the line that is retrieved. If the system finds an entry, it sets SY-SUBRC to zero, if not, it takes the value 4, as long as it is not influenced by one of the possible additions. If the internal table is an index table, SY-TABIX is set to the index of the line retrieved. If the table has a non-unique key and there are duplicate entries, the first entry is read. Specifying the Search Key The search key may be either the table key or another key.
Using the Table Key To use the table key of <itab> as a search key, enter <key> as follows:
READ TABLE <itab> FROM <wa> <result>.
or as follows
READ TABLE <itab> WITH TABLE KEY <k1> = <f1> ... <kn> = <fn> <result>.
In the first case, <wa> must be a work area compatible with the line type of <itab>. The values of the key fields are taken from the corresponding components of the work area. In the second case, you have to supply the values of each key field explicitly. If you do not know the name of one of the key fields until runtime, you can specify it as the content of a field <ni> using the form (<ni>) = <fi>. If the data types of <fi> are not compatible with the key fields, the system converts them. The system searches for the relevant lines as follows:
Standard tables
Linear search, where the runtime is in linear relation to the number of table entries.
Sorted tables
Binary search, where the runtime is in logarithmic relation to the number of table entries.
Hashed tables
The entry is found using the hash algorithm of the internal table. The runtime is
independent of the number of table entries.
Using a Different Search Key
To use a key other than the table key as a search key, enter <key> as follows:
READ TABLE <itab> WITH KEY = <f> <result>.
or as follows
READ TABLE <itab> WITH KEY <k1> = <f1> ... <kn> = <fn> <result>.
BC - ABAP Programming SAP AG
In the first case, the whole line of the internal table is used as the search key. The contents of the entire table line are compared with the contents of field <f>. If <f> is not compatible with the line type of the table, the value is converted into the line type. The search key allows you to find entries in internal tables that do not have a structured line type, that is, where the line is a single field or an internal table type. In the second case, the search key can consist of any of the table fields <k1>...<kn>. If you do not know the name of one of the components until runtime, you can specify it as the content of a field <ni> using the form (<ni>) = <fi>. If <ni> is empty when the statement is executed, the search field is ignored. If the data types of <fi> are not compatible with the components in the internal table, the system converts them. You can restrict the search to partial fields by pecifying offset and length.The search is linear for all table types. The runtime is in linear relation to the number of table lines. Specifying the Extra Processing Option
You can specify an option that specifies what the system does with the table entry that it finds. Using a Work Area You can write the table entry read from the table into a work area by specifying <result> as follows:
READ TABLE <itab> <key> INTO <wa> [COMPARING <f1> <f2> ...
|ALL FIELDS]
[TRANSPORTING <f1> <f2> ...
|ALL FIELDS
|NO FIELDS].
If you do not use the additions COMPARING or TRANSPORTING, the contents of the table line must be convertible into the data type of the work area <wa>. If you specify COMPARING or TRANSPORTING, the line type and work area must be compatible. You should always use a work area that is compatible with the line type of the relevant internal table. If you use the COMPARING addition, the specified table fields <fi> of the structured line type are compared with the corresponding fields of the work area before being transported. If you use
the ALL FIELDS option, the system compares all components. If the system finds an entry with the specified key <key> and if the contents of the compared fields are the same, SY-SUBRC is set to 0. If the contents of the compared fields are not the same, it returns the value 2. If the system cannot find an entry, SY-SUBRC is set to 4. If the system finds an entry, it copies it into the target work area regardless of the result of the comparison. If you use the TRANSPORTING addition, you can specify the table fields of the structured line type that you want to transport into the work area. If you specify ALL FIELDS without RANSPORTING, the contents of all of the fields are transported. If you specify NO FIELDS, no fields are transported. In the latter case, the READ statement only fills the system fields SYSUBRC and SY-TABIX. Specifying the work area <wa> with TRANSPORTING NO FIELDS is unnecessary, and should be omitted.
In both additions, you can specify a field <fi> dynamically as the contents of a field <ni> in the form (<ni>). If <ni> is empty when the statement is executed, it is ignored. You can restrict the search to partial fields by specifying offset and length.
Using a Field SymbolYou can assign the table entry read from the table to a field symbol by specifying <result> as
follows:
READ TABLE <itab> <key> ASSIGNING <FS>.
After the READ statement, the field symbol points to the table line. If the line type is structured, you should specify the same type for the field symbol when you declare it. This allows you to address the components of the field symbol. If you cannot specify the type statically, you must use further field symbols and the technique of assigning components of structures to address the components of the structure.For further information about assigning table lines to field symbols, refer to Access Using Field Symbols.
‎2007 Dec 20 4:21 AM
HI Ganapathi,
You can try something like this...
Open your ABAP editor then type read and select this read and press F1, then you will get some details regarding read statements used.
Regards
Naveen
‎2007 Dec 20 4:23 AM
Hi Ganapathi,
Read Table <body of itab> into <workarea> with key <keyfiled> = < > .
Read Table <body of itab> into <workarea>.
Regards,
sana.
‎2007 Dec 20 4:28 AM
Hi Ganapathi,
Different TYpes of Read Statements
1.
READ DATASET dset INTO dobj [MAXIMUM LENGTH mlen]
[[ACTUAL] LENGTH alen].
This statement exports data from the file specified in dataset into the data object dobj.
Example :
DATA: file TYPE string VALUE `flights.dat`,
wa TYPE spfli.
FIELD-SYMBOLS <hex_container> TYPE x.
OPEN DATASET file FOR INPUT IN BINARY MODE.
ASSIGN wa TO <hex_container> CASTING.
DO.
READ DATASET file INTO <hex_container>.
IF sy-subrc = 0.
WRITE: / wa-carrid,
wa-connid,
wa-countryfr,
wa-cityfrom,
wa-cityto,
wa-fltime,
wa-distance.
ELSE.
EXIT.
ENDIF.
ENDDO.
CLOSE DATASET file.
2.
READ { {LINE line [{OF PAGE page }|{OF CURRENT PAGE}]
[INDEX idx] }
| {CURRENT LINE} }
This statement assigns the content of a row stored in the list buffer to the system field sy-lisel, and allows other target fields to be specified in result.
Example :
DATA: date TYPE d,
flag TYPE c LENGTH 1,
wa TYPE c LENGTH 10.
START-OF-SELECTION.
date = sy-datum.
DO 10 TIMES.
date = date + sy-index.
WRITE: / flag AS CHECKBOX, (10) date.
ENDDO.
AT LINE-SELECTION.
DO.
READ LINE sy-index FIELD VALUE flag
date INTO wa.
IF sy-subrc <> 0.
EXIT.
ELSEIF flag = 'X'.
WRITE / wa.
ENDIF.
ENDDO.
3.
READ REPORT prog INTO itab [MAXIMUM WIDTH INTO wid].
This statement reads the source text of the program specified in prog from the Repository and copies its row into the internal table itab.
Example:
DATA prog TYPE c LENGTH 30.
DATA itab TYPE TABLE OF string.
prog = '...'.
READ REPORT prog INTO itab.
IF sy-subrc = 0.
APPEND 'FORM subr.' TO itab.
...
APPEND 'PERFORM ...' TO itab.
APPEND 'ENDFORM.' TO itab.
GENERATE SUBROUTINE POOL itab NAME prog.
PERFORM ('SUBR') IN PROGRAM (prog).
ENDIF.
4.
READ TABLE itab { table_key
| free_key
| index } result.
READ TABLE <EMPTAB> options:
1) READ TABLE <EMPTAB>.
2) READ TABLE <EMPTAB> WITH KEY <k1> = <v1>
<kn> = <vn>.
3) READ TABLE <EMPTAB> WITH TABLE KEY <k1> = <v1> ...
<kn> = <vn>.
4) READ TABLE <EMPTAB> WITH KEY = <value>.
5) READ TABLE <EMPTAB> WITH KEY . . . BINARY SEARCH.
6) READ TABLE <EMPTAB> INDEX <i>.
7) READ TABLE <EMPTAB> COMPARING <f1> <f2> . . . .
😎 READ TABLE <EMPTAB> COMPARING ALL FIELDS.
9) READ TABLE <EMPTAB> TRANSPORTING <f1> <f2> . . . .
10) READ TABLE <EMPTAB> TRANSPORTING NO FIELDS.
This statement reads a row from internal table itab. You have to specify the row by either naming values table_key for the table key, a free condition free_key or an index index
5.
READ TEXTPOOL prog INTO itab LANGUAGE lang.
This statement reads the text elements of the text pool of the language specified in lang and the program specified in prog from the Repository and places them into the internal table itab.
Reward points,id useful.
Regards
Manoj Kumar
Edited by: Manoj Kumar on Dec 20, 2007 12:24 PM
‎2007 Dec 20 4:58 AM
hi,
1) READ DATASET dset INTO dobj [MAXIMUM LENGTH
mlen] [[ACTUAL] LENGTH alen].
2) READ { {LINE line [{OF PAGE page }|{OF CURRENT
PAGE}] [INDEX idx] } | {CURRENT LINE} } [result].
3) READ REPORT prog INTO itab [MAXIMUM WIDTH INTO
wid] [STATE state].
4) READ TABLE itab { table_key
| free_key
| index } result.
5) READ TEXTPOOL prog INTO itab LANGUAGE lang
[STATE state].
regards,
Pavan