System fields II
-
Program code
-
-
REPORT ZBCTCB92.
-
TABLES: T000.
-
DATA: BEGIN OF T OCCURS 0,
-
DATA: NUM TYPE N.
-
DETAIL.
-
* sy-linct and sy-linsz describes
a page of the list
-
WRITE: / 'Example of sy-linct and sy-linsz'.
-
SKIP.
-
WRITE: / SY-LINCT, 'line and', (3) SY-LINSZ,
'column is a page'.
-
* sy-index works in do-enddo
and while-endwhile loops.
-
* it contains the number of loop passes.
-
WRITE: /'Example of sy-index'.
-
SKIP.
-
DO 5 TIMES.
-
ENDDO.
-
* sy-tabix is the index number
of the currently processed row
-
* for an internal table
-
SKIP.
-
WRITE: /'Example of sy-tabix'.
-
SKIP.
-
T-FIELD = 'One'. APPEND T.
-
T-FIELD = 'Two'. APPEND T.
-
T-FIELD = 'Three'. APPEND T.
-
T-FIELD = 'Four'. APPEND T.
-
T-FIELD = 'Five'. APPEND T.
-
WRITE: /'Example of sy-tabix I'.
-
SKIP.
-
LOOP AT T.
-
WRITE: / SY-TABIX, T-FIELD.
-
ENDLOOP.
-
*sy-fdpos contains off-set
after string comparison and search operations
-
SKIP.
-
WRITE: /'Example of sy-fdpos'.
-
SKIP.
-
CLEAR T.
-
SEARCH T FOR 're'.
-
READ TABLE T INDEX SY-TABIX.
-
WRITE: / SY-TABIX, T-FIELD.
-
SKIP.
-
WRITE: /9 'At the example of sy-tabix, Row', (3) SY-TABIX,
',' ,
-
'keyword ''re'' found at off-set position:', (3) SY-FDPOS.
-
SKIP.
-
* sy-dbcnt contains the number
of selected records.
-
* sy-subrc is 0 if an operation was successful.
-
WRITE: /'Example of sy-dbcnt and sy-subrc I'.
-
SKIP.
-
SELECT * FROM T000 WHERE MANDT BETWEEN '000' AND '066'.
-
WRITE: /10 'Mandant:', T000-MANDT.
-
ENDSELECT.
-
WRITE: /12 'Number of selected records:', SY-DBCNT
CENTERED.
-
WRITE: /12 'Return code: ' RIGHT-JUSTIFIED, SY-SUBRC
.
-
SKIP.
-
WRITE: /'Example of sy-dbcnt and sy-subrc II: don't find records'.
-
SKIP.
-
SELECT * FROM T000 WHERE MANDT EQ -1.
-
ENDSELECT.
-
WRITE: /12 'Number of selected records:', SY-DBCNT
CENTERED.
-
WRITE: /12 'Return code: ' RIGHT-JUSTIFIED, SY-SUBRC.
Bence Toth