A dynamic key access is slower than a static one, since the key specification must be evaluated at runtime. If TAB has n entries, linear search runs in O( n ) time, whereasīinary search in an internal table * Entries: 1000, Line width: 100* Key width: 20 * The READ ends with SY-SUBRC=4 READ TABLE ITAB INTO WAĭynamically specified keyREAD TABLE ITAB INTO WA WITH KEY (NAME) = ‘X’. Try to keep the table ordered and use binary search Search through all entries is very time-consuming. Using Two SelectsSELECT * FROM SPFLI INTO TABLE T_SPFLI WHERE CITYFROM = ‘FRANKFURT’ AND CITYTO = ‘NEW YORK’. Select with joinSELECT * INTO WA FROM SPFLI AS P INNER JOIN SFLIGHT AS F ON P~CARRID = F~CARRID AND P~CONNID = F~CONNID. To read data from several logically connected tables use a join instead of nested Select statements. SELECT * FROM SFLIGHT INTO SFLIGHT_WA WHERE CARRID = SPFLI_WA-CARRID AND CONNID = SPFLI_WA-CONNID. ![]() Nested Select statementsSELECT * FROM SPFLI INTO SPFLI_WA. To process a join, use a view instead of nested Select statements. Select with view SELECT * FROM DD01V INTO DD01V_WAWHERE DOMNAME LIKE ‘CHAR%’ AND DDLANGUAGE = SY-LANGU. ![]() Nested Select statementsSELECT * FROM DD01L INTO DD01L_WA WHERE DOMNAME LIKE ‘CHAR%’ AND AS4LOCAL = ‘A’. SELECT * FROM T006 INTO X006_WA.ENDSELECT. Internal table handling takes up much more space. If you process your data only once, use a Select-Endselect-loop instead of collecting data in an internal table with Select Into Table. Select Into Table t +Loopat t.SELECT * FROM T006 INTO TABLE X006. Frequent communication between the application program and database system produces considerable overhead.Īrray InsertINSERT CUSTOMERS FROM TABLE TAB. Whenever possible, use array operations instead of single-row operations to modify your database tables. Single-line InsertsLOOPAT TAB INTO TAB_WA. Select Into Table SELECT * FROM T006 INTO TABLE X006.It is always faster to use the Into Table version of a Select statement than to use Append statements. Select + Append statementDATA T006_WA TYPE T006. Select with buffer support SELECT SINGLE * FROM T100 INTO T100_WAWHERE SPRSL = ‘D’ AND ARBGB = ’00’ AND MSGNR = ‘999’. Select without buffer supportSELECT SINGLE * FROM T100 INTO T100_WA BYPASSING BUFFER WHERE SPRSL = ‘D’ AND ARBGB = ’00’įor all frequently used, read-only tables, try to use SAP buffering. ![]() Select with primary index supportSELECT * FROM SBOOK CLIENT SPECIFIED INTO SBOOK_WA WHERE MANDT IN ( SELECT MANDT FROM T000 ) AND CARRID = ‘LH’ AND CONNID = ‘0400’. Note that complex Where clauses are poison for the statement optimizer in any database system. You always use an index if you specify (a generic part of) the index fields concatenated with logical Ands in the Select statement’s Where clause. ENDSELECT.įor all frequently used Select statements, try to use an index. Select without index supportSELECT * FROM SBOOK CLIENT SPECIFIED INTO SBOOK_WA WHERE CARRID = ‘LH’ AND CONNID = ‘0400’. Whenever possible, use column updates instead of single-row updates to update your database tables.Ĭolumn UpdateUPDATE SFLIGHT SET SEATSOCC = SEATSOCC – 1. SFLIGHT_WA-SEATSOCC = SFLIGHT_WA-SEATSOCC – 1. Single-line UpdatesSELECT * FROM SFLIGHT INTO SFLIGHT_WA. SELECT * FROM SBOOK INTO SBOOK_WA UP TO 1 ROWS WHERE CARRID = ‘LH’. Select Single requires one communication with the database system, whereas Select-Endselect needs two. If all primary key fields are supplied in the Where conditions you can even use Select Single. ![]() If you are interested if there exists at least one row of a database table or view with a certain condition, use the Select … Up To 1 Rows statement instead of a Select-Endselect-loop with an Exit. Select … Up To 1 Rows SELECT * FROM SBOOK INTO SBOOK_WA WHERE CARRID = ‘LH’. SELECT MAX( MSGNR ) FROM T100 INTO max_msgnr WHERE SPRSL = ‘D’ AND ARBGB = ’00’. SELECT * FROM T100 INTO T100_WAĭATA: MAX_MSGNR type t100-msgnr. Select using an aggregate function DATA: MAX_MSGNR type t100-msgnr.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |