Professional Documents
Culture Documents
1.3 SELECT SINGLE vs. SELECT * SELECT SINGLE * is more efficient than SELECT * ENDSELECT. Whenever the full key of a table is known, use: SELECT SINGLE * FROM dbtab WHERE . (full key).
In this case, specifying values for as many of the tables key fields in a WHERE clause will make the SELECT statement more efficient than checking values after the select.
SELECT * FROM T001G WHERE BUKRS EQ US01. CHECK T001G-TXTKO+2(4) = PERS. .... ENDSELECT.
SELECT VBELN AUART KUNNR FROM VBAK INTO (VBAK-VBELN, VBAK-AUART, VBAK-KUNNR) WHERE WRITE: / ENDSELECT.
See the editor help for all the variants of the INTO clause.
The same consideration as for the UPDATE is true for the DELETE: Instead of deleting records within a SELECT ENDSELECT construct
e.g. SELECT * FROM ZVBAK WHERE VBELN IN S_VBELN. DELETE ZVBAK. ENDSELECT.
rather than:
READ TABLE itab WITH KEY key The second method performs a sequential read from the first record until if finds a match. The first method performs a binary search to find a matching record, but the table must be sorted first.
2.6 Reading large internal tables If you have to retrieve selected records from a large internal table, keep this table sorted.
In this way, you can access the table via the READ TABLE T_VBAK WITH KEY VBELN = W_VBELN BINARY SEARCH statement. If you only want to verify the existence of a record but dont need any of the fields from the record then use the addition
TRANSPORTING NO FIELDS If you only need a few fields from the internal table for processing then use the addition
TRANSPORTING <field1> <field2>
The same applies if you only want to verify that at least one record exists that satisfies a certain condition:
LOOP AT T_VBAK TRANSPORTING NO FIELDS WHERE EXIT. ENDLOOP. IF SY-SUBRC = 0. * Record found ENDIF.
2.11 DELETING DUPLICATE ENTRIES FROM AN INTERNAL TABLE To delete duplicate entries from an internal table the table has to be sorted by the fields used in the comparing condition. If there is no comparing condition the table should be sorted by all fields. DELETE ADJACENT DUPLICATES FROM T_VBAK [COMPARING field1 field2 ]
For example, fieldx can have values A, B, or C. A value of B is the most likely value to occur, followed by C, then A. To optimize a CASE statement for fieldx, code the CASE statement as follows:
CASE fieldx. WHEN B. .... WHEN C. .... WHEN A. .... ENDCASE. Most likely value Next most likely value Least likely value
The return code should always be checked after any database table read/update statements. For SELECT ... ENDSELECT processing loops, the return code should be checked after the ENDSELECT statement to check for the success of the SELECT statement.
For LOOP AT ... ENDLOOP processing loops, the return code should be checked after the ENDLOOP statement to check for the success of the LOOP statement.
the maintenance of these texts in other languages. 6.____________ system variable used to check the return code.
7. To delete duplicate entries from an internal table__________ statement is used.