2006 Nov 30 5:50 AM
hi!
I have a question with database tables.
If I want to read data from a database table using a record in an internal table, what is the best way of doing that? (for each record in the internal table, I have to read some records from the database table).
Thanks,
Srikanth.
2006 Nov 30 5:51 AM
hi,
<b>use for all entries syntax</b>
REPORT abc.
DATA : BEGIN OF itab OCCURS 0,
bukrs LIKE t001-bukrs,
END OF itab.
DATA : t001 LIKE TABLE OF t001 WITH HEADER LINE.
*--------------------
itab-bukrs = '1000'.
APPEND itab.
itab-bukrs = '1100'.
APPEND itab.
*--------------------
SELECT * FROM t001
INTO TABLE t001
FOR ALL ENTRIES IN itab
WHERE bukrs = itab-bukrs.
*--------------------------
LOOP AT t001.
WRITE :/ t001-bukrs.
ENDLOOP.
rgds
Anver
hi!
I have a question with database tables.
If I want to read data from a database table using a record in an internal table, what is the best way of doing that? (for each record in the internal table, I have to read some records from the database table).
Thanks,
Srikanth.
2006 Nov 30 5:51 AM
hi,
<b>use for all entries syntax</b>
REPORT abc.
DATA : BEGIN OF itab OCCURS 0,
bukrs LIKE t001-bukrs,
END OF itab.
DATA : t001 LIKE TABLE OF t001 WITH HEADER LINE.
*--------------------
itab-bukrs = '1000'.
APPEND itab.
itab-bukrs = '1100'.
APPEND itab.
*--------------------
SELECT * FROM t001
INTO TABLE t001
FOR ALL ENTRIES IN itab
WHERE bukrs = itab-bukrs.
*--------------------------
LOOP AT t001.
WRITE :/ t001-bukrs.
ENDLOOP.
rgds
Anver
2006 Nov 30 5:51 AM
2006 Nov 30 5:51 AM
2006 Nov 30 5:52 AM
Use the FOR ALL ENTRIES, so that for all the data in the internal table, you get the data form the database.
http://help.sap.com/saphelp_nw2004s/helpdata/en/fc/eb3a1f358411d1829f0000e829fbfe/content.htm
Else you will have to loop at the internal table and fire the select inside the loop which will have performance issues.
Regards,
Ravi
Note - Please mark all the helpful answers
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |