Вы находитесь на странице: 1из 3

Tricky Points: 1.

Difference Between SORT and SORT STABLE


SORT keyword sorts the internal table by the field we mention in the statement, either it can be ascending or descending. But the sort sequence will not be preserved, i.e, if we have a field with similar values for more than once the sort sequence might differ everytime we sort the table on that particular field. To preserve the sequence we can use keyword SORT STABLE. SORT STABLE keyword sorts the internal table and preserves the sort sequence. When we try to re-sort the table on the same sort criteria the sequence will not changed.

2. sy-tabix and sy-index.


sy-tabix = Index of Internal Tables set by commands processing internal tables (e.g. READ, LOOP) It contains the nr/index of the last line accessed for standard or sorted tables. In case of hashed tables it is set to 0 since hashed tables are no index tables, they use a hash administration.

sy-index = Loop Index. set by DO and WHILE loops. contains the number of the loop passes including the current pass.

3. Memory de-allocation for ITABs:


REFRESH This deletes the entire contents of the internal table. A part of the previously used memory remains available for future insertions. CLEAR With internal tables without a header line (all that have been previously defined in the course), the CLEAR statement has the same effect as REFRESH. For internal tables with a header line (see below) in contrast, it only initializes the header line. FREE This deletes the entire contents of the internal table and releases the previously used memory. You use the FREE statement for internal tables that have already

been evaluated and are no longer required in the further course of the program.

This has the effect that pre

4. COLLECT :
COLLECT wa INTO itab. itab must have a flat line type, and all of the fields that are not part of the table key must have a numeric type (f, i, p). You specify the line wathat you want to add as a work area that is compatible with the line type of itab. When the line is inserted, the system checks whether there is already a table entry that matches the key. If there is no corresponding entry already in the table, the COLLECT statement has the same effect as inserting the new line. If an entry with the same key already exists, the COLLECT statement does not append a new line, but adds the contents of the numeric fields in the work area to the contents of the numeric fields in the existing entry.

5. Subroutine Types:
Call by Value A copy is made of the actual parameter. This copy is assigned to the formal parameter. If in the subroutine a value is assigned to the corresponding formal parameter, this value will actually be assigned to a copy of the formal parameter and not its original. You use this pass type, to make the value of a global variable available to the subroutine (in the form of a variable copy) without making it possible to change the respective global variable (protecting the original). Please note, however, that creating copies, especially for large internal tables, can be time-consuming. Call by value and result With this transfer type, the same applies as for .call by value.. However, at the regular end of the subroutine, the value that was changed to this point is written back to the original. If the program is prematurely terminated through a STOP statement or a user message of type E, the writing back of the values is suppressed. You use this pass type to transfer the value of a global variable to the subroutine and to have the fully processed final value of the copy written back to the original. But note that the creation of copies and the writing back of values can be time-consuming, especially for large internal tables.

Call by reference The actual parameter is assigned directly to the formal parameter. This means that value assignments to the formal parameter are executed directly on the actual parameter. You use this pass type if you want to run the subroutine processing directly on the specified actual parameter. It is popular for avoiding the time-consuming creation of copies for large internal tables.

5. Import -Export stmts:


A simple example of ABAP memory is using the EXPORT/IMPORT statements. Here in this program, I get the data, export it to memory, clear out the internal table in my progam, then reimport the data into it and write out the data. You probably wounldn't do this in a normal program, but this is how you can pass data from program a to program b when A Submits program B.

report zrich_0002 . data: it001 type table of t001 with header line. select * into table it001 from t001. export it001 = it001 to memory id 'ZRICH_TEST'. clear it001. refresh it001. import it001 = it001 from memory id 'ZRICH_TEST'. loop at it001. write:/ it001-bukrs, it001-butxt. endloop.

Вам также может понравиться