ABAP/4 programming language overview ------------------------------------ This documentation describes the syntax and meaning of ABAP/4 key words (for Release 3.0). The contents are identical to the online help function. ADD Variants: 1. ADD n TO m. 2. ADD n1 THEN n2 UNTIL nz GIVING m. 3. ADD n1 THEN n2 UNTIL nz TO m. 4. ADD n1 THEN n2 UNTIL nz ...ACCORDING TO sel ...GIVING m. 5. ADD n1 FROM m1 TO mz GIVING m. Variant 1 ADD n TO m. Effect Adds the contents of n to the contents of M and stores the result in m. This is equivalent to: m = m + n. Example DATA: NUMBER TYPE I VALUE 3, SUM TYPE I VALUE 5. ADD NUMBER TO SUM. The field SUM now contains 8, whilst the contents of the field NUMBER remains unchanged at 3. Note The details about conversions and performance described under COMPUTE are identical for ADD. Note Runtime errors: - BCD_BADDATA: P field contains incorrect BCD format. - BCD_FIELD_OVERFLOW: Result field too small (type P). - BCD_OVERFLOW: Overflow with arithmetic operation (type P. - COMPUTE_INT_PLUS_OVERFLOW: Integer overflow when adding. Related COMPUTE, ADD-CORRESPONDING. Variant 2 ADD n1 THEN n2 UNTIL nz GIVING m. Effect Adds the contents of the fields n1, n2, ..., nz together and stores the result in m, where n1 is the first, n2 the second and nz the last of a sequence of fields the same distance apart. They can be either database fields or internal fields, but they must all have the same type and length. This is equivalent to: m = n1 + n2 + ... + nz. Example DATA: BEGIN OF NUMBERS, ONE TYPE P VALUE 10, TWO TYPE P VALUE 20, THREE TYPE P VALUE 30, FOUR TYPE P VALUE 40, FIVE TYPE P VALUE 50, SIX TYPE P VALUE 60, END OF NUMBERS, SUM TYPE I VALUE 1000. ADD NUMBERS-ONE THEN NUMBERS-TWO UNTIL NUMBERS-FIVE GIVING SUM. The field SUM now contains 150 but its initial value is unimportant. The fields within the field string NUMBERS remain unchanged. Variant 3 ADD n1 THEN n2 UNTIL nz TO m. Effect Calculates the total as in variant 2 but then adds it to the contents of the field m. This is equivalent to: m = m + n1 + n2 + ... + nz Example DATA: BEGIN OF NUMBERS, ONE TYPE P VALUE 10, TWO TYPE P VALUE 20, THREE TYPE P VALUE 30, FOUR TYPE P VALUE 40, FIVE TYPE P VALUE 50, END OF NUMBERS, SUM TYPE I VALUE 1000. ADD NUMBERS-ONE THEN NUMBERS-TWO UNTIL NUMBERS-FIVE TO SUM. The field SUM now contains 1150. Variant 4 ADD n1 THEN n2 UNTIL nz ...ACCORDING TO sel ...GIVING m. Parts marked with " ..." are interchangeable Effect Calculates the total as in variants 2 and 3. In this case, however, the operands from a sequence of fields of the same type are restricted to a partial sequence by the selection specification sel generated by SELECT-OPTIONS or RANGES. The partial sequence results from the indexes that satisfy the condition IN sel (see IF). Example DATA: BEGIN OF NUMBERS, ONE TYPE P VALUE 10, TWO TYPE P VALUE 20, THREE TYPE P VALUE 30, FOUR TYPE P VALUE 40, FIVE TYPE P VALUE 50, END OF NUMBERS, SUM TYPE I VALUE 1000, INDEX TYPE I. RANGES SELECTION FOR INDEX. SELECTION-SIGN = 'I'. SELECTION-OPTION = 'BT'. SELECTION-LOW = 2. SELECTION-HIGH = 4. APPEND SELECTION. ADD NUMBERS-ONE THEN NUMBERS-TWO UNTIL NUMBERS-FIVE ACCORDING TO SELECTION GIVING SUM. SUM now contains 90. Only the component fields TWO to FOUR were selected from the field string NUMBERS and added together. Variant 5 ADD n1 FROM m1 TO mz GIVING m. Effect The field n1 must be the first in a sequence of consecutive fields of the same type. m1 and mz should contain the numbers of the first and last fields in this sequence to be added together (whether fixed or variable). The total is stored in m. Example DATA: BEGIN OF NUMBERS, ONE TYPE P VALUE 10, TWO TYPE P VALUE 20, THREE TYPE P VALUE 30, FOUR TYPE P VALUE 40, FIVE TYPE P VALUE 50, END OF NUMBERS, START TYPE I VALUE 2, SUM TYPE I VALUE 1000. ADD NUMBERS-ONE FROM START TO 4 GIVING SUM. The field SUM now contains 90. Note Performance: The details for conversion and performance specified for COMPUTE are equally valid for ADD. The runtime required for adding two numbers of type I or F is about 2 msn (standardized microseconds), for type P it is roughly 8 msn. Note Runtime errors: Besides the runtime errors listed in variant 1, the error ADDF_INT_OVERFLOW can occur instead of COMPUTE_INT_PLUS_OVERFLOW in other variants. ADD-CONDITIONAL is not an ABAP/4 key word (in R/3). ADD-CORRESPONDING Basic form ADD-CORRESPONDING rec1 TO rec2. Effect Interprets rec1 and rec2 as field strings. If, for example, rec1 and rec2 are tables, executes the statement for their header lines. Searches for all sub-fields which occur both in rec1 and rec2 and then, for all relevant field pairs corresponding to the sub-fields ni, generates statements of the form ADD rec1-ni TO rec2-ni. The other fields remain unchanged. With complex structures, the complete names of the corresponding field pairs must be textually identical. Example DATA: BEGIN OF VECTOR, X TYPE I, Y TYPE I, LENGTH TYPE I, END OF VECTOR, BEGIN OF CIRCLE, VOLUME TYPE P Y TYPE P, RADIUS TYPE I, X TYPE I, END OF CIRCLE. ... ADD-CORRESPONDING VECTOR TO CIRCLE. The sub-fields X and Y occur in both the field strings VECTOR and CIRCLE. Therefore, the ADD-CORRESPONDING statement is equivalent to both the following statements: ADD VECTOR-X TO CIRCLE-X. ADD VECTOR-Y TO CIRCLE-Y. Note All fields with the same name are added, whether numeric or not. The same conversions are performed as with ADD and similar runtime errors to those possible with ADD can also occur. Related ADD MOVE-CORRESPONDING SUBTRACT-CORRESPONDING MULTIPLY-CORRESPONDING DIVIDE-CORRESPONDING ADD-SELECTIVE is not an ABAP/4 key word (in R/3). APPEND Variants: 1. APPEND [wa TO|INITIAL LINE TO] itab. 2. APPEND LINES OF itab1 [FROM idx1] [TO idx2] TO itab2. 3. APPEND [wa TO] itab SORTED BY f. Variant 1 APPEND [wa TO|INITIAL LINE TO] itab. Effect Appends a new line to the end of the internal table itab. If you specify wa TO, the new line is taken from the contents of the explicitly specified work area wa. If you use INITIAL LINE TO, a line filled with the correct value for the type is added. If the specification before itab is omitted, the new line is taken from the internal tbale itab. After the APEND, the system field SY-TABIX contains the index of the newly added table entry. Examples Generate a list with customer numbers: TABLES SCUSTOM. DATA: CUSTOMER LIKE SCUSTOM-ID OCCURS 0. APPEND SCUSTOM-ID TO CUSTOMER. Append a blank line or a line with its initial value to the above list: APPEND INITIAL LINE TO CUSTOMER Generate a compressed list with plane data PARAMETERS: SEATS_LO LIKE SAPLANE-SEATSMAX DEFAULT 30, SEATS_HI LIKE SAPLANE-SEATSMAX DEFAULT 50. DATA: PLANE LIKE SAPLANE OCCURS 0, PLANE_NEEDED LIKE SAPLANE WITH HEADER LINE. LOOP AT PLANE INTO PLANE_NEEDED WHERE SEATSMAX BETWEEN SEATS_LO AND SEATS_HI. APPEND PLANE_NEEDED. ENDLOOP. Notes Performance: 1. When using internal tables with a header line, avoid unnecessary assignments to the header line. Whenever possible, use statements which have an explicit work area. For example, "APPEND wa TO itab." is approximately twice as fast as "itab = wa. APPEND itab.". The same applies to COLLECT and INSERT. 2. In contrast to COLLECT, APPEND does not check whether an entry with the same default key exists. Therefore, it is considerably faster than COLLECT. If the COLLECT logic is not needed or lines with an identical default key cannot occur in a particular situation, you should always use APPEND instead of COLLECT. 3. The runtime required for APPEND increases with the line width of the table and depends on the number of fields. Appending an entry to an internal table with a width of 111 bytes takes about 9 msn (standardized microseconds). 4. To append an internal table to another internal table, you should use the variant APPEND LINES OF ... which is 3 to 4 times faster than using a LOOP to process the source table and append the entries line-by-line to the target table. Variant 2 APPEND LINES OF itab1 [FROM idx1] [TO idx2] TO itab2. Effect Appends the internal table itab1 or an extract from itab1 to the end of the internal table itab2. By specifying FROM idx1 or TO idx2 you can restrict the line area taken from the source table itab1. If there is no FROM specification, it begins with the first line of itab1. If there is no TO specification, it ends with the last line of itab1. This means that the complete table is appended if neither a FROM nor a TO is specified. After the APPEND, the system field SY-TABIX contains the index of the last table entry appended, i.e. the total number of entries from both tables. Note By comparing the values of SY-TABIX before and after the APPEND statement, you can determine how many lines were appended to the table. Example Merge two tables with whole numbers: DATA: ITAB1 TYPE I OCCURS 100, ITAB2 TYPE I OCCURS 100. APPEND 2 TO ITAB1. APPEND 3 TO ITAB1. APPEND 5 TO ITAB1. APPEND 7 TO ITAB1. APPEND 3 TO ITAB2. APPEND INITIAL LINE TO ITAB2. APPEND LINES OF ITAB1 FROM 2 TO 20 TO ITAB2. The table ITAB2 now contains five lines with the values 3, 0, 3, 5 and 7. Note Performance: This variant is 3 to 4 times faster than using a LOOP to process the source table and append the entries line-by-line to the target table. Variant 3 APPEND [wa TO] itab SORTED BY f. Effect Inserts the new entry into table and re-sorts the table by the sub-field f in descending order. This only makes sense if the table was sorted beforehand. When the number of table entries reaches the OCCURS parameter value, the last entry is deleted if the value f of a new entry is greater (particularly suitable for ranked lists). You can only sort by one sub-field. If you specify wa TO, the new line is taken from the contents of the explicitly specified work area wa. Otherwise, it comes from the header line of the internal table itab. Example DATA: BEGIN OF COMPANIES OCCURS 3, NAME(10), SALES TYPE I, END OF COMPANIES. COMPANIES-NAME = 'big'. COMPANIES-SALES = 90. APPEND COMPANIES. COMPANIES-NAME = 'small'. COMPANIES-SALES = 10. APPEND COMPANIES. COMPANIES-NAME = 'too small'. COMPANIES-SALES = 5. APPEND COMPANIES. COMPANIES-NAME = 'middle'. COMPANIES-SALES = 50. APPEND COMPANIES SORTED BY SALES. The table now has three (-> OCCURS 3) entries. The line with the contents 'too small' in the sub-field NAME is deleted from the table because the entry for 'middle' has a greater value in the sub-field SALES. This entry now appears in the second table line (after 'big' and before 'small'). Notes 1. Whenever an internal table is processed with APPEND SORTED BY, it should always be filled in this way. 2. If you specify APPEND with the parameter SORTED BY, the system always searches the entire table. Therefore, it is sometimes better to create the table with a simple APPEND and then use SORT to sort in descending ot ascending order afterwards. You can also sort in ascending order by first determining the insert position with READ TABLE itab WITH KEY f = itab-f BINARY SEARCH and then by inserting the new entry into the table (perhaps read SY-SUBRC beforehand) with INSERT itab INDEX SY-TABIX. However, you should be aware that, in such cases, the table may contain more entries than specified in the OCCURS parameter. 3. If several lines with an identical value f are added, lines added later are treated as smaller, i.e. they are inserted after existing lines with the same value f. 4. If you use APPEND ... SORTED BY f with an explicitly specified work area, this must be compatible with the line type of the internal table. 5. If the sort criterion f is not known until runtime, you can use SORTED BY (name) to specify it dynamically as the contents of the field name. If name is blank at runtime or contains an invalid component name, a runtime error occurs. 6. Regardless of whether you specify it statically or dynamically, you can restrict the sort criterion f further by defining an offset and/or length. Related COLLECT itab, INSERT itab, SELECT / FETCH NEXT CURSOR ... INTO/APPENDING TABLE itab, MODIFY itab, WRITE f TO itab INDEX idx, SORT itab, READ TABLE itab, LOOP AT itab, DELETE itab ASS-RPERF is not an ABAP/4 key word (in R/3). ASSIGN Variants: 1. ASSIGN f TO . 2. ASSIGN (f) TO . 3. ASSIGN TABLE FIELD (f) TO . 4. ASSIGN LOCAL COPY OF MAIN TABLE FIELD (f) TO . 5. ASSIGN COMPONENT idx OF STRUCTURE rec TO . 6. ASSIGN COMPONENT name OF STRUCTURE rec TO . Variant 1 ASSIGN f TO . Additions: 1. ... TYPE typ 2. ... DECIMALS dec 3. ... LOCAL COPY OF ... Effect Assigns the field f to the field symbol . The field symbol "points to" the contents of the field f at runtime, i.e. every change to the contents of f is reflected in and vice versa. If the field symbol is not typed (see FIELD-SYMBOLS), the field symbol adopts the type and atrributes of the field f at runtime, particularly the conversion exit. Otherwise, when the assignment is made, the system checks whether the type of the field f matches the type of the field symbol . Note With the ASSIGN statement, the offset and length specifications in field f (i.e. f+off, f+len or f+off(len)) have a special meaning: - They may be variable and thus not evaluated until runtime. - The system does not check whether the selected area still lies within the field f. - If an offset is specified, but no length, for the field f, the field symbol adopts the length of the field f. Caution: also points to an area behind the field f. If you do not want this, the offset and length specifications can be in the form ASSIGN f+off(*) TO .. This means that the field symbol is set so that the field limits of f are not exceeded. - In the ASSIGN statement, you can also use offset and length specifications to access field symbols, FORM and function parameters. - Warning: If the effect of the ASSIGN statement is to assign parts of other fields beyond the limits of the field f, the changing of the contents via the field symbol may mean that the data written to these fields does not match the data type of these fields and thus later results in a runtime error. Note Since the ASSIGN statement does not set any return code value in the system field SY-SUBRC, subsequent program code should not read this field. Example DATA NAME(4) VALUE 'JOHN'. FIELD-SYMBOLS . ASSIGN NAME TO . WRITE . Output: JOHN Example DATA: NAME(12) VALUE 'JACKJOHNCARL', X(10) VALUE 'XXXXXXXXXX'. FIELD-SYMBOLS . ASSIGN NAME+4 TO . WRITE . ASSIGN NAME+4(*) TO . WRITE . Output: JOHNCARLXXXX JOHNCARL Example DATA: NAME(12) VALUE 'JACKJOHNCARL', X(10) VALUE 'XXXXXXXXXX'. FIELD-SYMBOLS . ASSIGN NAME+4 TO . WRITE . ASSIGN NAME+4(*) TO . WRITE . Output: JOHNCARLXXXX JOHNCARL Addition 1 ... TYPE typ Effect With untyped field symbols, allows you to change the current type of the field symbol to the type typ. The output length of the field symbol is corrected according to its type. With typed field symbols, this addition should only be used if the type of the field f does not match the type of the field symbol . The specified type type must be compatible with the type of the field symbol. Since no conversion can be performed (as with MOVE, the system must be able to interpret f as a field with this type type. The type specification is in the form of a literal or a field. At present, only system types (C, D, T, P, X, N, F, I or W) are allowed; you can also specify type 's' for 2-byte integer fields with a sign and type 'b' for 1-byte integer fields without a sign (see also DESCRIBE FIELD). Note This statement results in a runtime error if the specified type is unknown or does not match the field to be assigned (due to a missing alignment or an inappropriate length). Example DATA LETTER TYPE C. FIELD-SYMBOLS . ASSIGN LETTER TO . The field symbol has the type C and the output length 1. ASSIGN LETTER TO TYPE 'X'. The field symbol has the type X and the output length 2. Addition 2 ... DECIMALS dec Effect This addition only makes sense when used with type P. The field symbol contains dec decimal places. Example Output sales in thousands: DATA SALES_DEC2(10) TYPE P DECIMALS 2 VALUE 1234567. FIELD-SYMBOLS . ASSIGN SALES_DEC2 TO DECIMALS 5. WRITE: / SALES_DEC2, / . Output: 1,234,567.00 1,234.56700 Note This statement results in a runtime error if the field symbol has a type other than P at runtime or the specified number of decimal places is not in the range 0 to 14. Addition 3 ... LOCAL COPY OF ... Effect With LOCAL COPY OF, the ASSIGN statement can only be used in subroutines. This creates a copy of f which points to the field symbol. Note The field symbol must also be defined locally in the subroutine. Example DATA X(4) VALUE 'Carl'. PERFORM U. FORM U. FIELD-SYMBOLS . ASSIGN LOCAL COPY OF X TO . WRITE . MOVE 'John' TO . WRITE . WRITE X. ENDFORM. Output: Carl John Carl Variant 2 ASSIGN (f) TO . Additions: 1. ... TYPE typ 2. ... DECIMALS dec 3. ... LOCAL COPY OF ... Effect Assigns the field whose name is stored in the field f to the field symbol. The statement "ASSIGN (f)+off(len) TO " is not allowed. Notes - The search for the field to be assigned is performed as follows: 1. If the statement is in a subroutine or function module, the system first searches in this modularization unit. 2. If the statement lies outside any such modularization units or if the field is not found there, the system searches for the field in the global data of the program. 3. If the field is not found there, the system searches in the table work areas of the main program of the current program group declared with TABLES - The name of the field to be assigned can also be the name of a field symbol or formal parameter (or even a component of one of these, if the field symbol or the parameter has a structure). - If the name of the field to be assigned is of the form "(program name)field name", the system searches in the global fields of the program with the name "Program name" for the field with the name "Field name". However,it is only found if the program has already been loaded. Warning: This option is for internal use by specialists only. Incompatible changes or developments may occur at any time without warning or prior notice. The return code value is set as follows: SY-SUBRC = 0: The assignment was successful. SY-SUBRC = 4: The field could not be assigned to the field symbol. Example DATA: NAME(4) VALUE 'XYZ', XYZ VALUE '5'. FIELD-SYMBOLS . ASSIGN (NAME) TO . WRITE . Output: 5 Addition 1 ... TYPE typ Addition 2 ... DECIMALS dec Addition 3 ... LOCAL COPY OF ... Effect See similar additions of variant 1. Variant 3 ASSIGN TABLE FIELD (f) TO . Effect Identical to variant 2, except that the system searches for the field f only in the data in the current program group declared with TABLES. The return code value is set as follows: SY-SUBRC = 0: The assignment was successful. SY-SUBRC = 4: The field could not be assigned to the field symbol. Example TABLES TRDIR. DATA NAME(10) VALUE 'TRDIR-NAME'. FIELD-SYMBOLS . MOVE 'XYZ_PROG' TO TRDIR-NAME. ASSIGN TABLE FIELD (NAME) TO . WRITE . Output: XYZ_PROG Example TABLES T100. T100-TEXT = 'Global'. PERFORM EXAMPLE. FORM EXAMPLE. DATA: BEGIN OF T100, TEXT(20) VALUE 'LOCAL', END OF T100, NAME(30) VALUE 'T100-TEXT'. FIELD-SYMBOLS . ASSIGN (NAME) TO . WRITE . ENDFORM. Output: Local - although the global table field T100-TEXT has "global" contents. (This kind of name assignment of work fields is, of course, not recommended.) Example TABLES TRDIR. DATA: F(8) VALUE 'F_global', G(8) VALUE 'G_global'. MOVE 'XYZ_PROG' TO TRDIR-NAME. PERFORM U. FORM U. DATA: F(8) VALUE 'F_local', NAME(30) VALUE 'F'. FIELD-SYMBOLS . ASSIGN (NAME) TO . WRITE . MOVE 'G' TO NAME. ASSIGN (NAME) TO . WRITE . MOVE 'TRDIR-NAME' TO NAME. ASSIGN (NAME) TO . WRITE . ENDFORM. Output: F_local G_global XYZ_PROG Example PROGRAM P1MAIN. TABLES TRDIR. DATA NAME(30) VALUE 'TFDIR-PNAME'. FIELD-SYMBOLS . MOVE 'XYZ_PROG' TO TRDIR-NAME. PERFORM U(P1SUB). ASSIGN (NAME) TO . WRITE . CALL FUNCTION 'EXAMPLE'. PROGRAM P1SUB. TABLES TFDIR. ... FORM U. FIELD-SYMBOLS . DATA NAME(30) VALUE 'TRDIR-NAME'. ASSIGN TABLE FIELD (NAME) TO . WRITE . MOVE 'FCT_PROG' TO TFDIR-PNAME. ENDFORM. FUNCTION-POOL FUN1. FUNCTION EXAMPLE. DATA NAME(30) VALUE 'TRDIR-NAME'. FIELD-SYMBOLS . ASSIGN (NAME) TO . IF SY-SUBRC = 0. WRITE . ELSE. WRITE / 'TRDIR-NAME cannot be accessed'. ENDIF. ENDFUNCTION. Output: XYZ_PROG FCT_PROG TRDIR-NAME cannot be accessed Example TABLES TRDIR. MOVE 'XYZ_PROG' to TRDIR-NAME. PERFORM U USING TRDIR. FORM U USING X STRUCTURE TRDIR. FIELD-SYMBOLS . DATA NAME(30) VALUE 'X-NAME'. ASSIGN (NAME) TO . WRITE . ENDFORM. Output: XYZ_PROG Variant 4 ASSIGN LOCAL COPY OF MAIN TABLE FIELD (f) TO . Additions: 1. ... TYPE typ 2. ... DECIMALS dec Note This statement is for internal use only. Incompatible changes or further developments may occur at any time without warning or notice. Effect Identical to variant 3, except that the system searches for the field whose name is in f steht only in the data in the program group of the main program declared with TABLES. However, the field symbol then points not directly to the found field, but to a copy of this field on theq value stack. This variant therefore ensures that any access to Dictionary fields of an external program group is read only and no changes are made. Example PROGRAM P1MAIN. TABLES TRDIR. DATA NAME(30) VALUE 'TFDIR-PNAME'. FIELD-SYMBOLS . MOVE 'XYZ_PROG' TO TRDIR-NAME. CALL FUNCTION 'EXAMPLE'. FUNCTION-POOL FUN1. FUNCTION EXAMPLE. DATA NAME(30) VALUE 'TRDIR-NAME'. FIELD-SYMBOLS . ASSIGN LOCAL COPY OF MAIN TABLE FIELD (NAME) TO . IF SY-SUBRC = 0. WRITE . ELSE. WRITE / 'TRDIR-NAME cannot be accessed'. ENDIF. ENDFUNCTION. Output: XYZ_PROG Addition 1 ... TYPE typ Addition 2 ... DECIMALS dec Effect See similar additions to variant 1. Variant 5 ASSIGN COMPONENT idx OF STRUCTURE rec TO . Variant 6 ASSIGN COMPONENT name OF STRUCTURE rec TO . Additions: 1. ... TYPE typ 2. ... DECIMALS dec Effect If the field name or idx has the type C or if it is a field string with no internal table, it is treated as a component name. Otherwise, it is considered as a component number. The corresponding component of the field string rec is assigned to the field symbol . The return code value is set as follows: SY-SUBRC = 0: The assignment was successful. SY-SUBRC = 4: The field could not be assigned to the field symbol. Note If idx has the value 0, the entire field string is assigned to the field symbol. Example PROGRAM P1MAIN. DATA: BEGIN OF REC, A VALUE 'a', B VALUE 'b', C VALUE 'c', D VALUE 'd', END OF REC, CN(5) VALUE 'D'. FIELD-SYMBOLS . DO 3 TIMES. ASSIGN COMPONENT SY-INDEX OF STRUCTURE REC TO . IF SY-SUBRC <> 0. EXIT. ENDIF. WRITE . ENDDO. ASSIGN COMPONENT CN OF STRUCTURE REC TO . WRITE . Output: a b c d Addition 1 ... TYPE typ Addition 2 ... DECIMALS dec Effect See similar additions to variant 1. Note Runtime errors: Depending on the operands, the ASSIGN statement can cause runtime errors. Note Performance: For performance reasons, you are recommended to use typed field symbols. The runtime for a typed ASSIGN statement amounts to approx. 9 msn (standardized microseconds) against approx. 13 msn for an untyped ASSIGN statement. AT Events in lists - AT LINE-SELECTION. - AT USER-COMMAND. - AT PFn. Events on selection screens - AT SELECTION-SCREEN. Control break with extracts - AT NEW f. - AT END OF f. - AT FIRST. - AT LAST. - AT fg. Control break with internal tables - AT NEW f. - AT END OF f. - AT FIRST. - AT LAST. AT - control break Variants: 1. AT NEW f. 2. AT END OF f. 3. AT FIRST. 4. AT LAST. Variant 1 AT NEW f. Variant 2 AT END OF f. Effect f is a sub-field of an internal table or extract dataset (EXTRACT) which is being processed with LOOP, i.e. the variants 1 and 2 only make sense within a LOOP. Both "AT NEW f." and "AT END OF f." introduce processing blocks which are concluded by "ENDAT.". These processing blocks are processed whenever the contents of a field f or a sub-field defined before f change as a result of processing with LOOP. "AT NEW f." begins a new group of (table) lines with the same contents as the field f while "AT END OF f." concludes such a group. Within the AT ... ENDAT processing of internal tables, all argument fields following f are filled with "*". Examples 1. AT for sub-fields of an internal table DATA: BEGIN OF COMPANIES OCCURS 20, NAME(30), PRODUCT(20), SALES TYPE I, END OF COMPANIES. ... LOOP AT COMPANIES. AT NEW NAME. NEW-PAGE. WRITE / COMPANIES-NAME. ENDAT. WRITE: / COMPANIES-PRODUCT, COMPANIES-SALES. AT END OF NAME. SUM. WRITE: / COMPANIES-NAME, COMPANIES-SALES. ENDAT. ENDLOOP. The AT statements refer to the field COMPANIES-NAME. Examples 2. AT for the field of an extract dataset DATA: NAME(30), SALES TYPE I. FIELD-GROUPS: HEADER, INFOS. INSERT: NAME INTO HEADER, SALES INTO INFOS. ... LOOP. AT NEW NAME. NEW-PAGE. ENDAT. ... AT END OF NAME. WRITE: / NAME, SUM(SALES). ENDAT. ENDLOOP. Notes 1. If the processing you want to perform on an internal table is fairly restricted (i.e. a WHERE addition with the LOOP statement), do not use the AT statements specified in variants 1 to 5, since the interaction of the WHERE addition and the AT statement is currently not defined. 2. When you use LOOP with an extract dataset, fields on hex zero are ignored during control level checking with AT NEW or AT END OF. This procedure is the same as the SORT statement. When sorting extracted datasets, this statement always sorts blank fields (i.e. fields on hex zero) regardless of the sequence (ascending or descending) before all fields that contain values. 3. Since fields addressed with AT are not set to an initial value when you enter a LOOP, the first new group of (table) lines in AT NEW f may not be processed, if f happens to be set to this value. Variant 3 AT FIRST. Variant 4 AT LAST. Effect The variants 3 and 4 only make sense within a LOOP. The processing block between AT FIRST and ENDAT is executed before the individual lines are processed; the processing block between AT LAST and ENDAT is executed after all the individual lines have been processed. In AT FIRST or AT LAST ... ENDAT processing, all argument fields are filled with "*" (internal tables). When you are processing extract datasets, a control total SUM(n) can only be processed with AT END OF or AT LAST. Example DATA: BEGIN OF COMPANIES OCCURS 20, NAME(30), PRODUCT(20), SALES TYPE I, END OF COMPANIES. ... LOOP AT COMPANIES. AT FIRST. SUM. WRITE: 'Sum of all SALES:', 55 COMPANIES-SALES. ENDAT. WRITE: / COMPANIES-NAME, COMPANIES-PRODUCT, 55 COMPANIES-SALES. ENDLOOP. AT - Control break with extracts Variants: 1. AT NEW f. 2. AT END OF f. 3. AT FIRST. 4. AT LAST. 5. AT fg. Effect In a LOOP which processes a dataset created with EXTRACT, you can use special control structures for control break processing. All these structures begin with AT and end with ENDAT. The sequence of statements which lies between them is then executed if a control break occurs. You can use these key words for control break processing with extract datasets only if the active LOOP statement is proceesing an extract dataset. The control level structure with extract datasets is dynamic. It corresponds exactly to the sort key of the extract dataset, i.e. to the order of fields in the field group HEADER by which the extract dataset was sorted. At the end of a control group (AT END OF, AT LAST), there are two types of control level information between AT and ENDAT: - If the sort key of the extract dataset contains a non-numeric field h (particularly in the field group HEADER), the field CNT(h) contains the number of control breaks in the (subordinate) control level h. - For extracted number fields g (see also ABAP/4 number types), the fields SUM(g) contain the relevant control totals. Notes 1. The fields CNT(h) and SUM(g) can only be addressed after they have been sorted. Otherwise, a runtime error may occur. 2. The fields CNT(h) and SUM(g) are filled with the relevant values for a control level at the end of each control group (AT END OF, AT LAST), not at the beginning (AT FIRST, AT NEW). 3. When calculating totals with SUM(g), the system automatically chooses the maximum field sizes so that an overflow occurs only if the absolute value area limits are exceeded. 4. You can also use special control break control structures with LOOPs on internal tables. Variant 1 AT NEW f. Variant 2 AT END OF f. Effect f is a field from the field group HEADER. The enclosed sequence of statements is executed if - the field f occurs in the sort key of the extract dataset (and thus also in the field group HEADER) and - the field f or a superior sort criterion has a different value in the current LOOP line than in the prceding (AT NEW) or subsequent (AT END OF) record of the extract dataset. Example DATA: NAME(30), SALES TYPE I. FIELD-GROUPS: HEADER, INFOS. INSERT: NAME INTO HEADER, SALES INTO INFOS. ... LOOP. AT NEW NAME. NEW-PAGE. ENDAT. ... AT END OF NAME. WRITE: / NAME, SUM(SALES). ENDAT. ENDLOOP. Notes 1. If the extract dataset is not sorted before processing with LOOP, no control level structure is defined and the statements following AT NEW or AT END OF are not executed. 2. Fields which stand at hex zero are ignored by the control break check with AT NEW or AT END OF. This corresponds to the behavior of the SORT statement, which always places unoccupied fields (i.e. fields which stand at hex zero) before all occupied fields when sorting extract datasets, regardless of whether the sort sequence is in ascending or descending order. Variant 3 AT FIRST. Variant 4 AT LAST. Effect Executes the relevant series of statements just once - either on the first loop pass (with AT FIRST) or on the last loop pass (with AT LAST). Variant 5 AT fg. Addition: ... WITH fg1 Effect This statement makes single record processing dependent on the type of extracted record. The sequence of statements following AT fg are executed whenever the current LOOP record is created with EXTRACT fg (in other words: when the current record is a fg record). Addition ... WITH fg1 Effect Executes the sequence of statements belonging to AT fg WITH fg1 only if the record of the field group fg in the dataset is immediately followed by a record of the field group fg1. AT - field group definition Basic form AT fg. Addition: ... WITH fg1 Effect When you are processing an extract dataset (EXTRACT) in a LOOP, this statement makes single record processing dependent on the type of extracted record. The processing block specified within AT fg ... ENDAT is executed if the record just read was generated with EXTRACT fg (i.e. if the record just read is an fg record). Addition ... WITH fg1 Effect The processing block under AT fg WITH fg1. is executed only if the record from the field group fg in the dataset is immediately followed by a record from the field group fg1. AT - Control break with internal tables Variants: 1. AT NEW f. 2. AT END OF f. 3. AT FIRST. 4. AT LAST. Effect In a LOOP which processes a dataset created with EXTRACT, you can use special control structures for control break processing. All these structures begin with AT and end with ENDAT. The sequence of statements which lies between them is then executed if a control break occurs. You can use these key words for control break processing with extract datasets only if the active LOOP statement is proceesing an extract dataset. The control level structure with extract datasets is dynamic. It corresponds exactly to the sort key of the extract dataset, i.e. to the order of fields in the field group HEADER by which the extract dataset was sorted. At the start of a new control level (i.e. immediately after AT), the following occurs in the output area of the current LOOP statement: - All default key fields (on the right) are filled with "*" after the current control level key. - All other fields (on the right) are set to their initial values after the current control level key. Between AT and ENDAT, you can use SUM to insert the appropriate control totals in the number fields (see also ABAP/4 number types) of the LOOP output area (on the right) after the current control level key. Summing is supported both at the beginning of a control level (AT FIRST, AT NEW f) and also the end of a control level (AT END OF f, AT LAST). At the end of the control level processing (i.e. after ENDAT), the old contents of the LOOP output area are restored. Notes 1. When calculating totals, you must ensure that the totals are inserted into the same sub-fields of the LOOP output area as those where the single values otherwise occur. If there is an overflow, processing terminates with a runtime error. 2. If an internal table is processed only in a restricted form (using the additions FROM, TO and/or WHERE with the LOOP statement), you should not use the control structures for control level processing because the interaction of a restricted LOOP with the AT statement is currenly not properly defined. 3. With LOOPs on extracts, there are also special control break control structures you can use. Note Runtime errors: - SUM_OVERFLOW: Overflow when calculating totals with SUM. Variant 1 AT NEW f. Variant 2 AT END OF f. Effect f is a sub-field of an internal table processed with LOOP. The sequence of statements which follow it is executed if the sub-field f or a sub-field in the current LOOP line defined (on the left) before f has a differnt value than in the preceding (AT NEW) or subsequent (AT END OF) table line. Example DATA: BEGIN OF COMPANIES OCCURS 20, NAME(30), PRODUCT(20), SALES TYPE I, END OF COMPANIES. ... LOOP AT COMPANIES. AT NEW NAME. NEW-PAGE. WRITE / COMPANIES-NAME. ENDAT. WRITE: / COMPANIES-PRODUCT, COMPANIES-SALES. AT END OF NAME. SUM. WRITE: / COMPANIES-NAME, COMPANIES-SALES. ENDAT. ENDLOOP. The AT statements refer to the field COMPANIES-NAME. Notes 1. If a control break criterion is not known until runtime, you can use AT NEW (name) or AT END OF (name) to specify it dynamically as the contents of the field name. If name is blank at runtime, the control break criterion is ignored and the sequence of statements is not executed. If name contains an invalid component name, a runtime error occurs. 2. By defining an offset and/or length, you can further restrict control break criteria - regardless of whether they are specified statically or dynamically. 3. A field symbol pointing to the LOOP output area can also be used as a dynamic control break criterion. If the field symbol does not point to the LOOP output area, a runtime error occurs. Note Runtime errors: - AT_BAD_PARTIAL_FIELD_ACCESS: Invalid sub-field access when dynamically specifying the control break criterion. - AT_ITAB_FIELD_INVALID: When dynamically specifying the control break criterion via a field symbol, the field symbol does not point to the LOOP output area. - ITAB_ILLEGAL_COMPONENT: When dynamically specifying the control break criterion via (name) the field name does not contain a valid sub-field name. Variant 3 AT FIRST. Variant 4 AT LAST. Effect Executes the appropriate sequence of statements once during the first (AT FIRST) or last (AT LAST) loop pass. Example DATA: BEGIN OF COMPANIES OCCURS 20, NAME(30), PRODUCT(20), SALES TYPE I, END OF COMPANIES. ... LOOP AT COMPANIES. AT FIRST. SUM. WRITE: 'Sum of all SALES:', 55 COMPANIES-SALES. ENDAT. WRITE: / COMPANIES-NAME, COMPANIES-PRODUCT, 55 COMPANIES-SALES. ENDLOOP. AT - Events in lists Variants: 1. AT LINE-SELECTION. 2. AT USER-COMMAND. 3. AT PFn. Variant 1 AT LINE-SELECTION. Effect Event in interactive reporting This event is processed whenever the user chooses a valid line in the list (i.e. a line generated by statements such as WRITE, ULINE or SKIP) with the cursor and presses the function key which has the function PICK in the interface definition. This should normally be the function key F2, because it has the same effect as double-clicking the mouse, or single-clicking in the case of a hotspot. The processing for the event AT LINE-SELECTION usually generates further list output (the details list) which completely covers the current list display. If the latter is still visible (to aid user orientation), this may be due to the key word WINDOW. In most cases, the information is from the selected line is used to retrieve more comprehensive information by direct reading. When displaying the original list, you store the key terms needed for this in the HIDE area of the output line. Note You can choose a line and start new processing even in the details lists. The following system fields are useful for orientation purposes, since their values change with each interactive event executed. SY-LSIND Index of list created by current event (basic list = 0, 1st details list = 1, ...) SY-PFKEY Status of displayed list (SET PF-STATUS) SY-LISEL Contents of selected line SY-LILLI Absolute number of this line in the displayed list SY-LISTI Index of this list - usually SY-LSIND - 1 (READ LINE) SY-CUROW Last cursor position: Line in window SY-CUCOL Last cursor position: Column in window (GET CURSOR) SY-CPAGE 1st displayed page of displayed list SY-STARO 1st displayed line of this page of displayed list SY-STACO 1st displayed column of displayed list (SCROLL LIST) The system field SY-LSIND defines the line selection level (basic list: SY-LSIND = 0). Example DATA TEXT(20). START-OF-SELECTION. PERFORM WRITE_AND_HIDE USING SPACE SPACE. AT LINE-SELECTION. CASE TEXT. WHEN 'List index'. PERFORM WRITE_AND_HIDE USING 'X' SPACE. WHEN 'User command'. PERFORM WRITE_AND_HIDE USING SPACE 'X'. WHEN OTHERS. SUBTRACT 2 FROM SY-LSIND. PERFORM WRITE_AND_HIDE USING SPACE SPACE. ENDCASE. CLEAR TEXT. FORM WRITE_AND_HIDE USING P_FLAG_LSIND P_FLAG_UCOMM. WRITE / 'SY-LSIND:'. PERFORM WRITE_WITH_COLOR USING SY-LSIND P_FLAG_LSIND. TEXT = 'List index'. HIDE TEXT. WRITE / 'SY-UCOMM:'. PERFORM WRITE_WITH_COLOR USING SY-UCOMM P_FLAG_UCOMM. TEXT = 'User command'. HIDE TEXT. IF SY-LSIND > 0. WRITE / 'PICK here to go back one list level'. ENDIF. ENDFORM. FORM WRITE_WITH_COLOR USING P_VALUE P_FLAG_POSITIVE. IF P_FLAG_POSITIVE = SPACE. WRITE P_VALUE COLOR COL_NORMAL. ELSE. WRITE P_VALUE COLOR COL_POSITIVE. ENDIF. ENDFORM. Depending on whether you choose the line at SY-LSIND or SY-UCOMM, the next details list contains the corresponding value with the color "positive". If the line is chosen without HIDE information, the list level is reduced. Variant 2 AT USER-COMMAND. Effect Event in interactive reporting This event is executed whenever the user presses a function key in the list or makes an entry in the command field. Some functions are executed directly by the system and thus cannot be processed by programs. These include: PICK See variant AT LINE-SELECTION PFn See variant AT PFn /... System command %... System command PRI Print BACK Back RW Cancel P... Scroll function (e.g.: P+, P-, PP+3, PS-- etc.) Instead of this functions, you can use the SCROLL statement in programs. Since many of these system functions begin with "P", you should avoid using this letter to start your own function codes. Otherwise, the effect is as for AT LINE-SELECTION; also, the current function code is stored in the system field SY-UCOMM. Example DATA: NUMBER1 TYPE I VALUE 20, NUMBER2 TYPE I VALUE 5, RESULT TYPE I. START-OF-SELECTION. WRITE: / NUMBER1, '?', NUMBER2. AT USER-COMMAND. CASE SY-UCOMM. WHEN 'ADD'. RESULT = NUMBER1 + NUMBER2. WHEN 'SUBT'. RESULT = NUMBER1 - NUMBER2. WHEN 'MULT'. RESULT = NUMBER1 * NUMBER2. WHEN 'DIVI'. RESULT = NUMBER1 / NUMBER2. WHEN OTHERS. WRITE 'Unknown function code'. EXIT. ENDCASE. WRITE: / 'Result:', RESULT. After entry of a function code, the appropriate processing is performed under the event AT USER-COMMAND and the result is displayed in the details list. Variant 3 AT PFn. Effect Event in interactive reporting Here, n stands for a numeric value between 0 and 99. This event is executed whenever the user presses a function key that contains the function code PFn in the interface definition. The default status for lists contains some of these functions. Otherwise, the effect is as for the variant AT LINE-SELECTION. The cursor can be on any line. Notes 1. To ensure that the chosen function is executed only for valid lines, you can check the current HIDE information. 2. This variant should be used only for test or prototyping purposes, since the default status is not normally used. Instead, you should set a program-specific status with SET PF-STATUS. This should not contain any function codes beginning with "PF". Example DATA NUMBER LIKE SY-INDEX. START-OF-SELECTION. DO 9 TIMES. WRITE: / 'Row', (2) SY-INDEX. NUMBER = SY-INDEX. HIDE NUMBER. ENDDO. AT PF8. CHECK NOT NUMBER IS INITIAL. WRITE: / 'Cursor was in row', (2) NUMBER. CLEAR NUMBER. AT - Events on selection screens Basic form AT SELECTION-SCREEN. Additions: 1. ... ON psel 2. ... ON END OF sel 3. ... ON VALUE-REQUEST FOR psel_low_high. 4. ... ON HELP-REQUEST FOR psel_low_high 5. ... ON RADIOBUTTON GROUP radi 6. ... ON BLOCK block 7. ... OUTPUT Effect This event only makes sense in reports, i.e. in programs set to type 1 in the attributes. Type 1 programs are started via a logical database and always have a selection screen where the user can specify the database selections. The event is processed when the selection screen has been processed (at the end of PAI). If an error message (MESSAGE Emnr) is sent during the event, all fields on the selection screen become ready for input. After further user input, AT SELECTION-SCREEN is executed again. Note You should only perform very expensive checks with AT SELECTION-SCREEN if the program is then started (not every time the user presses ENTER). Here, you can read the system field SSCRFIELDS-UCOMM (provided a statement TABLES SSCRFIELDS exists). If the field has one of the values 'ONLI' (= Execute) or 'PRIN' (= Execute and Print), the report is then started, i.e. the selection screen is closed and the processing continues with START-OF-SELECTION. Remember that the selection screen (and thus also AT SELECTION-SCREE N) is also processed in variant maintenance and with SUBMIT VIA JOB. You can determine which of these applies by calling the function module RS_SUBMIT_INFO . Addition 1 ... ON psel Effect This event is assigned to the selection screen fields corresponding to the report parameter or selection criterion psel. If the report starts an error dialog at this point, precisely these fields become ready for input. Addition 2 ... ON END OF sel Effect For each selection criterion sel on the selection screen, you can call a further screen by pressing a pushbutton. On this screen, you can enter any number of single values and ranges for the selection criterion sel. When this screen has been processed (i.e. at the end of PAI for this screen), the event AT SELECTION-SCREEN ON END OF sel is executed. At this point, all the values entered are available in the internal table sel. Addition 3 ... ON VALUE-REQUEST FOR psel_low_high Effect With this addition, the field psel_low_high is either the name of a report parameter or of the form sel-LOW or sel-HIGH, where sel is the name of a selection criterion. The effect of this is twofold: 1. The pushbutton for F4 (Possible entries) appears beside the appropriate field. 2. When the user selects this pushbutton or presses F4 for the field, the event is executed. You can thus implement a self-programmed possible entries routine for the input/output fields of the selection screen. If the program contains such an event and the user presses F4, the system processes this rather than displaying the check table or the fixed values of the Dictionary field - even if the report parameter or the selection option with LIKE or FOR points to a Dictionary field. You can, for example, use the CALL SCREEN statement to display a selection list of possible values. The contents of the field psel_low_high at the end of this processing block are copied to the appropriate input/output field. This addition is only allowed with report-specific parameters (PARAMETERS) or selection options (SELECT-OPTIONS). For database-specific parameters or selection options, you can achieve the same effect by using the addition VALUE-REQUEST FOR ... with the key word PARAMETERS or SELECT-OPTIONS in the include DBxyzSEL (where xyz = name of logical database). In this case, you must program the value help in the database program SAPDBxyz. Addition 4 ... ON HELP-REQUEST FOR psel_low_high Effect As with the addition ON VALUE-REQUEST the field psel_low_high is either the name of a report parameter or of the form sel-LOW or sel-HIGH, where sel is the name of a selection criterion. When the user presses F1 on the relevant field, the subsequent processing block is executed. You can thus implement a self-programmed help for the input/output fields of the selection screen. If the program contains such an event and the user presses F1, the system processes this rather than displaying the documentation of the Dictionary field - even if the report parameter or the selection option with LIKE or FOR points to a Dictionary field. This addition is only allowed with report-specific parameters (PARAMETERS) or selection options (SELECT-OPTIONS). For database-specific parameters or selection options, you can achieve the same effect by using the addition HELP-REQUEST FOR ... with the key word PARAMETERS or SELECT-OPTIONS in the include DBxyzSEL (where xyz = name of logical database). In this case, you must program the help in the database program SAPDBxyz. Addition 5 ... ON RADIOBUTTON GROUP radi Effect This event is assigned to the radio button groups on the selection screen defined by PARAMETERS par RADIOBUTTON GROUP radi. If the report starts an error dialog at this point, precisely these fields of the radio button group radi become ready for input again. Addition 6 ... ON BLOCK block Effect This event is assigned to the blocks on the selection screen defined by SELECTION-SCREEN BEGIN/END OF BLOCK block. If the report starts an error dialog at this point, precisely these fields of the block block become ready for input again. Note In which sequence are the events AT SELECTION-SCREEN ON psel ..., AT SELECTION-SCREEN ON RADIOBUTTON GROUP ..., AT SELECTION-SCREEN ON BLOCK ..., AT SELECTION-SCREEN processed? The AT SELECTION-SCREEN ON psel ... events assigned to the parameters or selection options are executed in the sequence they are declared in the program, i.e. in the sequence they appear on the selection screen. The events assigned to the radio button groups are executed according to the first parameter of the radio button group. The events assigned to the blocks are executed "from the inside to the outside". Example SELECT-OPTIONS SEL0 FOR SY-TVAR0. SELECTION-SCREEN BEGIN OF BLOCK BL0. SELECT-OPTIONS SEL1 FOR SY-TVAR1. SELECTION-SCREEN BEGIN OF BLOCK BL1. PARAMETERS P0 RADIOBUTTON GROUP RADI. PARAMETERS P1 RADIOBUTTON GROUP RADI. SELECTION-SCREEN BEGIN OF BLOCK BL2. PARAMETERS P3. SELECTION-SCREEN END OF BLOCK BL2. SELECT-OPTIONS SEL2 FOR SY-TVAR2. SELECTION-SCREEN END OF BLOCK BL1. SELECTION-SCREEN END OF BLOCK BL0. Sequence: AT SELECTION-SCREEN ON... SEL0 SEL1 RADIOBUTTON GROUP RADI P3 BLOCK BL2 SEL2 BLOCK BL1 BLOCK BL0 AT SELECTION-SCREEN is executed at the very end. Addition 7 ... OUTPUT Effect This event is executed at PBO of the selection screen every time the user presses ENTER - in contrast to INITIALIZATION. Therefore, this event is not suitable for setting selection screen default values. Also, since AT SELECTION-SCREEN OUTPUT is first executed after the variant is imported (if a variant is used) and after adopting any values specified under SUBMIT in the WITH clause, changing the report parameters or the selection options in AT SELECTION-SCREEN OUTPUT would destroy the specified values. Here, however, you can use LOOP AT SCREEN or MODIFY SCREEN to change the input/output attributes of selection screen fields. Example Output all fields of the SELECT-OPTION NAME highlighted: SELECT-OPTIONS NAME FOR SY-REPID MODIF ID XYZ. ... AT SELECTION-SCREEN OUTPUT. LOOP AT SCREEN. CHECK SCREEN-GROUP1 = 'XYZ'. SCREEN-INTENSIFIED = '1'. MODIFY SCREEN. ENDLOOP. The addition MODIF ID XYZ to the key word SELECT-OPTIONS assigns all fields of the selection option NAME to a group you can read in the field SCREEN-GROUP1. At PBO of the selection screen, all these fields are then set to highlighted. Note In the context of event processing, the SET PF-STATUS statement does not work. Instead, you must set a status using the function module RS_SET_SELSCREEN_STATUS or RS_EXTERNAL_SELSCREEN_STATUS. AUTHORITY-CHECK Basic form AUTHORITY-CHECK OBJECT object ID name1 FIELD f1 ID name2 FIELD f2 ... ID name10 FIELD f10. Effect Explanation of IDs: object Field which contains the name of the object for which the authorization is to be checked. name1 ... Fields which contain the names of the name10 authorization fields defined in the object. f1 ... Fields which contain the values for which the f10 authorization is to be checked. AUTHORITY-CHECK checks for one object whether the user has an authorization that contains all values of f (see SAP authorization concept). You must specify all authorizations for an object and a also a value for each ID (or DUMMY). The system checks the values for the IDs by AND-ing them together, i.e. all values must be part of an authorization assigned to the user. If a user has several authorizations for an object, the values are OR-ed together. This means that if the CHECK finds all the specified values in one authorization, the user can proceed. Only if none of the authorizations for a user contains all the required values is the user rejected. If the return code SY-SUBRC = 0, the user has the required authorization and may continue. The return code is modified to suit the different error scenarios. The return code values have the following meaning: 4 User has no authorization in the SAP System for such an action. If necessary, change the user master record. 8 Too many parameters (fields, values). Maximum allowed is 10. 12 Specified object not maintained in the user master record. 16 No profile entered in the user master record. 24 The field names of the check call do not match those of an authorization. Either the authorization or the call is incorrect. 28 Incorrect structure for user master record. 32 Incorrect structure for user master record. 36 Incorrect structure for user master record. If the return code value is 8 or possibly 24, inform the person responsible for the program. If the return code value is 4, 12, 15 or 24, consult your system administrator if you think you should have the relevant authorization. In the case of errors 28 to 36, contact SAP, since authorizations have probably been destroyed. Individual authorizations are assigned to users in their respective user profiles, i.e. they are grouped together in profiles which are stored in the user master record. Note Instead of ID name FIELD f, you can also write ID name DUMMY. This means that no check is performed for the field concerned. The check can only be performed on CHAR fields. All other field types result in 'unauthorized'. Example Check whether the user is authorized for a particular plant. In this case, the following authorization object applies: Table OBJ: Definition of authorization object M_EINF_WRK ACTVT WERKS Here, M_EINF_WRK is the object name, whilst ACTVT and WERKS are authorization fields. For example, a user with the authorizations M_EINF_WRK_BERECH1 ACTVT 01-03 WERKS 0001-0003 . can display and change plants within the Purchasing and Materials Management areas. Such a user would thus pass the checks AUTHORITY-CHECK OBJECT 'M_EINF_WRK' ID 'WERKS' FIELD '0002' ID 'ACTVT' FIELD '02'. AUTHORITY-CHECK OBJECT 'M_EINF_WRK' ID 'WERKS' DUMMY ID 'ACTVT' FIELD '01': but would fail the check AUTHORITY-CHECK OBJECT 'M_EINF_WRK' ID 'WERKS' FIELD '0005' ID 'ACTVT' FIELD '04'. To suppress unnecessary authorization checks or to carry out checks before the user has entered all the values, use DUMMY> - as in this example. You can confirm the authorization later with another AUTHORITY-CHECK. BACK Basic form BACK. Effect Returns output position to the first line of the current page after the TOP-OF-PAGE processing. When used in connection with RESERVE x LINES, the statement returns the output position to the first output line after RESERVE. Example DATA: TOWN(10) VALUE 'New York', CUSTOMER1(10) VALUE 'Charly', CUSTOMER2(10) VALUE 'Sam', SALES1 TYPE I VALUE 1100, SALES2 TYPE I VALUE 2200. RESERVE 2 LINES. WRITE: TOWN, CUSTOMER1, / CUSTOMER2 UNDER CUSTOMER1. BACK. WRITE: 50 SALES1, / SALES2 UNDER SALES1. Using the positioning in WRITE in column 50, data not yet output is not overwritten, but the sales volume is output after the customer names. Notes 1. If you use a '/' with the first WRITE after the BACK statement, this starts a (usually unwanted) new line. 2. BACK in the TOP-OF-PAGE processing positions the cursor after the standard header. Subsequent WRITE statements also overwrite the lines output under TOP-OF-PAGE. Note Performance: The runtime required to execute a BACK statement is about 1 msn (standardized microseconds). BREAK-POINT Variants: 1.BREAK-POINT. 2.BREAK-POINT f. Variant 1 BREAK-POINT. Effect The BREAK-POINT statement interrupts the processing and diverts the system to debugging mode. You can then display the contents of all the fields at runtime and also control the subsequent program flow. If the system is unable to branch to debugging for some reason (due to a background job or update), it generates a system log message. Note - After the BREAK-POINT, the system automatically performs any restart in the database, if no COMMIT WORK was executed. Since debugging sometimes switches off COMMIT WORK, you should not place a BREAK-POINT statement in a SELECT loop. - In the editor, you can also set a breakpoint dynamically without making any changes to the ABAP/4 program. These dynamic breakpoints are valid only for the current user in the current session. Variant 2 BREAK-POINT f. Effect Behaves like variation 1, except that the field contents of f remain in the event of any system log messages. CALL Call a function module - CALL FUNCTION func. - CALL FUNCTION func STARTING NEW TASK taskname. - CALL FUNCTION func IN UPDATE TASK. - CALL FUNCTION func DESTINATION dest. - CALL FUNCTION func IN BACKGROUND TASK. - CALL CUSTOMER-FUNCTION func. Call a screen - CALL SCREEN scr. Call a transaction - CALL TRANSACTION tcod. Call a dialog module - CALL DIALOG dial. Call a method of an external object - CALL METHOD OF obj m. Call a system function - CALL cfunc. CALL - Call a system function Note This statement is for internal use only. Incompatible changes or further developments may occur at any time without warning or notice. Basic form 6 CALL cfunc. Addition: ... ID id1 FIELD f1 ... ID idn FIELD fn Effect Calls the system function cfunc. The relevant function must exist in the file sapactab.h. If you change or recreate a function, you have to compile and link the SAP kernel again. For this, you need the C source code files. Normally, external programs should be called via RFC with CALL FUNCTION ... DESTINATION. Addition ... ID id1 FIELD f1 ... ID idn FIELD fn Effect Passes fields to the called program by reference. With "ID id1", you specify the name of a formal parameter, and with "FIELD f1" the relevant field from the ABAP/4 program. If a formal parameter expects an internal table, the latter is passed in the form "FIELD tab[]". Example DATA RESULT(8). CALL 'MULTIPLY' ID 'P1' FIELD '9999' ID 'P2' FIELD '9999' ID 'RES' FIELD RESULT. Note Runtime errors: CALL_C_FUNCTION_NOT_FOUND: Specified system function is unknown. CALL FUNCTION Variant 6 CALL CUSTOMER-FUNCTION func. Additions: The same as for CALL FUNCTION func. Effect Calls the function module func. func must be a 3-character literal (e.g. '001') In line with SAP's enhancement concept, function modules are delivered empty and must be implemented by the customer (the transactions used for this are SMOD at SAP and CMOD at the customer's). The interface and call location are both defined by SAP. Note The customer can use Transaction CMOD to activate the function module. The final name of the function module is compiled from EXIT_, the name of the module pool where the function module is called, and the name func. For example, the statement "CALL CUSTOMER-FUNCTION '001'" in the module pool SAPMS38M calls the function module EXIT_SAPMS38M_001. CALL DIALOG - Call a dialog module CALL DIALOG dial. Additions: 1. ... AND SKIP FIRST SCREEN 2. ... EXPORTING f1 FROM g1 ... fn FROM gn 3. ... IMPORTING f1 TO g1 ... fn TO gn 4. ... USING itab ... MODE mode. Effect Calls the dialog module dial; dial can be a literal or a variable. To edit dialog modules, select Tools -> ABAP/4 Workbench -> Development -> Programming environ. -> Dialog modules. Addition 1 ... AND SKIP FIRST SCREEN Effect Processes the first screen of the dialog module in the background, if all required entry fields have been filled. Addition 2 ... EXPORTING f1 FROM g1 ... fn FROM gn Effect Specifies all data objects (fields, field strings, internal tables) to be passed to the dialog module. If the names in the calling and called programs are identical, you can omit "FROM g1". Otherwise, fi refers to the field in the dialog module, while gi specifies the field in the calling program. Addition 3 ... IMPORTING f1 TO g1 ... fn TO gn Effect Specifies all data objects (fields, field strings, internal tables) to be returned from the dialog module. If the names in the calling and called programs are identical, you can omit "TO g1". Otherwise, fi refers to the field in the dialog module, while gi specifies the field in the calling program. Examples DATA: BEGIN OF ITAB, LINE(72), END OF ITAB, TITLE LIKE SY-TITLE. CALL DIALOG 'RS_EDIT_TABLE' EXPORTING SOURCETAB FROM ITAB TITLE IMPORTING SOURCETAB TO ITAB. Notes - The system field SY-SUBRC is automatically exported and imported. - The unknown export/import data in the dialog module is ignored. - The data objects passed should have the same type or structure in the calling program and the dialog module. Addition 4 ... USING itab ... MODE mode Effect Calls the dialog module dial and also passes the internal table itab which contains one or more screens in batch input format. If required, the dialog module may return a message to the system fields SY-MSGID, SY-MSGTY, SY-MSGNO, SY-MSGV1, ..., SY-MSGV4. The specified processing mode mode mode can accept the following values: 'A' Display screen 'E' Display only if an error occurs 'N' No display If the addition MODE is not specified, the processing mode is 'A'. The return code value is set as follows: SY-SUBRC = 0: The processing was successful. SY-SUBRC <> 0: The dialog ended with an error. Notes - All lock arguments are automatically exported and imported. In contrast to a transaction, a dialog module does not form its own LUW (see Transaction processing). Any update requests which occur there are not processed until the calling program executes a COMMIT WORK. - To return from the dialog module, use the key word LEAVE PROGRAM. Note Runtime errors: - CALL_DIALOG_NOT_FOUND: The called dialog module is unknown. - CALL_DIALOG_WRONG_TDCT_MODE: The called dialopg module contains errors (incorrect entry in table TDCT). - CALL_DIALOG_NAME_TOO_LONG: The name of a parameter is longer than permitted. - CALL_DIALOG_NO_CONTAINER: No memory for parameter transfer. Related CALL TRANSACTION, CALL FUNCTION CALL - call a function module Variants: Call a function module: 1. CALL FUNCTION func. Call a function module in a different mode (asynchronous Remote Function Call): 2. CALL FUNCTION func STARTING NEW TASK taskname. Call a function module in the update task: 3. CALL FUNCTION func IN UPDATE TASK. Call a function module in a remote system (Remote Function Call, RFC): 4. CALL FUNCTION func DESTINATION dest. Asynchronous call to a function module with transactional processing (transactional Remote Function Call): 5. CALL FUNCTION func IN BACKGROUND TASK. Call a function module which can be activated in the context of enhancements: 6. CALL CUSTOMER-FUNCTION func. CALL FUNCTION Variant 1 CALL FUNCTION func. Additions: 1. ... EXPORTING p1 = f1 ... pn = fn 2. ... IMPORTING p1 = f1 ... pn = fn 3. ... TABLES p1 = itab1 ... pn = itabn 4. ... CHANGING p1 = f1 ... pn = fn 5. ... EXCEPTIONS except1 = rc1 ... exceptn = rcn Effect Calls the function module func; func can be a literal or a variable. To edit function modules, select Tools -> ABAP/4 Workbench -> Function Library. The assignment of parameters is by name (p1, p2, etc.), not by sequence. To return from the function module, you use the key word EXIT, unless EXIT occurs in a loop or a subroutine. Note You can use the editor commands "SHOW FUNCTION func" and "SHOW FUNCTION *" to get information about the function module func or any other function module. Addition 1 ... EXPORTING p1 = f1 ... pn = fn Effect EXPORTING passes fields, field strings or internal tables to the function module. You must declare the parameters p1 ... pn in the function interface as import parameters. When you call the function module, you must assign values to all import parameters which are not flagged in the interface definition as optional and do not have any default values. Addition 2 ... IMPORTING p1 = f1 ... pn = fn Effect IMPORTING passes fields, field strings or internal tables from the function module back to the calling program. The parameters p1 ... pn must be declared as export parameters in the function interface. Addition 3 ... TABLES p1 = itab1 ... pn = itabn Effect TABLES passes references to internal tables. The parameters p1 ... pn must be declared as table parameters in the function interface. When you call the function module, you must assign values to all table parameters which are not flagged as optional in the interface definition. Addition 4 ... CHANGING p1 = f1 ... pn = fn Effect CHANGING passes fields, field strings or internal tables to the function module and the changed values are returned. The parameters p1 ... pn must be declared as CHANGING parameters in the function interface. When you call the function module, you must assign values to all CHANGING parameters of the function module which are not flagged as optional in the interface definition and have no default values. Addition 5 ... EXCEPTIONS except1 = rc1 ... exceptn = rcn Effect EXCEPTIONS lists the exceptions to be handled by the calling program itself. At the end of the exception list, you can use OTHERS to refer to all the remaining exceptions. If one of the listed exceptions occurs, SY-SUBRC is set to the appropriate value rc (a number literal!) and control passes back to the calling program. By specifying a return code, you can divided the exceptions into classes. With the second form, without "=rc", SY-SUBRC is set to a value other than 0 if an exception occurs. If the function module triggers an exception (with the statements RAISE and MESSAGE ... RAISING) and the exception is not to be handled by the calling program itself, - RAISE terminates the program with a runtime error; - MESSAGE ... RAISING outputs the message. Note The following EXCEPTIONS are predefined by the system and have a special meaning: - OTHERS: Covers all user-defined exceptions in the called function module. - ERROR_MESSAGE: This exception instructs the system to ignore S messages, I messages and W messages until return from the function module (although they still appear in the log during background processing). When an E message or an A message occurs, the called function module terminates, as if the exception ERROR_MESSAGE has been triggered. Examples DATA: FIELD(30) VALUE 'Example: This is a field.', head(30). CALL FUNCTION 'STRING_SPLIT' EXPORTING DELIMITER = ':' STRING = FIELD IMPORTING HEAD = HEAD TAIL = FIELD EXCEPTIONS NOT_FOUND = 1 OTHERS = 2. CASE SY-SUBRC. WHEN 1. ... WHEN 2. .... ENDCASE. ... DATA: BEGIN OF TAB1 OCCURS 10, X, END OF TAB1, BEGIN OF TAB2 OCCURS 20, Y, END OF TAB2. CALL FUNCTION 'ITAB_COPY' TABLES TAB_IN = TAB1 TAB_OUT = TAB2. Note Runtime errors: - CALL_FUNCTION_NOT_FOUND: The called function is unknown. - CALL_FUNCTION_NO_VB: Only update function modules can be called in the update task. - CALL_FUNCTION_NOT_ACTIVE: The called function is known, but not active. - CALL_FUNCTION_PARM_MISSING: The function expects a parameter, but none was passed by the calling program. - CALL_FUNCTION_PARM_UNKNOWN: The calling program passed a parameter which the function does not recognize. - CALL_FUNCTION_CONFLICT_LENG: The function expected a different actual parameter length. - CALL_FUNCTION_CONFLICT_TYPE - CALL_FUNCTION_CONFLICT_GEN_TYP: The actual parameter type does not satisfy the requirements of the function interface. - CALL_FUNCTION_WRONG_ALIGNMENT: An actual parameter does not satisfy the alignment requirements of the corresponding formal parameter. - CALL_FUNCTION_BASE_LITL: A literal was supposed to be passed to a structured formal parameter. CALL FUNCTION Variants: Call a function module 1. CALL FUNCTION func. Call a function module in new mode (asynchronous Remote Function Call) 2. CALL FUNCTION func STARTING NEW TASK taskname dest. Call a function module in the update task 3. CALL FUNCTION func IN UPDATE TASK. Call a function module in a remote system (Remote Function Call) 4. CALL FUNCTION func DESTINATION dest. Asynchronous call to function module with transaction-like processing (transaction-like Remote Function Call) 5. CALL FUNCTION func IN BACKGROUND TASK. Call a function module that can be activated within framework of enhancement concept. 6. CALL CUSTOMER-FUNCTION func. CALL FUNCTION Variant 5 CALL FUNCTION func IN BACKGROUND TASK. Additions: 1. ... DESTINATION dest 2. ... EXPORTING p1 = f1 ... pn = fn 3. ... TABLES p1 = itab1 ... pn = itabn Effect Flags the function module func to be run asynchronously. It is not executed at once, but the data passed with EXPORTING bzw. TABLES is placed in a database table and the next COMMIT WORK then executes the function module in another work process. Note This variant applies only from R/3 Release 3.0. Both partner systems (the client and the server systems) must have a Release 3.0 version of the R/3 System. Addition 1 ... DESTINATION dest Effect Executes the function module externally as a Remote Function Call (RFC); dest can be a literal or a variable. Depending on the specified destination, the function module is executed either in another R/3 System or as a C-implemented function module. Externally callable function modules must be flagged as such in the function library (of the target system). Since each destination defines its own program context, further calls to the same or different function modules with the same destination can access the local memory (global data) of these function modules. Addition 2 ... EXPORTING p1 = f1 ... pn = fn Effect EXPORTING passes values of fields and field strings from the calling program to the function module. In the function module, the formal parameters are defined as import parameters. Default values must be assigned to all import parameters of the function module in the interface definition. Addition 3 ... TABLES p1 = itab1 ... pn = itabn Effect TABLES passes references to internal tables. All table parameters of the function module must contain values. Notes If several function module calls with the same destination are specified before COMMIT WORK, these form an LUW in the target system. Type 2 destinations (R/3 - R/2 connections) cannot be specified. CALL FUNCTION Variant 6 CALL CUSTOMER-FUNCTION func. Additions: The same as with CALL FUNCTION func. Effect Calls the function module func; this can be activated. func must be a 3-character literal (e.g. '001'). The function modules are delivered empty within the framework of the enhancement concept and must be implemented by the customer. They are maintained with the Transactions SMOD (at SAP) and CMOD (at the csutomer's). SAP determines both the interface and the place where the call is made. Note By using the Transaction CMOD, the customer can activate the function module. The final name of the function module comprises EXIT_, the name of the module pool where the function module is called, and the name func. For example, the statement "CALL CUSTOMER-FUNCTION '001'" in the module pool SAPMS38M calls the function module EXIT_SAPMS38M_001. CALL FUNCTION Variant 4 CALL FUNCTION func DESTINATION dest. Additions: 1. The same as with CALL FUNCTION func 2. ... EXCEPTIONS syst_except = rc MESSAGE mess Effect Executes the function module externally as a Remote Function Call (RFC); dest can be a literal or a variable. Depending on the specified destination, the function module is executed in another R/3 or R/2 System. Externally callable function modules must be flagged as such in the function library (of the target system). Since each destination defines its own program context, further calls to the same or different function modules with the same destination can access the local memory (global data) of these function modules. You can maintain existing destinations by selecting Tools -> Administration -> Administration -> Network -> RFC destinations. Notes Special destinations: - The destination NONE refers to the calling system. Function modules called with CALL FUNCTION func DESTINATION 'NONE' ... are executed in the system of the calling program, but in their own program context. - You can use the destination BACK if the current program was already called by RFC. The, BACK refers back to the calling program: CALL FUNCTION func DESTINATION 'BACK' ... If the program is not called from a "remote" source, the exception COMMUNICATION_FAILURE is triggered. - Each R/3 System has a standard name. This is formed from the host name (e.g. SY-HOST), the system name (SY-SYSID) and the system nummer (two-character number assigned on installation of the applications server). You can use this name as a destination. For example, you can call the function module func in the system C11 on the host sapxyz with system number 00 as follows: CALL FUNCTION func DESTINATION 'sapxyz_C11_00' ... - You can also use saprouter path names as destinations (see also saprouter documentation). Note Parameter passing. When you pass data to an externally called function module, there are some differences to the normal function module call: - With table parameters, only the table itself is passed, not the header line. - If one of the parameters of the interface of an externally called function module is not specified when called, the import parameters are set to their initial value. If no default value was given in the interface definition, TABLES parameters are defined as an empty table and unspecified export parameters are lost. Note Passing structured data objects. Since transport to another system may require data conversion, the structure of field strings and internal tables must be known to the runtime system when the call is made. The structure of a field string or internal table is not known if it was defined with ... LIKE structure, if the structure passed was passed to the subroutine with the explicit addition STRUCTURE, or if it is a parameter of a function module. In these cases, external calls can result in a conversion error. Note C interface. You can call externally callable function modules from C programs. It is also possible to store function modules in a C program and call them via CALL FUNCTION ... DESTINATION. For this purpose, SAP provides a C interface. Addition 2 ... EXCEPTIONS syst_except = rc MESSAGE mess Effect Function module calls with the addition DESTINATION can handle two special system exceptions: SYSTEM_FAILURE This is triggered if a system crash occurs on the receiving side. COMMUNICATION_FAILURE This is triggered if there is a connection or communication problem. In both cases, you can use the optional addition ... MESSAGE mess to receive a description of the error. Note Runtime errors: - CALL_FUNCTION_DEST_TYPE:Destination type not allowed. - CALL_FUNCTION_NO_DEST:Destination does not exist. - CALL_FUNCTION_NO_LB_DEST:Destination (in 'Load Balancing' mode) does not exist. - CALL_FUNCTION_TABINFO:Data error (info internal table) during 'Remote Function Call'. CALL FUNCTION Variant 2 CALL FUNCTION func ...STARTING NEW TASK taskname. Additions: 1. ... DESTINATION dest 2. ... PERFORMING form ON END OF TASK 3. ... EXPORTING p1 = f1 ... pn = fn 4. ... TABLES p1 = itab1 ... pn = itabn 5. ... EXCEPTIONS syst_except = rc MESSAGE mess Effect Starts the function module func asynchronously in a new mode. In contrast to normal function module calls, the calling program resumes processing as soon as the function module is started in the target system. It does not wait until the function module has finished. Through CALL SCREEN, the called function module can, for example, display a screen and thus interact with the user. Notes This variant applies only from R/3 Release 3.0. Both partner systems (the client and the server systems) must have a Release 3.0 version of the R/3 System. With this variant, the called function module must also be flagged in the Function Library as externally callable, even if it is executed locally (without the addition DESTINATION). Addition 1 ... DESTINATION dest Effect Executes the function module externally as a Remote Function Call (RFC); dest can be a literal or a variable. The R/3 System where the function module is executed depends on the specified destination. Externally callable function modules must be flagged as such in the Function Library (of the target system). Addition 2 ... PERFORMING form ON END OF TASK Whereas the parameters for receiving results (i.e. IMPORTING and TABLES parameters) are specified directly as additions in the case of "conventional" function modules (see variant 2), these are logged in the FORM routine form when making an asynchronous call (see RECEIVE). Note If a function module returns no result, this addition (... PERFORMING form ON END OF TASK) can be omitted. Addition 3 ... EXPORTING p1 = f1 ... pn = fn Effect EXPORTING passes values of fields and field strings from the calling program to the function module. In the function module, the formal parameters are defined as import parameters. Addition 4 ... TABLES p1 = itab1 ... pn = itabn Effect TABLES passes references to internal tables. All table parameters of the function module must contain values. Addition 5 ... EXCEPTIONS syst_except = rc MESSAGE mess Effect While any exceptions arising in the called function module are handled by the second addition (in the FORM routine), this addition can handle two special system exceptions, as with function module calls with the addition DESTINATION: SYSTEM_FAILURE is triggered, if a system crash occurs on the receiving side. COMMUNICATION_FAILURE is triggered if there is a connection or communication problem. In both cases, you can get a description of the error with the optional addition ... MESSAGE mess Example DATA: MSG_TEXT(80). "Message text ... * Asynchronous call to Transaction SM59 --> * Create a new session CALL FUNCTION 'ABAP4_CALL_TRANSACTION' STARTING NEW TASK 'TEST' DESTINATION 'NONE' EXPORTING TCODE = 'SM59' EXCEPTIONS COMMUNICATION_FAILURE MESSAGE MSG_TEXT. IF SY-SUBRC NE 0. WRITE: MSG_TEXT. ELSE. WRITE: 'O.K.'. ENDIF. Note Runtime errors: - CALL_FUNCTION_TASK_YET_OPEN: Task already open. CALL FUNCTION Variant 3 CALL FUNCTION func IN UPDATE TASK. Additions: 1. ... EXPORTING p1 = f1 ... pn = fn 2. ... TABLES p1 = itab1 ... pn = itabn Effect Flags the function module func for execution in the update task. It is not executed at once, but the data passed with EXPORTING or TABLES is placed in a database table and a subsequent COMMIT WORK then causes the function module to be executed by the update task. Update function modules must be flagged as such in the function library. Addition 1 ... EXPORTING p1 = f1 ... pn = fn Effect Values of fields and field strings specified under EXPORTING are passed from the calling program to the function module. In the function module, the formal parameters are defined as import parameters. In the interface definition, default values must be assigned to all import parameters of the update function module. Addition 2 ... TABLES p1 = itab1 ... pn = itabn Effect TABLES passes references to internal tables. All table parameters of the function module must have values. Note With update function modules, both import parameters and exceptions are ignored when the call is made. Administration transaction CALL METHOD - Call a method of an external object Basic form CALL METHOD OF obj m. Additions: 1. ... = f 2. ... EXPORTING p1 = f1 ... pn = fn 3. ... NO FLUSH Effect Calls the method m of the object obj. m can be a literal or a variable. Normally, all consecutive OLE statements are buffered by the ABAP/4 processor and sent to the presentation server in bundled form. This means that it is possible for a statement to refer to the results of preceding statements. In debugging, however, you should remember that the values of the return parameters cannot be displayed until directly before execution of the first ABAP/4 statement external to OLE. Even a command which refers to an object not yet generated by any OLE statement terminates the bundling. The return code value of SY-SUBRC indicates whether all the bundled commands have been successfully executed. The return code value is set as follows: SY-SUBRC = 0: All commands were successfully executed. SY-SUBRC = 1: When communicating with the presentation server, a system error occurred. The system field SY-MSGLI contains a short description of the error. SY-SUBRC = 2: A method call resulted in an error. SY-SUBRC = 3: Setting a property resulted in an error. SY-SUBRC = 4: Reading a property resulted in an error. In the last 3 cases, a dialog box containing an error note is displayed on the presentation server. CALL METHOD belongs to a group of key words which allow you to process external objects with ABAP/4. At present, only the object model OLE2 is supported, i.e. all objects must be of type OLE2_OBJECT. This type and other necessary data are defined in the include program OLE2INCL. Addition 1 ... = f Effect Stores the return value of the method in the variable f. The return value can also be of type OLE2_OBJECT. This addition must always come before other additions. Addition 2 ... EXPORTING p1 = f1 ... pn = fn Effect EXPORTING passes values of fields to the parameters of the method. p1, p2, ... are either key word parameters or position parameters. If assignment of parameters is by sequence, p1, p2, ... must begin with "#", followed by the position number of the parameter. At present, only position parameters are supported. The export parameters always come at the end of the statement. Addition 3 ... NO FLUSH The addition NO FLUSH continues the collection process, even if the next command is not an OLE statement. This means that you can set a series of properties in a loop and download them to the presentation server in a single transport operation. If you do not use NO FLUSH, you must ensure that you do not rely on the contents of return parameters not yet filled. Also, all objects must be initialized in a bundle, i.e. they must be generated by an OLE call that has already been executed. Every FREE statement always causes a download of the buffer. Example Open an EXCEL file with the method 'Open'. INCLUDE OLE2INCL. DATA EXCEL TYPE OLE2_OBJECT. DATA WORKBOOK TYPE OLE2_OBJECT. CREATE OBJECT EXCEL 'Excel.Application'. CALL METHOD OF EXCEL 'Workbooks' = WORKBOOK. CALL METHOD OF WORKBOOK 'Open' EXPORTING #1 = 'C:\EX1.XLS'. Related SET PROPERTY GET PROPERTY CREATE OBJECT FREE OBJECT CALL SCREEN - Call a screen Basic form CALL SCREEN scr. Addition: ... STARTING AT x1 y1 ... ENDING AT x2 y2 Effect Calls the screen scr; scr is the number of a screen of the main program. You use SET SCREEN 0. or LEAVE SCREEN. to define the return from the CALL screen. Addition ... STARTING AT x1 y1 ENDING AT x2 y2 Effect The coordinates x1, y1 (start column and start line in the window) and x2, y2 (end column and end line in the window) define the size and position of the CALL screen ("top left - bottom right"). Besides these coordinates, you can also see the contents of the primary window, but cannot perform any action there. Note - If "ENDING AT ..." is not specified, suitable values are substituted for x2 and y2, taking into account the size of the called screen. Note Runtime errors: DYNP_TOO_MANY_CALL_SCREENS: No further screen level (call screen); the maximum number of nested screen levels is restricted to 50 at present. CALL TRANSACTION - Call a transaction Basic form CALL TRANSACTION tcod. Additions: 1. ... AND SKIP FIRST SCREEN 2. ... USING itab 2a. ... MODE mode 2b. ... UPDATE upd 2c. ... MESSAGES INTO messtab Effect Calls the SAP Transaction tcod; tcod can be a literal or a variable. To return from the called transaction, you use the key word LEAVE PROGRAM. Example CALL TRANSACTION 'SP01'. Addition 1 ... AND SKIP FIRST SCREEN Effect Skips the first screen in the transaction (provided all the required fields have been assigned values by the SPA/GPA process). Addition 2 ... USING itab Effect Calls the Transaction tcod and passes the internal table itab, which contains one or several screens in batch input format. If necessary, one of the messages output by the Transaction is returned to the fields SY-MSGID, SY-MSGTY SY-MSGNO, SY-MSGV1, ..., SY-MSGV4. The return code value is set as follows: SY-SUBRC = 0: Processing was successful. SY-SUBRC <> 0: Transaction ended with an error. Note A called Transaction ends successfully for the following reasons: 1. COMMIT WORK 2. Next screen = 0 3. LEAVE TO TRANSACTION ' ' Addition 2a ... MODE mode Effect The specified processing mode can accept the following values: 'A' Display screen 'E' Display screen only if an error occurs 'N' No display If the addition MODE is not specified, the processing mode is set to 'A'. Addition 2b ... UPDATE upd Effect The specified update mode upd defines the update type. This can have one of the following values: 'A' Asynchronous update 'S' Synchronous update If the addition UPDATE is not specified, the processing mode is set to 'A'. Addition 2c ... MESSAGES INTO messtab Effect The specified internal table contains all system messages that occur during CALL TRANSACTION USING ... . The internal table messtab must have the structure BDCMSGCOLL. Example DATA BEGIN OF BDCDATA OCCURS 100. INCLUDE STRUCTURE BDCDATA. DATA END OF BDCDATA. DATA BEGIN OF MESSTAB OCCURS 10. INCLUDE STRUCTURE BDCMSGCOLL. DATA END OF MESSTAB. DATA REPORT(8). BDCDATA-PROGRAM = 'SAPMS38M'. BDCDATA-DYNPRO = '0100'. BDCDATA-DYNBEGIN = 'X'. APPEND BDCDATA. CLEAR BDCDATA. BDCDATA-FNAM = 'RS38M-PROGRAMM'. BDCDATA-FVAL = REPORT. APPEND BDCDATA. ... CALL TRANSACTION 'SE38' USING BDCDATA MODE 'N' MESSAGES INTO MESSTAB. Notes Runtime errors: - CALL_TRANSACTION_NOT_FOUND: Transaction is unknown. - CALL_TRANSACTION_IS_MENU: Transaction is a menu. - CALL_TRANSACTION_USING_NESTED: Recursive CALL TRANSACTION USING Related SUBMIT CALL DIALOG CASE Basic form CASE f. Effect Case distinction. Depending on the current contents of a field, this statement executes one of several alternative processing branches. The field whose contents determine how the subsequent processing is specified after CASE; the individual processing branches are introduced by WHEN, followed by the value to be tested. The entire block is concluded by ENDCASE. The structure of the CASE statement is as follows: CASE f. WHEN f1. ... WHEN f2. ... ... ENDCASE. On reaching such a CASE statement, the processor compares f with f1. If f = f1, it executes the processing block between "WHEN f1." and the next WHEN statement. If there are no further WHEN statements, it executes the processing block up to the ENDCASE statement and then continues with any subsequent processing. If f <> f1, the processor compares the field f2 in the next WHEN statement with f and proceeds as with f1 and so on. Although f should be a variable, f1 can be a variable or a literal. For the comparison "f = f1", the rules are the same as for IF. There is a second variant of the WHEN statement: WHEN OTHERS. No more than one such WHEN statement is allowed within a CASE block. The "WHEN OTHERS" processing block is always concluded by ENDCASE, i.e. no further WHEN statements can follow. The "WHEN OTHERS" processing block is executed only if none of the preceding WHEN blocks have been executed, i.e. if all previous comparisons ("f = ...) have returned a negative result. Example DATA: ONE TYPE I VALUE 1, THREE TYPE P VALUE 3. DO 5 TIMES. CASE SY-INDEX. WHEN ONE. WRITE / 'That is'. WHEN 2. WRITE 'a'. WHEN THREE. WRITE 'good'. WRITE 'example'. WHEN OTHERS. WRITE '!'. ENDCASE. ENDDO. Output: "That is a good example ! !" Notes 1. You can nest several CASE statements and even combine them with IF statements. 2. The statement "WHEN: f1, f2." does not make sense. The example below shows that the block belonging to "WHEN f1" is empty: WHEN f1. WHEN f2. Related IF, ELSEIF CHECK Within loops and events - CHECK logexp. Special for reports with logical databases - CHECK sel. - CHECK SELECT-OPTIONS. CHECK - within loops Basic form CHECK logexp. Effect CHECK evaluates the subsequent logical expression. If it is true, the processing continues with the next statement. In loop structures like DO ... ENDDO WHILE ... ENDWHILE LOOP ... ENDLOOP SELECT ... ENDSELECT CHECK with a negative outcome terminates the current loop pass and goes back to the beginning of the loop to start the next pass, if there is one. In structures like FORM ... ENDFORM FUNCTION ... ENDFUNCTION MODULE ... ENDMODULE AT CHECK with a negative outcome terminates the routine or modularization unit. If CHECK is not in a loop or a routine or a modularization unit, a negative logical expression terminates the current event. In contrast, the statement REJECT terminates the current event, even from loops or subroutines. Note If a CHECK produces a negative result in a GET event, the GET events in subordinate tables of the logical database are not processed either. Related CONTINUE, EXIT, REJECT, STOP CHECK - special for reports with logical databases Variants: 1. CHECK sel. 2. CHECK SELECT-OPTIONS. Variant 1 CHECK sel. Effect Checks the selection criterion requested by the statement SELECT-OPTIONS sel .... This statement is equivalent to f IN sel, if sel was defined by SELECT-OPTIONS sel FOR f and can be used anywhere in logical expressions If the result of this check is negative, the processing in this event is terminated and the GET events for any subordinate database tables are not processed either. This variant of the CHECK statement should be used only if the logical database for the corresponding table does not support dynamic selections (see CHECK SELECT-OPTIONS), or SELECT-OPTIONS with the addition NO DATABASE SELECTION. Otherwise, the relevant record is not read from the database and made available to the program. Variant 2 CHECK SELECT-OPTIONS. Effect Called only after a GET event. This statement checks all the selections for SELECT-OPTIONS where the reference field after FOR belongs to the current table dbtab (specified after GET. However, this applies only if the logical database for dbtab does not support dynamic selections. Otherwise, the selections are passed directly to the logical database (with the exception: addition "NO DATABASE SELECTION" to SELECT-OPTIONS). This variant of the CHECK statement only makes sense if the logical database does not support dynamic selections for the corresponding table or SELECT-OPTIONS are defined with the addition "NO DATABASE SELECTION". You can determine from the ABAP/4 Development Workbench whether dynamic selections are defined and, if so, for which logical database tables by selecting Development -> Programming environ. -> Logical databases followed by Extras -> Dynamic selections. Example The logical database F1S of the demo flight reservation system contains the tables SPFLI with, and the table SFLIGHT without, dynamic selections. TABLES: SPFLI, SFLIGHT. SELECT-OPTIONS: SF_PRICE FOR SFLIGHT-PRICE, SP_CARR FOR SPFLI-CARRID, SP_FROM FOR SPFLI-CITYFROM NO DATABASE SELECTION, SP_DEPT FOR SPFLI-DEPTIME. Since dynamic selections are defined with the table SPFLI, but not with the table SFLIGHT, the following procedure applies: ... GET SFLIGHT. CHECK SELECT-OPTIONS. This CHECK statement is equivalent to the following statement: CHECK SF_PRICE. With GET SPFLI. CHECK SELECT-OPTIONS. the CHECK statement is equivalent to the following statement: CHECK SP_FROM. Note With CHECK SELECT-OPTIONS, fields from superior tables in the database hierarchy are not (!) checked. Note Runtime errors: - CHECK_SELOPT_ILLEGAL_OPTION: Wrong "OPTION" in SELECT-OPTIONS or RANGES table - CHECK_SELOPT_ILLEGAL_SIGN: Wrong "SIGN" in SELECT-OPTIONS or RANGES table Related CONTINUE, EXIT, REJECT, STOP CLEAR Basic form CLEAR f. Additions: 1. ... WITH g 2. ... WITH NULL Effect Resets the contents of f to its initial value. For predefined types (see DATA), the following initial values are used: Type C: ' ... ' (blank character) Type N: '00...0' Type D: '00000000' Type T: '000000' Type I: 0 Type P: 0 Type F: 0.0E+00 Type X: 0 If f is a field string, each component field is reset to its initial value. If it is an internal table without a header line, the entire table is deleted together with all its entries. If, however, f is an internal table with a header line, only the sub-fields in the table header entry are reset to their initial values. Example DATA: TEXT(10) VALUE 'Hello', NUMBER TYPE I VALUE 12345, ROW(10) TYPE N VALUE '1234567890', BEGIN OF PLAYER, NAME(10) VALUE 'John', TEL(8) TYPE N VALUE '08154711', MONEY TYPE P VALUE 30000, END OF PLAYER. ... CLEAR: TEXT, NUMBER, PLAYER. The field contents are now as follows: ROW = '1234567890' TEXT = ' ' NUMBER = 0 PLAYER-NAME = ' ' PLAYER-TEL = '00000000' PLAYER-MONEY = 0 Notes 1. When CLEAR references an internal table itab with a header line, it only resets the sub-fields in the header entry to their initial values (as mentioned above). The individual table entries remain unchanged. To delete the entire internal table together with all its entries, you can use CLEAR itab[] or REFRESH itab. 2. Within a logical expression, you can use f IS INITIAL to check that the field f contains the initial value appropriate for its type. 3. Variables are normally initialized according to their type, even if the specification of an explicit initial value (addition "... VALUE lit" of the DATA statement) is missing. For this reason, it is not necessary to initialize variables again with CLEAR after defining them. Addition 1 ... WITH g Effect The field f is filled with the value of the first byte of the field g. Addition 2 ... WITH NULL Effect Fills the field with hexadecimal zeros. Note You should use this addition with particular care because the fields of most data types thus receive values which are really invalid. Note Performance: CLEAR requires about 3 msn (standardized microseconds) of runtime to process a field of type C with a length of 10 and about 2 msn to process a field of the type I. To delete an internal table with 15 fields, it needs about 5 msn. CLOSE Basic form 1. CLOSE DATASET dsn. 2. CLOSE CURSOR c. Basic form 1 CLOSE DATASET dsn. Effect Closes the file dsn, ignoring any errors which may occur. CLOSE is required only if you want to edit dsn several times. For further details, see the documentation for OPEN DATASET. Basic form 2 CLOSE CURSOR c. Effect Closes the database cursor c. CLOSE CURSOR is only required if you want to read sets of database records several times with c. For further information, refer to the documentation on OPEN CURSOR and FETCH. CLOSE CURSOR belongs to the Open SQL command set. CNT Basic form ... CNT(h) ... Effect CNT(h) is not a statement, but a field which is automatically created and filled by the system if f is a sub-field of an extract dataset. CNT(h) can only be addressed from within a LOOP on a sorted extract. If h is a non-numeric field (see also ABAP/4 number types) from the field group HEADER and part of the sort key of the extract dataset, the end of a control level (AT END OF, AT LAST) is such that CNT(h) contains the number of different values which the field h has accepted in the group, i.e. the number of records in the group for which the field f has changed its value. Related SUM(g) COLLECT Basic form COLLECT [wa INTO] itab. Addition: ... SORTED BY f Effect COLLECT is used to create unique or compressed datsets. The key fields are the default key fields of the internal table itab. If you use only COLLECT to fill an internal table, COLLECT makes sure that the internal table does not contain two entries with the same default key fields. If, besides its default key fields, the internal table contains number fields (see also ABAP/4 number types), the contents of these number fields are added together if the internal table already contains an entry with the same key fields. If the default key of an internal table processed with COLLECT is blank, all the values are added up in the first table line. If you specify wa INTO, the entry to be processed is taken from the explicitly specified work area wa. If not, it comes from the header line of the internal table itab. After COLLECT, the system field SY-TABIX contains the index of the - existing or new - table entry with default key fields which match those of the entry to be processed. Notes 1. COLLECT can create unique or compressed datasets and should be used precisely for this purpose. If uniqueness or compression are unimportant, or two values with identical default key field values could not possibly occur in your particular task, you should use APPEND instead. However, for a unique or compressed dataset which is also efficient, COLLECT is the statement to use. 2. If you process a table with COLLECT, you should also use COLLECT to fill it. Only by doing this can you guarantee that - the internal table will actually be unique or compressed, as described above and - COLLECT will run very efficiently. 3. If you use COLLECT with an explicitly specified work area, it must be compatible with the line type of the internal table. Example Compressed sales figures for each company DATA: BEGIN OF COMPANIES OCCURS 10, NAME(20), SALES TYPE I, END OF COMPANIES. COMPANIES-NAME = 'Duck'. COMPANIES-SALES = 10. COLLECT COMPANIES. COMPANIES-NAME = 'Tiger'. COMPANIES-SALES = 20. COLLECT COMPANIES. COMPANIES-NAME = 'Duck'. COMPANIES-SALES = 30. COLLECT COMPANIES. The table COMPANIES now has the following appearance: NAME ! SALES ---------------------------- Duck ! 40 Tiger ! 20 Addition ... SORTED BY f Effect COLLECT ... SORTED BY f is obsolete and should no longer be used. Use APPEND ... SORTED BY f which has the same meaning. Note Performance: 1. When using internal tables with a header line, avoid unnecessary assignments to the header line. Whenever possible, use statements which have an explicit work area. For example, "APPEND wa TO itab." is approximately twice as fast as "itab = wa. APPEND itab.". The same applies to COLLECT and INSERT. 2. The cost of a COLLECT in terms of performance increases with the width of the default key needed in the search for table entries and the number of numeric fields with values which have to be added up, if an entry is found in the internal table to match the default key fields. If no such entry is found, the cost is reduced to that required to append a new entry to the end of the table. A COLLECT statement used on a table which is 100 bytes wide and has a key which is 60 bytes wide and seven numeric fields is about approx. 50 msn (standardized microseconds). Note Runtime errors: - COLLECT_OVERFLOW: Overflow in integer field when calculating totals. - COLLECT_OVERFLOW_TYPE_P: Overflow in type P field when calculating totals. Related APPEND, WRITE ... TO, MODIFY, INSERT COMMIT Basic form COMMIT WORK. Addition: ... AND WAIT Effect Executes a database commit and thus closes a logical processing unit or Logical Unit of Work (LUW) (see also Transaction processing). This means that - all database changes are made irrevocable and cannot be reversed with ROLLBACK WORK and - all database locks are released. COMMIT WORK also - calls the subroutines specified by PERFORM ... ON COMMIT, - executes asynchronously any update requests (see CALL FUNCTION ... IN UPDATE TASK) specified in these subroutines or started just before, - processes the function modules specified in CALL FUNCTION ... IN BACKGROUND TASK, - cancels all existing locks (see SAP locking concept) if no update requests exist, - closes all open database cursors (see OPEN CURSOR) and - resets the time slice counter to 0. COMMIT WORK belongs to the Open SQL command set. The return code value SY-SUBRC is set to 0. Notes 1. All subroutines called with PERFORM ... ON COMMIT are processed in the LUW concluded by the COMMIT WORK command. All V1 update requests specified in CALL FUNCTION ... IN UPDATE TASK are also executed in one LUW. When all V1 update requests have been successfully concluded, the V2 update requests ("update with start delayed") are processed, each in one LUW. Parallel to this, the function modules specified in CALL FUNCTION ... IN BACKGROUND TASK are each executed in one LUW per destination. 2. COMMIT WORK commands processed within CALL DIALOG processing - execute a database commit (see above), - close all open database cursors, - reset the time slice counter and - call the function modules specified by CALL FUNCTION IN BACKGROUND TASK in the CALL DIALOG processing. However, subroutines and function modules called with PERFORM ... ON COMMIT or CALL FUNCTION ... IN UPDATE TASK in the CALL DIALOG processing are not executed in the calling transaction until a COMMIT WORK occurs. 3. Since COMMIT WORK closes all open database cursors, any attempt to continue a SELECT loop after a COMMIT WORK results in a runtime error. For the same reason, a FETCH after a COMMIT WORK on the now closed cursors also produces a runtime error. You must therefore ensure that any open cursors are no longer used after the COMMIT WORK. 4. With batch input and CALL TRANSACTION ... USING, COMMIT WORK successfully concludes the processing. Addition ... AND WAIT Effect The addition ... AND WAIT makes the program wait until the type V1 updates have been completed. The return code value is set as follows: SY-SUBRC = 0: The update was successfully performed. SY-SUBRC <> 0: The update could not be successfully performed. Note Runtime errors: - COMMIT_IN_PERFORM_ON_COMMIT: COMMIT WORK is not allowed in a FORM callled with PERFORM ... ON COMMIT. - COMMIT_IN_POSTING: COMMIT WORK is not allowed in the update task. COMMUNICATION Variants: 1. COMMUNICATION INIT DESTINATION dest ID id. 2. COMMUNICATION ALLOCATE ID id. 3. COMMUNICATION ACCEPT ID id. 4. COMMUNICATION SEND ID id BUFFER f. 5. COMMUNICATION RECEIVE ID id ...BUFFER f ...DATAINFO d ...STATUSINFO s. 6. COMMUNICATION DEALLOCATE ID id. The COMMUNICATION statement allows you to develop applications which perform direct program-to-program communication. The basis for this is CPI-C (Common Programming Interface - Coummunication), defined by IBM within the context of SAA standards as a standardized communications interface. The COMMUNICATION statement provides the essential parameters for implementing simple communication. Its starter set covers the following functionality: Establishing a connection Accepting a communication Sending data Receiving data Closing a connection The other essential part of such a communication is an ABAP/4 program containing a FORM routine which is executed when the connection has been established. This program may be in an R/3 System or an R/2> System. Here, you should be aware that the application programs themselves declare a protocol. In particular, logon to the partner SAP System must be performed in the calling program. The partner programs must also manage different character sets, e.g. ASCII - EBCDIC themselves. A facility known as the Remote Function Call (RFC) has now been developed to save users from having to deal with these problems. External programs (e.g. a program written in C on a UNIX workstation) can also be used as partner programs. For this purpose, SAP provides a platform-specific development library. For more detailed information about communication in the SAP System, you can refer to the manual SAP Communication: Programming Further information about communication can be found in any of the following literature: IBM SAA Common Programming Interface Communication Reference SC 26-4399 X/Open Developers' Specification CPI-C X/Open Company Ltd. ISBN 1 872630 02 2 Variant 1 COMMUNICATION INIT DESTINATION dest ID id. Addition: ... RETURNCODE rc Effect Initializes a program-to-program connection. The partner system is specified in the dest field. You can use any name you like, but it must be entered in the connection table TXCOM and can be no more than 8 characters long. This entry in TXCOM determines to which physical system a connection is established using the symbolic name of the target system. In the field id, the system assigns an eight-character ID number of type C to the connection. The system field SY-SUBRC contains an appropriate return code value. All return codes can be read using their symbolic names. For this purpose, you can use the program RSCPICDF which contains these names and can be included, if required. Addition ... RETURNCODE rc Effect Stores the return code in the field rc. Example TYPES: CONVERSATION_ID(8) TYPE C, DESTINATION(8) TYPE C, RETURN_CODE LIKE SY-SUBRC. DATA: CONVID TYPE CONVERSATION_ID, DEST TYPE DESTINATION VALUE 'C00', CPIC_RC TYPE RETURN_CODE. INCLUDE RSCPICDF. COMMUNICATION INIT DESTINATION DEST ID CONVID RETURNCODE CPIC_RC. IF CPIC_RC NE CM_OK. WRITE: /'COMMUNICATION INIT, RC = ', CPIC_RC. EXIT. ENDIF. Variant 2 COMMUNICATION ALLOCATE ID id. Addition: As for variant 1. Effect Sets up a program-to-program connection. The call must immediately follow COMMUNICATION INIT. Example TYPES: CONVERSATION_ID(8) TYPE C, DESTINATION(8) TYPE C, RETURN_CODE LIKE SY-SUBRC. DATA: CONVID TYPE CONVERSATION_ID, DEST TYPE DESTINATION VALUE 'C00', CPIC_RC TYPE RETURN_CODE. INCLUDE RSCPICDF. COMMUNICATION INIT DESTINATION DEST ID CONVID RETURNCODE CPIC_RC. IF CPIC_RC NE CM_OK. WRITE: /'COMMUNICATION INIT, RC = ', CPIC_RC. EXIT. ENDIF. COMMUNICATION ALLOCATE ID CONVID RETURNCODE CPIC_RC. IF CPIC_RC NE CM_OK. WRITE: /'COMMUNICATION ALLOCATE, RC = ', CPIC_RC. EXIT. ENDIF. Variant 3 COMMUNICATION ACCEPT ID id. Addition: As for variant 1. Effect Accepts a connection requested by the partner program. id is a field of type C which is 8 characters long and contains the ID of the accepted connection after a successful call. Example FORM CPIC_EXAMPLE. TYPES: CONVERSATION_ID(8) TYPE C, RETURN_CODE LIKE SY-SUBRC. DATA: CONVID TYPE CONVERSATION_ID, CPIC_RC TYPE RETURN_CODE. INCLUDE RSCPICDF. COMMUNICATION ACCEPT ID CONVID RETURNCODE CPIC_RC. IF CPIC_RC NE CM_OK. EXIT. ENDIF. ENDFORM. Variant 4 COMMUNICATION SEND ID id BUFFER f. Additions: 1. ... RETURNCODE rc 2. ... LENGTH len Effect Sends data to the partner program. The data is stored in the field f which follows the key word parameter BUFFER. It is sent in the full length of the field f. If the partner program is part of a system which has a different character set, you must perform an appropriate conversion yourself. To do this, use the TRANSLATE statement. Addition 1 ... RETURNCODE rc Effect Stores the return code in the field rc. Addition 2 ... LENGTH leng Effect Sends the contents of the field f to the partner program in the specified length. Example TYPES: CONVERSATION_ID(8) TYPE C, DESTINATION(8) TYPE C, RETURN_CODE LIKE SY-SUBRC. DATA: CONVID TYPE CONVERSATION_ID, DEST TYPE DESTINATION VALUE 'C00', CPIC_RC TYPE RETURN_CODE. INCLUDE RSCPICDF. COMMUNICATION INIT DESTINATION DEST ID CONVID RETURNCODE CPIC_RC. IF CPIC_RC NE CM_OK. WRITE: /'COMMUNICATION INIT, RC = ', CPIC_RC. EXIT. ENDIF. COMMUNICATION ALLOCATE ID CONVID RETURNCODE CPIC_RC. IF CPIC_RC NE CM_OK. WRITE: /'COMMUNICATION ALLOCATE, RC = ', CPIC_RC. EXIT. ENDIF. RECORD = 'The quick brown fox jumps over the lazy dog'. COMMUNICATION SEND ID CONVID BUFFER RECORD LENGTH LENG RETURNCODE CPIC_RC. IF CPIC_RC NE CM_OK. WRITE: / 'COMMUNICATION SEND, RC = ', CPIC_RC. EXIT. ENDIF. Since the length is specified explicitly in this example, only the part 'The quick brown fox ' is transferred from the contents of the field RECORD. Variant 5 COMMUNICATION RECEIVE ID id ...BUFFER f ...DATAINFO d ...STATUSINFO s. Parts marked with " ..." are interchangeable Additions: 1. ... RETURNCODE rc 2. ... LENGTH leng 3. ... RECEIVED m 4. ... HOLD Effect Receives data in the field f. If no length is explicitly defined, the amount of data accepted depends on the length of the field. The fields d and s contain information about the receive process. You can address the contents of these using symbolic names in the include program RSCPICDF. The field d indicates whether the data was received in its entirety. The status field s informs the RECEIVE user of the status of the program. Here, it is important to know whether the program is in receive status or send status. It is, for example, not possible to send data if the program is in receive status. For more detailed information about these protocol questions, refer to the manuals listed above. Addition 1 ... RETURNCODE rc Effect Stores the return code in the field rc. Addition 2 ... LENGTH leng Effect Receives data only in the specified length leng. Addition 3 ... RECEIVED m Effect After the call, m contains the number of bytes received by the partner program. Addition 4 ... HOLD Effect Normally, data is received asynchronously, i.e. the system performs a rollout. However, this may not be desirable if, for example, the data is received in a SELECT loop, the database cursor is lost due to the rollout and the loop is terminated. To prevent a rollout, you can use the addition HOLD. Then, the SAP process waits until the data has been received and is thus available for use by other users. Note The fields d, s and m which contain information about the outcome of the call must be of type X with length 4. Example FORM CPIC_EXAMPLE. TYPES: CONVERSATION_ID(8) TYPE C, RETURN_CODE LIKE SY-SUBRC, C_INFO(4) TYPE X. DATA: CONVID TYPE CONVERSATION_ID, CPIC_RC TYPE RETURN_CODE, RECORD(80) TYPE C, DINFO TYPE C_INFO, SINFO TYPE C_INFO. INCLUDE RSCPICDF. COMMUNICATION ACCEPT ID CONVID RETURNCODE CPIC_RC. IF CPIC_RC NE CM_OK. EXIT. ENDIF. COMMUNICATION RECEIVE ID CONVID BUFFER RECORD STATUSINFO SINFO DATAINFO DINFO RETURNCODE CPIC_RC. IF CPIC_RC NE CM_OK. EXIT. ENDIF. ENDFORM. Variant 6 COMMUNICATION DEALLOCATE ID id. Addition: As for variant 1 Effect Severs connection and releases all resources. Example TYPES: CONVERSATION_ID(8) TYPE C, DESTINATION(8) TYPE C, RETURN_CODE LIKE SY-SUBRC, C_INFO(4) TYPE X. DATA: CONVID TYPE CONVERSATION_ID, CPIC_RC TYPE RETURN_CODE, DEST TYPE DESTINATION VALUE 'C00'. DATA: RECORD(80) TYPE C, LENG TYPE I VALUE 20. INCLUDE RSCPICDF. COMMUNICATION INIT DESTINATION DEST ID CONVID RETURNCODE CPIC_RC. IF CPIC_RC NE CM_OK. WRITE: / 'COMMUNICATION INIT, RC = ', CPIC_RC. EXIT. ENDIF. COMMUNICATION ALLOCATE ID CONVID RETURNCODE CPIC_RC. IF CPIC_RC NE CM_OK. WRITE: / 'COMMUNICATION ALLOCATE, RC = ', CPIC_RC. EXIT. ENDIF. RECORD = 'The quick brown fox jumps over the lazy dog'. COMMUNICATION SEND ID CONVID BUFFER RECORD LENGTH LENG RETURNCODE CPIC_RC. IF CPIC_RC NE CM_OK. WRITE: / 'COMMUNICATION SEND, RC = ', CPIC_RC. EXIT. ENDIF. COMMUNICATION DEALLOCATE ID CONVID RETURNCODE CPIC_RC. IF CPIC_RC NE CM_OK. WRITE: / 'COMMUNICATION DEALLOCATE, RC = ', CPIC_RC. EXIT. ENDIF. Note The above examples illustrate the basic functionality of the key words. However, the example program can only have an external system as partner. If the partner is an SAP System, the calling program must first logon to the SAP System and receive an acknowledgement. Only then can you begin to transmit the actual data. When logging on to an R2 System and an R3 System, the logon data must be converted to EBCDIC. All user data should be converted according to the partner system. This is in the concluding example of an R/3 - R/2 connection. Example PROGRAM ZCPICTST. TYPES: CONVERSATION_ID(8) TYPE C, DESTINATION(8) TYPE C, RETURN_CODE LIKE SY-SUBRC, C_INFO(4) TYPE X. DATA: BEGIN OF CONNECT_STRING, REQID(4) VALUE 'CONN', TYPE(4) VALUE 'CPIC', MODE(4) VALUE '1 ', MANDT(3) VALUE '000', NAME(12) VALUE 'CPICUSER', PASSW(8) VALUE 'CPIC', LANGU(1) VALUE 'D', KORRV(1), REPORT(8) VALUE 'ZCPICTST', FORM(30) VALUE 'CPIC_EXAMPLE', END OF CONNECT_STRING. DATA: CONVID TYPE CONVERSATION_ID, DEST TYPE DESTINATION VALUE 'R2-SYST', CPIC_RC TYPE RETURN_CODE, DINFO TYPE C_INFO, SINFO TYPE C_INFO. DATA: RECORD(80) TYPE C, LENG TYPE I VALUE 20. INCLUDE RSCPICDF. COMMUNICATION INIT DESTINATION DEST ID CONVID RETURNCODE CPIC_RC. IF CPIC_RC NE CM_OK. WRITE: / 'COMMUNICATION INIT, RC = ', CPIC_RC. EXIT. ENDIF. COMMUNICATION ALLOCATE ID CONVID RETURNCODE CPIC_RC. IF CPIC_RC NE CM_OK. WRITE: / 'COMMUNICATION ALLOCATE, RC = ', CPIC_RC. EXIT. ENDIF. * Convert logon data to EBCDIC TRANSLATE CONNECT_STRING TO CODE PAGE '0100'. COMMUNICATION SEND ID CONVID BUFFER CONNECT_STRING. IF CPIC_RC NE CM_OK. WRITE: / 'COMMUNICATION ALLOCATE, RC = ', CPIC_RC. EXIT. ENDIF. * Receive acknowledgement of logon COMMUNICATION RECEIVE ID CONVID BUFFER RECORD DATAINFO DINFO STATUSINFO SINFO RETURNCODE CPIC_RC. IF CPIC_RC NE CM_OK. WRITE: / 'COMMUNICATION RECEIVE, RC = ', CPIC_RC. EXIT. ENDIF. * Convert acknowledgement to ASCII TRANSLATE RECORD FROM CODE PAGE '0100'. * Now begin user-specific data exchange RECORD = 'The quick brown fox jumps over the lazy dog'. * Depending on the partner system, convert to another * character set TRANSLATE RECORD TO CODE PAGE '0100'. COMMUNICATION SEND ID CONVID BUFFER RECORD LENGTH LENG RETURNCODE CPIC_RC. IF CPIC_RC NE CM_OK. WRITE: / 'COMMUNICATION SEND, RC = ', CPIC_RC. EXIT. ENDIF. COMMUNICATION DEALLOCATE ID CONVID RETURNCODE CPIC_RC. IF CPIC_RC NE CM_OK. WRITE: / 'COMMUNICATION DEALLOCATE, RC = ', CPIC_RC. EXIT. ENDIF. PROGRAM ZCPICTST. INCLUDE RSCPICDF. * The receiving procedure in the relevant partner program follows FORM CPIC_EXAMPLE. TYPES: CONVERSATION_ID(8) TYPE C, RETURN_CODE LIKE SY-SUBRC, C_INFO(4) TYPE X. DATA: CONVID TYPE CONVERSATION_ID, CPIC_RC TYPE RETURN_CODE, RECORD(80) TYPE C, DINFO TYPE C_INFO, SINFO TYPE C_INFO. COMMUNICATION ACCEPT ID CONVID RETURNCODE CPIC_RC. IF CPIC_RC NE CM_OK. EXIT. ENDIF. COMMUNICATION RECEIVE ID CONVID BUFFER RECORD STATUSINFO SINFO DATAINFO DINFO RETURNCODE CPIC_RC. IF CPIC_RC NE CM_OK AND CPIC_RC NE CM_DEALLOCATED_NORMAL. EXIT. ENDIF. ENDFORM. COMPONENT-CHECK Variations: 1. COMPONENT-CHECK NUMBER n. 2. COMPONENT-CHECK TRANSACTION tcod. 3. COMPONENT-CHECK PROGRAM prog. Effect Determines whether a particular SAP price list component is installed. Variation 1 COMPONENT-CHECK NUMBER n. Effect Determines whether the SAP price list component n is installed. The return code in the system field SY-SUBRC may be set to either of the following values: 0 SAP price list component active. 4 SAP price list component not active. Variation 2 COMPONENT-CHECK TRANSACTION tcod. Effect Determines whether the SAP price list component for Transaction tcod is installed. The return code in the system field SY-SUBRC may be set to any of the following values: 0 SAP price list component active. 4 SAP price list component not active. 8 Transaction tcod does not belong to any SAP price list component (i.e. no entry in Table DIR). Variation 3 COMPONENT-CHECK PROGRAM prog. Effect Determines whether the SAP price list component for the program prog is installed. The return code in the system field SY-SUBRC may be set to any of the following values: 0 SAP price list component active. 4 SAP price list component not active. 8 Program p does not belong to any SAP price list component (i.e. no entry in Table DIR). COMPUTE Basic form COMPUTE n = arithexp. Effect Evaluates the arithmetic expression arithexp and places the result in the field n. Allows use of the four basic calculation types +, -, * and /, the whole number division operators DIV (quotient) and MOD (remainder), the exponentiation operator ** (exponentiation "X ** Y means X to the power of Y) as well as the functions listed below. When evaluating mixed expressions, functions have priority. Then comes exponentiation, followoed by the "point operations" *, /, DIV and MOD, and finally + and - . Any combination of parentheses is also allowed. The fields involved are usually of type I, F or P, but there are exceptions to this rule (see below). You can omit the key word COMPUTE. Built-in functions - Functions for all number types ABS Amount (absolute value) |x| of x SIGN Sign (preceding sign) of x; 1 x > 0 SIGN( x ) = 0 if x = 0 -1 x < 0 CEIL Smallest whole number value not less than x FLOOR Greatest whole number value not greater than x TRUNC Whole number part of x FRAC Decimal part of x - Floating point functions ACOS Arc cosine(x) in the range [-pi/2, pi/2], x from [-1, 1] ASIN Arc cosine(x) in the range [0, pi], x aus [-1, 1] ATAN Arc tangent(x) in the range [-pi/2, pi/2] (pi = 3.1415926535897932) COS Cosine of an angle specified in the arc SIN Sine of an angle specified in the arc TAN Tangent of an angle specified in the arc COSH Hyperbola cosine SINH Hyperbola sine TANH Hyperbola tangent EXP Exponential function for base e = 2.7182818284590452 LOG Natural logarithm (i.e. base e) of a positive number LOG10 Logarithm of x for base 10, x > 0 SQRT Square root of a non-negative number - String functions STRLEN Length of a string up to the last non-blank character (i.e. the occupied length) Function expressions consist of three parts: 1. Function identifier directly followed by an opening parenthesis 2. Argument 3. Closing parenthesis All parts of an expression, particularly any parts of a function expression, must be separated from each other by at least one blank. Example The following statements, especially the arithmetic expressions, are syntactically correct: DATA: I1 TYPE I, I2 TYPE I, I3 TYPE I, F1 TYPE F, F2 TYPE F, WORD1(10), WORD2(20). ... F1 = ( I1 + EXP( F2 ) ) * I2 / SIN( 3 - I3 ). COMPUTE F1 = SQRT( SQRT( ( I1 + I2 ) * I3 ) + F2 ). I1 = STRLEN( WORD1 ) + STRLEN( WORD2 ). Notes 1. When used in calculations, the amount of CPU time needed depends on the data type. In very simple terms, type I is the cheapest, type F needs longer and type P is the most expensive. Normally, packed numbers arithmetic is used to evaluate arithmetic expressions. If, however, the expression contains a floating point function, or there is at least one type F operand, or the result field is type F, floating point arithmetic is used instead for the entire expression. On the other hand, if only type I fields or date and time fields occur (see below), the calculation involves integer operations. 2. You can also perform calculations on numeric fields other than type I, F or P. Before executing calculations, the necessary type conversions are performed (see MOVE). You can, for instance, subtract one date field (type D) from another, in order to calculate the number of days difference. However, for reasons of efficiency, only operands of the same number type should be used in one arithmetic expression (apart from the operands of STRLEN). This means that no conversion is necessary and special optimization procedures can be performed. 3. Division by 0 results in termination unless the dividend is also 0 (0 / 0). In this case, the result is 0. 4. As a string processing command, the STRLEN operator treats operands (regardless of type) as character strings, without triggering internal conversions. On the other hand, the operands of floating point functions are converted to type F if they have another type. Example Date and time arithmetic DATA: DAYS TYPE I, DATE_FROM TYPE D VALUE '19911224', DATE_TO TYPE D VALUE '19920101', DAYS = DATE_TO - DATE_FROM. DAYS now contains the value 8. DATA: SECONDS TYPE I, TIME_FROM TYPE T VALUE '200000', TIME_TO TYPE T VALUE '020000'. SECONDS = ( TIME_TO - TIME_FROM ) MOD 86400. SECONDS now contains the value 21600 (i.e. 6 hours). The operation "MOD 86400" ensures that the result is always a positive number, even if the period extends beyond midnight. Note Packed numbers arithmetic: All P fields are treated as whole numbers. Calculations involving decimal places require additional programming to include multiplication or division by 10, 100, ... . The DECIMALS specification with the DATA declaration is effective only for output with WRITE. If, however, fixed point arithmetic is active, the DECIMALS specification is also taken into account. In this case, intermediate results are calculated with maximum accuracy (31 decimal places). This applies particularly to division. For this reason, you should always set the program attribute "Fixed point arithmetic". Example DATA P TYPE P. P = 1 / 3 * 3. Without "fixed point arithmetic", P has the value 0, since "1 / 3" is rounded down to 0. With fixed point arithmetic, P has the value 1, since the intermediate result of "1 / 3" is 0.333333333333333333333333333333. Note Floating point arithmetic With floating point arithmetic, you must always expect some loss of accuracy through rounding errors (ABAP/4 number types). Note Exponentiation The exponential expression "x**y" means x*x*...*x y times, provided that y is a natural number. For any value of y, x**y is explained by exp(y*log(x)). Operators of the same ranke are evaluated from left to right. Only the exponential operator, as is usual in mathematics, is evaluated from right to left. The expression "4 ** 3 ** 2" thus corresponds to "4 ** ( 3 ** 2 )" and not "( 4 ** 3 ) ** 2", so the result is 262144 and not 4096. The following resrtictions apply for the expression "X ** Y": If X is equal to 0, Y must be positive. If X is negative, Y must be a whole number. Note DIV and MOD The whole number division operators DIV and MOD are defined as follows: - ndiv = n1 DIV n2 - nmod = n1 MOD n2 so that: 1. n1 = ndiv * n2 + nmod 2. ndiv is a whole number 3. 0 <= nmod < |n2| A runtime error occurs if n2 is equal to 0 and n1 is not equal to 0. Example DATA: D1 TYPE I, D2 TYPE I, D3 TYPE I, D4 TYPE I, M1 TYPE P DECIMALS 1, M2 TYPE P DECIMALS 1, M3 TYPE P DECIMALS 1, M4 TYPE P DECIMALS 1, PF1 TYPE F VALUE '+7.3', PF2 TYPE F VALUE '+2.4', NF1 TYPE F VALUE '-7.3', NF2 TYPE F VALUE '-2.4', D1 = PF1 DIV PF2. M1 = PF1 MOD PF2. D2 = NF1 DIV PF2. M2 = NF1 MOD PF2. D3 = PF1 DIV NF2. M3 = PF1 MOD NF2. D4 = NF1 DIV NF2. M4 = NF1 MOD NF2. The variables now have the following values: D1 = 3, M1 = 0.1, D2 = - 4, M2 = 2.3, D3 = - 3, M3 = 0.1, D4 = 4, M4 = 2.3. Example Functions ABS, SIGN, CEIL, FLOOR, TRUNC, FRAC DATA: I TYPE I, P TYPE P DECIMALS 2, M TYPE F VALUE '-3.5', D TYPE P DECIMALS 1. P = ABS( M ). " 3,5 I = P. " 4 - commercially rounded I = M. " -4 I = CEIL( P ). " 4 - next largest whole number I = CEIL( M ). " -3 I = FLOOR( P ). " 3 - next smallest whole number I = FLOOR( M ). " -4 I = TRUNC( P ). " 3 - whole number part I = TRUNC( M ). " -3 D = FRAC( P ). " 0,5 - decimal part D = FRAC( M ). " -0,5 Notes Floating point functions 1. Although the functions SIN, COS and TAN are defined for any numbers, the results are imprecise if the argument is greater than about 1E8, i.e. 10**8. 2. The logarithm for a base other than e or 10 is calculated as follows: Logarithm of b for base a = LOG( b ) / LOG( a ) Note Runtime errors: Depending on the operands, the above operators and functions can cause runtime errors (e.g. when evaluating the logarithm with a negative argument). Related ADD, SUBTRACT, MULTIPLY, DIVIDE, MOVE CONCATENATE Basic form CONCATENATE f1 ... fn INTO g. Addition: ... SEPARATED BY h Note As with any string processing statement, all the operands are processed here as type C fields (regardless of tyep). No internal conversion is performed. Effect Places the fields f1 to fn after g. With the fields fi (1 <= i <= n), trailing blanks are ignored, i.e. these fields are considered only to have the length STRLEN( fi). The return code value is set as follows: SY-SUBRC = 0: The result fits in g. SY-SUBRC = 4: The result was too long for g and was only copied to g in that length. Example DATA: ONE(10) VALUE 'John', TWO(3) VALUE ' F.', THREE(10) VALUE ' Kennedy', NAME(20). CONCATENATE ONE TWO THREE INTO NAME. Then, NAME contains the value "John F. Kennedy". Addition ... SEPARATED BY h Effect Inserts the separator h between the fields fi. Here, h is used in its defined length. Examples DATA: ONE(10) VALUE 'John', TWO(3) VALUE 'F.', THREE(10) VALUE 'Kennedy', NAME(20). CONCATENATE ONE TWO THREE INTO NAME SEPARATED BY SPACE. Then, NAME has the value "John F. Kennedy". DATA SEPARATOR(4) VALUE 'USA'. CONCATENATE SPACE ONE TWO THREE INTO NAME SEPARATED BY SEPARATOR. Then, NAME has the value "USA JohnUSA F.USA Ke". The return value of SY-SUBRC is set to 4. Related SPLIT, SHIFT, REPLACE, TRANSLATE, CONDENSE Note Performance: You are recommended to use the key word CONCATENATE rather than your own constructions because it is safer, more efficient and clearer. The runtime required to append two 30-byte fields amounts to approx. 14 msn (standardized microseconds). CONDENSE Basic form CONDENSE c. Addition: ... NO-GAPS Note As with any string processing statement, all the operands are processed here as type C fields (regardless of tyep). No internal conversion is performed. Effect Shifts the contents of the field c to the left, so that each word is separated by exactly one blank. Example DATA: BEGIN OF NAME, TITLE(8), VALUE 'Dr.', FIRST_NAME(10), VALUE 'Michael', SURNAME(10), VALUE 'Hofmann', END OF NAME. CONDENSE NAME. WRITE NAME. produces the output: Dr. Michael Hofmann Addition ... NO-GAPS Effect Suppresses all blanks from the field c Example DATA: BEGIN OF NAME, TITLE(8), VALUE 'Dr.', FIRST_NAME(10), VALUE 'Michael', SURNAME(10), VALUE 'Hofmann', END OF NAME. CONDENSE NAME NO-GAPS. The contents of NAME is now "Dr.MichaelHofmann". Since the field string NAME is interpreted and handled like a type C field, the CONDENSE statement treats it as a whole and ignores any sub-fields. The contents of the component field would therefore now be as follows: NAME-TITLE = 'Dr.Micha' NAME-FIRST_NAME = 'elHofmann ' NAME-SURNAME = ' ' Note Do not use CONDENSE to manipulate field strings that include fields not of type C. This could result in these component fields containing characters of a different (i.e. incorrect) type. Related SHIFT, CONCATENATE, REPLACE, SPLIT Note Performance: The runtime required to condense three fields is about 20 msn (standardized micooseconds). The variant ... NO-GAPS needs about 12 msn. CONSTANTS Variants: 1. CONSTANTS c. ... VALUE [ val | IS INITIAL ]. 2. CONSTANTS c(len) ... VALUE [ val | IS INITIAL ]. 3. CONSTANTS: BEGIN OF crec, ... END OF crec. Effect The CONSTANTS statement defines global and local constants. Constants allow you to read statically declared data objects. They always have a particular data type. Data types and data objects are essential components of the ABAP/4 type concept. In contrast to variables defined with the DATA statement, you cannot change the value of a constant once it has been defined. Apart from the additions ... TYPE typ OCCURS n, ... LIKE f1OCCURS n and WITH HEADER LINE, all the additions used with the DATA statement are allowed. However, in contrast to the DATA statement, the addition ... VALUE val or VALUE IS INITIAL obligatory with variants 1 and 2. See additions with DATA. Example CONSTANTS CHAR1 VALUE 'X'. CONSTANTS INT TYPE I VALUE 99. CONSTANTS: BEGIN OF CONST_REC, C(2) TYPE I VALUE 'XX', N(2) TYPE N VALUE '12', X TYPE X VALUE 'FF', I TYPE I VALUE 99, P TYPE P VALUE 99, F TYPE F VALUE '9.99E9', D TYPE D VALUE '19950101', T TYPE T VALUE '235959', END OF CONST_REC. CONTINUE Basic form CONTINUE. Effect Within loop structures like - DO ... ENDDO - WHILE ... ENDWHILE - LOOP ... ENDLOOP - SELECT ... ENDSELECT CONTINUE terminates the current loop pass, returns the processing to the beginning of the loop and starts the next loop pass, if there is one. Example DO loop: Omit an area (10 ... 20) DO 100 TIMES. IF SY-INDEX >= 10 AND SY-INDEX <= 20. CONTINUE. ENDIF. ... ENDDO. Related CHECK, EXIT CONTROLS Basic form CONTROLS ctrl TYPE ctrl_type. Effect Defines a control A control defines an ABAP/4 runtime object which displays data in a particular visual format, depending on the type. It offers the user standard processing options. At present, the following types of control are supported: Table control Related REFRESH CONTROL ABAP/4 table control Basic form CONTROLS ctrl TYPE TABLEVIEW USING SCREEN scr. Effect Creates a table control ctrl of the type TABLEVIEW. The reference screen for the initialization is the screen scr. Area of use The table control (referred to here as TC ) facilitates the display and entry of one-line, tabular data in dialog transactions. The functional scope has been defined so that you can implement many typical set operations usually handled by an elementary STEP-LOOP with the standard methods of a TC. Functional scope - Resizeable table grid for displaying and editing data. - Column width and column position modifiable by user and by program. - Storing and loading of user-specific column layout. - Selection column for line selection with color selection display. - Variable column headers as pushbuttons for column selection. - Simple selection, multiple selection, Select/deselect all. - Scrolling functions (horizontal and vertical) via scroll bar. - Fixing of any number of key columns. - Setting attributes for each cell at runtime. Programming The data exchange between the application and the SAPgui is achieved with a STEP-LOOP, i.e. an ABAP/4 module is called to transfer data for each page. Example Processing without an internal table PROCESS BEFORE OUTPUT. LOOP WITH CONTROL ctrl. MODULE ctrl_pbo. ENDLOOP. PROCESS AFTER INPUT. LOOP WITH CONTROL ctrl. MODULE ctrl_pai. ENDLOOP. In this case, the module ctrl_pbo OUTPUT is called once for each output line before the screen is displayed, in order to fill the output fields. After the user has entered data on the screen, the module ctrl_pai INPUT is executed to check the input and copy the new contents. Example Processing with an internal table PROCESS BEFORE OUTPUT. LOOP AT itab WITH CONTROL ctrl CURSOR ctrl-CURRENT_LINE. ENDLOOP. PROCESS AFTER INPUT. LOOP AT itab WITH CONTROL ctrl. MODULE ctrl_pai. ENDLOOP. Here, the system fills the output fields before displaying the screen by reading the internal table itab. When the user has entered data, the module ctrl_pai INPUT must be executed to check the input and to refresh the contents of the internal table. Vertical scrolling with the scroll bar is followed by the event PAI for the displayed page. Then, cntl-TOP_LINE is increased and PBO is processed for the next page. Program-driven scrolling and the most of the functionality described above is achieved by manipulating the control attributes. Attributes The CONTROLS statement creates a complex data object of the type CXTAB_CONTROL with the name of the control. You maintain the initial values in the Screen Painter and assign the screen with the initial values for a control using the addition USING SCREEN. Initialization is achieved automatically in the "1st access to the control" (setting or reading values). You can use the customizing button (in the top right corner) to save the current setting (column widths and column positions) and use it as the initial value for the next call. All the initial values can be overwritten by the program using the MOVE ... TO TC attributes statement. Example ctrl-fixed_cols = 2. "2 columns fixed The contents of the SCREEN structure (table Cols) acts as a default value for each line of this column, but within LOOP ... ENDLOOP (flow logic), it can be overwritten by LOOP AT SCREEN / MODIFY SCREEN. With the attributes listed below, you should be aware of the following: LINES This must always be set as the only attribute if you are not using LOOP AT itab. TOP_LINE Also set by the SAPgui through the vertical scroll bar slider. CURRENT_LINE Read only, set by the system (TOP_LINE + SY-STEPL - 1) LEFT_COL Also set by the SAPgui through the horizontal scroll bar slider. COLS-INDEX Also set by the SAPgui after moving columns. COLS-SELECTED Also set by the SAPgui after column selection. When displaying the control, the system uses the current contents when the event DCO occurs (i.e. after all PBO modules have run). The modified values (brought about by the user making changes on the screen) are set immediately after DCI (i.e. before the first PAI module runs). CONVERT Variants: 1. CONVERT DATE f1 INTO INVERTED-DATE f2. 2. CONVERT INVERTED-DATE f1 INTO DATE f2. Effect Allows conversion between different formats which do not have their own type (see also MOVE). The field f1 is converted from the source format to the target format and placed in f2. At present, the following formats are supported: 1. DATE ==> INVERTED-DATE 2. INVERTED-DATE ==> DATE Both formats form the nine's complement of internal date representation, e.g. 19950511 ==> 80049488 or 80049488 ==> 19950511. In inverse date format, the most recent date has the lowest numerical value. This is useful when sorting date specifications. Note The technique of modifying the sequence of dates by inverting the internal date format is only used in very rare cases. For example, you can sort internal tables in ascending or descending date order much more elegantly with the additons ... ASCENDING bzw. ... DESCENDING of the SORT statement. Example DATA DATE_INV LIKE SY-DATUM. CONVERT DATE SY-DATUM INTO INVERTED-DATE DATE_INV. If, for example, the internal representation of 11.05.95 in SY-DATUM is 19950511, the value of DATE_INV after execution of the CONVERT statement is 80049488. Note Runtime errors: - CONVERT_ILLEGAL_CONVERSION: Conversion not possible due to incorrect field length. CREATE Basic form CREATE OBJECT obj class. Addition: ... LANGUAGE langu Effect Generates an object of the class class. To address an OLE automation server (e.g. EXCEL) from ABAP/4, the server must be registered with SAP. The transaction SOLE allows you to assign an automation server to a class. The CREATE statement generates the initial object and this can be processed further with the relevant key words. The return code value of SY-SUBRC indicates the result of the generation: The return code value is set as follows: SY-SUBRC = 0: Object successfully generated. SY-SUBRC = 1: SAPGUI communication error. SY-SUBRC = 2: SAPGUI function call error. The OLE function modules are implemented only under Windows. SY-SUBRC = 3: The OLE API call resulted in an error; this is possibly a storage space problem. SY-SUBRC = 4: The object is not registered with SAP. Addition ... LANGUAGE langu Effect Determines the language chosen for method and attribute names of the object class. If no specification is made, English is the default. CREATE OBJECT belongs to a group of key words which allow you to process external objects with ABAP/4. At present, only the object model OLE2 is supported, i.e. all objects must be of type OLE2_OBJECT. This type and other necessary data are defined in the include program OLE2INCL. Example Generate an EXCEL object. INCLUDE OLE2INCL. DATA EXCEL TYPE OLE2_OBJECT. CREATE OBJECT EXCEL 'Excel.Application'. Related SET PROPERTY GET PROPERTY CALL METHOD FREE OBJECT This statement is not supported in the R/3 System. Use the following function modules instead: CONVERT_TO_FOREIGN_CURRENCY CONVERT_TO_LOCAL_CURRENCY DATA Variants: 1.DATA f. 2.DATA f(len). 3.DATA: BEGIN OF rec, ... END OF rec. 4. DATA: BEGIN OF itab OCCURS n, ... END OF itab. 5. DATA: BEGIN OF COMMON PART c, ... END OF COMMON PART. Effect Defines global and local variables. Variables allow you to address declared data objects. They always have a particular data type. Data types and data objects are important components of the ABAP/4 type concept. Variant 1 DATA f. Additions: 1. ... TYPE typ 2. ... LIKE f1 3. ... TYPE typ OCCURS n 4. ... LIKE f1 OCCURS n 5. ... TYPE LINE OF itabtyp 6. ... LIKE LINE OF itab 7. ... VALUE lit 8. ... DECIMALS n 9. ... WITH HEADER LINE Effect Creates the internal field f in its standard length. If you do not specify the type (using the addition TYPE), a field of type C is assumed. The field f can be up to 30 characters long. You can use any characters you like except the special characters '(', ')', '+', '-', ',' and ':'. Numeric characters are allowed but the field name may not consist of numbers alone. SPACE is a reserved word and therefore cannot be used. Also, the field name cannot be the same as one of the additional parameters of the introductory key word (e.g. PERFORM SUB USING CHANGING.). Recommendations for field names: 1. Always use a letter as the first character. 2. Use the underscore to join together words which are part of the same name (e.g. NEW_PRODUCT). The hyphen should not be used here, since it is reserved for the names of field string components (see below). Addition 1 ... TYPE typ. Effect Creates a field f of the type typ. You can use either one of the predefined types listed below or one of your own types which you define with TYPES. The standard length (SL) of the field depends on the type. Type Description SL Initial value C Text (character) 1 Blank N Numeric text 1 '00...0' D Date (YYYYMMDD) 8 '00000000' T Time (HHMMSS) 6 '000000' X Hexadecimal 1 X'00' I Whole number (integer) 4 0 P Packed number 8 0 F Floating point no. 8 '0.0' Example DATA NUMBER TYPE I. Creates the field NUMBER as type I. You can also use it in the program, particularly if you want to assign number values and perform calculations. Notes - The data type I is the whole number type on which the hardware is based. Its value range is from -2**31 to 2**31-1 (from -2.147.483.648 to 2.147.483.647). You use type P for fields containing monetary amounts, but type I is more suitable for number fields, index fields, specifying positions and so forth. - You can use type F for positive and negative numbers other than zero in the range from 1E-307 to 1E+308 with a degree of accuracy up to 15 decimal places. (The ABAP/4 processor always uses the floating point operations of the hardware in question rather than standardizing them.) Floating point literals must be enclosed in quotation marks. The standard output length is 22. Entries in type F fields may be formatted in any of the following ways: As a decimal number with or without sign and with or without a decimal point. In the form e, where you specify the mantissa as above and the exponent with or without a sign. (Examples of floating point literals: '1', '-12.34567', '-765E-04', '1234E5', '+12E+34', '+12.3E-4'. Since floating point arithmetic is fast on our hardware platforms, you should use it when you need a greater value range and you are able to tolerate rounding errors. Rounding errors may occur when converting the external (decimal) format to the corresponding internal format (base 2 or 16) or vice-versa (ABAP/4 number types). Addition 2 ... LIKE f1 Effect Creates the field f with the same field attributes as the field F1 which is already known. Any data objects are valid (fields, parameters, structures, ...) as long as types have been assigned. f1 can be any Dictionary reference. Example DATA TABLE_INDEX LIKE SY-TABIX. The field TABLE_INDEX now has the same attributes as SY-TABIX (the index for internal tables). Note This addition is often useful, since the ABAP/4 runtime system performs type changes on fields automatically. Any unnecessary and/or unwanted conversions are thus avoided. Addition 3 ... TYPE typ OCCURS n Effect Defines an internal table without header line. Such a table consists of any number of table lines with the type typ. To fill and edit this table, you can use statements like APPEND, READ TABLE, LOOP and SORT. The OCCURS parameter n defines how many tables lines are created initially. If necessary, you can increase the size later. Otherwise, the OCCURS parameter is of no significance, apart from the exception that applies with APPEND SORTED BY. Example TYPES: BEGIN OF LINE_TYPE, NAME(20) TYPE C, AGE TYPE I, END OF LINE_TYPE. DATA: PERSONS TYPE LINE_TYPE OCCURS 20, PERSONS_WA TYPE LINE_TYPE. PERSONS_WA-NAME = 'Michael'. PERSONS_WA-AGE = 25. APPEND PERSONS_WA TO PERSONS. PERSONS_WA-NAME = 'Gabriela' PERSONS_WA-AGE = 22. APPEND PERSONS_WA TO PERSONS. The internal table PERSONS now consists of two table entries. Note Access to table entries not in main memory takes much longer. On the other hand, there is not enough space in main memory to hold such large tables because the roll area is resticted (see above). Addition 4 ... LIKE f1 OCCURS n Effect Defines an internal table without header line. Such a table consists of any number of table lines with the structure as specified by the data object f1. Processing is the same as for addition 3. Example DATA: BEGIN OF PERSON, NAME(20), AGE TYPE I, END OF PERSON. DATA: PERSONS LIKE PERSON OCCURS 20. PERSON-NAME = 'Michael'. PERSON-AGE = 25. APPEND PERSON TO PERSONS. PERSON-NAME = 'Gabriela' PERSON-AGE = 22. APPEND PERSON TO PERSONS. The internal table PERSONS now consists of two table entries. Addition 5 ... TYPE LINE OF itabtype Effect The specified type itabtyp must be an internal table type. This operation creates a data object with the same line type as the table type specified. Example TYPES TAB_TYP TYPE I OCCURS 10. DATA TAB_WA TYPE LINE OF TAB_TYP. The data object TAB_WA now has the same attributes as a line of the table type TAB_TYP and thus the type I. Addition 6 ... LIKE LINE OF itab Effect The data object tab must be an internal table with or without a header line. This operation creates a data object with the same line type as the table specified. Example DATA TAB TYP TYPE I OCCURS 10. DATA TAB_WA TYPE LINE OF TAB. The data object TAB_WA now has the same attributes as a line of the table TAB and thus the type I. Addition 7 ... VALUE lit Effect The initial value of the field f is the literal lit instead of that defined in the table above. You can also specify a constant or even use IS INITIAL. In the latter case, the field is preset to the type-specific initial value. This form is particularly important in connection with the CONSTANTS statement which always requires you to use the addition VALUES. Example DATA NUMBER TYPE I VALUE 123, FLAG VALUE 'X', TABLE_INDEX LIKE SY-TABIX VALUE 45. When created, the field NUMBER of type I contains 123 rather than the expected initial value of 0. The newly created field FLAG of type C (length 1) contains 'X', while TABLE_INDEX contains 45, since the system field SY-TABIX is a numeric field. Addition 8 ... DECIMALS n Effect Only makes sense with field type P. When you perform calculations and on output, the field has n decimal decimal places, where n is a number between 0 and 14. In the case of newly generated programs, you normally activate fixed point arithmetic in the attributes. If it is not set, the DECIMALS specification is taken into account on output, but not when performing calculations. This means that the programmer must take care of any decimal point calculations by multiplying or dividing by powers of ten. (see COMPUTE) Fixed point arithmetic should always be active when you are performing calculations, since this enables intermediate results (for division) to be calculated as accurately as possible (in this case, to 31 decimal places). To decide whether you should use the fixed point type P or the floating point type F, see "ABAP/4 number types". Addition 9 ... WITH HEADER LINE Effect You can only use this addition with table types. When you specify WITH HEADER LINE, you create a header line with the same name type as a table line in addition to the table. With non-table operations (e.g. MOVE), the name f refers to this header line. With table operations (e.g. APPEND, the name f refers to the table or the table and header line. The notation f[] always denotes the table. The result of this expression is a table without a header line and can be used as such. Example DATA: BEGIN OF PERSON_TYPE, NAME(20), AGE TYPE I, END OF PERSON_TYPE. DATA: PERSONS LIKE PERSON_TYPE OCCURS 20 WITH HEADER LINE. PERSON-NAME = 'Michael'. PERSON-AGE = 25. APPEND PERSONS. PERSON-NAME = 'Gabriela' PERSON-AGE = 22. APPEND PERSONS. * Delete header line CLEAR PERSONS. * Delete table CLEAR PERSONS[]. Variant 2 DATA f(len). Additions: As for variant 1 Effect Creates the field f in the length len. You can use this variant only for fields of type C, N, P and X. Any other field types must have their standard lengths (see table under effect of variant 1). The lengths allowed depend on the field type: Type Allowed lengths C 1 - 65535 N 1 - 65535 P 1 - 16 X 1 - 65535 Note Each byte can contain (one character or) two decimal or hexadecimal digits. Since one place in type P fields is reserved for the sign, a type P field of length 3 can contain 5 digits, whereas a type X field of length 3 can hold 6 digits. Both have an output length of 6. Variant 3 DATA: BEGIN OF rec, ... END OF rec. Effect Defines the field string rec which groups together all the fields defined for the field string rec between "BEGIN OF REC" and "END OF rec". Each field carries the prefix "rec-". Field strings can be nested to any depth. See Data objects. When a field string needs the same fields as an already defined field string in addition to its own fields, you can include these fields in the field string with INCLUDE STRUCTURE. If no additional fields are needed, it is better to use LIKE. Example DATA: BEGIN OF PERSON, NAME(20) VALUE 'May', AGE TYPE I, END OF PERSON. PERSON-AGE = 35. The field PERSON-NAME now contains the contents "May". DATA: BEGIN OF PERSON1, FIRSTNAME(20) VALUE 'Michael'. INCLUDE STRUCTURE PERSON. DATA END OF PERSON1. Notes - If you list a field string as a field, this field ("rec") is type C, but you should not use a field string like a field, if the field string contains number fields (i.e. type I, F or F). The length of rec is derived from the sum of the lengths of all components of rec. However, since some fields (for example, to the limit of a word), they include padding fields that also contribute to the overall length of rec; for this reason, you cannot use the lengths of fields that occur before a particular field string component to calculate its offset to the start of the field string. On the other hand, you can guarantee that two fields with the same structure always have the same structure (even where padding fields are concerned). This means that you can compare and assign fields directly below each other (with MOVE, IF, etc.) and do not have to work field by field (e.g. with MOVE-CORRESPONDING). INCLUDEs are aligned according to maxumum alignment of their components. This applies both to INCLUDEs in ABAP/4 programs and also INCLUDEs in Dictionary structures. - The TABLES statement automatically defines a field string (the work area. Even the header line belonging to an internal table (see below) is a field string. Variant 4 DATA: BEGIN OF itab OCCURS n, ... END OF itab. Additions: ... VALID BETWEEN f1 AND f2 Effect Defines the internal table itab. An internal table includes a header line, which is a field string containing the fields defined between "BEGIN OF itab OCCURS n" and "END OF itab" (see variant 3), and any number of table lines with the same structure as the header line. To fill and edit an internal table, you use various statements such as APPEND, READ TABLE, LOOP and SORT. The OCCURS parameter n determines how many table lines are held in main storage (the roll area). If you also generate table entries, these are rolled out either to a main storage buffer or to disk (the paging area). Example DATA: BEGIN OF PERSONS OCCURS 20, NAME(20), AGE TYPE I, END OF PERSONS. PERSONS-NAME = 'Michael'. PERSONS-AGE = 25. APPEND PERSONS. PERSONS-NAME = 'Gabriela'. PERSONS-AGE = 22. APPEND PERSONS. The internal table now consists of two table entries. PERSONS also includes the header line (work area) through which all operations on the actual table pass. Note Access to table entries not in main storage is considerably slower. Also, main storage cannot hold large tables in their entirety, since the size of the roll area is restricted (see above). Addition ... VALID BETWEEN f1 AND f2 Effect Can appear only after "END OF itab". The sub-fields f1 and f2 of the internal table itab must have the line-related validity range (see PROVIDE). Variant 5 DATA: BEGIN OF COMMON PART c, ..... END OF COMMON PART. Effect Defines one or more common data areas in programs linked by external PERFORM calls. If only one common data area exists, you can omit the name c. There may be just one unnamed COMMON area or one or more named COMMON areas. You assign named COMMON areas to each other by name. The structure of data areas must always be the same for both the calling and the called program (otherwise, the program terminates with an error message at runtime). - The table work areas are always in the common data area. - In general, you define the area created as COMMON with a common INCLUDE STRUCTURE. Occasionally, you use a INCLUDE report which contains precisely the definition of the COMMON PART. - Field symbols cannot belong to a common data area, even if the FIELD-SYMBOLS statement lies between DATA BEGIN OF COMMON PART and DATA END OF COMMON PART. DEFINE Basic form DEFINE macro. Effect Defines a program component (macro) under the name macro. It must consist only of ABAP/4 statements and is expanded at compilation time. A macro should always be concluded with the END-OF-DEFINITION statement. In the definition, you can use &n to reference positional parameters (n = 0 .. 9). When the macro is called, &n is replaced by the n-th actual parameter. Example Define a macro called "++" for use in the program. DEFINE ++. ADD 1 TO &1. END-OF-DEFINITION. DATA: NUMBER TYPE I VALUE 1. ... ++ NUMBER. Notes - In general, it is better to use subroutines (FORM, FUNCTION) rather than macros because subroutines - unlike macros - are supported by all the ABAP/4 Development Workbench tools (including debugging, runtime analysis, runtime error handling, ...). - You cannot nest macro definitions. DELETE Delete from a database table - DELETE FROM dbtab WHERE condition. DELETE FROM (dbtabname) WHERE condition. - DELETE dbtab. DELETE *dbtab. DELETE (dbtabname) ... . - DELETE dbtab FROM TABLE itab. DELETE (dbtabname) FROM TABLE itab. - DELETE dbtab VERSION vers. DELETE *dbtab VERSION vers. Delete from an internal table - DELETE itab. - DELETE itab INDEX idx. - DELETE itab FROM idx1 TO idx2. - DELETE itab WHERE condition. - DELETE ADJACENT DUPLICATES FROM itab. Delete a program - DELETE REPORT prog. Delete text elements - DELETE TEXTPOOL prog LANGUAGE lg. Delete a data cluster - DELETE FROM DATABASE dbtab(ar) ...ID key. Delete a file - DELETE DATASET dsn. Delete a screen - DELETE DYNPRO f. DELETE - delete a file Basic form DELETE DATASET dsn. Effect Deletes the file specified in the field dsn. The return code value is set as follows: SY-SUBRC = 0: File deleted. SY-SUBRC = 4: File does not exist or could not be deleted. Possible reasons: 1) The file does not exist. 2) The file is a directory. 3) The R/3 System has no search authorization for a component of the file name. 4) The R/3 System has no search authorization for the directory which contains the file. 5) A component of the search path is not a directory. 6) The file is a symbolic link which cannot be resolved (endless loop ?). 7) The file is a program which is currently running. Related OPEN DATASET, READ DATASET, CLOSE. DELETE - Delete from a database table Variants: 1. DELETE FROM dbtab WHERE condition. DELETE FROM (dbtabname) WHERE condition. 2. DELETE dbtab. DELETE *dbtab. DELETE (dbtabname) ... 3. DELETE dbtab FROM TABLE itab. DELETE (dbtabname) FROM TABLE itab. 4. DELETE dbtab VERSION vers. DELETE *dbtab VERSION vers. Effect Deletes lines in a database table. You can specify the name of the database table either in the program itself with DELETE FROM dbtab ... or at runtime as the contents of the field dbtabname with DELETE FROM (dbtabname) .... In both cases, the database table must be known in the ABAP/4 Dictionary. If you specify the name in the program, there must also be an appropriate TABLES statement. Only data from the current client is usually deleted. You can delete data using a view only if the view refers to a single table and was created in the ABAP/4 Dictionary with the maintenance status "No restriction". DELETE belongs to the Open SQL command set. Note The DELETE statement does not perform authorization checks: You must program these yourself. Variant 1 DELETE FROM dbtab WHERE condition. DELETE FROM (dbtabname) WHERE condition. Addition: ... CLIENT SPECIFIED Effect Deletes lines in a database table that satisfy the WHERE clause condition. With this variant, specification of a WHERE condition is obligatory. When the statement has been executed, the system field SY-DBCNT contains the number of deleted lines. The return code value is set as follows: SY-SUBRC = 0: At least one line was deleted. SY-SUBRC = 4: No lines were deleted, since no line was selected. Example Delete all bookings for the Lufthansa flight 0400 on 28.02.1995 (in the current client): TABLES SBOOK. DELETE FROM SBOOK WHERE CARRID = 'LH' AND CONNID = '0400' AND FLDATE = '19950228'. Note To delete all the lines in a table, you must specify a WHERE condition that is true for all lines. You can achieve this with ... WHERE f IN itab If the internal table itab is empty, such a condition would select all lines. Addition ... CLIENT SPECIFIED Effect Switches off automatic client handling. This allows you to delete data across all clients in the case of client-specific tables. The client field is then treated like a normal table field, for which you can formulate suitable conditions in the WHERE clause. You must specify the addition CLIENT SPECIFIED immediately after the name of the database table. Variant 2 DELETE dbtab. DELETE *dbtab. DELETE (dbtabname) ... Additions: 1. ... FROM wa 2. ... CLIENT SPECIFIED Effect These are SAP-specific short forms used to delete a single line of a database table. If the name of the database table is specified in the program, the primary key of the line to be deleted is taken from the specified work area - dbtab or *dbtab. If the name of the database table is not determined until runtime (DELETE (dbtabname) ...), the addition ... FROM wa is obligatory. When the statement has been executed, the system field SY-DBCNT contains the number of deleted lines (0 or 1). The return code value is set as follows: SY-SUBRC = 0: The line was deleted. SY-SUBRC = 4: No lines could be deleted, since no line exists with the primary key specified. Example Delete the booking with the booking number 3 for the Lufthansa flight 0400 on 28.02.1995 (in the current client): TABLES SBOOK. SBOOK-CARRID = 'LH'. SBOOK-CONNID = '0400'. SBOOK-FLDATE = '19950228'. SBOOK-BOOKID = '00000003'. DELETE SBOOK. Addition 1 ... FROM wa Effect Takes the primary key for the line to be deleted not from the table work area dbtab, but from the explicitly specified work area wa. Here, the key values from left to right are taken from wa according to the structure of the primary key in the table work area dbtab (see TABLES). The structure of wa is not taken into account. Therefore, the work area wa must be at least as wide (see DATA) as the primary key in the table work area dbtab and the alignment of the work area wa must correspond to the alignment of the primary key in the table work area. Otherwise, you get a runtime error. Note If a work area is not explicitly specified, the values for the line to be deleted are taken from the table work area dbtab, even if the statement appears in a subroutine (see FORM) or Funktionsbaustein (see FUNCTION) where the table work area is stored in a formal parameter or a local variable of the same name. Addition 2 ... CLIENT SPECIFIED Effect As with variant 1. Variant 3 DELETE dbtab FROM TABLE itab. DELETE (dbtabname) FROM TABLE itab. Addition: ... CLIENT SPECIFIED Effect Mass deletion: Deletes all database table lines for which the internal table itab contains values for the primary key fields. The lines of the internal table itab must satisfy the same condition as the work area wa in addition 1 to variant. The system field SY-DBCNT contains the number of deleted lines, i.e. the number of lines of the internal table itab for whose key values there were lines in the database table dbtab. The return code value is set as follows: SY-SUBRC = 0: All lines from itab could be used to delete lines from dbtab. SY-SUBRC = 4: For at least one line of the internal table in the database table, there was no line with the same primary key. All found lines are deleted.. Note If the internal table itab is empty, SY-SUBRC and SY-DBCNT are set to 0. Addition ... CLIENT SPECIFIED Effect As with variant 1. Variant 4 DELETE dbtab VERSION vers. DELETE *dbtab VERSION vers. Note This variant is obsolete, since variants 1 - 3 allow you to specify the database table name dynamically. Effect Deletes a line in a database table, the name of which is taken from the field vers at runtime. The database table must be known to the ABAP/4 Dictionary and its name must conform to the following naming convention: It must begin with 'T' and can consist of four additional characters. The field vers must contain the table name without a leading 'T'. Only lines in the current client are deleted. The line to be deleted is taken from the statically specified table work area dbtab or *dbtab. The return code value is set as follows: SY-SUBRC = 0: The line was deleted. SY-SUBRC = 4: No lines could be deleted because no line existed with the specified primary key. DELETE DYNPRO - delete a screen Note This statement is for internal use only. Incompatible changes or further developments may occur at any time without warning or notice. Basic form DELETE DYNPRO f. Effect Deletes the screen specified in the field f. The return code value is set as follows: SY-SUBRC = 0: The screen was deleted. SY-SUBRC = 4: The screen does not exist. The contents of f consist of the 8-character program name and the 4-character screen number. Example DELETE DYNPRO 'SAPTESTX0100'. Related IMPORT DYNPRO, EXPORT DYNPRO, GENERATE DYNPRO, SYNTAX-CHECK FOR DYNPRO. DELETE - delete a data cluster Basic form DELETE FROM DATABASE dbtab(ar) ID key. Addition: ... CLIENT f Effect Deletes the data cluster stored in the table dbtab under the area ar (constant) and the ID key (field or literal) (EXPORT ... TO DATABASE ...). Example TABLES INDX. DATA: BEGIN OF TAB OCCURS 1, CONT(30), END OF TAB. DATA: FLD(30) TYPE C. ... EXPORT TAB FLD TO DATABASE INDX(AR) ID 'TEST'. You can delete this data cluster with the following statement: DELETE FROM DATABASE INDX(AR) ID 'TEST'. Addition 1 ... CLIENT f Effect Deletes the data cluster in the client specified in the table f (only with client-specific import/export databases). Example TABLES INDX. DELETE FROM DATABASE INDX(AR) CLIENT '001' ID 'TEST'. DELETE - Delete from an internal table Variants: 1. DELETE itab. 2. DELETE itab INDEX idx. 3. DELETE itab FROM idx1 TO idx2. 4. DELETE itab WHERE condition. 5. DELETE ADJACENT DUPLICATES FROM itab. Effect Deletes one or more lines from an internal table. Note The deletion of lines within a LOOP ... ENDLOOP loop is performed in a sequence of loop passes. Variant 1 DELETE itab. Effect The current entry of the internal table itab is deleted in a LOOP loop. The return code value is set to 0. Note After deleting the current entry in an internal table in a LOOP loop, the effect of further update operations on the current entry without an INDEX specification is not guaranteed and may changed in later Releases. Variant 2 DELETE itab INDEX idx. Effect Deletes the idx entry from the internal table itab. The return code value is set as follows: SY-SUBRC = 0: The entry was deleted. SY-SUBRC = 4: The entry does not exist. Variant 3 DELETE itab FROM idx1 TO idx2. Effect Deletes the line area from index idx1 to idx2 from internal table itab. At least one of the two parameters FROM idx1 or TO idx2 should be specified. If parameter FROM is missing, the area from the start of the table to line idx2 is deleted. If parameter TO is missing, the area from line idx1 to the end of the table is deleted. Start index idx1 must be greater than 0. The return code value is set as follows: SY-SUBRC = 0: At least one entry was deleted. SY-SUBRC = 4: None of the entries were deleted. Variant 4 DELETE itab WHERE condition. Additions: 1. ... FROM idx1 2. ... TO idx2 Effect Deletes all entries from internal table itab, which satisfies the condition condition. The return code value is set as follows: SY-SUBRC = 0: At least one entry was deleted. SY-SUBRC = 4: None of the entries were deleted. Addition 1 ... FROM idx1 Effect The line area to be investigated is restricted to the lines up to index idx1. If the addition FROM idx1 is missing, a search is carried out from the beginning of the table. The addition FROM must come before the WHERE condition. Addition 2 ... TO idx2 Effect Restricts the line area to be investigated to the lines up to index idx2. If the addition TO idx2 is missing, a search is carried out until the end of the table. The addition TO must come before the WHERE condition. Example Delete all lines in a name table between lines 5 and 36, if the entry begins with one of the letters 'A' to 'C': DATA: BEGIN OF NAMETAB OCCURS 100, NAME(30) TYPE C, END OF NAMETAB. ... DELETE NAMETAB FROM 5 TO 36 WHERE NAME CA 'ABC'. Variant 5 DELETE ADJACENT DUPLICATES FROM itab. Additions: 1. ... COMPARING f1 f2 ... 2. ... COMPARING ALL FIELDS Effect Deletes neighboring, duplicate entries from the internal table itab. If there are n duplicate entries, the first entry is retained and the other n - 1 entries are deleted. Two lines are considered to be duplicated if their default keys match. The return code value is set as follows: SY-SUBRC = 0: At least one duplicate exists, at least one entry deleted. SY-SUBRC = 4: No duplicates exist, no entry deleted. Addition 1 ... COMPARING f1 f2 ... Effect Two lines of the internal table itab are considered to be duplicates if the specified fields f1, f2, .... match. Addition 2 ... COMPARING ALL FIELDS Effect Two lines are considered to be duplicates if all fields of the table entries match. Notes 1. The DELETE ADJACENT DUPLICATES statement is especially useful if the internal table itab is sorted by fields (whether in ascending or descending order) which were compared during duplicate determination. In this case, the deletion of neighbouring duplicates is the same as the deletion of all duplicates. 2. If a comparison criterion is only known at runtime, it can be specified dynamically as the content of a field name by using COMPARING ... (name) .... If name is blank at runtime, the comparison criterion is ignored. If name contains an invalid component name, a runtime error occurs. 3. Comparison criteria - statistically or dynamically specified - can be further restriced by specifying the offset and/or length. Note Performance: 1. Deleting a line from an internal table incurs index maintenance costs which depend on the index of the line to be deleted. The runtime depends on the line width of the table. For example, deleting a line in the middle of an internal table with 200 entries requires about 10 msn (standardized microseconds). Deleting a range of entries with "DELETE itab FROM idx1 TO idx2." deleting a set of entries with "DELETE itab WHERE ..." only incur index maintenance costs once. Compared with a LOOP, which deletes line-by-line, this is much faster. 2. To delete neighboring, duplicate entries from an internal table, use the variant "DELETE ADJACENT DUPLICATES FROM itab." instead of LOOP constructions. Related INSERT itab, MODIFY itab DELETE - delete a program Note This statement is for internal use only. Incompatible changes or further developments may occur at any time without warning or notice. Basic form DELETE REPORT prog. Effect Deletes some components (source code, attributes, text elements and generated version) of the program specified in the field prog. The return code value is set as follows: SY-SUBRC = 0: The program was deleted. SY-SUBRC = 4: The program does not exist. Note This statement deletes neither the variants nor the documentation. Normally, you should use the function module RS_DELETE_PROGRAM to delete a program. Related INSERT REPORT, DELETE TEXTPOOL DELETE - delete text elements Note This statement is for internal use only. Incompatible changes or further developments may occur at any time without warning or notice. Basic form DELETE TEXTPOOL prog LANGUAGE lg. Effect Deletes all text elements of the program specified in the field prog for the language specified in the field lg from the library. If you use the value '*' for lg, the text elements of all languages are deleted. Example Delete all text elements of the program PROGNAME in the language "English": DATA: PROGRAM(8) VALUE 'PROGNAME'. DELETE TEXTPOOL PROGRAM LANGUAGE 'E'. Related INSERT TEXTPOOL, READ TEXTPOOL DEQUEUE is not an ABAP/4 key word (in R/3). To unlock resources, you must use a function module. DESCRIBE Return attributes of a field - DESCRIBE FIELD f. Return attributes of an internal table - DESCRIBE TABLE itab. Determine distance between two fields - DESCRIBE DISTANCE BETWEEN f1 AND f2 INTO f3. Return attributes of a list - DESCRIBE LIST NUMBER OF LINES lin. - DESCRIBE LIST NUMBER OF PAGES n. - DESCRIBE LIST LINE lin PAGE pag. - DESCRIBE LIST PAGE pag. DESCRIBE DISTANCE BETWEEN f1 AND f2 INTO f3 Effect Returns the distance between the fields f1 and f2 in f3. Example TABLES LFA1. DATA DIS TYPE P. DESCRIBE DISTANCE BETWEEN LFA1-LAND1 AND LFA1-NAME1 INTO DIS. Result: DIS contains the value 14, since exactly two fields lie between LAND1 and NAME1, namely LNRZA (10 bytes) and LOEVM (1 byte); additionally, the sub-field LAND1 is 3 bytes long. Therefore, the start of the sub-field LAND1 is exactly 14 bytes from the start of the sub-field NAME1. DESCRIBE - determine distance between two fields Basic form DESCRIBE DISTANCE BETWEEN f1 AND f2 INTO f3. Effect Determines the distance between the fields f1 and f2 and places the result (in bytes) in f3. Example Determine the distance between two components of the demo table SBOOK in the flight reservation system: TABLES SBOOK. DATA DIST TYPE I. DESCRIBE DISTANCE BETWEEN SBOOK-CARRID AND SBOOK-BOOKID INTO DIST. Result: DIST contains the value 15 because exactly two fields, SFLIGHT-CONNID (4 bytes) and SBOOK-FLDATE (8 bytes), lie between the SBOOK components CARRID and BOOKID; also, SBOOK-CARRID is itself 3 bytes long. The sum of these values gives the distance between the two components in bytes. DESCRIBE - Supply attributes of a field Basic form DESCRIBE FIELD f. Effect Supplies the attributes of the field f. You must specify at least one of the additions: Additions: 1. ... LENGTH len 2. ... TYPE typ 3. ... TYPE typ COMPONENTS n 4. ... OUTPUT-LENGTH len 5. ... DECIMALS n 6. ... EDIT MASK mask Addition 1 ... LENGTH len Effect Returns the length of the field f in the field len. Example DATA: FLD(8), LEN TYPE P. DESCRIBE FIELD FLD LENGTH LEN. Result: LEN contains the value 8. Addition 2 ... TYPE typ Effect Returns the data type of f in the field typ Example DATA: FLD(8) TYPE N, F_TYPE. DESCRIBE FIELD FLD TYPE F_TYPE. Result: F_TYPE contains the value 'N'. Note Along with the elementary data types you can specify under DATA (C, N, etc.), several other data types are created either with reference to Dictionary fields or during generation. These data types, which are also returned by DESCRIBE, have the following type IDs: h Internal table s 2-byte integer with leading sign b 1-byte integer without leading sign u Structure without internal table v Structure containing at least one internal table For compatibility reasons, ... TYPE typ returns C rather than u or v with structures. Addition 3 ... TYPE typ COMPONENTS n Effect Similar to ... TYPE typ except that, with structures in typ, u or v are returned and in the number of structure components is set in n. If f is not a structure, n is set to 0. Example Recursive processing of the pages of an ABAP/4 data structure: FORM TEST USING F. DATA: TYP(1) TYPE C, N TYPE I. FIELD-SYMBOLS: . DO. ASSIGN COMPONENT SY-INDEX OF STRUCTURE F TO . IF SY-SUBRC <> 0. EXIT. ENDIF. DESCRIBE FIELD TYPE TYP COMPONENTS N. IF N > 0. " Equivalent is TYP = 'u' OR TYP = 'v' PERFORM TEST USING . ELSE. PERFORM DO_SOMETHING USING . ENDIF. ENDDO. ENDFORM. Addition 4 ... OUTPUT-LENGTH len Effect Enters the output length of the field f in the variable len. Example DATA: FLD(4) TYPE P, O_LEN TYPE P. DESCRIBE FIELD FLD OUTPUT-LENGTH O_LEN. Result: O_LEN contains the value 8. Addition 5 ... DECIMALS n Effect Enters the number of decimal places for the field f (defined in addition ... DECIMALS of the DATA statement or in the ABAP/4 Dictionary) in the variable n. Example DATA: FLD(8) TYPE P DECIMALS 2, DEC TYPE P. DESCRIBE FIELD FLD DECIMALS DEC. Resultat: DEC contains the value 2. Addition 6 ... EDIT MASK mask Effect If the field f has a conversion routine in the ABAP/4 Dictionary, this is placed in the field mask in the form "==conv". "conv" stands for the name of the conversion routine, e.g. "==ALPHA" in the conversion routine "ALPHA". In this form, mask can then be used in the addition USING EDIT MASK mask of the WRITE statement. Example Check whether there is a conversion routine for the field "customer number" in the table SBOOK: TABLES SBOOK. DATA: CONV_EXIT(10). DESCRIBE FIELD SBOOK-CUSTOMID EDIT MASK CONV_EXIT. IF CONV_EXIT <> SPACE. ... ENDIF. Result: CONV_EXIT contains the value "==ALPHA". Note If the required field is only known at runtime, this field can also be assigned dynamically to a field symbol (see FIELD-SYMBOLS, ASSIGN). DESCRIBE - supply attributes of a list Variants: 1. DESCRIBE LIST NUMBER OF LINES lin. 2. DESCRIBE LIST NUMBER OF PAGES n. 3. DESCRIBE LIST LINE lin PAGE pag. 4. DESCRIBE LIST PAGE pag. Effect Returns the attributes of a list. All variants have the addition ... INDEX idx allowing you to determine the attributes of a particular list level (SY-LSIND = 0,1,2,3,... ). Note You should use this key word only in exceptional cases (e.g. when editing an 'anonymous' list in a program other than that which generated the list). In all other cases, you should save the relevant values when you generate the list. Take care when attempting to retrieve the list attributes being set up (...INDEX SY-LSIND), since some attributes (number of pages, number of lines, ...) may not have been updated yet. Variant 1 DESCRIBE LIST NUMBER OF LINES lin. Addition: ... INDEX idx Effect Returns the number of lines in the list. The return code value is set as follows: SY-SUBRC = 0: OK SY-SUBRC <> 0: List does not exist (only with the addition INDEX) Addition ... INDEX idx Effect Returns the attributes of the list level idx (0, 1,2,3,...). Example After line selection, determine the number of lines in the displayed list: DATA: LN LIKE SY-PAGNO. ... AT LINE-SELECTION. DESCRIBE LIST NUMBER OF LINES LN. The variable LN now contains the number of lines in the displayed list. Variant 2 DESCRIBE LIST NUMBER OF PAGES n. Addition: ... INDEX idx Effect Returns the number of pages in the list. The return code value is set as follows: SY-SUBRC = 0: OK SY-SUBRC <> 0: List does not exist (only with the addition INDEX) Addition ... INDEX idx Effect Returns the attributes of the list level idx (0, 1,2,3,...). Example After line selection, determine the number of pages in the displayed list: DATA: PN LIKE SY-PAGNO. ... AT LINE-SELECTION. DESCRIBE LIST NUMBER OF PAGES PN. The variable PN now contains the number of pages in the displayed list (i.e. the contents of the system field SY-PAGNO after the list has been generated!). Variant 3 DESCRIBE LIST LINE lin PAGE pag. Addition: ... INDEX idx Effect Returns the number of the page for the line lin in the list. Note In interactive reporting, line selection causes a value to be assigned to the system field SY-LILLI (absolute number of selected list line). The system field SY-CPAGE contains the page number for the first displayed line in the list. The selected line does not have to belong to this page (in cases where several pages are displayed at the same time). The page number may be of interest even with direct reading of lines (see READ LINE). The return code value is set as follows: SY-SUBRC = 0: OK SY-SUBRC = 4: Line does not exist SY-SUBRC = 8: List does not exist Addition ... INDEX idx Effect Returns the attributes of the list level idx (0, 1,2,3,...). Example After line selection, determine the page number for the selected line (SY-LILLI): DATA: PAGENUMBER LIKE SY-PAGNO. ... AT LINE-SELECTION. DESCRIBE LIST LINE SY-LILLI PAGE PAGENUMBER. The variable PAGENUMBER now contains the page number for the line SY-LILLI (i.e. the contents of the system field SY-PAGNO when outputting the line SY-LILLI!). Variant 4 DESCRIBE LIST PAGE pag Additions: 1. ... INDEX idx 2. ... LINE-SIZE col 3. ... LINE-COUNT lin 4. ... LINES lin 5. ... FIRST-LINE lin 6. ... TOP-LINES lin 7. ... TITLE-LINES lin 8. ... HEAD-LINES lin 9. ... END-LINES lin Effect Returns the attributes of the page pag in the list. The return code value is set as follows: SY-SUBRC = 0: OK SY-SUBRC = 4: Page does not exist SY-SUBRC = 8: List does not exist Addition 1 ... INDEX idx Effect Returns the attributes of the list level idx (0, 1,2,3,...). Addition 2 ... LINE-SIZE col Effect Returns the line length for the page pag (see NEW-PAGE...LINE-SIZE). Addition 3 ... LINE-COUNT lin Effect Returns the permitted number of lines for the page pag (see NEW-PAGE...LINE-COUNT). Addition 4 ... LINES lin Effect Returns the number of lines output on the page pag. Addition 5 ... FIRST-LINE lin Effect Returns the absolute line number of the first line of the page pag. Addition 6 ... TOP-LINES lin Effect Returns the number of lines output by page header processing (i.e. standard title + column headers + TOP-OF-PAGE). Addition 7 ... TITLE-LINES lin Effect Returns the number of lines output as standard title lines by page header processing (see NEW-PAGE...NO-TITLE/WITH-TITLE). Note The value of TITLE-LINES is contained in TOP-LINES. Addition 8 ... HEAD-LINES lin Effect Returns the number of lines output as column headers by page header processing (see NEW-PAGE...NO-HEADING/WITH-HEADING). Note The value of HEAD-LINES is contained in TOP-LINES. Addition 9 ... END-LINES lin Effect Returns the number of lines reserved for end-of-page processing (see END-OF-PAGE). Example Determine the number of lines output on the third page of the basic list (SY-LSIND = 0) in the event TOP-OF-PAGE: DATA: TOP TYPE I, HEAD TYPE I, TITLE TYPE I, REAL_TOP TYPE I. DESCRIBE LIST INDEX 0 PAGE 3 TOP-LINES TOP HEAD-LINES HEAD TITLE-LINES TITLE. REAL_TOP = TOP - TITLE - HEAD. Examples Determine the absolute number of lines in the displayed list: DATA: LN TYPE I, "number of lines on a page FLN TYPE I, "number of first line on a page PN TYPE I, "number of a page LIST_LINES TYPE I. "total number of lines in list Determine number of last page: DESCRIBE LIST NUMBER OF PAGES PN. Determine number of first line of last page and number of lines on that page: DESCRIBE LIST PAGE PN FIRST-LINE FLN LINES LN. Number of list lines = number of first line of last page + number of lines - 1. LIST_LINES = FLN + LN - 1. Or: Count lines of all pages in a loop: CLEAR LIST_LINES. DO PN TIMES. DESCRIBE LIST PAGE SY-INDEX LINES LN. ADD LN TO LIST_LINES. ENDDO. or: DESCRIBE LIST NUMBER OF LINES LIST_LINES. DESCRIBE - return attributes of an internal table Basic form DESCRIBE TABLE itab. Effect Returns the attributes of the internal table itab. You must use at least one of the additions listed below. Additions: 1.... LINES lin 2.... OCCURS n Addition 1 ... LINES lin Effect Places the number of filled lines of the table t in the field lin. Example DATA: BEGIN OF TAB OCCURS 10, X, END OF TAB. DATA: LIN TYPE P. ... CLEAR TAB. REFRESH TAB. MOVE '?' TO TAB-X. APPEND TAB. DESCRIBE TABLE TAB LINES LIN. Result: LIN contains the value 1. Addition 2 ... OCCURS n Effect Transfers the size of the OCCURS parameter from the table definition to the variable n. Example DATA: BEGIN OF TAB OCCURS 10, X, END OF TAB. OCC TYPE P. DESCRIBE TABLE TAB OCCURS OCC. Result: OCC contains the value 10. Note If the table is meant to accept more lines than specified by the OCCURS parameter, the parameter value is roughly doubled as long as the table size remains smaller than 8 KB; this table area is held in the roll area. If the table exceeds the maximum permitted size, the OCCURS parameter is not increased and the remaining part of the table is rolled out to the paging area (see DATA). For this reason, the OCCURS value determined by the DESCRIBE statement may differ from that in the DATA statement. The runtime required to execute the DESCRIBE TABLE statement is approx. 4 msn (standardized microseconds). DETAIL Basic form DETAIL. This key word is the same as the statement FORMAT INTENSIFIED OFF. The latter is recommended due to better readability. Note When outputting data to a list, you also use the addition INTENSIFIED OFF of the WRITE statement to change the output format for single fields. Related FORMAT DIVIDE Basic form DIVIDE n1 BY n2. Effect Divides the contents of n1 by n2 and places the result in n1. This is equivalent to: n1 = n1 / n2. Example DATA: SUM TYPE P, NUMBER TYPE P. DIVIDE SUM BY NUMBER. Note The details regarding conversions and performance given under COMPUTE apply equally to DIVIDE. Furthermore: Division by 0 is not allowed, except where 0 / 0 results in 0. Note Runtime errors: - BCD_BADDATA: P field contains no correct BCD format - BCD_FIELD_OVERFLOW: Result field is too small (type P) - BCD_OVERFLOW: Overflow during arithmetic operation (type P) - BCD_ZERODIVIDE: Division by 0 (type P) - COMPUTE_FLOAT_ZERODIVIDE: Division by 0 (type F) - COMPUTE_INT_DIV_OVERFLOW: Whole number overflow with division - COMPUTE_INT_ZERODIVIDE: Division by 0 (type I) Related COMPUTE, DIVIDE-CORRESPONDING DIVIDE-CORRESPONDING Basic form DIVIDE-CORRESPONDING rec1 BY rec2. Effect Interprets rec1 and rec2 as field strings, i.e. if rec1 and rec2 are tables with header lines, the statement is executed for their header lines. Searches for all sub-fields that occur both in rec1 and rec2 and then generates, for all field pairs corresponding to the sub-fields ni, statements similar in the following form: DIVIDE rec1-ni BY rec2-ni. The other fields remain unchanged. With more complex structures, the complete names of the field pairs must be identical. Example DATA: BEGIN OF MONEY, VALUE_IN(20) VALUE 'German marks'. USA TYPE I VALUE 100, FRG TYPE I VALUE 200, AUT TYPE I VALUE 300, END OF MONEY, BEGIN OF CHANGE, DESCRIPTION(30) VALUE 'DM to national currency'. USA TYPE F VALUE '1.5', FRG TYPE F VALUE '1.0', AUT TYPE F VALUE '0.14286', END OF CHANGE. DIVIDE-CORRESPONDING MONEY BY CHANGE. MONEY-VALUE_IN = 'National currency'. The above DIVIDE-CORRESPONDING statement is equivalent to the following three statements: DIVIDE MONEY-USA BY CHANGE-USA. DIVIDE MONEY-FRG BY CHANGE-FRG. DIVIDE MONEY-AUT BY CHANGE-AUT. Note All fields of the same name are divided, whether numeric or not. The conversions performed are the same as those for DIVIDE and similar runtime errors can occur. Related DIVIDE, MOVE-CORRESPONDING, ADD-CORRESPONDING, SUBTRACT-CORRESPONDING, MULTIPLY-CORRESPONDING DO Variants: 1.DO. 2.DO n TIMES. Variant 1 DO. Addition: ... VARYING f FROM f1 NEXT f2 Effect Repeats the processing enclosed by the DO and ENDDO statements until the loop is terminated by EXIT, STOP or REJECT. You can use the CONTINUE statement to end the current loop pass prematurely and continue with the next loop pass. The system field SY-INDEX counts the number of loop passes, starting from 1. You can nest DO loops. When the processing leaves a DO loop, the value of SY-INDEX belonging to the outer DO loop is restored. Example DO. WRITE: / 'SY-INDEX - Begin:', (3) SY-INDEX. IF SY-INDEX = 10. EXIT. ENDIF. WRITE: 'End:', (3) SY-INDEX. ENDDO. This DO loop outputs 9 lines of the form "SY-INDEX - Begin: n End: n ". Here, n stands for the numbers 1 to 9. The last line displayed is "SY-INDEX - Begin: 10". On the 10th pass, the loop is terminated. Note The danger with this statement is programming endless loops. Therefore, you must ensure that the loop contains at least one EXIT, STOP or REJECT statement which is executed at least once. Addition 1 ... VARYING f FROM f1 NEXT f2 Effect This addition is useful if you have a series of fields of the same type and the same distance from each other. f is a variable which you define in a DATA statement. On each loop pass, f contains a new value. The field f1 after "FROM" specifies the first value of the variable f, while the field f2 after "NEXT" specifies the value to be assigned to the variable f in the second pass. For each subsequent pass, the variable f contains the next value in the sequence determined by the distance between the fields f1 and f2 in memory. The fields f1 and f2 should be type-compatible and convertible to f. If the value of f changes during the loop pass, the new value is then placed in the appropriate field fn assigned to f (transfer type: pass by value and result). If the loop pass terminates because of a dialog message, the new value is not passed back if f changes. The addition ... VARYING f FROM f1 NEXT f2 can be used several times in a DO statement. Example DATA: BEGIN OF WORD, ONE VALUE 'E', TWO VALUE 'x', THREE VALUE 'a', FOUR VALUE 'm', FIVE VALUE 'p', SIX VALUE 'l', SEVEN VALUE 'e', EIGHT VALUE '!', END OF WORD, LETTER1, LETTER2. DO VARYING LETTER1 FROM WORD-ONE THEN WORD-THREE VARYING LETTER2 FROM WORD-TWO THEN WORD-FOUR. WRITE: LETTER1, LETTER2. IF LETTER2 = '!'. EXIT. ENDIF. ENDDO. The resulting output is the character string "E x a m p l e !". Note When using this addition, ensure that the DO loop terminates at the "right" time, in order to avoid assigning meaningless values that happen to be in memory after this sequence of fields. This could result in a runtime error. Variant 2 DO n TIMES. Addition: ... VARYING f FROM f1 NEXT f2 (similar to variant 1) Effect Repeats the processing enclosed by the DO and ENDDO statements n times. If n changes within the loop, this has no effect on loop passes. Example DATA COUNT TYPE I. DO 10 TIMES. ADD SY-INDEX TO COUNT. ENDDO. The field COUNT now contains 55 (1+2+...+10). Related WHILE, LOOP Note Performance: The runtime required to pass once through an empty DO loop is about 11 msn (standardized microseconds). For 100 loop passes, about 230 msn would be needed. If possible, use a WHILE loop instead of a DO / EXIT construction because this improves the performance slightly and is clearer. DOWNLOAD is not an ABAP/4 key word (in R/3). Please use the function module WS_DOWNLOAD. DYNPROS is not an ABAP/4 key word (in R/3). To create batch input sessions, please use the function module BDC_... from the group SBDC. ABAP/4 editor You can specify editor commands in any of the following ways: - as header commands (in the command line above the line ruler) or - as line commands (by overwriting the line numbers) or - by pressing function keys and selecting menu options. Header commands A(TTACH) n Display the text from line n B(OTTOM) Go to the last page. or ++ T(OP) Go to the first page. or -- + Go to the next page. - Go to the previous page. FIND c Find the character string c from the current cursor position; cursor is placed on the relevant line. If the character string contains blanks or special characters, you must enclose it within special characters not contained in the string itself. Example: FIND /empty- / The command does not distinguish between upper and lower case. N(EXT) Find and go to the last search string that was specified, starting from the current cursor position. R(EPLACE) c1 c2 Replace the character string c1 by the character string c2 in the entire text. c1 and c2 can have different lengths. If one of the character strings contains blanks or special characters, you must enclose c1 and c2 in special characters (see FIND). Example: R /empty- /blanks/ F(ETCH) prog Get the program prog; the command releases the current program first. S(AVE) Store the editor contents temporarily in a standard UNIX directory; they remain there even if you leave the editor. To return the text from intermediate storage to the editor, either select the editor or use the FETCH command. UPDATE deletes any text in intermediate storage. If a crash occurs during the editor session, the editor contents are often recovered in intermediate storage. RES(TORE) Restore text from the UNIX directory to the editor; overwrites any previous editor contents. RES(TORE) AKTIV Restore the active version from the DLIB file to the editor; overwrites any previous editor contents. SAVEAS prog Save the editor contents under the different name prog; the previous name (for the editor contents) remains unchanged. U(PDATE) Save the editor contents (inapplicable in display mode). CHECK Check the syntax of the program in the editor for errors. PCF(ETCH) Upload for a file on the presentation server. PC(DOWN) Download the editor contents to the presentation server. HELP word Display the documentation for the ABAP/4 statement word (for further information, enter HELP HELP). I(NSERT) n Insert n new lines at end of text. IC word Insert the structure of the ABAP/4 statement word at the current cursor position. This is effective for the statements CASE, DO, FORM, IF, LOOP, MESSAGE, MODULE, SELECT, SHIFT, SORT, TRANSFER, WHILE and WINDOW. IC FUNCTION func Insert the structure of a CALL FUNCTION statement for the function module func (generic names are also allowed). IC SELECT tab Insert the structure of a SELECT statement for the pooled table/data base table tab; you can select the table fields beforehand (in a window). IC ... Insert at cursor position ... *f - FORM comment block *m - MODULE comment block *.* - Comment line *....text...........* *-* - Comment line *-------------------* *-*1 - Comment area with a blank line ** - Comment line ********************* **n - Comment area with n blank lines (1 <= n <= 5) PP Format program text ("Pretty Print") without including includes; no update takes place. PRINT Print editor contents; subsequently requires you to enter print parameters. RENUM(BER) Renumber lines. SHOW tab Display the fields of the DB/pooled table tab. SHOW FUNCTION func Display the function module func (generic names also allowed). Line commands * Go to this line. T+ Go to first line (cf. header command T). B- Go to last line. > Insert the program lines of the include file instead of the INCLUDE statement; special comment lines frame the include lines as an include block. < Delete the include block and re-insert the INCLUDE statement. The cursor must appear on the special comment line before the include block. u Write the include block to the include file; the command then removes the block and re-inserts the INCLUDE statement (see '<'). A Target line for a C/CC or M/MM command; line or block of lines then appears after this line. B Target line for a C/CC or M/MM command; line or block of lines then appears before this line. O Target line for a C or M command; C line fills the blanks on this line (overlay). C Copy this line (target line A/B/O). CC ... CC Copy this block of lines (target A/B). M Move this line (target A/B/O). MM ... MM Move this block of lines (target A/B). I Insert a new line. In Insert n new lines; if n > 9, the last digit must be followed by a blank N Insert a comment area. D Delete this line. DD ... DD Delete this block of lines. R Duplicate (repeat) this line. Rn Duplicate this line n times. RR ... RR Duplicate this block of lines. J Join the subsequent line to this line, if there is enough space. S Split this line at the cursor position. SH ... SH Shift this block of lines horizontally to the cursor position. WW ... WW Mark this block of lines in the general clipboard (the general clipboard is available across different systems). W Copy the general clipboard after this line. XX ... XX Mark this block of lines in the X clipboard. X Copy the X clipboard after this line. YY ... YY Mark this block of lines in the Y clipboard. Y Copy the Y clipboard after this line. ZZ ... ZZ Mark this block of lines in the Z clipboard. Z Copy the Z clipboard after this line. CLEAR Delete the X, Y and Z buffers. RESET Delete flagged line commands. PR ... PR Print this block of lines. Function keys F2/mouse If the cursor is in the line number area, this line becomes the first line in the display (cf. line command *). If the cursor is in the text area, the word concerned is interpreted as the name of a program object (i.e. data field, table, FORM routine, module, function module, dialog module, transaction code, message, screen number, GUI status, title or include file). Procedure thereafter depends on whether the object is defined or used at this point. Where-defined: Display hit list containing all the places where the object is used. Where-used: Branch to place where object is defined. Where no definition is found, you see another window asking if you want to insert the definition in the program. If yes, the system branches to the appropriate place in the program or to the appropriate include and inserts a definition template which you have to complete. F5 Duplicate this line (cf. line command R). F6 Insert a blank line (cf. line command I). F7 Append next line (cf. line command J). F8 Split this line (cf. line command S). F9 Mark this line as the start or end of a range. To edit ranges marked in this way, use the options in the Edit menu. F11 Save the editor contents (cf. header command U). F12 Restore from UNIX directoy (cf. line command RES). F13 Insert a statement structure at the cursor position (cf. header command IC). F14 Delete this line (cf. line command D). F16 Check program (cf. header command CHECK). F17 Continue replace. F18 Continue search. F19 Note line in notepad. F20 Switch between display and change mode. EDITOR-CALL Call editor for internal tables - EDITOR-CALL FOR itab. Call editor for ABAP/4 programs - EDITOR-CALL FOR REPORT prog. EDITOR-CALL - call editor for internal tables Basic form EDITOR-CALL FOR itab. Additions: 1. ... TITLE text 2. ... DISPLAY-MODE Effect Displays the internal table itab in the ABAP/4 Editor. You can then use normal editor functions (e.g. insert, delete, search, replace) to make changes. When you save (with F11) or leave (with F3), any changes are adopted. The return code value is set as follows: SY-SUBRC = 0: Changes saved before leaving editor. SY-SUBRC = 4: Changes not saved before leaving editor. Notes - The internal table can contain only type C components. - The lines of the internal table can be up 72 characters long. Addition 1 ... TITLE text Effect Displays the specified text string (up to 30 characters) in the editor header line. Addition 2 ... DISPLAY MODE Calls the editor in display mode. You can neither make changes here nor switch to change mode. Example Define and fill the internal table T. Then, use EDITOR-CALL to present it to the user for modification. Finally, output the table. DATA: BEGIN OF T OCCURS 200, TEXT1(60),TEXT2(12), END OF T. T-TEXT1 = 'Text 1'. T-TEXT2 = 'A'. APPEND T. T-TEXT1 = 'Text 2'. T-TEXT2 = 'B'. APPEND T. T-TEXT1 = 'Text 3'. T-TEXT2 = 'C'. APPEND T. T-TEXT1 = 'Text 4'. T-TEXT2 = 'D'. APPEND T. EDITOR-CALL FOR T TITLE 'Editor for internal tables'. LOOP AT T. WRITE: / T-TEXT1, T-TEXT2. ENDLOOP. Related EDITOR-CALL FOR REPORT EDITOR-CALL - call ABAP/4 program editor Basic form EDITOR-CALL FOR REPORT prog. Addition: ... DISPLAY-MODE Effect Reads the program prog from the library and places it in the ABAP/4 Editor. When you save (with F11), the program is written back to the library. Addition ... DISPLAY-MODE Effect Calls the editor in display mode. Changes are not allowed here, but you can switch to change mode from within the editor. Example Call the ABAP Editor for the report SAPTEST in display mode: EDITOR-CALL FOR REPORT 'SAPTEST' DISPLAY-MODE. Related EDITOR-CALL FOR itab ELSE Basic form ELSE. Effect Within an "IF ... ENDIF" processing block, precedes the code to be executed if the logical expression specified by IF fails. Example DATA: RESULT TYPE I, OP1 TYPE I, OP2 TYPE I. ... RESULT = OP1 - OP2. IF RESULT > 0. WRITE / 'Result greater than zero.'. ELSE. WRITE / 'Result less or equal zero.'. ENDIF. Depending on the value of RESULT, both different texts are output. Related IF, ELSEIF, CASE ELSEIF Basic form ELSEIF logexp. Effect Within a processing block enclosed by "IF ... ENDIF", this statement indicates the processing to be executed if the logical expressions specified by IF and the preceding ELSEIFs are false, but the logical expression in this ELSEIF processing block is true. Between the IF and ENDIF statements, there may be any number of ELSEIFs. These may be followed, optionally, by an ELSE statement, but this is executed only if none of the logical expressions under IF or ELSEIF is true. Example DATA RESULT TYPE I. ... IF RESULT < 0. WRITE / 'Result less than zero'. ELSEIF RESULT = 0. WRITE / 'Result equal zero'. ELSE. WRITE / 'Result greater than zero'. ENDIF. Depending on the value of RESULT, the three different texts are output. Related IF, ELSE, CASE END-OF-DEFINITION Basic form END-OF-DEFINITION. Effect DEFINE. END-OF-PAGE Basic form END-OF-PAGE. Effect List processing event. The END-OF-PAGE event is executed whenever processing reaches that area when formatting a list page or if the RESERVE statement detects that there is insufficient space remaining on the current page. Note - The size of the END-OF-PAGE area of list pages is defined in the LINE-COUNT specification of the REPORT statement (e.g. EXPORT TEST LINE-COUNT 65(3)). If no size is defined, the END-OF-PAGE area contains no lines and the event END-OF-PAGE is never executed. - If the standard setting LINE-COUNT 0 applies (i.e. no restriction on the number of lines per page), the event END-OF-PAGE is not processed, since no automatic new page follows. - If you explicitly specify a new page with NEW-PAGE, END-OF-PAGE is ignored. Related TOP-OF-PAGE END-OF-SELECTION Basic form END-OF-SELECTION. Effect Processing event Executes the code after END-OF-SELECTION when all the logical database records have been read and processed. Related START-OF-SELECTION, STOP, GET dbtab ENDAT Basic form ENDAT. Effect The ENDAT statement closes the control structure introduced by AT. ENDCASE Basic form ENDCASE. Effect The ENDCASE statement closes a case disinction introduced by CASE. ENDDO Basic form ENDDO. Effect Closes a loop introduced by DO. ENDEXEC Basic form ENDEXEC. Effect Closes a processing block introduced by EXEC SQL. ENDFOR is not an ABAP/4 key word (in R/3). ENDFORM Basic form ENDFORM. Effect Closes a subroutine definition introduced by FORM. ENDFUNCTION Basic form ENDFUNCTION. Effect Closes a subroutine definition introduced by FUNCTION. ENDIF Basic form ENDIF. Effect The ENDIF statement concludes a statement introduced by IF. ENDIFEND is not an ABAP/4 key word (in R/3). ENDLOOP Basic form ENDLOOP. Effect The ENDLOOP statement closes a loop introduced by LOOP. ENDMODULE Basic form ENDMODULE. Effect Closes a module definition introduced by MODULE. ENDON Basic form ENDON. Effect The ENDON statement closes a structure introduced by ON (CHANGE OF). ENDPROVIDE Basic form ENDPROVIDE. Effect Closes a loop introduced by PROVIDE. ENDSELECT Basic form ENDSELECT. Effect Closes a loop introduced by SELECT. Note SELECT is not concluded by ENDSELECT - if it is a SELECT SINGLE command, - if only aggregate functions appear in the INTO clause or - if the INTO clause INTO TABLE itab or APPENDING TABLE itab does not include the addition PACKAGE SIZE. ENDUPLOAD is not an ABAP/4 key word (in R/3). ENDWHILE Basic form ENDWHILE. Effect Closes a loop introduced by WHILE. ENQUEUE is not an ABAP/4 key word (in R/3). To lock resources, you must use an ENQUEUE function module (see SAP locking concept). EXEC Basic form EXEC SQL. Addition: ... PERFORMING form Effect Executes the Native SQL command enclosed by the statements EXEC SQL and ENDEXEC. In contrast to Open SQL, addressed database tables do not have to be known to the ABAP/4 Dictionary and the ABAP/4 program does not have to contain appropriate TABLES statements. Example Create the table AVERI_CLNT: EXEC SQL. CREATE TABLE AVERI_CLNT ( CLIENT CHAR(3) NOT NULL, ARG1 CHAR(3) NOT NULL, ARG2 CHAR(3) NOT NULL, FUNCTION CHAR(10) NOT NULL, PRIMARY KEY (CLIENT, ARG1, ARG2) ) ENDEXEC. With Native SQL commands, passing data between an ABAP/4 program and the database is achieved using host variables. A host variable is an ABAP/4 variable prefixed by a "*" in the Native SQL statement. Example Display a section of the table AVERI_CLNT: DATA: F1(3), F2(3), F3(3). F3 = ' 1 ' EXEC SQL. SELECT CLIENT, ARG1 INTO :F1, :F2 FROM AVERI_CLNT WHERE ARG2 = :F3 ENDEXEC. WRITE: / F1, F2. To simplify the spelling of INTO lists in the SELECT command, you can specify a single structure as the target area as in Open SQL. Example Display a section of the table AVERI_CLNT: DATA: BEGIN OF WA, CLIENT(3), ARG1(3), ARG2(3), END OF WA. DATA F3(3). F3 = ' 1 ' EXEC SQL. SELECT CLIENT, ARG1 INTO :WA FROM AVERI_CLNT WHERE ARG2 = :F3 ENDEXEC. WRITE: / WA-CLIENT, WA-ARG1. Notes 1. In contrast to Open SQL, a client field in Native SQL is a field like any other and must be specified explicitly in calls. 2. Authorization checks cannot be properly realized in EXEC SQL. You should perform these in the program. 3. When you start the R/3 System, a CONNECT to the current database is executed automatically. An explicit CONNECT is unnecessary. 4. A Native SQL command can (but does not have to) end with a ";". Under no circumstances should it end with a ".". 5. Some database systems allow upper and lower case in table names and field names. If you want to take advantage of this, you must ensure that the spelling of names is correct. To enable entry of lower case letters in names in the ABAP/4 editor, you must set the attribute for upper/lower case in the report. 6. Since there are no arrays in ABAP/4, array operations are not possible in Native SQL. If the result of a SELECT command is a table, you can read this table line by line either with the Native SQL command FETCH or with the addition ... PERFORMING form. 7. Unlike in ABAP/4 programs, the character " in a Native SQL statement does not introduce a comment until the end of the editor line. Addition ... PERFORMING form Effect If the result of a SELECT command is a table, you can read this table line by line in a processing loop. The subroutine form is called once for each line. In this subroutine, you can leave the loop by using EXIT FROM SQL. If the result of the selection is a single record, the subroutine is called only once. Example Display a section of the table AVERI_CLNT: DATA: F1(3), F2(3), F3(3). F3 = ' 1 ' EXEC SQL PERFORMING WRITE_AVERI_CLNT. SELECT CLIENT, ARG1 INTO :F1, :F2 FROM AVERI_CLNT WHERE ARG2 = :F3 ENDEXEC. FORM WRITE_AVERI_CLNT. WRITE: / F1, F2. ENDFORM. Note This addition is allowed only with a SELECT command. Related SELECT, INSERT, UPDATE, MODIFY, DELETE, OPEN CURSOR, FETCH, CLOSE CURSOR, COMMIT WORK and ROLLBACK WORK. EXIT Basic forms: 1. EXIT. 2. EXIT FROM STEP-LOOP. 3. EXIT FROM SQL. EXIT in loops and modularization units Basic form EXIT. Effect - In loop structures: Leaves the loop processing (DO, WHILE, LOOP, SELECT) - In subroutines and other modularization units (but outside loop structures): Leaves the subroutine or modularization unit (FORM, MODULE, FUNCTION, TOP-OF-PAGE, END-OF-PAGE) - Outside loop structures and modularization units (report processing): Cancels the report processing and displays the list Example TABLES T100. DATA SAP_COUNT TYPE I. SELECT * FROM T100 WHERE SPRSL = SY-LANGU AND ARBGB = 'DS'. WRITE / T100-TEXT. IF T100-TEXT CS 'SAP'. ADD 1 TO SAP_COUNT. IF SAP_COUNT = 3. EXIT. ENDIF. ENDIF. ENDSELECT. Note If there are several nested loops, the effect of EXIT is only to leave the current loop. Processing continues after the next END... statement in the next loop up. Related CONTINUE, CHECK, REJECT, STOP EXIT FROM SQL Basic form EXIT FROM SQL. Effect Leaves loop processing of the selected lines introduced by EXEC SQL PERFORMING form. Leaves the function form and cancels the processing of the block of code introduced by EXEC SQL and concluded by ENDEXEC. Related EXEC SQL EXIT FROM STEP-LOOP Basic form EXIT FROM STEP-LOOP. Effect Leaves a step loop (screen). The current line and all subsequent lines are either not displayed (PBO) or not processed (PAI). EXPORT Export data - EXPORT obj1 ... objn TO MEMORY. - EXPORT obj1 ... objn TO DATABASE dbtab(ar) ID key. - EXPORT obj1 ... objn TO DATASET dsn(ar) ID key. Export a screen - EXPORT DYNPRO h f e m ID id. Export a structure description - EXPORT NAMETAB h f ID id. EXPORT - Export data Variants: 1. EXPORT obj1 ... objn TO MEMORY. 2. EXPORT obj1 ... objn TO DATABASE dbtab(ar) ID key. 3. EXPORT obj1 ... objn TO DATASET dsn(ar) ID key. Variant 1 EXPORT obj1 ... objn TO MEMORY. Additions: 1. ... FROM g (for each field to be exported) 2. ... ID key Effect Exports the objects obj1 ... objn (fields, structures or tables) as a data cluster to ABAP/4 memory. If you call a transaction, report or dialog module (with CALL TRANSACTION, SUBMIT or CALL DIALOG), the contents of ABAP/4 memory are retained, even across several levels. The called transaction can then retrieve the data from there using IMPORT ... FROM MEMORY. Each new EXPORT ... TO MEMORY statement overwrites any old data, so no data is appended. If the processing leaves the deepest level of the call chain, the ABAP/4 memory is released. Note The header lines of internal tables cannot be exported, because specifying the name of an internal table with a header line always exports the actual table data. Addition 1 ... FROM g (for each object to be exported) Effect Exports the contents of the data object g and stores them under the name specified before FROM. Addition 2 ... ID key Effect Stores the exported data under the ID key in ABAP/4 memory. You can then use the ID to read it in again (with IMPORT). The ID can be up to 32 characters long. Note If you store data both with and without an ID, the data stored without an ID remains separate and you can re-import it (using IMPORT without ID). Note Runtime errors: - EXPORT_NO_CONTAINER: SAP paging exhausted Variant 2 EXPORT obj1 ... objn TO DATABASE dbtab(ar) ID key. Additions: 1. ... FROM g (for each field to be exported) 2. ... CLIENT h (after dbtab(ar)) 3. ... USING form Effect Exports the objects obj1 ... objn (fields, structures or tables) as a data cluster to the database table dbtab. The database table dbtab must have a standardized structure. The database table dbtab is divided into different logically related areas (ar, 2-character name). You can export collections of data objects (known as data clusters) under a freely definable key (field key) to an area of this database. IMPORT allows you to import individual data objects from this cluster. Notes - The table dbtab specified after DATABASE must be declared under TABLES. - The header lines of internal tables cannot be exported because specifying the name of an internal table with a header line always exports the actual table data. Example Export two fields and an internal table to the database table INDX: TABLES INDX. DATA: INDXKEY LIKE INDX-SRTFD VALUE 'KEYVALUE', F1(4), F2 TYPE P, BEGIN OF ITAB3 OCCURS 2, CONT(4), END OF ITAB3. * Before the export, the data fields in * front of CLUSTR are filled. INDX-AEDAT = SY-DATUM. INDX-USERA = SY-UNAME. * Export der Daten. EXPORT F1 F2 ITAB3 TO DATABASE INDX(ST) ID INDXKEY. Addition 1 ... FROM g (for each object to be exported) Effect Exports the contents of the field g and stores them under the specified name in the database. Addition 2 ... CLIENT h (after dbtab(ar)) Effect Stores the data objects in the client h (if the import/export database table dbtab is client-specific). Addition 3 ... USING form Note This statement is for internal use only. Incompatible changes or further developments may occur at any time without warning or notice. Effect Does not export the data to the database table. Instead, calls the FORM routine form for every record written to the database without this addition. This routine can take the data from the database table work area and therefore has no parameters. Note Runtime errors: Errors in the structure of the EXPORT/IMPORT database can cause runtime errors. Variant 3 EXPORT obj1 ... objn TO DATASET dsn(ar) ID key. Note This variant is not to be used at present. Note Runtime errors: - EXPORT_DATASET_CANNOT_OPEN: Unable to describe file. - EXPORT_DATASET_WRITE_ERROR: File write error. EXPORT - Export a screen Note This statement is for internal use only. Incompatible changes or further developments may occur at any time without warning or notice. Basic form EXPORT DYNPRO h f e m ID id. Effect Exports the screen specified in the field id. The screen information is taken from the structure h (screen header, structure D020S) and the internal tables f (field list, structure D021S), e (flow logic, structure D022S) and m (matchcode information, structure D023S). Related IMPORT DYNPRO, GENERATE DYNPRO, SYNTAX-CHECK FOR DYNPRO, DELETE DYNPRO. EXPORT NAMETAB - Export a structure description Note This statement is for internal use only. Incompatible changes or further developments may occur at any time without warning or notice. Basic form EXPORT NAMETAB h f ID id. Effect Exports a generated structure description. This statement can only be used by ABAP/4 Repository tools! Note Runtime errors: - EXPORT_NAMETAB_WRONG_ID: Table name is too long EXTRACT Basic form EXTRACT fg. Effect Writes all fields of the field group fg (see FIELD-GROUPS) as one record to a sequential dataset (paging). If a field group HEADER has been defined, its fields prefix each record to form a sort key. You can sort this dataset with SORT and process it with LOOP ... ENDLOOP. After this, EXTRACT cannot be execuuted again. Note As soon as the first dataset for a field group has been extracted with EXTRACT, the field group cannot be expanded using INSERT. The field group HEADER, in particular, cannot be expanded after the first EXTRACT (regardless of field group). Note Runtime errors: - EXTRACT_AFTER_SORT/LOOP: EXTRACT after SORT or LOOP. - EXTRACT_FIELD_TOO_LARGE: Occupied length of a single field is too long. - EXTRACT_HEADER_NOT_UNIQUE: Field group HEADER was modified after records had been extracted with EXTRACT. - EXTRACT_TOO_LARGE: Total data length of a record to be extracted (including HEADER fields) is too long. FETCH Basic form FETCH NEXT CURSOR c target. Effect Uses the cursor c to read the next line or lines from the dataset of a database table determined by OPEN CURSOR. The cursor must be a variable of the type CURSOR and must be explicitly opened with OPEN CURSOR. To specify the target area into which you read the selected data, use INTO clause target. FETCH belongs to the Open SQL command set. After each execution of the FETCH statement, the system field SY-DBCNT contains the number of lines read so far. The return code value is set as follows: SY-SUBRC = 0: At least one line was read. SY-SUBRC = 4: No line was read. Example Output the passenger list for the Lufthansa flight 0400 on 28-02.1995: TABLES SBOOK. DATA C TYPE CURSOR, WA LIKE SBOOK. OPEN CURSOR C FOR SELECT * FROM SBOOK WHERE CARRID = 'LH ' AND CONNID = '0400' AND FLDATE = '19950228' ORDER BY PRIMARY KEY. DO. FETCH NEXT CURSOR C INTO WA. IF SY-SUBRC <> 0. CLOSE CURSOR C. EXIT. ENDIF. WRITE: / WA-BOOKID, WA-CUSTOMID, WA-CUSTTYPE, WA-SMOKER, WA-LUGGWEIGHT, WA-WUNIT, WA-INVOICE. ENDDO. Related SELECT FIELD-GROUPS Basic form FIELD-GROUPS fg. Effect Defines a field group. A field group combines several existing fields together under one name. You use the INSERT statement to determine which fields belong to a field group at runtime. Example FIELD-GROUPS: HEADER, ORDER, PRODUCT. Note Neither defining a field group (statically) using FIELD-GROUPS nor filling a field group (dynamically) with INSERT generates more memory. Rather, there exists for each field group element a pointer to an (existing) field. FIELD-SYMBOLS Basic form FIELD-SYMBOLS . Additions: 1. ... STRUCTURE s DEFAULT wa 2. ... TYPE t 3. ... TYPE LINE OF t 4. ... LIKE s 5. ... LIKE LINE OF s Effect This statement declares a symbolic field called . At runtime, you can assign a concrete field to the field symbol using ASSIGN. All operations performed with the field symbol then directly affect the field assigned to it. You can only use one of the additions. Example Output aircraft type from the table SFLIGHT using a field symbol: FIELD-SYMBOLS . TABLES SFLIGHT. ... ASSIGN SFLIGHT-PLANETYPE TO . WRITE . Addition 1 ... STRUCTURE s DEFAULT wa Effect Assigns any (internal) field string or structure to the field symbol from the ABAP/4 Dictionary (s). All fields of the structure can be addressed by name: -fieldname. The structured field symbol points initially to the work area wa specified after DEFAULT. The work area wa must be at least as long as the structure s. If s contains fields of the type I or F, wa should have the structure s or at least begin in that way, since otherwise alignment problems may occur. Example Address components of the flight bookings table SBOOK using a field symbol: DATA SBOOK_WA LIKE SBOOK. FIELD-SYMBOLS STRUCTURE SBOOK DEFAULT SBOOK_WA. ... WRITE: -BOOKID, -FLDATE. Addition 2 ... TYPE t Addition 3 ... TYPE LINE OF t Addition 4 ... LIKE s Addition 5 ... LIKE LINE OF s Effect You can use additions 2 to 5 to type field symbols in the same way as FORM parameters (see also Type assignment of subroutine parameters). ASSIGN performs the same type checks as with USING parameters of FORMs. Related ASSIGN, DATA FIELDS Basic form FIELDS f. Effect Addresses a field. The statement is used mainly to address fields statically which are otherwise accessed dynamically. By doing this, you explicitly specify to check programs such as the extended program check that the field in question is used. FILL is not an ABAP/4 key word (in R/3). FOR is not an ABAP/4 key word (in R/3). FORM Basic form FORM form. Additions: 1. ... TABLES itab1 ... itabn 2. ... USING p1 ... pn 3. ... CHANGING p1 ... pn Effect Defines a subroutine called by PERFORM Example PERFORM WELCOME. FORM WELCOME. WRITE / 'Hello world'. ENDFORM. The subroutine WELCOME called by the PERFORM statement outputs 'Hello world' Notes 1. Subroutines defined by FORM can have parameters and local fields. These parameters and local fields shadow global fields. 2. Any local fields you declare with DATA after a FORM statement are recreated and initialized for each PERFORM call. When the call has finished, the memory for local fields is released again. 3. FORM statements are not allowed within FORM ... ENDFORM structures (i.e. no nested definitions). 4. Nested and recursive calls are possible. 5. The optional parameters must always be specified in the order TABLES, USING and CHANGING. Addition 1 ... TABLES itab1 ... itabn Effect TABLES allows you to pass internal tables with or without header lines to subroutines. For information about assigning types TABLES parameters, see Type assignment. TABLES parameters are passed by reference. Example DATA: BEGIN OF X. INCLUDE STRUCTURE SFLIGHT. DATA: ADDITION(8) TYPE C, END OF X. ... PERFORM U USING X. ... FORM U USING X STRUCTURE SFLIGHT. WRITE: X-FLDATE. ENDFORM. Example TYPES: BEGIN OF FLIGHT_STRUC, FLCARRID LIKE SFLIGHT-CARRID, PRICE LIKE SFLIGHT-FLDATE, END OF FLIGHT_STRUC. DATA: MY_FLIGHT TYPE FLIGHT_STRUC OCCURS 0 WITH HEADER LINE, IBOOK1 LIKE SBOOK OCCURS 0 WITH HEADER LINE, IBOOK2 LIKE IBOOK1 OCCURS 0, STRUC LIKE SBOOK. PERFORM DISPLAY TABLES MY_FLIGHT IBOOK1 IBOOK2 USING STRUC. FORM DISPLAY TABLES P_ITAB LIKE MY_FLIGHT[] P_BOOK1 LIKE IBOOK1[] P_BOOK2 LIKE IBOOK2[] USING P_STRU LIKE STRUC. DATA L_CARRID LIKE P_ITAB-FLCARRID. ... WRITE: / P_STRU-CARRID, P_STRU-CONNID. ... LOOP AT P_ITAB WHERE FLCARRID = L_CARRID. ... ENDLOOP. ... ENDFORM. Addition 2 ... USING p1 ... pn Effect Defines the formal parameters p1,...pn which are replaced by actual parameters when you call the subroutine. The formal parameters p1,...pn can have a particular type (see Type assignment). You can also specify the transfer type (i.e. how you want to pass them). Note 1. Transfer types: 1. USING ... p ... Transfer is by reference. This means you can change the transferred field continually in the subroutine. 2. USING ... VALUE(p) ... When you specify VALUE(...), transfer is by value, i.e. the field contents are passed to the relevant local field. VALUES parameters thus behave in the same way as local fields. Addition 3 ... CHANGING p1 ... pn Effect The parameters after CHANGING can accept the same specifications as those after USING. To link the VALUE specification with the change of a parameter value, you can use the addition CHANGING ... . Then, all the formal parameters specified by VALUE(...) are transported back to the actual parameters at the end of the subroutine (i.e. after ENDFORM). If the subroutine is terminated by a dialog message, none of the parameters referenced by CHANGING VALUE ... changes. Otherwise, the effect of USING and CHANGING is identical. Example DATA: NUMBER_1 TYPE I VALUE 1, NUMBER_2 TYPE I VALUE 2, TEXT_1(10) VALUE 'one', TEXT_2(10) VALUE 'two'. PERFORM CONFUSE USING NUMBER_1 NUMBER_2 TEXT_1 NUMBER_1 TEXT_2. FORM CONFUSE USING PAR_NUMBER_1 TYPE I PAR_NUMBER_2 TYPE I PAR_TEXT_1 TYPE C VALUE(PAR_V_NUMBER_1) TYPE I VALUE(PAR_V_TEXT_2) TYPE C. ADD 3 TO PAR_V_NUMBER_1. ADD 4 TO PAR_NUMBER_1. ADD NUMBER_1 TO PAR_NUMBER_2. TEXT_2 = 'three'. PAR_TEXT_1 = PAR_V_TEXT_2. PAR_V_TEXT_2 = 'four'. ENDFORM. Field contents after the PERFORM call: NUMBER_1 = 5 NUMBER_2 = 7 TEXT_1 = 'two' TEXT_2 = 'three' Note In subroutines, you are recommended to use the following procedure: 1. Pass input parameters as USING parameters and output parameters as CHANGING parameters. If in doubt, pass the parameter by VALUE. You should be particularly careful with passed SY fields. For performance reasons, data objects which contain tables should not be passed by VALUE if at all possible. 2. You can protect TABLES parameters whose heasder lines must remain unchanged with LOCAL. 3. STATICS allows you to create global fields with a local visibility area. In the case of local fields which are initialized on each call, you can replace DATA by STATICS. With frequently called FORM routines, this can lead to a noticeable improvement in performance. 4. To avoid shadowing problems with parameters, you are recommended to keep to the naming convnetion for fields in subroutines. You should, for instance, always start FORM parameters with the prefix 'P_' and local fields with the prefix 'L_'. FORMAT Basic form FORMAT. Additions: 1. ... COLOR n [ON] or ... COLOR OFF 2. ... INTENSIFIED [ON] or ... INTENSIFIED OFF 3. ... INVERSE [ON] or ... INVERSE OFF 4. ... HOTSPOT [ON] or ... HOTSPOT OFF 5. ... INPUT [ON] or ... INPUT OFF 6. ... RESET Effect Sets or modifies the valid output format. Notes The formats set by FORMAT work from the next output in the list, i.e. from the next WRITE command or from the next new line. The addition ... ON for switching on the relevant output format is optional. Addition 1 ... COLOR n [ON] or ...COLOR OFF Color of line background. n can have the following values: OFF or COL_BACKGROUND Background (GUI-specific) 1 or COL_HEADING Headers (grayish blue) 2 or COL_NORMAL List body (bright gray) 3 or COL_TOTAL Totals (yellow) 4 or COL_KEY Key columns (bluish green) 5 or COL_POSITIVE Positive threshold value (green) 6 or COL_NEGATIVE Negative threshold value (red) 7 or COL_GROUP Control levels (violet) Note Every time a new event (START-OF-SELECTION, TOP-OF-PAGE, ... ) is started, the system setting reverts to COLOR 0. The additions .. INTENSIFIED and ... INVERSE both affect the color display (see below). The attribute ...COLOR does not work for lines. Addition 2 ... INTENSIFIED [ON] or ... INTENSIFIED OFF Intensified - affects the background color. Each color exists in a normal (desaturated) and in an intensified (saturated) form. ... INTENSIFIED takes the current background color from the "intensified" palette, while the ... INTENSIFIED OFF uses the "normal" palette. Note Every time a new event (START-OF-SELECTION, TOP-OF-PAGE, ...) is started, the system setting reverts to ... INTENSIFIED. On a standard background (COLOR COL_BACKGROUND), the foreground color may be affected in certain cases. If, for example, you use the addition ... INVERSE with the color palette "output field intense" (IntNorm), the addition ... INTENSIFIED has no effect; the only exception to this rule is COLOR COL_BACKGROUND. The attribute ...COLOR does not work for lines. Addition 3 ... INVERSE [ON] or ... INVERSE OFF Inverse - affects the background and foreground colors. Each color exists in an inverse form. ... INVERSE takes the current color from the "inverse" palette and uses it as the foreground (script) color. The background (COL_BACKGROUND) then has no color. ... INVERSE OFF switches off the inverse display. Note Every time a new event (START-OF-SELECTION, TOP-OF-PAGE, ...) is started, the system setting reverts to ... INVERSE. If the use of ... INVERSE results in the same background and foreground colors (COLOR OFF INVERSE), the background color and the foreground color are merely reversed. When you are using the inverse display, the addition ... INTENSIFIED has no effect. (As mentioned above, COLOR OFF INVERSE is an exception to this rule.) The attribute ...COLOR does not work for lines. Addition 4 ... HOTSPOT [ON] or ... HOTSPOT OFF Effect Affects the display format of the mouse pointer and the effect of the mouse single click: If you drage the mouse pointer over list areas which are output with the format ...HOTSPOT (lines or fields), the mouse pointer switches from its standard display format (usually an arrow) to the format of a hand with an outstretched index finger. If you then click once, the effect is like double-clicking or pressing the function key F2 (AT LINE-SELECTION). Note The addition ...HOTSPOT has no effect on input fields. Addition 5 ... INPUT [ON] or ... INPUT OFF Effect Determines whether the user can enter data. You can change the contents of list lines output with the format ... INPUT on the screen. You can also print out the change or process it further by using READ LINE in interactive events. ... INPUT OFF reverses the ready for input status. Note Every time a new event (START-OF-SELECTION, TOP-OF-PAGE, ...) is started, the system setting reverts to ... INPUT. The additions ... COLOR, ... INVERSE and ... HOTSPOT have no effect on input fields. The addition ... INTENSIFIED affects the background color (color palette "input field" or "output field intensified"). The attribute ... INPUT causes lines to be displayed character-by-character and ready for input (| or -). Addition 6 ... RESET Effect Resets all formats (color, intensified, inverse, hotspot and input). This corresponds to the command: FORMAT COLOR OFF INTENSIFIED OFF INVERSE OFF HOTSPOT OFF INPUT OFF. Example FORMAT INTENSIFIED INPUT. WRITE 5 'JOHN'. FORMAT INPUT OFF. WRITE 40 'CARL'COLOR COL_GROUP. produces the following output: ....+....10...+....20...+....30...+....40...+ JOHN CARL ready for input: <-------> intensified: <------------------------------------------> color: <---> From the beginning of the line to the last character of 'JOHN', the list is ready to accept input and is thus displayed in intensified form. From column 9 (i.e. after the 'N' of of 'JOHN'), the list line is also intensified but no longer ready for input. 'CARL' is output from line 40, together with a colored bar (color COL_GROUP = 7 from the palette "color intensified"). The script color is the color "output field intensified" (ProtInt). The intensified line display ends with the last character of 'CARL'. Note If the formats apply only to the output of a single field, you can set the same (and other) parameters as additions to the WRITE statement. If you want to display different formats on the screen, there are no reserved characters, i.e. you may output 2 fields with different formats one directly after the other (without gaps). You can also set the static additions ON, OFF and n (for COLOR) dynamically with = var which always interprets the contents of var as a number. Values other than zero are used as ON or color number, zero works like OFF. For color numbers less than zero or greater than 7, the result is not defined. Recommended data type: I(nteger) Example DATA C TYPE I VALUE 5. FORMAT INTENSIFIED ON COLOR = C. FREE Reset to appropriate initial value for type, including release of resources - FREE f. Release an area in the ABAP/4 memory - FREE MEMORY. Release the memory occupied by an external object - FREE OBJECT obj. FREE - Reset to correct initial value for type, including release of resources Basic form FREE f. Effect Like CLEAR f, FREE f resets any data object f to the correct initial value for its type. In contrast to CLEAR, however, FREE also releases any resources connected with the data object f. This may be relevant with internal tables, structures with tabular components as well as table work areas (created with TABLES). After FREE f, you can address the data object f again at any time, but this may involve reallocating resources. Note If f is an internal table with a header line, the FREE f statement refers to the table body, but the CLEAR f statement refers to the header line. Note Performance: The runtime required to execute the FREE statement is about 5 msn (standardized microseconds). FREE - release work area of a database table Variant 2 FREE dbtab. Effect Releases the work area for the database table dbtab specified with TABLES. When you access this table again, the work area is re-allocated. Related TABLES FREE - Release memory occupied by an internal table Basic form FREE itab. Effect Releases the memory space needed to process the internal table itab. Example Release internal table ITAB after processing: DATA : BEGIN OF ITAB OCCURS 10, NAME(10) TYPE C, END OF ITAB. ITAB-NAME = 'James'. APPEND ITAB. ... LOOP AT ITAB. WRITE ITAB-NAME. ENDLOOP. FREE ITAB. Note Performance: The runtime needed to execute the FREE statement is approx. 5 msn (standardized microseconds). FREE - Release an area in ABAP/4 memory Basic form FREE MEMORY. Addition: ... ID key Effect Releases an area in ABAP/4 memory previously defined with EXPORT TO MEMORY, i.e. an additional IMPORT ... FROM MEMORY sets the return code value of SY-SUBRC to 4. Note FREE MEMORY deletes the entire ABAP/4 memory, including data exported with EXPORT TO MEMORY ID key. Addition ... ID key Effect Releases only the ABAP/4 memory for the ID key. Related EXPORT TO MEMORY, IMPORT FROM MEMORY FREE - Release memory occupied by an external object Basic form FREE OBJECT obj. Effect Releases the memory needed for object obj. The object cannot be processed afterwards. The return code value is set as follows: SY-SUBRC = 0: Object was released successfully. SY-SUBRC = 1: Error during communication with SAPGUI. SY-SUBRC = 2: Error during function call in SAPGUI. The OLE function modules are only implemented in Windows. FREE OBJECT belongs to a group of key words which allow you to process external objects with ABAP/4. At present, only the object model OLE2 is supported, i.e. all objects must be of type OLE2_OBJECT. This type and other necessary data are defined in the include program OLE2INCL. Example Release an EXCEL object: INCLUDE OLE2INCL. DATA EXCEL TYPE OLE2_OBJECT. CREATE OBJECT EXCEL 'Excel.Application'. FREE OBJECT EXCEL. Related CREATE OBJECT, SET PROPERTY, GET PROPERTY, CALL METHOD FROM clause Variants: 1. ... FROM dbtab 2. ... FROM (dbtabname) Effect When used in a SELECT statement, specifies the source (database table or view) from which data can be selected. Variant 1 ... FROM dbtab Additions: 1. ... CLIENT SPECIFIED 2. ... BYPASSING BUFFER 3. ... UP TO n ROWS Effect Specifies the name of the database table dbtab in the program. The database table must be known to the ABAP/4 Dictionary and the program must contain an appropriate TABLES statement. Example Output a list of all customers: TABLES SCUSTOM. SELECT * FROM SCUSTOM. WRITE: / SCUSTOM-ID, SCUSTOM-NAME. ENDSELECT. Addition 1 ... CLIENT SPECIFIED Effect Switches off automatic client handling. With client-specific tables, this enables you to read data across all clients. The client field is treated like a normal table field for which conditions can be formulated in the WHERE clause. The addition CLIENT SPECIFIED must appear immediately after the name of the database table. Example Output a list of all customers in client 3: TABLES SCUSTOM. SELECT * FROM SCUSTOM CLIENT SPECIFIED WHERE MANDT = '003'. WRITE: / SCUSTOM-ID, SCUSTOM-NAME. ENDSELECT. Addition 2 ... BYPASSING BUFFER Effect Reads the data records directly from the database, even if the table is in the SAP buffer. Example Output address of aircraft manufacturer Boeing: TABLES SPROD. SELECT * FROM SPROD BYPASSING BUFFER WHERE PRODUCER = 'BOE'. WRITE: / SPROD-STREET, SPROD-NAME, SPROD-POSTCODE, SPROD-CITY, SPROD-COUNTRY. ENDSELECT. Addition 3 ... UP TO n ROWS Effect Restricts the result set to a maximum of n lines. Example Output a list of the 3 business customers with the highest discounts: TABLES SCUSTOM. SELECT * FROM SCUSTOM UP TO 3 ROWS WHERE CUSTTYPE = 'B'. ORDER BY DISCOUNT DESCENDING. WRITE: / SCUSTOM-ID, SCUSTOM-NAME, SCUSTOM-DISCOUNT. ENDSELECT. Notes 1. If you combine UP TO n ROWS with an ORDER-BY clause, the records are arranged in the specified order and the first n records are output. To achieve this, you must sometimes read more than n records in the database. 2. If n = 0, all the selected records are returned. 3. If n < 0, a runtime error occurs. Variant 2 ... FROM (dbtabname) Additions: 1. ... CLIENT SPECIFIED 2. ... BYPASSING BUFFER 3. ... UP TO n ROWS Effect Specifies the name of the database table as the contents of the field dbtabname at runtime. The database table must be known to the ABAP/4 Dictionary. Example Output a list of all customers: DATA TABNAME(10). DATA: BEGIN OF WA, ID LIKE SCUSTOM-ID, NAME LIKE SCUSTOM-NAME, REST(100), END OF WA. TABNAME = 'SCUSTOM'. SELECT * INTO WA FROM (TABNAME). WRITE: / WA-ID, WA-NAME. ENDSELECT. Notes 1. If you use an INTO clause, you can only specify the name of the database table at runtime. 2. The database table name must always be in upper case. Addition 1 ... CLIENT SPECIFIED Effect As for variant 1. Addition 2 ... BYPASSING BUFFER Effect As for variant 1. Addition 3 ... UP TO n ROWS Effect As for variant 1. Note Performance: With small datasets, you should always try to avoid specifying the name of the database table at runtime because this adversely affects performance. With larger datasets, there is no such problem. FUNCTION Basic form FUNCTION func. Effect Defines a function module called by CALL FUNCTION. Note To create and edit function modules, select Tools -> ABAP/4 Workbench -> Function Library. FUNCTION-POOL Effect The FUNCTION-POOL statement is equivalent to the REPORT statement and introduces a function group. A function group contains function modules introduced by the FUNCTION statement and called with the CALL FUNCTION statement. GENERATE Note This statement is for internal use only. Incompatible changes or further developments may occur at any time without warning or notice. Generate a program - GENERATE REPORT prog. - GENERATE SUBROUTINE POOL itab NAME name. Generate a screen - GENERATE DYNPRO h f e m ID g. GENERATE - Generate a screen Note This statement is for internal use only. Incompatible changes or further developments may occur at any time without warning or notice. GENERATE DYNPRO h f e m ID g. ...MESSAGE F1 ...LINE F2 ...WORD F3. Parts marked with " ..." are interchangeable Additions: 1. ... OFFSET f4 2. ... TRACE-FILE f5 Effect Generates the screen specified in the field g. Here, the source code is taken from the structure h and the internal tables f, e and m. The field h (screen header) should correspond to the structure D020S, the internal table f (field list) to the structure D021S, the internal table e (flow logic) to the structure D022S and the internal table m (matchcode information) to the structure D023S. If a syntax error occurs, the error message is stored in the field f1. If a syntax error occurs, the number of the incorrect line is stored in the field f2. By reading the return code value, you can determine whether this line refers to the flow logic or the field list. If a syntax error occurs, the incorrect word is stored in the field f3. The return code value is set as follows: SY-SUBRC = 0: The screen was generated. SY-SUBRC <> 0: The screen could not be generated. SY-SUBRC = 4: The error is in the flow logic. SY-SUBRC = 8: The error is in the field list. Addition 1 ... OFFSET f4 Effect If a syntax error occurs, the position of the incorrect word is output in this field. Addition 2 ... TRACE-FILE f5 Effect Stores performance data in this file. This addition automatically switches on the trace mode. Related IMPORT DYNPRO, EXPORT DYNPRO, DELETE DYNPRO, SYNTAX-CHECK FOR DYNPRO. GENERATE - Generate a program Note This statement is for internal use only. Incompatible changes or further developments may occur at any time without warning or notice. Variants: 1. GENERATE REPORT prog. 2. GENERATE SUBROUTINE POOL itab NAME name. Variant 1 GENERATE REPORT prog. Additions: 1. ... MESSAGE f1 2. ... INCLUDE f2 3. ... LINE f3 4. ... WORD f4 5. ... OFFSET f5 6. ... TRACE-FILE f6 7. ... DIRECTORY ENTRY f7 8. ... WITHOUT SELECTION-SCREEN Effect Generates the program specified in the field prog. If the program is a report (i.e. a type 1 program), the selection screen is generated automatically. The return code value is set as follows: SY-SUBRC = 0: Program generated successfully. SY-SUBRC <> 0: Unable to generate program. SY-SUBRC = 4: Syntax error. SY-SUBRC = 8: Generation error. SY-SUBRC = 12: Error when generating selection screen. Addition 1 ... MESSAGE f1 Effect When a syntax error occurs, the error message is stored in this field. Addition 2 ... INCLUDE f2 Effect When a syntax error occurs, the name of the include program concerned is stored in this field. Addition 3 ... LINE f3 Effect When a syntax error occurs, the number of the incorrect line is stored in this field. Addition 4 ... WORD f4 Effect When a syntax error occurs, the incorrect word is stored in this field. Addition 5 ... OFFSET f5 Effect When a syntax error occurs, the position of the incorrect word in the incorrect line is stored in this field. Addition 6 ... TRACE-FILE f6 Effect Trace output is stored in this file. This addition automatically activates the trace mode. Addition 7 ... DIRECTORY ENTRY f7 Effect The program attributes required for checking are taken from the field f4. This field must correspond to the structure of the table TRDIR. Addition 8 ... WITHOUT SELECTION-SCREEN Effect Does not generate the selection screen. Variant 2 GENERATE SUBROUTINE POOL itab NAME name. Additions: 1. ... MESSAGE f1 2. ... INCLUDE f2 3. ... LINE f3 4. ... WORD f4 5. ... OFFSET f5 6. ... TRACE-FILE f6 The additions have the same meaning as with GENERATE REPORT. Only the addition DIRECTORY-ENTRY is not supported with GENERATE SUBROUTINE POOL because temporary subroutine pools are always generated as type S programs and the arithmetic flag is taken over from the generating program. Effect Generates a temporary subroutine pool. The source code for the subroutine pool to be generated is passed on in the internal table itab. The field name contains the name under which FORM routines can be addressed in the temporary subroutine pool via external PERFORM. The return code value is set as follows: SY-SUBRC = 0: Generation successful. SY-SUBRC <> 0: Generation unsuccessful. SY-SUBRC = 4: Syntax error. SY-SUBRC = 8: Generation error. In contrast to GENERATE REPORT, the source code is passed on in an internal table with GENERATE SUBROUTINE POOL, not read from the database. The load version generated is not written to the database but held in main memory only. Notes 1. Temporary subroutine pools belong to the runtime context of the generating program, i.e. to the roll area of the internal mode from which the generation is performed. They may therefore be addressed only within this context, i.e. the generated FORM routines can only be called from within the generating mode. 2. Up to 36 temporary subroutine pools can currently be managed for each roll area. Related SYNTAX-CHECK GET Basic forms: 1. GET dbtab. 2. GET CURSOR ... 3. GET PARAMETER ID key FIELD f. 4. GET TIME. 5. GET RUN TIME FIELD f. 6. GET PROPERTY OF obj p = f. GET Basic form 1 GET dbtab. Additions: 1. ... LATE 2. ... FIELDS f1 ... fn Effect Processing event. Gets the table dbtab for processing while the logical database is running. You can address all the fields from dbtab in the subsequent processing. You can also refer to fields from tables in the logical database on the access path to the table dbtab. Note You can use the event "GET dbtab." only once in the report. Example The program uses the logical database F1S which has a structure where the table BOOKING appears below the table FLIGHT. TABLES: SFLIGHT, SBOOK. GET SFLIGHT. WRITE: SFLIGHT-CARRID, SFLIGHT-CONNID, SLFIGHT-FLDATE, SFLIGHT-PLANETYPE. GET SBOOK. WRITE: SBOOK-BOOKID, SBOOK-CUSTOMID, SBOOK-ORDER_DATE. Addition 1 ... LATE. Effect Executes the code following "GET dbtab LATE." only when all the subordinate tables have been read and processed. Example Count the smokers among the bookings already made. TABLES: SFLIGHT, SBOOK. DATA SMOKERS TYPE I. GET SFLIGHT. ULINE. WRITE: / SFLIGHT-SEATSMAX, SFLIGHT-SEATSOCC. SMOKERS = 0. GET SBOOK. CHECK SBOOK-SMOKER <> SPACE. ADD 1 TO SMOKERS. GET FLIGHT LATE. WRITE SMOKERS. Addition 2 ... FIELDS f1 ... fn Effect Performance option. Addresses only the fields f1, ..., fn of the tabelle dbtab (also possible with a dynamic ASSIGN). Since only these fields have to be assigned values by the logical database, this can improve performance considerably. Notes 1. The addition (for GET dbtab or GET dbtab LATE) is allowed only for tables intended for field selection by the logical database (SELECTION-SCREEN FIELD SELECTION FOR TABLE dbtab). 2. When executing the events GET dbtab, GET dbtab LATE or GET dbtab_2 for a subordinate table dbtab_2 in the database hierarchy, the contents of all all fields of dbtab apart from f1, ..., fn are undefined. 3. If both GET dbtab FIELDS f1 ...fn and GET dbtab LATE FIELDS g1 ...gm occur in the program, values are assigned to all the fields f1, ..., fn, g1, ..., gm. 4. In addition to the specified fields, values are also assigned to the key fields of dbtab. 5. If you use the FIELDS addition, you access only the specified fields. Any external PERFORM calls should be taken into account here. 6. A special rule applies for tables which are intended for field selection by the logical database, for which neither a GET dbtab nor a GET dbtab LATE event exists in the program, yet for which there is a subordinate table dbtab_2 with GET dbtab_2 or GET dbtab_2 LATE in the program. If the table is declared with TABLES dbtab in the program, the work area of dbtab exists for GET dbtab_2 or GET dbtab_2 LATE and is can therfore receive values. Also, if a restricted field selection is sufficient for dbtab, you can achieve this with a GET dbtab FIELDS f1 ... fn statement (without subsequent processing). If the program contains no TABLES dbtab statement, the system assumes no access to the work area of dbtab. In this case, therefore, only the key fields of dbatab are assigned values. If, however, you want to fill the work area of dbtab completely (e.g. for an external PERFORM call), you must include the TABLES dbtab statement in the program. 7. The field lists are made available to the report and the logical database in an internal table SELECT_FIELDS. The exact definition of the object SELECT_FIELDS is stored in the TYPE-POOL RSFS and reads: TYPES: BEGIN OF RSFS_TAB_FIELDS, TABLENAME LIKE RSDSTABS-PRIM_TAB, FIELDS LIKE RSFS_STRUC OCCURS 10, END OF RSFS_TAB_FIELDS. ... TYPES: RSFS_FIELDS TYPE RSFS_TAB_FIELDS OCCURS 10. DATA SELECT_FIELDS TYPE RSFS_FIELDS. SELECT_FIELDS is thus an internal table. Each line of this internal table contains a table name (TABLENAME) and another internal table (FIELDS) which contains the desired table fields (TABLENAME). Neither the TYPE-POOL RSFS nor the declaration of SELECT_FIELDS have to be in the report. Both are automatically included by the system, if required. If, for some reason, you need to assign values to more fields, you can manipulate this table under INITIALIZATION or START-OF-SELECTION. Examples 1. Specify the necessary fields under GET. Both SFLIGHT and SBOOK must be defined for field selection. TABLES: SFLIGHT, SBOOK. GET SFLIGHT FIELDS CARRID CONNID FLDATE PLANETYPE. WRITE: SFLIGHT-CARRID, SFLIGHT-CONNID, SFLIGHT-FLDATE, SFLIGHT-PLANETYPE. GET SBOOK FIELDS BOOKID CUSTOMID ORDER_DATE. WRITE: SBOOK-BOOKID, SBOOK-CUSTOMID, SBOOK-ORDER_DATE. 2. In the above 'smoker' example, you can also specify the required SFLIGHT fields under 'GET SFLIGHT LATE': TABLES: SFLIGHT, SBOOK. DATA SMOKERS TYPE I. GET SFLIGHT. ULINE. WRITE: / SFLIGHT-SEATSMAX, SFLIGHT-SEATSOCC. SMOKERS = 0. GET SBOOK FIELDS SMOKER. CHECK SBOOK-SMOKER <> SPACE. ADD 1 TO SMOKERS. GET SFLIGHT LATE FIELDS SEATSMAX SEATSOCC. WRITE SMOKERS. 3. Only fields from SBOOK are output. No TABLES SFLIGHT statement exists. Then, for the table SFLIGHT, only the key fields are read (regardless of whether the FIELDS addition is used with GET SBOOK or not). TABLES: SBOOK. GET SBOOK FIELDS BOOKID CUSTOMID ORDER_DATE. WRITE: SBOOK-BOOKID, SBOOK-CUSTOMID, SBOOK-ORDER_DATE. 4. Only fields from SBOOK are output, but SFLIGHT is declared by TABLES SFLIGHT. In this case, all the fields of table SFLIGHT are read (regardless of whether the FIELDS addition is used with GET SBOOK or not). TABLES: SFLIGHT, SBOOK. GET SBOOK FIELDS BOOKID CUSTOMID ORDER_DATE. WRITE: SBOOK-BOOKID, SBOOK-CUSTOMID, SBOOK-ORDER_DATE. Related PUT GET CURSOR Variants: 1. GET CURSOR FIELD f. 2. GET CURSOR LINE lin. Variant 1 GET CURSOR FIELD f. Additions: 1. ... OFFSET off 2. ... LINE lin 3. ... VALUE g 4. ... LENGTH len Effect Transfers the name of the field at the cursor position to the field f. The return code value is set as follows: SY-SUBRC = 0: Cursor was positionedd on a field. SY-SUBRC = 4: Cursor was not positioned on a field. Note Unlike screen processing, list processing allows you to output literals, field symbols, parameters and local variables of subroutines. Literals, local variables and VALUE parameters of subroutines are treated like fields without names (field name SPACE, return value 0). Otherwise, GET CURSOR FIELD returns only names of global fields, regardless of whether they are addressed directly (i.e. by "WRITE"), by field symbols or by reference parameters. Example DATA: CURSORFIELD(20), GLOB_FIELD(20) VALUE 'global field', REF_PARAMETER(30) VALUE 'parameter by reference', VAL_PARAMETER(30) VALUE 'parameter by value', FIELD_SYMBOL(20) VALUE 'field-symbol'. FIELD-SYMBOLS: . PERFORM WRITE_LIST USING REF_PARAMETER VAL_PARAMETER. ASSIGN GLOB_FIELD TO . AT LINE-SELECTION. GET CURSOR FIELD CURSORFIELD. WRITE: / CURSORFIELD, SY-SUBRC. FORM WRITE_LIST USING RP VALUE(VP). DATA: LOK_FIELD(20) VALUE 'lokal field'. ASSIGN FIELD_SYMBOL TO . WRITE: / GLOB_FIELD, / LOK_FIELD, / RP, / VP, / 'literal', / FIELD_SYMBOL. ENDFORM. When you double-click on the word "global field", CURSORFIELD contains the field name GLOB_FIELD, on "parameter by reference" the field name REF_PARAMETER, on "field symbol" the field name FIELD_SYMBOL, and on "local field", "parameter by value" and "literal" the value SPACE. Addition 1 ... OFFSET off Effect Copies the position of the cursor within the field to the field off (1st column = 0). If the cursor is not somewhere within a field (SY-SUBRC = 4), the offset value is set to 0. Addition 2 ... LINE lin Effect With step loops, lin contains the number of the loop line where the cursor stands. In list processing, this is the absolute line number (as stored in the system field SY-LILLI). Addition 3 ... VALUE g Effect g contains the value of the field where the cursor stands, always in output format (character display). Addition 4 ... LENGTH len Effect len contains the output length of the field where the cursor stands. Variant 2 GET CURSOR LINE lin. Additions: 1. ... OFFSET off 2. ... VALUE g 3. ... LENGTH len Effect As for variant 1 with addition LINE, except that there are differences with the return value and the effect of the additions. The return code value is set as follows: SY-SUBRC = 0: The cursor is on one of the list lines (list processing) or on a loop line (step loop). SY-SUBRC = 4: The cursor is not on one of the list or loop lines. Addition 1 ... OFFSET off Effect Applies to list processing only. The field off contains the position of the cursor releative to the beginning of the list line (1st column = 0). With horizontally shifted lists, the offset value can thus be greater than 0, even if the cursor is positioned on the extreme left of the window. Addition 2 ... VALUE g Effect List processing only. The field g contains the list line where the cursor is positioned. Addition 3 ... LENGTH len Effect List processing only. len contains the length of the line (LINE-SIZE). Related SET CURSOR GET Basic form 3 GET PARAMETER ID key FIELD f. Effect Transfers the value stored under the key pid from the global user-related SAP memory memory to the field f. The key pid must consist of three characters. For an overview of the keys (parameters) used, refer to the SAP system description or the appropriate function in the ABAP/4 Development Workbench. The return code value is set as follows: SY-SUBRC = 0: A value was read from SAP memory. SY-SUBRC = 4: No value was found in SAP memory under the specified key Notes - The global user-related SAP memory is available to each user for the entire duration of a terminal session. For this reason, set values are retained when you leave a program. - The SAP memory should not be used for intermediate storage, since a user's parallel sessions use the same global memory. Example Read the program name from SAP memory: DATA : REPID(8). GET PARAMETER ID 'RID' FIELD REPID. Related SET PARAMETER GET Basic form 6 GET PROPERTY OF obj p = f. Addition: ... NO FLUSH Effect Transfers attribute p of object obj to field f. Object obj must be of type OLE2_OBJECT. Normally, all consecutive OLE statements are buffered by the ABAP/4 processor and sent to the presentation server in bundled form. This means that it is possible for a statement to refer to the results of preceding statements. In debugging, however, you should remember that the values of the return parameters cannot be displayed until directly before execution of the first ABAP/4 statement external to OLE. Even a command which refers to an object not yet generated by any OLE statement terminates the bundling. The return code value of SY-SUBRC indicates whether all the bundled commands have been successfully executed. The return code value is set as follows: SY-SUBRC = 0: All commands were successfully executed. SY-SUBRC = 1: When communicating with the presentation server, a system error occurred. The system field SY-MSGLI contains a short description of the error. SY-SUBRC = 2: A method call resulted in an error. SY-SUBRC = 3: Setting a property resulted in an error. SY-SUBRC = 4: Reading a property resulted in an error. In the last 3 cases, a dialog box containing an error note is displayed on the presentation server. GET PROPERTY belongs to a group of key words which allow you to process external objects with ABAP/4. At present, only the object model OLE2 is supported, i.e. all objects must be of type OLE2_OBJECT. This type and other necessary data are defined in the include program OLE2INCL. Addition ... NO FLUSH The addition NO FLUSH continues the collection process, even if the next command is not an OLE statement. This means that you can set a series of properties in a loop and download them to the presentation server in a single transport operation. If you do not use NO FLUSH, you must ensure that you do not rely on the contents of return parameters not yet filled. Also, all objects must be initialized in a bundle, i.e. they must be generated by an OLE call that has already been executed. Every FREE statement always causes a download of the buffer. Example Read the attribute 'Visible' of an EXCEL worksheet. INCLUDE OLE2INCL. DATA: EXCEL TYPE OLE2_OBJECT, VISIBLE TYPE I. CREATE OBJECT EXCEL 'Excel.Application'. GET PROPERTY OF EXCEL 'Visible' = VISIBLE. Related SET PROPERTY CALL METHOD CREATE OBJECT FREE OBJECT GET Basic form 5 GET RUN TIME FIELD f. Effect Relative runtime in microseconds. The first call sets (initializes) the field f to zero. For each subsequent call, f contains the runtime in microseconds since the first call. The field F should be of type I. Note If the applications server is a multiple processor, switching the CPU to another processor may lead to fluctuations in the returned runtime. When measuring the runtime of smaller program components, you can achieve the correct result by taking several small measurements. Example DATA: T1 TYPE I, T2 TYPE I, TMIN TYPE I. DATA: F1(4000), F2 LIKE F1. TMIN = 1000000. DO 10 TIMES. GET RUN TIME FIELD T1. MOVE F1 TO F2. "Time measurement of the MOVE statement GET RUN TIME FIELD T2. T2 = T2 - T1. IF T2 < TMIN. TMIN = T2. ENDIF. ENDDO. WRITE: 'MOVE 4000 bytes takes', TMIN, 'microseconds'. Related To perform runtime measurements of complex processes use the runtime analysis transaction (SE30). GET TIME Basic form 4 GET TIME. Addition: ... FIELD f Effect Sets the system field SY-UZEIT to the current time and resets SY-DATUM. Addition ... FIELD f Effect Transfers the current time to the field f, depending on the type. SY-DATUM and SY-UZEIT are not set. GROUP-BY clause Variants: 1. ... GROUP BY f1 ... fn 2. ... GROUP BY (itab) Variant 1 ... GROUP BY f1 ... fn Effect Groups database table data in a SELECT command on one line in the result set. A group is a set of lines which all have the same values in each column determined by the database fields f1 ... fn. ... GROUP BY f1 ... fn always requires a list in the SELECT clause. Each field f1 ... fn must be specified in this list If you use aggregate functions together with one or more database fields in the SELECT clause, you must also all the database fields not specified by one of the aggregate functions under GROUP BY f1 ... fn. Example Output the number of passengers, the total weight and the average weight of luggage for all Lufthansa flights on 28.02.1995: TABLES SBOOK. DATA: COUNT TYPE I, SUM TYPE P DECIMALS 2, AVG TYPE F. DATA: CONNID LIKE SBOOK-CONNID. SELECT CONNID COUNT( * ) SUM( LUGGWEIGHT ) AVG( LUGGWEIGHT ) INTO (CONNID, COUNT, SUM, AVG) FROM SBOOK WHERE CARRID = 'LH' AND FLDATE = '19950228' GROUP BY CONNID. WRITE: / CONNID, COUNT, SUM, AVG. ENDSELECT. Note ... GROUP BY f1 ... fn is not supported for pooled and cluster tables. Variant 2 ... GROUP BY (itab) Effect Works like GROUP BY f1 ... fn if the internal table itab contains the list f1 ... fn as ABAP/4 source code. The internal table itab can only have one field. This field must be of the type C and should not be more than 72 characters long. itab must be enclosed in parentheses and there should be no blanks between the parentheses and the table name. Note The same restrictions apply to this variant as to GROUP BY f1 ... fn. Example Output all Lufthansa departure points with the number of destinations: TABLES: SPFLI. DATA: BEGIN OF WA. INCLUDE STRUCTURE SPFLI. DATA: COUNT TYPE I. DATA: END OF WA. DATA: GTAB(72) OCCURS 5 WITH HEADER LINE, FTAB(72) OCCURS 5 WITH HEADER LINE, COUNT TYPE I. REFRESH: GTAB, FTAB. FTAB = 'CITYFROM COUNT( * ) AS COUNT'. APPEND FTAB. GTAB = 'CITYFROM'. APPEND GTAB. SELECT DISTINCT (FTAB) INTO CORRESPONDING FIELDS OF WA FROM SPFLI WHERE CARRID = 'LH' GROUP BY (GTAB). WRITE: / WA-CITYFROM, WA-COUNT. ENDSELECT. Note Performance: If possible, you should use the aggregate functions (for example, to determine the minimum value of a database field). HELP Basic form HELP word Effect HELP is not an ABAP/4 statement, but an editor command allowing you to display the documentation for the key word you require without leaving the editor. This means you do not have to save your work beforehand. What you see on the screen depends on what you enter: 1. If the word is an ABAP/4 statement (as is normally the case), the system displays an exact description of the statement. 2. If you enter HELP ABAP, the system displays a list of all the available ABAP/4 programming language statements. 3. The HELP EDITOR command returns information about the editor. 4. You can display this text by entering HELP HELP. Notes - If the cursor is on the line number area, you can obtain a list of available line commands by pressing F1. - If the cursor is on an ABAP/4 statement in the program code, you can obtain the associated documentation by pressing F1. HIDE Basic form HIDE f. Effect Hides the contents of the field f in relation to the current output line. If you select this line, the system automatically assigns the hidden value to f. Such a selection may result from any of the following: 1. AT LINE-SELECTION 2. AT PFx 3. AT USER-COMMAND 4. READ LINE To hide the contents of a field, you do not need to output the field beforehand with WRITE. IF Basic form IF logexp. Effect Used for case distinction. Depending on whether the logical expression logexp is true or not, this statement triggers the execution of various sections of code enclosed by IF and ENDIF. There are three different types: 1. IF logexp. processing1 ENDIF. If the logical expression is true, processing1 is executed. Otherwise, the program resumes immediately after ENDIF. 2. IF logexp. processing1 ELSE. processing2 ENDIF. If the logical expression is true, processing1 is executed. Otherwise, processing2 is executed (see ELSE). 3. IF logexp1. processing1 ELSEIF logexp2. processing2 ELSEIF ... ... ELSE. processingN ENDIF. If the logexp1 is false, logexp2 is evaluated and so on. You can use any number of ELSEIF statements. If an ELSE statement exists, it always appears after all the ELSEIF statements. Notes 1. All IF statements must be concluded in the same processing block by ENDIF. 2. IF statements can be nested as mayn times as you like. 3. The IF statement does not directly affect the selection. For this purpose, you should use the CHECK statement. IMPORT Get data - IMPORT f itab FROM MEMORY. - IMPORT f itab FROM DATABASE dbtab(ar) ID key. - IMPORT DIRECTORY INTO itab FROM DATABASE dbtab(ar) ID key. - IMPORT f itab FROM DATASET dsn(ar) ID key. Get a screen - IMPORT DYNPRO h f e m ID id. IMPORT - Get data Variants: 1. IMPORT f itab FROM MEMORY. 2. IMPORT f itab FROM DATABASE dbtab(ar) ID key. 3. IMPORT DIRECTORY INTO itab FROM DATABASE dbtab(ar) ID key. 4. IMPORT f itab FROM DATASET dsn(ar) ID key. Variant 1 IMPORT f itab FROM MEMORY. Additions: 1. ... TO g (for each field f to be imported) 2. ... ID key Effect Imports data objects (fields or tables) from the ABAP/4 memory (see EXPORT). Reads in all data without an ID that was exported to memory with "EXPORT ... TO MEMORY.". In contrast to the variant IMPORT FROM DATABASE, it does not check that the structure matches in EXPORT and IMPORT. The return code value is set as follows: SY-SUBRC = 0: The data objects were successfully imported. SY-SUBRC = 4: The data objects could not be imported, probably because the ABAP/4 memory was empty. The contents of all objects remain unchanged. Addition 1 ... TO g (for each field f to be imported) Effect Takes the field contents stored under f from the global ABAP/4 memory and places them in the field g. Addition 2 ... ID key Effect Imports only data stored in ABAP/4 memory under the ID key. The return code value is set as follows: SY-SUBRC = 0: The data objects were successfully imported. SY-SUBRC = 4: The data objects could not be imported, probably because an incorrect ID was used. The contents of all objects remain unchanged. Variant 2 IMPORT f itab FROM DATABASE dbtab(ar) ID key. Additions: 1. ... TO g (for each field f to be imported) 2. ... MAJOR-ID maid (instead of ID key) 3. ... MINOR-ID miid (together with MAJOR-ID maid) 4. ... CLIENT h (after dbtab(ar)) 5. ... USING form Effect Imports data objects (fields, field strings or internal tables) with the ID key from the area ar of the database dbtab (see also EXPORT) The return code value is set as follows: SY-SUBRC = 0: The data objects were successfully imported. SY-SUBRC = 4: The data objects could not be imported, probably because an incorrect ID was used. The contents of all objects remain unchanged. Example Import two fields and an internal table: TABLES INDX. DATA: INDXKEY LIKE INDX-SRTFD, F1(4), F2 TYPE P, BEGIN OF TAB3 OCCURS 10, CONT(4), END OF TAB3. INDXKEY = 'INDXKEY'. IMPORT F1 F2 TAB3 FROM DATABASE INDX(ST) ID INDXKEY. Notes The structure of fields, field strings and internal tables to be imported must match the structure of the objects exported to the dataset. In addition, the objects must be imported under the same name used to export them. If this is not the case, either a runtime error occurs or no import takes place. Exception: You can lengthen or shorten the last field if it is of type CHAR, or add/omit CHAR fields at the end of the structure. Addition 1 ... TO g (for each field f to be imported) Effect Takes the field contents stored under the name f from the database and places them in g. Addition 2 ... MAJOR-ID maid (instead of ID key) Addition 3 ... MINOR-ID miid (together with MAJOR-ID maid) Effect Searches for a record with an ID that matches maid in the first part (length of maid) and - if MINOR-ID miid is also specified - is greater than or equal to miid in the second part. Addition 4 ... CLIENT h (after dbtab(ar)) Effect Takes the data from the client h (only with client-specific import/export databases). Example TABLES INDX. DATA F1. IMPORT F1 FROM DATABASE INDX(AR) CLIENT '002' ID 'TEST'. Addition 5 ... USING form Note This statement is for internal use only. Incompatible changes or further developments may occur at any time without warning or notice. Effect Does not read the data from the database. Instead, calls the FORM routine form for each record read from the database without this addition. This routine can take the data key of the data to be retrieved from the database table work area and write the retrieved data to this work area schreiben; it therefore has no parameters. Note Runtime errors: Depending on the operands or the datsets to be imported, various runtime errors may occur. Variant 3 IMPORT DIRECTORY INTO itab FROM DATABASE dbtab(ar) ID key. Additions: 1. ... CLIENT h (after dbtab(ar)) Effect Imports an object directory stored under the specified ID with EXPORT into the table itab. The return code value is set as follows: SY-SUBRC = 0: The directory was successfully imported. SY-SUBRC = 4: The directory could not be imported, probably because an incorrect ID was used. The internal table itab must have the same structure as the Dictionary structure CDIR (INCLUDE STRUCTURE). Addition 1 ... CLIENT h (after dbtab(ar)) Effect Takes data from the client h (only with client-specific import/export databases). Example Directory of a cluster consisting of two fields and an internal table: TABLES INDX. DATA: INDXKEY LIKE INDX-SRTFD, F1(4), F2 TYPE P, BEGIN OF TAB3 OCCURS 10, CONT(4), END OF TAB3, BEGIN OF DIRTAB OCCURS 10. INCLUDE STRUCTURE CDIR. DATA END OF DIRTAB. INDXKEY = 'INDXKEY'. EXPORT F1 F2 TAB3 TO DATABASE INDX(ST) ID INDXKEY. " TAB3 has 17 entries ... IMPORT DIRECTORY INTO DIRTAB FROM DATABASE INDX(ST) ID INDXKEY. Then, the table DIRTAB contains the following: NAME OTYPE FTYPE TFILL FLENG ----------------------------------- F1 F C 0 4 F2 F P 0 8 TAB3 T C 17 4 The meaning of the individual fields is as follows: NAME: Name of stored object OTYPE: Object type (F: Field, R: Field string / Dictionary structure, T: Internal table) FTYPE: Field type (C: Character, P: Packed, ...) Field strings and internal tables have the type C. TFILL: Number of internal table lines filled FLENG: Length of field in bytes With internal tables: Length of header line. Variant 4 IMPORT f itab ... FROM DATASET dsn(ar) ID key. Note This variant is not to be used at present. IMPORT DYNPRO - Import a screen Note This statement is for internal use only. Incompatible changes or further developments may occur at any time without warning or notice. Basic form IMPORT DYNPRO h f e m ID id. Effect Imports the screen specified in the field id. Loads the screen information into the structure h (screen header, structure D020S) and into the internal tables f (field list, structure D021S), e (flow logic, structure D022S) and m (matchcode information, structure D023S). The return code value is set as follows: SY-SUBRC = 0: The screen was successfully imported. SY-SUBRC = 4: The screen does not exist. Related EXPORT DYNPRO, GENERATE DYNPRO, SYNTAX-CHECK FOR DYNPRO, DELETE DYNPRO. INCLUDE Basic forms: 1. INCLUDE prog. 2. INCLUDE STRUCTURE rec. 3. INCLUDE TYPE type. INCLUDE prog Basic form INCLUDE prog. Effect Includes the program prog in the main program for syntax check and generation purposes. Include programs are used to divide very large programs into smaller more manageable units. They also allow you to create common program components. Example INCLUDE LSPRITOP. Notes 1. The whole of an INCLUDE statement must appear on one line where it is the only statement allowed. 2. The include program must consist of complete statements (and comments). 3. You can use the service report RSINCL00 to generate reference lists for include programs. INCLUDE STRUCTURE Basic form INCLUDE STRUCTURE rec. Effect When you define a structure rec (with DATA or TYPES), this statement copies the components of the structured data type subRec to the structure rec. Since you can define nested data structures (i.e. structures with sub-structures) starting from Release 3.0, you should use INCLUDE STRUCTURE only if you want to introduce types in a program first and nested structures in a later step. A data definition DATA: BEGIN OF rec. INCLUDE STRUCTURE subRec. DATA: END OF rec. is equivalent to DATA rec LIKE subRec. You are recommended to use the second formulation. Even if the structure rec to be defined contains additional components, instead of DATA: BEGIN OF rec, ... INCLUDE STRUCTURE subRec. DATA: ... END OF rec. you should use DATA: BEGIN OF rec, ... rec LIKE subRec, ... END OF rec. so that subRec can be referenced as a sub-structure of rec. Note Although "INCLUDE STRUCTURE subRec." breaks up the sub-structure subRec into its components, the alignment of subRec is retained. This means that padding fields may be inserted before the first and/or before the last component of subRec in rec. Related INCLUDE TYPE INCLUDE TYPE Basic form INCLUDE TYPE subRec. Effect When you define a structure rec (with DATA or TYPES), this statement copies the components of the structured data type subRec to the structure rec. Since you can define nested data structures (i.e. structures with sub-structures) starting from Release 3.0, you should use INCLUDE TYPE only if you want to introduce types in a program first and nested structures in a later step. Related INCLUDE STRUCTURE INFOTYPES Basic form INFOTYPES nnnn. nnnn between 0000 and 0999: HR master data info types nnnn between 1000 and 1999: HR planning data info types nnnn between 2000 and 2999: HR time data info types nnnn between 3000 and 8999: Not yet used nnnn between 9000 and 9999: Customer-specific info types Additions: 1. ... NAME c 2. ... OCCURS occ 3. ... MODE N 4. ... VALID FROM begin TO end Effect Declares the HRinfo type nnnn. Creates an internal table as follows: DATA BEGIN OF Pnnnn OCCURS 10. INCLUDE STRUCTURE Pnnnn. DATA END OF Pnnnn VALID BETWEEN BEGDA AND ENDDA. Example INFOTYPES: 0000, 0001, 0002. Addition 1 ... NAME c Effect c is a name up to 20 characters long. Creates an internal table as follows: DATA BEGIN OF c OCCURS 10. INCLUDE STRUCTURE Pnnnn. DATA END OF c VALID BETWEEN BEGDA AND ENDDA. Example INFOTYPES: 0005 NAME VACATION, 0006 NAME ADDRESS. Addition 2 ... OCCURS occ Effect occ is a number for the OCCURS value. Creates an internal table as follows: DATA BEGIN OF c OCCURS m. INCLUDE STRUCTURE Pnnnn. DATA END OF c VALID BETWEEN BEGDA AND ENDDA. Example INFOTYPES 0003 OCCURS 1. Addition 3 ... MODE N Applies only to the HR logical databases PNP and PCH. Effect The info type tables are not filled by GET PERNR (logical database PNP) or GET OBJEC (logical database PCH). The effect of the INFOTYPES statement is then the same as the data declaration of an internal table (as described above). Example INFOTYPES: 2001 MODE N, 2002 MODE N, 2003 MODE N. Addition 4 ... VALID FROM begin TO end. Effect This addition should only be used with the logical database PNP. GET PERNR retrieves only those info type records which are valid within the time range (begin and end) specified. begin and end are dates with the format YYYYMMDD. Example INFOTYPES: 0007 VALID FROM 19910101 TO 19911231. Note Each info type has a formal description in the ABAP/4 Dictionary as table Pnnnn. If you enter SHOW INFOTYPES nnnn in the editor command line, the system displays information about the info type nnnn. If you enter SHOW INFOTYPES *, you see a list of all info types. INITIALIZATION Basic form INITIALIZATION. Effect Processing event. Executed before the selection screen is displayed. The parameters (PARAMETERS) and selection criteria (SELECT-OPTIONS) defined in the program already contain default values (if specified). You can assign different values here and also change the database-specific selections. In contrast to R/2, this event is also executed during background processing. Example Define the last day of the previous month as the key date: PARAMETERS QUAL_DAY TYPE D DEFAULT SY-DATUM. INITIALIZATION. QUAL_DAY+6(2) = '01'. QUAL_DAY = QUAL_DAY - 1. Here, the default value of QUAL_DAY is the current date, e.g. 05.04.88 (QUAL_DAY = '19880405'). Two subseqent statements set the date first to the beginning of the month, e.g. 01.04.88 (QUAL_DAY = '19880401') and then, by subtracting one day, to the last day of the previous month, e.g. 31.03.88 (QUAL_DAY = '19880331'). Note In more precise terms, INITIALIZATION is executed in the following steps: 1. Specify default values for the selections. 2. Execute the event INITIALIZATION. 3. Import variant (if used to start the report). On SUBMIT, the values specified for each WHERE clause are also transferred, if necessary. 4. Execute the event AT SELECTION-SCREEN OUTPUT, if it occurs in the report (unlike INITIALIZATION, this event is always executed for PBO of a selection screen). 5. Display selection screen. 6. Transport the screen fields containing user input to the report fields. 7. Continue with START-OF-SELECTION. Note Since INITIALIZATION is only executed once when you start the report, it is not suitable for screen modifications such as suppressing individual parameters (LOOP AT SCREEN, MODIFY SCREEN) because these changes would disappear again when the user pressed ENTER. The correct event for screen modifications is AT SELECTION-SCREEN OUTPUT. Note The SET PF-STATUS statement does not work during the processing of an event. Instead, you should set a status using one of the function modules RS_SET_SELSCREEN_STATUS or RS_EXTERNAL_SELSCREEN_STATUS. Related AT SELECTION-SCREEN, START-OF-SELECTION INPUT Basic form INPUT. This key word will only be supported for a limited period (for the sake of compatibility with R/2). Instead, please use FORMAT INPUT (see FORMAT) or the addition ... INPUT of the WRITE statement. INSERT Insert into a database table - INSERT INTO dbtab [CLIENT SPECIFIED] VALUES wa. INSERT INTO (dbtabname) [CLIENT SPECIFIED] VALUES wa. - INSERT dbtab [CLIENT SPECIFIED]. INSERT *dbtab [CLIENT SPECIFIED]. INSERT (dbtabname) [CLIENT SPECIFIED] ... . - INSERT dbtab [CLIENT SPECIFIED] FROM TABLE itab. INSERT (dbtabname) [CLIENT SPECIFIED] FROM TABLE itab. Insert into an internal table - INSERT [wa INTO|INITIAL LINE INTO] itab [INDEX idx]. INSERT LINES OF itab1 [FROM idx1] [TO idx2] INTO itab2 [INDEX idx3]. Insert into a field group - INSERT f1 f2 ... INTO fg. Insert a program - INSERT REPORT prog FROM itab. Insert text elements - INSERT TEXTPOOL prog ...FROM itab ...LANGUAGE lg. INSERT - Insert in a database table Variants: 1. INSERT INTO dbtab VALUES wa. or INSERT INTO (dbtabname) VALUES wa. 2. INSERT dbtab. or INSERT *dbtab. or INSERT (dbtabname) ... 3. INSERT dbtab FROM TABLE itab. or INSERT (dbtabname) FROM TABLE itab. Effect Inserts new lines in a database table. You can specify the name of the database table either in the program itself in the form dbtab or at runtime as the contents of the field dbtabname. In both cases, the database table must be defined in the ABAP/4 Dictionary. If the program contains the name of the database table, it must also include a corresponding TABLES statement. Normally, lines are inserted only in the current client. Data can only be inserted using a view if the view refers to a single table and was defined in the ABAP/4 Dictionary with the maintenance status "No restriction". INSERT belongs to the Open SQL command set. Notes 1. You cannot insert a line if a line with the same primary key already exists or if a UNIQUE index already has a line with identical key field values. 2. When inserting lines using a view, all fields of the database table that are not in the view are set to their initial value (see TABLES) - if they were defined with NOT NULL in the ABAP/4 Dictionary. Otherwise they are set to NULL. 3. Since the INSERT statement does not perform authorization checks, you must program these yourself. 4. Lines specified in the INSERT command are not actually added to the database table until after the next COMMIT WORK statement occurs. Prior to this, you can cancel any changes to the database with ROLLBACK WORK. Lines added within a transaction remain locked until the transaction has finished. The end of a transaction is either a COMMIT WORK, where all database changes performed within the transaction are made irrevocable, or a ROLLBACK WORK, which cancels all database changes performed within the transaction. Variant 1 INSERT INTO dbtab VALUES wa. or INSERT INTO (dbtabname) VALUES wa. Addition: ... CLIENT SPECIFIED Effect Inserts one line into a database table. The line to be inserted is taken from the work area wa and the data read from left to right according to the structure of the table work area dbtab (see TABLES). Here, the structure of wa is not taken into account. For this reason, the work area wa must be at least as wide (see DATA) as the table work area dbtab and the alignment of the work area wa must correspond to the alignment of the table work area. Otherwise, a runtime error occurs. When the command has been executed, the system field SY-DBCNT contains the number of inserted lines (0 or 1). The return code value is set as follows: SY-SUBRC = 0: Line was successfully inserted. SY-SUBRC = 4: Line could not be inserted since a line with the same key already exists. Example Insert the customer Robinson in the current client: TABLES SCUSTOM. SCUSTOM-ID = '12400177'. SCUSTOM-NAME = 'Robinson'. SCUSTOM-POSTCODE = '69542'. SCUSTOM-CITY = 'Heidelberg'. SCUSTOM-CUSTTYPE = 'P'. SCUSTOM-DISCOUNT = '003'. SCUSTOM-TELEPHONE = '06201/44889'. INSERT INTO SCUSTOM VALUES SCUSTOM. Addition ... CLIENT SPECIFIED Effect Switches off automatic client handling. This allows you to insert data across all clients even when dealing with client-specific tables. The client field is then treated like a normal table field which you can program to accept values in the work area wa that contains the line to be inserted. The addition CLIENT SPECIFIED must be specified immediately after the name of the database table. Example Insert the customer Robinson in client 2: TABLES SCUSTOM. SCUSTOM-MANDT = '002'. SCUSTOM-ID = '12400177'. SCUSTOM-NAME = 'Robinson'. SCUSTOM-POSTCODE = '69542'. SCUSTOM-CITY = 'Heidelberg'. SCUSTOM-CUSTTYPE = 'P'. SCUSTOM-DISCOUNT = '003'. SCUSTOM-TELEPHONE = '06201/44889'. INSERT INTO SCUSTOM CLIENT SPECIFIED VALUES SCUSTOM. Variant 2 INSERT dbtab. or INSERT *dbtab. or INSERT (dbtabname) ... Additions: 1. ... FROM wa 2. ... CLIENT SPECIFIED Effect These are the SAP-specific short forms for the statements explained under variant 1. - INSERT INTO dbtab VALUES dbtab. or - INSERT INTO dbtab VALUES *dbtab. or - INSERT INTO (dbtabname) VALUES wa. When the command has been executed, the system field SY-DBCNT contains the number of inserted lines (0 or 1). The return code value is set as follows: SY-SUBRC = 0: Line successfully inserted. SY-SUBRC = 4: Line could not be inserted, since a line with the same key already exists. Example Add a line to a database table: TABLES SAIRPORT. SAIRPORT-ID = 'NEW'. SAIRPORT-NAME = 'NEWPORT APT'. INSERT SAIRPORT. Addition 1 ... FROM wa Effect The values for the line to be inserted are not taken from the table work area dbtab, but from the explicitly specified work area wa. The work area wa must also satisfy the conditions described in variant 1. As with this variant, the addition allows you to specify the name of the database table directly or indirectly. Note If a work area is not explicitly specified, the values for the line to be inserted are taken from the table work area dbtab if the statement is in a FORM or FUNCTION where the table work area is stored in a formal parameter or local variable of the same name. Addition 2 ... CLIENT SPECIFIED Effect As for variant 1. Variant 3 INSERT dbtab FROM TABLE itab. or INSERT (dbtabname) FROM TABLE itab. Additions: ... CLIENT SPECIFIED ... ACCEPTING DUPLICATE KEYS Effect Mass insert: Inserzts all lines of the internal table itab in a single operation. The lines of itab must satisfy the same conditions as the work area wa in variant 1. When the command has been executed, the system field SY-DBCNT contains the number of inserted lines. The return code value is set as follows: SY-SUBRC = 0: All lines successfully inserted. Any other result causes a runtime error. Note If the internal table itab is empty, SY-SUBRC and SY-DBCNT are set to 0 after the call. Addition 1 ... CLIENT SPECIFIED Effect As for variant 1. Addition 2 ... ACCEPTING DUPLICATE KEYS Effect If a line cannot be inserted, the processing does not terminate with a runtime error, but the return code value of SY-SUBRC is merely set to 4. All the remaining lines are inserted when the command is executed. INSERT - Insert into a field group Basic form INSERT f1 f2 ... INTO fg. Effect Inserts one or more fields into the field group fg (see FIELD-GROUPS). Notes 1. This basic form of INSERT is not a declarative, but an operational, statement, i.e. it must be executed at runtime. 2. A field group can only accept global data objects, not data objects which have been defined locally in a FORM or FUNCTION. 3. The actual data transport is performed by EXTRACT. 4. As soon as the first dataset for a field group has been extracted with EXTRACT, the field group can no longer be extended with INSERT. The field group HEADER cannot be extended at all after the first EXTRACT (regardless of the field group). Note Runtime errors: - EXTRACT_INSERT_LOCAL_DATA: Attempt to insert local data objects into a field group. - INSERT_INTO_LOCKED_FIELD_GROUP: INSERT into field group after records of this type had already been extracted with EXTRACT. INSERT - Insert into internal table Variants: 1. INSERT [wa INTO|INITIAL LINE INTO] itab [INDEX idx]. 2. INSERT LINES OF itab1 [FROM idx1] [TO idx2] INTO itab2 [INDEX idx3]. Variant 1 INSERT [wa INTO|INITIAL LINE INTO] itab [INDEX idx]. Effect Inserts a new line into an internal table. If you specify wa INTO, the new line is taken from the contents of the explicitly specified work area wa. When using INITIAL LINE INTO, a line containing the appropriate initial value for its type is inserted into the table. If you omit the specification before itab, the new line is taken from the header line of the internal table itab. INDEX idx specifies the table index before which the line is inserted into the table itab. If the table has exactly idx - 1 entries, the line is appended to the table. Within a LOOP, on an internal table, you do not have to specify the insertion point with INDEX idx. The source table is then inserted before the current LOOP line in the target table. The return code value is set as follows: When specifying the insertion point with INDEX idx: SY-SUBRC = 0: The entry was inserted. SY-SUBRC = 4: Index specification too large. The entry was not inserted because the table has fewer than idx - 1 entries. If the insertion point is not specified, the return code value is set to 0. Note 1. Inserting lines within a LOOP ... ENDLOOP structure affects subsequent loop passes. 2. Invalid index specifications (for example, idx <= 0), result in a runtime error. Example Insert values into a table of whole numbers: DATA: VALUE TYPE I, ITAB TYPE I OCCURS 100 WITH HEADER LINE. ITAB = 5. VALUE = 36. INSERT ITAB INDEX 1. INSERT VALUE INTO ITAB INDEX 2. INSERT INITIAL LINE INTO ITAB INDEX 2. The table ITAB now contains three lines with the values 5, 0 and 36. Variant 2 INSERT LINES OF itab1 [FROM idx1] [TO idx2] INTO itab2 [INDEX idx3]. Effect Inserts the internal table itab1 or a section of itab1 into the internal table itab2. As with variant 1, INDEX idx3 is to specifies the table index before which you want to insert in the target table itab2. Within a LOOP, on an internal table, you do not have to specify the insertion point with INDEX idx3. The source table is then inserted before the current LOOP line in the target table. By specifying FROM idx1 or TO idx2, you can restrict the line area from which the source table itab1 is taken. If there is no FROM specification, the line area begins with the first line of itab1. If there is no TO specification, the line area ends with the last line of itab1. This means that the whole table is inserted, if neither a FROM nor a TO is specified. The return code value is set as for variant 1. Note You can use DESCRIBE TABLE itab1 LINES ... to determine the size of the table itab1 before or after the INSERT statement and thus establish how many lines were actually inserted into the table. Note 1. Inserting lines within a LOOP ... ENDLOOP structure affects subsequent loop passes. 2. Invalid index specifications (for example, idx <= 0), result in a runtime error. Example Insert a name table into another name table: TYPES NAME(10) TYPE C. DATA: NAME_TAB_1 TYPE NAME OCCURS 5, NAME_TAB_2 TYPE NAME OCCURS 5. APPEND 'Alice' TO NAME_TAB_1. APPEND 'Martha' TO NAME_TAB_1. APPEND 'Ruth' TO NAME_TAB_1. APPEND 'Harry' TO NAME_TAB_2. APPEND 'Walter' TO NAME_TAB_2. INSERT LINES OF NAME_TAB_1 FROM 2 INTO NAME_TAB_2 INDEX 2. After the insertion, the table NAME_TAB_2 contains four entries with the names Harry, Martha, Ruth and Walter. Note Performance: 1. When using internal tables with a header line, avoid unnecessary assignments to the header line. Whenever possible, use statements which have an explicit work area. For example, "APPEND wa TO itab." is approximately twice as fast as "itab = wa. APPEND itab.". The same applies to COLLECT and INSERT. 2. Inserting a line into an internal table incurs index maintenance costs which depend on the insertion point. For example, inserting a line in the middle of a 100-byte wide internal table with 200 entries requires about 90 msn (standardized microseconds). 3. If you want to insert the contents of one internal table into another internal table, you incur index maintenance costs only once with the variant INSERT LINES OF .... Compared with a LOOP which inserts the lines of the source table one-by-one into the target table, this represents a distinct improvement in performance. Inserting a table of 500 lines with a 100-byte line width in the middle of a similar size table can thus be amde up to 20 times faster. Note Runtime errors: - TABLE_INVALID_INDEX: Invalid index value (<= 0) with a FROM, TO or INDEX specification. Related COLLECT itab, APPEND, SELECT / FETCH NEXT CURSOR ... INTO/APPENDING TABLE itab, MODIFY itab, WRITE f TO itab INDEX idx, SORT itab, READ TABLE itab, LOOP AT itab, DELETE itab INSERT - Insert a program Basic form INSERT REPORT prog FROM itab. Effect Inserts the program prog from the internal table itab into the library. The internal table itab contains the source code; the lines of the table cannot be more than 72 characters long. The program attributes (type, date, ...) are set by the system, but you can change them manually or in the program (table TRDIR). Note Runtime errors: - INSERT_PROGRAM_INTERNAL_NAME: The program name prog is reserve internally; it begins with '%_T'. - INSERT_PROGRAM_NAME_BLANK: The program name prog must not contain any blanks characters. - INSERT_PROGRAM_NAME_TOO_LONG: The program name prog is too long; it cannot be more than 8 characters long. - INSERT_REPORT_LINE_TOO_LONG: One of the source code lines is longer than 72 characters. Related DELETE REPORT, READ REPORT, INSERT TEXTPOOL, SYNTAX-CHECK, GENERATE REPORT INSERT - Insert text elements Basic form INSERT TEXTPOOL prog ...FROM itab ...LANGUAGE lg. Parts marked with " ..." are interchangeable Effect Assigns the text elements in the internal table itab to the program prog and the language lg and inserts them in the library. The line structure of the table itab is described in the section Text elements. Example The following program uses the internal table TAB to set the text elements of the program PROGNAME. DATA: PROGRAM(8) VALUE 'PROGNAME', TAB LIKE TEXTPOOL OCCURS 50 WITH HEADER LINE. TAB-ID = 'T'. TAB-KEY = SPACE. TAB-ENTRY = 'Sales'. APPEND TAB. TAB-ID = 'I'. TAB-KEY = '200'. TAB-ENTRY = 'Tax'. APPEND TAB. TAB-ID = 'H'. TAB-KEY = '001'. TAB-ENTRY = 'Name Age'. APPEND TAB. TAB-ID = 'S'. TAB-KEY = 'CUST'. TAB-ENTRY = 'Customer'. APPEND TAB. TAB-ID = 'R'. TAB-KEY = SPACE. TAB-ENTRY = 'Test program'. APPEND TAB. SORT TAB BY ID KEY. INSERT TEXTPOOL PROGRAM FROM TAB LANGUAGE SY-LANGU. Notes 1. As in the example, the internal table should be sorted by the components ID and KEY to enable faster access to the text elements at runtime. However, this is not obligatory. 2. The component LENGTH (see text elements) for the length of a text element does not have to be set explicitly. In this case - as in the example - the actual length of the text element is used. 3. The value of LENGTH cannot be smaller than the text to which it applies. If your length specification is too short, it is ignored by INSERT and the actual length is used instead. On the other hand, larger values are allowed and can be used to reserve space for texts that may be longer when translated into other languages. Related DELETE TEXTPOOL, READ TEXTPOOL INTO clause Variants: 1. ... INTO wa 2. ... INTO CORRESPONDING FIELDS OF wa 3. ... INTO (f1, ..., fn) 4. ... INTO TABLE itab 5. ... INTO CORRESPONDING FIELDS OF TABLE itab 6. ... APPENDING TABLE itab 7. ... APPENDING CORRESPONDING FIELDS OF TABLE itab Effect With SELECT or FETCH, this statement determines the target area into which the data is to be read. If no data is read, the target area remains unchanged. The result set is transported to the target area field by field. This means that the ABAP/4 Dictionary data types must correspond to the ABAP/4 data types of the target fields as follows: Result field Target field Dict. data type ABAP/4 data type ACCP -> C or N CHAR -> C CLNT -> C CUKY -> C CURR -> I, P or F DEC -> I, P or F DATS -> D FLTP -> I or F INT1 -> I, P or F INT2 -> I, P or F INT4 -> I, P or F LCHR -> C LRAW -> X LANG -> C NUMC -> C or N PREC -> X QUAN -> I, P or F RAW -> X TIMS -> T UNIT -> C VARC -> C If the ABAP/4 data type of the target field is C, N or X, the contents of the result field are placed left-justified in the target field. If the target field is too short, the result value is truncated. If the ABAP/4 of the target field is numeric, the target field must be long enough to hold the contents of the result field. When transporting the contents of a result field of type FLTP ot a target field of type I, the whole number part is copied. If a field in the result set contains a NULL value, the initial value of the ABAP/4 data type corresponding to the field type is placed in the target area (see TABLES). Depending on the database system, any violation of the correspondence rules can lead to a runtime error. Variant 1 ... INTO wa Effect Places the result set in the target area wa line by line. The fields are transported to the corresponding components of the wa from left to right. If you specify a "*" in the SELECT clause, the selected data is placed left-justified in wa according to the structure of the table work area dbtab (see TABLES). Therefore, the structure of wa does not have to correspond to the structure of the result set. However, to access the columns of the results line symbolically, the structures of wa and dbtab must be compatible. In each case, the work area wa must be at least as wide as the table work area dbtab. If wa is wider, the contents of the remaining area on the right are undefined. If you specify a list of fields in the SELECT clause, the selected data is placed field by field in wa according to the structure of the work area. If wa has fewer components than the SELECT list, a runtime error occurs. If it has more, the contents of the excess components of wa remain undefined. If the result of a selection is a table, the data is retrieved in a processing loop introduced by SELECT and concluded by ENDSELECT. The processing passes through the loop once for each line read. If the result is a single record, the closing ENDSELECT is omitted. Examples Output a list of all airlines (with short description and name): TABLES SCARR. DATA WA LIKE SCARR. SELECT * INTO WA FROM SCARR. WRITE: / WA-CARRID, WA-CARRNAME. ENDSELECT. Output a list of all airlines (with short description and name): TABLES SCARR. DATA TABNAME(10). DATA BEGIN OF WA1, CARRID LIKE SCARR-CARRID, CARRNAME LIKE SCARR-CARRNAME, REST(100), END OF WA1. TABNAME = 'SCARR'. SELECT * INTO WA1 FROM (TABNAME). WRITE: / WA1-CARRID, WA1-CARRNAME. ENDSELECT. Output a list of all airlines (with short description and name): DATA BEGIN OF WA2, CARRID LIKE SCARR-CARRID, CARRNAME LIKE SCARR-CARRNAME, REST(100), END OF WA2. SELECT CARRID CARRNAME INTO WA2 FROM SCARR. WRITE: / WA2-CARRID, WA2-CARRNAME. ENDSELECT. Variant 2 ... INTO CORRESPONDING FIELDS OF wa Effect Places the result set in the target area wa line by line. Each field of the result set is transported to the field of the same name in wa. If no such field exists, a runtime error occurs. If the result of a selection is a table, the data is retrieved in a processing loop introduced by SELECT and concluded by ENDSELECT. The processing passes through the loop once for each line read. If the result is a single record, the closing ENDSELECT is omitted. Example Output a list of all airlines (with short description and name): TABLES SCARR. SELECT CARRID CARRNAME INTO CORRESPONDING FIELDS OF SCARR FROM SCARR. WRITE: / SCARR-CARRID, SCARR-CARRNAME. ENDSELECT. Variant 3 ... INTO (f1, ..., fn) Places the result set in the target area (f1, ..., fn). The fields of the result set are transported to the target fields fi from left to right. INTO (f1, ..., fn) is allowed only if a list with n elements is also specified in the SELECT clause. If the result of a selection is a table, the data is retrieved in a processing loop introduced by SELECT and concluded by ENDSELECT. The processing passes through the loop once for each line read. If the result is a single record, the closing ENDSELECT is omitted. Example Output a list of all airlines (with short description and name): TABLES SCARR. DATA: CARRID LIKE SCARR-CARRID, CARRNAME LIKE SCARR-CARRNAME, SELECT CARRID CARRNAME INTO (CARRID, CARRNAME) FROM SCARR. WRITE: / CARRID, CARRNAME. ENDSELECT Variant 4 ... INTO TABLE itab Addition: ... PACKAGE SIZE n Works like ... INTO wa, except that the selected data is not assigned to the internal table itab line by line, but in one single operation. In this case, SELECT does not introduce a processing loop, so there can be no ENDSELECT statement. The old contents of itab are overwritten. Example Output a list of all airlines (with short description and name): TABLES SCARR. DATA ITAB LIKE SCARR OCCURS 100 WITH HEADER LINE. SELECT * INTO TABLE ITAB FROM SCARR. LOOP AT ITAB. WRITE: / ITAB-CARRID, ITAB-CARRNAME. ENDLOOP. Addition ... PACKAGE SIZE n Works like ... INTO wa, except that the selected data is not assigned to the internal table REPORT ... LINE-SIZE). ..BY n PLACES.. (corresponds to OK code PS+n or PS-n) Moves the report by c columns (to the left or right). You determine the direction with the ..LEFT.. and ..RIGHT.. parameters. ..LINE n.. (corresponds to OK code PLnn) Displays the report from line n. Return code: The system field SY-SUBRC indicates whether or not the operation was successful and may contain any of the following values: 0 = OK. 4 = Report limit reached - cannot scroll. 8 = Report does not exist - cannot scroll. Examples: * Scroll displayed report one page down. SCROLL LIST FORWARD. * Scroll to beginning of report at report level 1. SCROLL LIST INDEX 1 TO TOP. * Scroll to page 7 of report at report level 1. SCROLL LIST INDEX 1 TO PAGE 7. * Scroll to page 7 of report at report level 1 and display from line 5. SCROLL LIST INDEX 1 TO PAGE 7 LINE 5. * Position report at last displayed report level 2 columns to the left. SCROLL LIST LEFT BY 2 PLACES. WINDOW Caution! At present, you have to simulate a WINDOW statement by using CALL SCREENfor a secondary list. The documentation will only be valid when amodal windows are available. Effect: Overlays a section of the screen. Syntax: WINDOW..........STARTING AT x1 y1.....................>> :.LIST.: :.ENDING AT x2 y2.: >>........................... . :.WITH FRAME............: :.TITLE t.: Effect (WINDOW..) Defines a section of screen (or 'window'). Any subsquent lines output with ==> WRITE are incorporated in the window. The same rules apply as for displaying a report, i.e. the page size corresponds to the window size. The basic form (no LIST after WINDOW) does not support the following functions (==> ..LIST.. parameter): - Scrolling in the window - Hiding field contents (==> HIDE), - Line selection in the window In the case of line selection with windows, ABAP/4 always processes the concealed report line. You can release the window by: - Pressing F3 - Pressing Enter or placing the cursor in the OK code line - Scrolling (PF21-24), - Displaying a new window at this report level Please note: Although reports can define several different windows, you can only display one at a time (i.e. only one can be active at any one time). * Additional specification 1: LIST Effect: Provides a window with the full functionality of an ABAP report, thus supporting the following functions: - Scrolling - Hiding field contents (==> HIDE), - Line selection This affects the following system fields which contain corresponding values: SY-WINSL = Selected line in window, SY-LISEL = Selected line in hidden report SY-WINCO = Column position of cursor in relation to start of window SY-WINRO = Line position of cursor in relation the end of window You can release the window by: - Entering F3 - Displaying a new window at this report level * Additional specification 2: STARTING AT x1 y1 - Effect: Positions the top left corner of the window at column x1 and line y1. If you do not use the additional specification ENDING AT, positions the lower right corner of the window at column 80 and line 23. You can use variables to specify the coordinates but these must lie within the limits of the screen (i.e. 80 columns, 23 lines). * Additional specification 3: ENDING AT x2 y2 Effect: Positions the lower right corner of the window in column x2 and line y2. You can use variables to specify the coordinates. * Additional specification 4: WITH FRAME Effect: Frames the window with bars. Each horizontal bar needs one line, whilst each vertical bar needs 2 bars. If there is insufficient space, the current bar is omitted. Note: The window coordinats x1, x2, y1 and y2 refer to the actual window and not to the frame. * Additional specification 5: TITLE t Effect: Inserts the text t in a central position along the top of the window frame. Example: Define a window with dimensions covering columns 1 to 79 and lines 15 to 23: - This hides the lower part of the screen from line 15. - The window contains 79 columns and 9 lines. WINDOW STARTING AT 1 15 ENDING AT 79 23. Define a window with dimensions covering columns 1 to 79 and lines 15 to 23 with frame. - The top frame bar appears in line 14, but all other frame bars are omitted (insufficient space) WINDOW STARTING AT 1 15 ENDING AT 79 23 WITH FRAME. Define a window with dimensions covering columns 1 to 79 and lines 15 to 23 with frame and title 'Information'. - The top frame bar appears in line 14 and contains the title 'Information' in a central position. WINDOW STARTING AT 1 15 ENDING AT 79 23 WITH FRAME TITLE 'Information'. Define a report window with frame and title. - Scrolling is possible. - "HIDE" is possible. - Line selection is possible. WINDOW LIST STARTING AT 1 15 ENDING AT 79 23 WITH FRAME TITLE 'Information'. WITH FRAME TITLE 'Information'. * Reports: RFSCHU30, RFSCHU31, RFSCHU35 LEAVE Effect Leave processing. Basic forms: 1. LEAVE PROGRAM. 2. LEAVE TO TRANSACTION tcod. 3. LEAVE TO SCREEN scr. 4. LEAVE SCREEN. 5. LEAVE TO LIST-PROCESSING. 6. LEAVE LIST-PROCESSING. 7. LEAVE. LEAVE Basic form 7 LEAVE. Effect Leaves the "CALL mode" (introduced by: CALL TRANSACTION, CALL DIALOG, SUBMIT ... AND RETURN) and returns directly to where the call was made. Exception: LEAVE TO LIST-PROCESSING Effect of LEAVE after 1. CALL TRANSACTION tcod: Return from the called transaction tcod. Processing continues after "CALL TRANSACTION ...". 2. CALL DIALOG dial: Return from the called dialog module dial. The IMPORT objects of the calling program are passed. Processing continues after "CALL DIALOG ...". 3. SUBMIT prog AND RETURN: Return from the called program prog. Processing continues after the call to "SUBMIT prog ...". 4. LEAVE TO LIST-PROCESSING AND RETURN TO SCREEN scr: Return from list processing. The screen scr is reprocessed. Note LEAVE is not required if you use standard F keys in the list processing (F3 Back and F15 Exit). Related LEAVE PROGRAM, LEAVE SCREEN, LEAVE LIST-PROCESSING. LEAVE LIST-PROCESSING Basic form LEAVE LIST-PROCESSING. Effect Returns from list processing and re-processes the return screen (LEAVE TO LIST-PROCESSING). Note LEAVE LIST-PROCESSING is not required if you use the standard F keys in list processing (F3 Back and F15 Exit). Related LEAVE SCREEN Basic form 1 LEAVE PROGRAM. Effect Leaves the current program and continues processing after CALL TRANSACTION, CALL DIALOG or SUBMIT prog AND RETURN. If you use LEAVE TO TRANSACTION, SUBMIT prog or start the program via the transaction menu or a transaction code, you branch to the transaction selection screen. Note LEAVE PROGRAM always leaves the current program - there is never any processing after LEAVE PROGRAM! LEAVE SCREEN Basic form 4 LEAVE SCREEN. Effect Leaves the current screen and processes the next screen. If the next screen has the number 0 (either defined statically or set dynamically by SET SCREEN 0), processing in CALL mode continues after the CALL SCREEN statement. Otherwise, you branch to the transaction selection screen. Note If the next screen is specified dynamically, you can use the short form "LEAVE TO SCREEN scr." instead of a combination of the "SET SCREEN scr." and "LEAVE SCREEN." commands. Related SET SCREEN, LEAVE TO SCREEN LEAVE TO LIST-PROCESSING Basic form 5 LEAVE TO LIST-PROCESSING. Addition: ... AND RETURN TO SCREEN scr. Effect Switches from "dialog processing" (module pool, screens) of the current transaction to "list processing". You can then use all the usual list layout commands (WRITE, SKIP, ...). After leaving the current screen, the list formatted in this way is displayed implicitly or explicitly by LEAVE SCREEN. Here, all list programming options are possible, e.g. line selection, F keys, windows. LEAVE LIST-PROCESSING continues with "Processing Before Output" (PBO) of the screen which controls the list processing. Note After switching to list processing mode with SET PF-STATUS ..., you are recommended to define a GUI (Graphical User Interface) of type List or List in dialog box. Addition ... AND RETURN TO SCREEN scr. Effect LEAVE LIST-PROCESSING continues with "Processing Before Output" (PBO) of the screen scr. Note Using LEAVE LIST-PROCESSING to leave list processing explicitly is only necessary in exceptional cases; normally, the standard F keys (F3 Back and F15 Exit) are sufficient. LEAVE TO SCREEN Basic form 3 LEAVE TO SCREEN scr. Effect Leaves the current screen and processes the screen scr. If scr = 0, processing in CALL mode continues after the CALL SCREEN statement. Otherwise, you branch to the transaction selection screen. Related SET SCREEN, LEAVE SCREEN LEAVE TO TRANSACTION Basic form 2 LEAVE TO TRANSACTION tcod. Addition: ... AND SKIP FIRST SCREEN Effect Terminates the current processing and starts the (new) transaction tcod. Examples 1. Start Transaction SM02: LEAVE TO TRANSACTION 'SM02'. 2. Restart current transaction: LEAVE TO TRANSACTION SY-TCODE. Addition ... AND SKIP FIRST SCREEN Effect Processes the first screen of the transaction in the background. If possible, the fields on this screen are filled with values from the SAP memory. Therefore, you should set the desired values with SET PARAMETER. If an error occurs when processing the initial screen (due to incorrect or imcomplete parameter values), this is reported and you must correct or complete the input manually on this screen. LOAD Note This statement is for internal use only. Incompatible changes or further developments may occur at any time without warning or notice. Basic form LOAD REPORT prog PART part INTO itab. Variants: 1. LOAD REPORT prog PART 'HEAD' INTO itab. 2. LOAD REPORT prog PART 'TRIG' INTO itab. 3. LOAD REPORT prog PART 'CONT' INTO itab. 4. LOAD REPORT prog PART 'DATA' INTO itab. 5. LOAD REPORT prog PART 'DDNM' INTO itab. 6. LOAD REPORT prog PART 'DATV' INTO itab. 7. LOAD REPORT prog PART 'SELC' INTO itab. 8. LOAD REPORT prog PART 'STOR' INTO itab. 9. LOAD REPORT prog PART 'LITL' INTO itab. 10.LOAD REPORT prog PART 'SYMB' INTO itab. 11.LOAD REPORT prog PART 'LREF' INTO itab. 12.LOAD REPORT prog PART 'SSCR' INTO itab. 13.LOAD REPORT prog PART 'BASE' INTO itab. 14.LOAD REPORT prog PART 'INIT' INTO itab. 15.LOAD REPORT prog PART 'DATP' INTO itab. 16.LOAD REPORT prog PART 'TXID' INTO itab. 17.LOAD REPORT prog PART 'COMP' INTO itab. Effect Loads the specified part of the generated version of the program prog into the internal table itab (for analysis purposes only). The return code value is set as follows: SY-SUBRC = 0: The load for the program prog exists and is current. SY-SUBRC = 4: The load for the program prog does not exist. SY-SUBRC = 8: The load for the program prog exists, but is not current. In some cases, this SY-SUBRC may mean that the program load has been destroyed. You can resolve this by generating the program. With PART 'LREF', SY-SUBRC = 8 means that the line reference table is incorrect for the program. With PART 'CONT', it means that the reference part of the internal table is empty. itab has been filled only if SY-SUBRC = 0. Variant 1 LOAD REPORT prog PART 'HEAD' INTO itab. Effect Loads the program header into line 1 of the internal table itab. itab must have the Dictionary structure RHEAD. Variant 2 LOAD REPORT prog PART 'TRIG' INTO itab. Effect Loads the event control blocks into the internal table itab. itab must have the Dictionary structure RTRIG. Variant 3 LOAD REPORT prog PART 'CONT' INTO itab. Effect Loads the processing control blocks into the internal table itab. itab must have the Dictionary structure RCONT. Variant 4 LOAD REPORT prog PART 'DATA' INTO itab. Effect Loads the static data descriptions into the internal table itab. itab must have the Dictionary structure RDATA. To find the data description for a data index i, proceed as follows: 0 <= i < 2^14 ==> i+1 Index in data_itab 2^14 <= i < 2^15 ==> i+1 - 2^14 Index in datv_itab 2^15 <= i < 2^16 ==> i+1 - 2^15 Parameter index (2^14 = 16384, 2^15 = 32768) Variant 5 LOAD REPORT prog PART 'DDNM' INTO itab. Effect The names of the dictionary structures used in the program are set in the internal table itab. itab must have the dictionary structure RDDNM. Variant 6 LOAD REPORT prog PART 'DATV' INTO itab. Effect Loads the variable data descriptions into the internal table itab. itab must have the Dictionary structure RDATA. To find the data description for a data index i, proceed as follows: 0 <= i < 2^14 ==> i+1 Index in data_itab 2^14 <= i < 2^15 ==> i+1 - 2^14 Index in datv_itab 2^15 <= i < 2^16 ==> i+1 - 2^15 Parameter index (2^14 = 16384, 2^15 = 32768) Variant 7 LOAD REPORT prog PART 'SELC' INTO itab. Effect Loads the description of the selection variables (SELECT-OPTIONS and PARAMETERS) into the internal table itab. itab must have the Dictionary structure RSELC. Variant 8 LOAD REPORT prog PART 'STOR' INTO itab. Effect Loads the initial values of the global data into the internal table itab. The line width of itab determines where the line break occurs. Ideally, itab should contain exactly one field of the type X. Variant 9 LOAD REPORT prog PART 'LITL' INTO itab. Effect Loads the literal table into the internal table itab. The line width of itab determines where the line break occurs. Ideally, itab should contain exactly one field of the type X. Variant 10 LOAD REPORT prog PART 'SYMB' INTO itab. Effect Loads the symbol table into the internal table itab. itab must have the Dictionary structure RSYMB. Variant 11 LOAD REPORT prog PART 'LREF' INTO itab. Effect Loads the line reference into the internal table itab. itab must have the Dictionary structure RLREF. Variant 12 LOAD REPORT prog PART 'SSCR' INTO itab. Effect Loads the description of the selection screen into the internal table itab. itab must have the Dictionary structure RSSCR. Variant 13 LOAD REPORT prog PART 'BASE' INTO itab. Effect Loads the segment table into the internal table itab. itab must have the Dictionary structure RBASE. Variant 14 LOAD REPORT prog PART 'INIT' INTO itab. Effect Loads the initial values of the local data into the internal table itab. The line width of itab determines where the line break occurs. Ideally, itab should contain exactly one field of the type X. Variant 15 LOAD REPORT prog PART 'DATP' INTO itab. Effect Loads the data descriptions of the parameters and local field symbols into the internal table itab. itab must have the dictionary structure RDATA. Variant 16 LOAD REPORT prog PART 'TXID' INTO itab. Effect Loads the index of the text elements (assignment of text keys to data control blocks) into the internal table itab. itab must have the dictionary structure RTXID. Variant 17 LOAD REPORT prog PART 'COMP' INTO itab. Effect Loads the description of the components of the (internal) structures used in the program into the internal table itab. itab must have the dictionary structure RDATA. Note Runtime errors: - LOAD_REPORT_PART_NOT_FOUND: An invalid identification was specified under part. - LOAD_REPORT_PROGRAM_NOT_FOUND: The specified program prog does not exist. - LOAD_REPORT_TABLE_TOO_SHORT: The specified internal table is too narrow. LOAD REPORT Note This statement is for internal use only. Incompatible changes or further developments may occur at any time without warning or notice. Variations: 1. LOAD REPORT prog PART 'HEAD' INTO itab. 2. " 'TRIG' " 3. " 'CONT' " 4. " 'DATA' " 5. " 'DATV' " 6. " 'SELC' " 7. " 'STOR' " 8. " 'LITL' " 9. " 'SYMB' " 10. " 'LREF' " 11. " 'SSCR' " 12. " 'BASE' " 13. " 'INIT' " Effect Loads the specified part of the generated version of the program prog into the internal table itab (for analysis purposes only). After LOAD REPORT, SY-SUBRC may be set to any of the following values: 0 if the load for the program prog exists and is current, 4 if the load for the program prog does not exist, 8 if the load for the program prog exists, but is not current. In certain cases, this value of SY-SUBRC can also mean that the program load has been destroyed. The remedy for this is normally a generation. With PART 'LREF', a SY-SUBRC value of 8 means that the line reference table is not correct for the program. With PART 'CONT', it means that the reference part of the internal table is empty. Only where SY-SUBRC = 0 is itab filled. Variant 1 LOAD REPORT prog PART 'HEAD' INTO itab. Effect Loads the program header into line 1 of internal table itab. The structure of itab must be the same as the Dictionary structure RHEAD. Variant 2 LOAD REPORT prog PART 'TRIG' INTO itab. Effect Loads the event control block into the internal table itab. The structure of itab must be the same as the Dictionary structure RTRIG. Variant 3 LOAD REPORT prog PART 'CONT' INTO itab. Effect Loads the processing control blocks into the internal table itab. The structure of itab must be the same as the Dictionary structure RCONT. Variant 4 LOAD REPORT prog PART 'DATA' INTO itab. Effect Loads the static data descriptions into the internal table itab. The structure of itab must be the same as the Dictionary structure RDATA. To find the relevant data description for a data index i, proceed as follows: 0 <= i < 2^14 ==> i+1 Index in data_itab 2^14 <= i < 2^15 ==> i+1 - 2^14 Index in datv_itab 2^15 <= i < 2^16 ==> i+1 - 2^15 Parameter index (2^14 = 16384, 2^15 = 32768) Variant 5 LOAD REPORT prog PART 'DATV' INTO itab. Effect Loads the variable data descriptions into the internal table itab. The structure of itab must be the same as the Dictionary structure RDATA. To find the relevant data description for a data index i, proceed as follows: 0 <= i < 2^14 ==> i+1 Index in data_itab 2^14 <= i < 2^15 ==> i+1 - 2^14 Index in datv_itab 2^15 <= i < 2^16 ==> i+1 - 2^15 Parameter index (2^14 = 16384, 2^15 = 32768) Variant 6 LOAD REPORT prog PART 'SELC' INTO itab. Effect Loads the description of the selection variables (SELECT-OPTIONS and PARAMETERS) into the internal table itab. The structure of itab must be the same as the Dictionary structure RSELC. Variant 7 LOAD REPORT prog PART 'STOR' INTO itab. Effect Loads the initial values of the global data into the internal table itab. The line length of itab determines the line break. Ideally, itab should also contain exactly one field of type X. Variant 8 LOAD REPORT prog PART 'LITL' INTO itab. Effect Loads the literal table into the internal table itab. The line length of itab determines the line break. Ideally, itab should contain exactly one field of type X. Variant 9 LOAD REPORT prog PART 'SYMB' INTO itab. Effect Loads the symbol table into the internal table itab. itab must have the same structure as the Dictionary structure RSYMB. Variant 10 LOAD REPORT prog PART 'LREF' INTO itab. Effect Loads the line reference into the internal table itab. itab must have the same structure as the Dictionary structure RLREF. Variant 11 LOAD REPORT prog PART 'SSCR' INTO itab. Effect Loads the selection screen description into the internal table itab. itabmust have the same structure as the Dictionary structure RSSCR. Variant 12 LOAD REPORT prog PART 'BASE' INTO itab. Effect Loads the segment table into the internal table itab. itabmust have the same structure as the Dictionary structure RBASE. Variant 13 LOAD REPORT prog PART 'INIT' INTO itab. Effect Loads the initial values of the local data into the internal table itab. The line length of itab determines the line break. Ideally, itab should contain exactly one field of type X. LOCAL Basic form LOCAL f. Effect Can only be used after the FORM statement. Saves the current value of the field f when you enter the routine and restores it when you leave the routine. You can also use LOCAL for field symbols and formal parameters. With field symbols, it not only saves and restores the field reference created using ASSIGN, but also the contents of the field referenced when you enter the routine. With formal parameters, please note that although changing the value of the formal parameter does not affect the actual parameter after you leave the routine (if you specified the formal parameter after LOCAL), the values of the formal and actual parameter within the routine are always identical. This contrasts with the VALUE specification (see FORM) where changing the passed field within the routine does not affect the value of the formal parameter. LOOP Loop on an internal table - LOOP AT itab. LOOP AT itab INTO wa. Loop on an extract dataset - LOOP. Loop on screen fields - LOOP AT SCREEN. Loop on a database table - LOOP AT dbtab. LOOP - Loop on an extract dataset Basic form LOOP. Effect Processes the extracted dataset. By using LOOP ... ENDLOOP, you can process the dataset generated by EXTRACT like an internal table (as in LOOP AT itab) - if required, after sorting with SORT. For control break processing in a LOOP on an extract dataset, there are special control break control structures for extracts you can use. At the end of a control level, the control total of a numeric field f is stored in the field SUM(f). This total includes all records read, even if further processing in the LOOP has been skipped by CHECK. At the end of a control level, the number of different values which a field f has accepted from the sort key within the group, i.e. the number of control records where the field f has changed its value, is stored in the field CNT(f). You can use the CONTINUE statement to leave the current loop pass prematurely and continue with the next loop pass. To leave loop processing altogether, you use EXIT. At present, the return code value in SY-SUBRC is not set when you use LOOP with extracts. In Release 4.0, however, SY-SUBRC will also specify for LOOP via extracts at the end of loop processing (i.e. after ENDLOOP) whether the loop was processed at least once when (similar to LOOP with internal tables). Notes 1. When you have processed a dataset with SORT or LOOP ... ENDLOOP, you cannot extract any more records with EXTRACT. 2. You cannot nest loops on extracted datasets (unlike internal tables), i.e. only one loop on an extracted dataset can be active at any time. However, several consecutive loops are allowed. Example DATA: ONR(7), POSITION(3) TYPE N, CUSTOMER(20), PNR(5) TYPE N, NAME(15), UNITS TYPE I, ORDERS TYPE I. FIELD-GROUPS: HEADER, ORDER, PRODUCT. INSERT ONR POSITION INTO HEADER. INSERT CUSTOMER INTO ORDER. INSERT PNR NAME UNITS INTO PRODUCT. ONR = 'GF00012'. POSITION = '000'. CUSTOMER = 'Good friend'. EXTRACT ORDER. ADD 1 TO POSITION. PNR = '12345'. NAME = 'Screw'. UNITS = 100. EXTRACT PRODUCT. ADD 1 TO POSITION. PNR = '23456'. NAME = 'Nail'. UNITS = 200. EXTRACT PRODUCT. ONR = 'NB00056'. POSITION = '000'. CUSTOMER = 'Nobody'. EXTRACT ORDER. ONR = 'MM00034'. POSITION = '000'. CUSTOMER = 'Moneymaker'. EXTRACT ORDER. ADD 1 TO POSITION. PNR = '23456'. NAME = 'Nail'. UNITS = 300. EXTRACT PRODUCT. ADD 1 TO POSITION. PNR = '34567'. NAME = 'Hammer'. UNITS = 4. EXTRACT PRODUCT. SORT. LOOP. AT ORDER. WRITE: /, / ONR, CUSTOMER. ENDAT. AT ORDER WITH PRODUCT. WRITE 'ordered:'. ENDAT. AT PRODUCT. WRITE: / ONR, PNR, NAME, UNITS. ENDAT. AT END OF ONR. WRITE: / 'Sum of units:', 26 SUM(UNITS). ORDERS = CNT(POSITION) - 1. WRITE: / 'Number of orders:', ORDERS. ENDAT. ENDLOOP. This code generates the following list: GF00012 Good friend ordered: GF00012 12345 Screw 100 GF00012 23456 Nail 200 Sum of units: 300 Number of orders: 2 MM00034 Moneymaker ordered: MM00034 23456 Nail 300 MM00034 34567 Hammer 4 Sum of units: 304 Number of orders: 2 NB00056 Nobody Sum of units: 0 Number of orders: 0 Related EXTRACT, LOOP AT itab Note Runtime errors: - LOOP_WITHIN_LOOP: Nested loop on an extracted dataset. LOOP - loop processing with a database table Basic form LOOP AT dbtab. Addition: ... VERSION vers Note This variant is no longer maintained and should therefore not be used (see also Obsolete key words). Instead, please use a SELECT statement. Effect Loop processing of the database table dbtab. You must declare the table dbtab under TABLES in the program. dbtab is a table name which begins with "T" and consists of up to five characters. The processing is the same as for variant 1 (except that the system field SY-TABIX is not set). If you want to process the whole table, you must set all table fields to SPACE. Otherwise, the table fields you want to use as a generic argument must be filled beforehand (READ TABLE dbtab.). Note Fields of type P and type N have an initial value other than SPACE. This means that fields of this type after CLEAR or MOVE SPACE TO ... are not set to SPACE. In the case of tables which have arguments containing fields of type P or type N, the entire table header line must be set to SPACE (MOVE SPACE TO dbtab, not (!) CLEAR dbtab). It is preferable to use SELECT instead. Addition ... VERSION vers Note You should use this addition only if it is absolutely necessary. In some cases, you can (and it makes sense) to avoid this LOOP addition by using a generation program. Effect Specifies a dynamically definable table name. The field vers must be a 4-character C field which contains the table name. It is declared under PARAMETERS and evaluated at runtime. The entry read is always placed in the assigned table T.... . LOOP - Loops on an internal table Basic form LOOP AT itab. LOOP AT itab INTO wa. Additions: 1. ... FROM n1 2. ... TO n2 3. ... WHERE logexp 4. ... TRANSPORTING NO FIELDS Effect Processes an internal table (DATA) in a loop which begins with LOOP and ends with ENDLOOP. Each of the internal table entries is sent to the output area in turn. When LOOP AT itab. is used, the header line of the internal table itab is used as output area. In the case of LOOP AT itab INTO wa, there is an explicitly specified work area wa. If the internal table is empty, all the statements between LOOP and ENDLOOP are ignored. In each loop pass, SY-TABIX contains the index of the current table entry. After leaving a LOOP, SY-TABIX has the same value as it had before. Inserting and/or deleting lines in a LOOP affects subsequent loop passes. For control break processing in a LOOP on internal tables, there are special control break control structures for internal tables you can use. You can use the CONTINUE statement to leave the current loop pass prematurely and continue with the next loop pass. To leave loop processing altogether, you use EXIT. At the end of loop processing (i.e. after ENDLOOP), the return code value of SY-SUBRC specifies whether the loop was actually processed. SY-SUBRC = 0: The loop was executed at least once. SY-SUBRC = 4: The loop was not executed, either because there was no entry at all or because there was no entry which satisfied the conditions. Example The table T is defined as follows: DATA: BEGIN OF T OCCURS 100, BAREA(2), BLNCE TYPE P, END OF T. After the table has been filled with data (using APPEND), it is then output: LOOP AT T. WRITE: / T-BAREA, T-BLNCE. ENDLOOP. Notes 1. If an internal table is processed only on a restricted basis (with the additions FROM, TO and /or WHERE), you should not use the control structures for control break processing because the interaction of a restricted LOOP and the AT statement is undefined at present. 2. If SUM is used in a LOOP and an explicit output area wa has also been specified, this output area must be compatible with the line type of the internal table itab . Addition 1 ... FROM n1 Addition 2 ... TO n2 Effect Places all internal table entries from the entry with the index (SY-TABIX) = n1 to the entry with the index = n2 inclusive in the output area in turn. Note If either one of the additions "FROM n1" or "TO n2 " is missing, then the table is processed either from the first entry or up to the last entry (according to what is missing). Example Output table entries 7 and 8: DATA: BEGIN OF T OCCURS 100, BAREA(5), BLNCE(5), END OF T. LOOP AT T FROM 7 TO 8. WRITE: / T-BAREA, T-BLNCE. ENDLOOP. Addition 3 ... WHERE logexp Effect Places all internal table entries which satisfy the condition logexp in turn in the output area. The condition logexp can be almost any logical expression. The only restriction is that the first field for each comparison must be a sub-field of the line structure of the internal table itab. Example DATA: BEGIN OF T OCCURS 100, BAREA(5), BLNCE(5), END OF T. LOOP AT T WHERE BAREA > 0. WRITE: / T-BAREA, T-BLNCE. ENDLOOP. which has the same effect as: LOOP AT T. CHECK T-BAREA > 0. WRITE: / T-BAREA, T-BLNCE. ENDLOOP. Notes 1. The interaction between the LOOP AT ... WHERE statement and the ATcontrol break statements is currently undefined. It is therefore important to avoid using either the AT NEW/END OF or FIRST/LAST statements in a LOOP loop with a WHERE condition. 2. The performance of a LOOP AT ... WHERE statement can be improved significantly if the fields to be compared always have the same data type. The comparison fields should be defined as follows: DATA LIKE . Example DATA: BEGIN OF T OCCURS 100, BAREA(5), BLNCE(5), END OF T. DATA CMP_BAREA LIKE T-BAREA. CMP_BAREA = '01'. LOOP AT T WHERE BAREA = CMP_BAREA. WRITE: / T-BAREA, T-BLNCE. ENDLOOP. Addition 4 ... TRANSPORTING NO FIELDS Effect There is no field transport in the output area of the internal table. This addition can be used only in conjunction with a WHERE condition. Since it would make no sense to specify a work area with INTO wa when using the addition TRANSPORTING NO FIELDS, this option does not exist. This addition can be used to determine a set of line indexes (index set) or to determine the number of lines in a table which satisfy a given condition. Example Determining the number COUNT of lines in a name table TAB which contain the name 'Walter' and the corresponding index set INDEX_SET. DATA: BEGIN OF TAB OCCURS 100, NAME(30) TYPE C, END OF TAB, COUNT TYPE I, INDEX_SET LIKE SY-TABIX OCCURS 10 WITH HEADER LINE. LOOP AT TAB TRANSPORTING NO FIELDS WHERE NAME CS 'Walter'. INDEX_SET = SY-TABIX. APPEND INDEX_SET. ADD 1 TO COUNT. ENDLOOP. Related Loop structures: DO, WHILE Table processing: APPEND, COLLECT, INSERT, MODIFY, DELETE, SORT, AT NEW/END OF/FIRST/LAST, READ TABLE. LOOP - Loops on screen fields Basic form LOOP AT SCREEN. Effect All fields of the current screen are stored in the system table SCREEN with their attributes. The "LOOP AT SCREEN" statement places this information in the header line of the system table. If you want to change the attributes, you must put back the changed header line with MODIFY SCREEN. However, you can only do this in the PBO module of a screen. If you use this statement for step loop processing, the information (and any changes) apply only to the current steploop line. Outside step loop processing, the information for a step loop field applies to the complete column. Step loop fields should never be changed after the corresponding step loop processing has been performed. You can use the CONTINUE statement to leave the current loop pass prematurely and continue with the next loop pass. Overview of all SCREEN fields: Field Length Type Meaning SCREEN-NAME 30 C Field name SCREEN-GROUP1 3 C Evaluation of modification group 1 SCREEN-GROUP2 3 C Evaluation of modification group 2 SCREEN-GROUP3 3 C Evaluation of modification group 3 SCREEN-GROUP4 3 C Evaluation of modification group 4 SCREEN-REQUIRED 1 C Field input mandatory SCREEN-INPUT 1 C Field ready to accept input SCREEN-OUTPUT 1 C Field will be displayed SCREEN-INTENSIFIED 1 C Field highlighted SCREEN-INVISIBLE 1 C Field invisible SCREEN-LENGTH 1 X Field length SCREEN-ACTIVE 1 C Field active Example Make all fields display only: CONSTANTS OFF VALUE '0'. LOOP AT SCREEN. SCREEN-INPUT = OFF. MODIFY SCREEN. ENDLOOP. Related MODIFY SCREEN, LOOP AT itab MARK Basic form MARK. This key word will only be supported for a limited period (for reasons of compatibility with R/2). MAXIMUM Basic form MAXIMUM f. Note This key word MAXIMUM is no longer maintained and should therefore not be used (see also obsolete key words). Effect Specifies the fields for which the maximum value occurring should automatically be made available at END-OF-SELECTION. You can reference it using the name MAX_f. (cf. SUMMING). Related MINIMUM, SUMMING MESSAGE Variants: 1. MESSAGE xnnn. 2. MESSAGE ID mid TYPE mtyp NUMBER mnr. Variant 1 MESSAGE xnnn. Additions: 1. ... WITH f1 ... f4 2. ... RAISING exception Effect Outputs the message no. nnn for the MESSAGE-ID specified in the REPORT statement with the message type x. Dialog control recognizes the following message types: I - Info : Press ENTER to continue W - Warning : Correction possible E - Error : Correction required A - Abend : Transaction terminated X - Exit : Transaction terminated with short dump MESSAGE_TYPE_X S - Success : Message on next screen See also MODULE. Notes In list processing (see LEAVE TO LIST-PROCESSING), the effect of the message types differs in some respects: - With type E messages, the processing leaves any details list which has been started and returns to the previous list level. - Type W messages are always output as error messages (like type E). - During generation of the basic list, type W and type E messages result in termination (like type A). Example MESSAGE I121. Notes - You edit messages by selecting Tools -> ABAP/4 Workbench -> Development -> Programming environ. -> Messages. - You can specify a different MESSAGE-ID in parentheses after the error number, e.g. MESSAGE I121(44). - When executing the statement, the following system variables are set: * SY-MSGID (message ID) * SY-MSGTY (message type) * SY-MSGNO (message number) Addition 1 ... WITH f1 ... f4 Effect Inserts the contents of a field fi in the message instead of in the variables &i. If unnumbered variables (&) are used in a message text, these are replaced consecutively by the fields f1 to f4. To aid conversion, only numbered variables (&1 to &4) are to be used in future if several fields are involved. If a "&" is supposed to appear in the message at runtime, you must enter "&&". In the long text of a message, the symbol &Vi& is replaced by the field contents of fi. After WITH, you can specify 1 to 4 fields. Note You can output up to 50 characters per field. If the field contains more characters, these are ignored. Example MESSAGE E010 WITH 'Example' SY-UNAME. Note When executing the statement, the contents of the fields f1 to f4 are assigned to the system fields SY-MSGV1, SY-MSGV2, SY-MSGV3 and SY-MSGV4. Addition 2 ... RAISING except. Effect Only possible within a function module (see FUNCTION): Triggers the exception except. If the program calling the function module handles the exception itself, control returns immediately to that program (see CALL FUNCTION). In this case, the export parameters of the function module are ignored. However, the calling program can refer to the system field values (see above). If the calling program does not handle the exception itself, the message is output (see RAISE). Example MESSAGE E777 RAISING NOT_FOUND. Variant 2 MESSAGE ID mid TYPE mtyp NUMBER mnr. Effect As for variant 1, where you can set the following message components dnyamically: ID Message ID TYPE Message type NUMBER Number You can also use all the other additions as with the basic form. Example MESSAGE ID 'XX' TYPE 'E' NUMBER '001' WITH 'Text'. Outputs the message with the number 001 and MESSAGE-ID XX (see above) as an E (Error) message and replaces the first variable (&) with 'Text'. Example MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. Constructs the message dynamically from the contents of the system fields SY-MSGID, SY-MSGTY, SY-MSGNR and SY-MSGV1-4. These may, for example, be set by an exception after CALL FUNCTION or CALL TRANSACTION ... USING. Note Runtime errors: - MESSAGE_TYPE_UNKNOWN: Message type unknown - MESSAGE_TYPE_X: Conscious triggering of termination with short dump MINIMUM Basic form MINIMUM f. Note This key word is no longer supported and should therefore not be used (see also Obsolete key words). Effect Specifies the fields for which the minimum value should automatically be made available at END-OF-SELECTION. You can reference the value under the name MIN_f (see also SUMMING). Related MAXIMUM, SUMMING MODIFY Change a database table - MODIFY dbtab. MODIFY *dbtab. MODIFY (dbtabname) ... . - MODIFY dbtab FROM TABLE itab. MODIFY (dbtabname) FROM TABLE itab. - MODIFY dbtab VERSION vers. MODIFY *dbtab VERSION vers. Change an internal table - MODIFY itab [FROM wa] [INDEX idx]. Change a list line - MODIFY LINE n. - MODIFY LINE n OF CURRENT PAGE. - MODIFY LINE n OF PAGE m. - MODIFY CURRENT LINE. Change the attributes of a screen field - MODIFY SCREEN. MODIFY - Change a database table Variants: 1. MODIFY dbtab. or MODIFY *dbtab. or MODIFY (dbtabname) ... .. 2. MODIFY dbtab FROM TABLE itab. or MODIFY (dbtabname) FROM TABLE itab. 3. MODIFY dbtab VERSION vers. or MODIFY *dbtab VERSION vers. Effect Inserts new lines or updates existing lines in a database table. If a line with the specified primary key already exists, an INSERT is executed. Otherwise, an UPDATE is performed. You can specify the name of the database table either in the program itself in the form MODIFY dbtab ... or at runtime as the contents of the field dbtabname in the form MODIFY (dbtabname) ... . In both cases, the database table must be defined in the ABAP/4 Dictionary. If the program contains the name of the database table, it must also have a corresponding TABLES statement. Normally, records are inserted or updated only in the current client. Data can only be inserted or updated using a view, if the view refers to a single table and was created in the ABAP/4 Dictionary with the maintenance status "No restriction". MODIFY belongs to the Open SQL command set. When the statement has been executed, the system field SY-DBCNT contains the number of edited lines. The return code value is set as follows: SY-SUBRC = 0: All lines were successfully inserted or updated. Any other result causes a runtime error. Notes 1. Automatic definition of INSERT and UPDATE is expensive. You should therefore use MODIFY only if you cannot define the INSERT and UPDATE cases yourself in the program. 2. Since the MODIFY statement does not perform authority checks, you have to program them yourself. Variant 1 MODIFY dbtab. or MODIFY *dbtab. or MODIFY (dbtabname) ... . Additions: 1. ... FROM wa 2. ... CLIENT SPECIFIED Effect Inserts a new line or updates an existing line in a database table. If you specify the name of the database table yourself, the primary key for identifying the line to be inserted or updated and the relevant values are taken from the table work area dbtab or *dbtab (see TABLES). If the name of the database table is not determined until runtime, you need to use the addition ... FROM wa. Example Insert or change data of the customer Robinson in the current client: TABLES SCUSTOM. SCUSTOM-ID = '12400177'. SCUSTOM-NAME = 'Robinson'. SCUSTOM-POSTCODE = '69542'. SCUSTOM-CITY = 'Heidelberg'. SCUSTOM-CUSTTYPE = 'P'. SCUSTOM-DISCOUNT = '003'. SCUSTOM-TELEPHONE = '06201/44889'. MODIFY SCUSTOM. Addition 1 ... FROM wa Effect The values for the line to be inserted or upodated are not taken from the table work area dbtab, but from the explicitly specified work area wa. When doing this, the data is read from left to right according to the structure of the table work area dbtab (see TABLES). Since the structure of wa is not taken into account, the work area wa must be at least as wide (see DATA) as the table work area dbtab and the alignment of the work area wa must correspond to the alignment of the table work area. Otherwise, a runtime error occurs. Note If a work area is not explicitly specified, the values for the line to be inserted or updated are also taken from the table work area dbtab if the statement is in a FORM or FUNCTION where the table work area is storeed in a formal parameter or local variable of the same name. Addition 2 ... CLIENT SPECIFIED Effect Switches off automatic client handling. This allows you to edit data across all clients even when dealing with client-specific tables. The client field is treated like a normal table field that can be programmed to accept values in the table work area dbtab or *dbtab where the line to be edited occurs. The addition CLIENT SPECIFIED must be specified immediately after the name of the database table. Variant 2 MODIFY dbtab FROM TABLE itab. or MODIFY (dbtabname) FROM TABLE itab. Addition: ... CLIENT SPECIFIED Effect Mass modify: Inserts new lines or updates existing lines of a database table. The primary keys for identifying the lines to be inserted or updated and the relevant values are taken from the internal table itab. The lines of the internal table itab must satisfy the same conditions as the work area wa in addition 1 to variant 1. Note If the internal table itab is empty, SY-SUBRC and SY-DBCNT are set to 0. Addition ... CLIENT SPECIFIED Effect As for variant 1. Variant 3 MODIFY dbtab VERSION vers. or MODIFY *dbtab VERSION vers. Note This variant is obsolete. Effect Inserts a new line or updates an existing line in a database table, the name of which is taken from the field vers at runtime. If no line exists with the specified primary key, an INSERT is executed. Otherwise, an UPDATE is performed. The database table must be defined in the ABAP/4 Dictionary and its name must conform to the naming conventions for R/2 ATAB tables. These stipulate that the name must begin with 'T' and may contain up to four further characters. The field vers must contain the table name without the leading 'T'. Only lines in the current client are inserted or updated. The line to be inserted is taken from the statically specified table work area dbtab or *dbtab. SY-SUBRC is set to 0 if the line is successfully inserted or updated. SY-SUBRC <> 0 is not possible since any other result causes a runtime error. MODIFY - Change an internal table Variant MODIFY itab [FROM wa] [INDEX idx]. Effect Changes an entry in the internal table itab. If you specify FROM wa, the line is replaced by the explicitly specified work area wa. If the FROM specification is omitted, the line is replaced by the header line from itab. With INDEX idx, you can specify the table index of the line to be changed. The index specification can be omitted in a LOOP on an internal table. The INDEX specification can also appear before the FROM specification. The return code value is set as follows: When specifying the insertion point with INDEX idx: SY-SUBRC = 0: The change was executed. SY-SUBRC = 4: The index specification was too big. The change was not executed because the table had fewer than idx entries. If you do not specify the insertion point, the &ABAP_SUBRC is set to 0. Note The counting of table entries begins with 1. Note Performance: You can avoid unnecessary assignments by using statements which have an explicitly specified work area for internal tables with a header. The runtime required to execute the MODIFY itab INDEX idx statement is about 5 msn (standardized microseconds). MODIFY - Change a list line Variants: 1. MODIFY LINE n. 2. MODIFY LINE n OF CURRENT PAGE. 3. MODIFY LINE n OF PAGE m. 4. MODIFY CURRENT LINE. Variant 1 MODIFY LINE n. Additions: 1. ... INDEX idx 2. ... LINE FORMAT fmt1 ... fmtn 3. ... FIELD VALUE f1 FROM g1 ... fn FROM gn 4. ... FIELD FORMAT f1 fmt11 ... fmt1m ... fn fmtn1 ... fmtnm Effect Changes the nth line of the list. This could be, for example, after line selection (AT LINE-SELECTION, AT PFxx, AT USER-COMMAND). The current contents of the system field SY-LISEL are restored to the list as the line contents and the HIDE area for the line is re-determined from the current contents of the fields hidden with HIDE. The return code value is set as follows: SY-SUBRC = 0: Line was successfully changed. SY-SUBRC <> 0: Line does not exist. Note With multiple-level line selection, the modification is always performed in the list where the (last) line selection was made, except in the case of the addition ... INDEX idx and MODIFY CURRENT LINE (see below). Addition 1 ... INDEX idx Effect Changes the relevant line in the list to list level idx (0, 1, 2, ...) with multiple line selection (SY-LSIND). Addition 2 ... LINE FORMAT fmt1 ... fmtn Effect The output format of the selected line is determined by the format specifications fmt1, fmt2 ... . For a list of valid format specifications, see FORMAT. Example DATA I TYPE I VALUE 2. WRITE: / 'Intensified' INTENSIFIED, 'Input' INPUT, 'color 1' COLOR 1, 'intensified off' INTENSIFIED OFF. * Line selection AT LINE-SELECTION. MODIFY CURRENT LINE LINE FORMAT INVERSE INPUT OFF COLOR = I. After you have selected the the output list line (by double-clicking), the whole line is set to COLOR 2 and INVERSE and all INPUT fields are set to INPUT OFF. The fields with the attribute INTENSIFIED or INTENSIFIED OFF retain this because the attribute is not addressed here. Addition 3 ... FIELD VALUE f1 FROM g1 ... fn FROM gn Effect Overwrites the contents of the fields f1, f2, ... in the list line with the current contents of the fields g1, g2, ... (type conversion as for MOVE g1, g2, ... to type C). The field contents of f1, f2, ... themselves remain unchanged. Notes - If a field (e.g. f2) is output several times in the line to be modified, only the first occurrence is modified. If the field is not output in the line at all, it is ignored. - You can omit the addition FROM g2 if the field f2 in the list line is to be modified from the current contents of f2. This means that ... FIELD VALUE f2 has the same effect as ... FIELD VALUE f2 FROM f2 The return code value of SY-SUBRC is not affected by the addition FIELD VALUE and so only depends on the existence of the selected list line. Addition 4 ... FIELD FORMAT f1 fmt11 ... fmt1m ... fn fmtn1 ... fmtnm Effect Modifies the output format of the field f1 according to the format specifications fmt11 ... fmt1m. Similar to f2, ..., fn. For a list of valid format specifications, see FORMAT. Fields that occur several times or not at all in the line are treated as in the addition FIELD VALUE. Notes - If you combine the additions LINE FORMAT and FIELD FORMAT, the format set by LINE FORMAT is always valid for the whole line initially. Afterwards, it is changed by the format specifications for the individual fields. Example DATA: FLAG VALUE 'X', TEXT(20) VALUE 'Australia', I TYPE I VALUE 7. FORMAT INTENSIFIED OFF. WRITE: / FLAG AS CHECKBOX, TEXT COLOR COL_NEGATIVE. AT LINE-SELECTION. MODIFY CURRENT LINE LINE FORMAT INTENSIFIED FIELD VALUE FLAG FROM SPACE FIELD FORMAT FLAG INPUT OFF TEXT COLOR = I. When the user selects the displayed list line by double-clicking, the checkbox for FLAG is reset and can no longer accept values. The format of the entire line is set to "intensified" and TEXT is displayed in a different color. Variant 2 MODIFY LINE n OF CURRENT PAGE. Additions: 1. ... FIELD VALUE f1 FROM g1 ... fn FROM gn 2. ... LINE FORMAT fmt1 .. fmtn 3. ... FIELD FORMAT f1 fmt11 ... fmt1m ... fn fmtn1 ... fmtnm Effect Changes the nth line on the current page (stored in the system field SY-CPAGE). Addition 1 ... FIELD VALUE f1 FROM g1 ... fn FROM gn Addition 2 ... LINE FORMAT fmt1 .. fmtn Addition 3 ... FIELD FORMAT f1 fmt11 ... fmt1m ... fn fmtn1 ... fmtnm Effect See MODIFY LINE Variant 3 MODIFY LINE n OF PAGE m. Additions: 1. ... FIELD VALUE f1 FROM g1 ... fn FROM gn 2. ... LINE FORMAT fmt1 ... fmtn 3. ... FIELD FORMAT f1 fmt11 ... fmt1m ... fn fmtn1 ... fmtnm Effect Changes the nth line on page m. Addition 1 ... FIELD VALUE f1 FROM g1 ... fn FROM gn Addition 2 ... LINE FORMAT fmt1 ... fmtn Addition 3 ... FIELD FORMAT f1 fmt11 ... fmt1m ... fn fmtn1 ... fmtnm Effect See MODIFY LINE Variant 4 MODIFY CURRENT LINE. Additions: 1. ... FIELD VALUE f1 FROM g1 ... fn FROM gn 2. ... LINE FORMAT fmt1 ... fmtn 3. ... FIELD FORMAT f1 fmt11 ... fmt1m ... fn fmtn1 ... fmtnm Effect Changes the last line read (with line selection or READ LINE), even across line levels. This variant is especially useful if the line to be modified has been read immediately before through line selection or using READ LINE. You then need to note the number of the line until the MODIFY. Addition 1 ... FIELD VALUE f1 FROM g1 ... fn FROM gn Addition 2 ... LINE FORMAT fmt1 ... fmtn Addition 3 ... FIELD FORMAT f1 fmt11 ... fmt1m ... fn fmtn1 ... fmtnm Effect See MODIFY LINE MODIFY - Change the attributes of a screen field Basic form MODIFY SCREEN. Effect Changes the attributes belonging to the current screen field whilst processing with LOOP AT SCREEN ... ENDLOOP. The attributes of all fields of a screen are stored in the system table SCREEN. This can be edited line by line using LOOP AT SCREEN ... ENDLOOP. Changes to the properties of the attributes of the current screen field (= current line in the system table SCREEN) can be put into effect using MODIFY SCREEN. Note This statement should be used only within a LOOP AT SCREEN ... ENDLOOP loop at PBO time as part of the process logic of a screen. Related MODIFY itab MODULE Basic form MODULE modl. Additions: 1. ... OUTPUT 2. ... INPUT Effect The processing block between the "MODULE modl." and "ENDMODULE." statements is known as a module. You call the module modl in the screen flow logic with the statement "MODULE modl.". This screen must belong to the same program (module pool) as the module. Example DATA: INPUT, GOOD_INPUT. MODULE CONTROL. ... IF INPUT NE GOOD_INPUT. MESSAGE E123. ENDIF. ENDMODULE. Note The ABAP/4 statement MODULE, which is always terminated by ENDMODULE, must not be confused with the flow logic statement MODULE (screen). Addition 1 ... OUTPUT Addition 2 ... INPUT Effect The module called before screen output (in the PROCESS BEFORE OUTPUT section of the flow logic) should be qualified by the addition OUTPUT. Since the addition INPUT is the default value, it can be omitted. This means that the module called user input (in the PROCESS AFTER INPUT section of the flow logic), is either followed by no addition or qualified by the addition INPUT. A module modl can thus exist twice - as an input and as an output module. Notes - You cannot combine the additions OUTPUT and INPUT. - An error message (MESSAGE Emnr) cancels processing of the module. - A warning message (MESSAGE Wmnr) repeats the current module (or the module chain [CHAIN]) if you enter different data. If you just press ENTER after the warning (or even after I and S messages), processing continues after the MESSAGE statement. MOVE Variants: 1. MOVE f TO g. 2. MOVE f+off1(len1) TO g+off2(len2). 3. MOVE c1 TO c2 PERCENTAGE n. Variant 1 MOVE f TO g. Effect Moves the contents of field f to field g. Field f remains unchanged. This statement is equivalent to: g = f. Example DATA: NUMBER TYPE I, FIVE TYPE I. MOVE 5 TO FIVE. MOVE FIVE TO NUMBER. The fields NUMBER and FIVE now both 5. Notes 1. Multiple assignments like NUMBER = FIVE = 5. are also possible. ABAP/4 executes them from right to left (as in the above example). 2. If the field types or lengths differ, type conversion follows automatically. Type I fields are handled like type P fields. If you select the fixed point arithmetic attribute for an ABAP/4 program, type P fields are either rounded according to the number of decimal places or filled with zeros. 3. In contrast to WRITE TO, the decimal character is always a period (.), regardless of the specification in the user master. 4. MOVE allows you to copy tables and structures which contain other tables. Two tables can be copied only if this is possible for their respective lines. If the line types are incompatible, conversions are performed line by line. If itab is a table with a header line, the table itself can be addressed with itab[]. Two structures which themselves contain tables can only be copied if they are compatible (i.e. if the ABAP/4 type check allows this). Conversion table (f -> g) depending on the types of f and g: C -> C Left-justified transfer. If the target field is longer than the source field, it is padded with blanks on the right. If it is shorter than the source field, the left part of the source field is copied and the rest is truncated. C -> D The field f must be an 8-character date in YYYYMMDD format. C -> F The character string in f must be a valid representation of a floating point number (DATA). C -> N Only the digits in f are valid here. They are moved to g, right-justified and padded with zeros on the left. If the target field is too short, digits on the left are truncated. C -> T The field f must contain a 6-character time specification in HHMMSS format. C -> P the field f must contain a decimal number, i.e. a sequence of numeric characters with optional signs and more than once decimal point; there may be blanks on either side. If g is too short, an overflow error can occur. C -> X The field f must contain a hexadecimal character string (i.e. the only valid characters are 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F). The number to be converted is treated as a hexadecimal number rather than a decimal number, e.g.: C'15' -> X'15'. It is transported left-justified to g and either padded with zeros or truncated, e.g.: C'AB' -> X'AB00'. f is processed up to the first blank. Examples: C'ABC' -> X'ABC0', C'ABC0' -> X'ABC0' C'ABC D' -> X'ABC0', C' AB' -> X'0000' D -> C Left-justified transfer without conversion D -> D Transfer without conversion D -> F As for D -> P and then P -> F D -> N As for D -> C and then C -> N D -> P Inverse of P -> D D -> T Not supported: Error message D -> X Inverse of X -> D F -> C f is converted to E format and moved to g. E.g.: F'-3.142' -> C'-3.14200000000000E+00' If the mantissa is unequal to 0, it is standardized so that it lies between 1.0 and 9.99... The exponent is generally 2-digit; it is only converted to 3-digit format if it is greater than 99 or smaller than -99 The exponent always appears with a sign. If g is too short, the mantissa is rounded. e.g.: F'3.152' -> C' 3.2E+00'. The length of g should be at least 6, otherwise it g is filled with asterisks (*). F -> D See F -> N F -> F Transfer without conversion F -> N f is rounded as with F -> P and then treated like a P field. F -> P f is rounded, e.g. F'-3.512' -> P'-4'. F -> T See F -> N F -> X See F -> N N -> C f is treated like a C field; leading zeros remain. N -> D As for N -> C and then C -> D N -> F As for N -> P and then P -> F N -> N Right-justified transfer; on the left, padded with zeros or truncated. N -> P f is packed and moved to g with a positive sign (+). If g is too short, an overflow error can occur. N -> T As for N -> C and then C -> T N -> X As for N -> P and then P -> X P -> C f is moved to g with a trailing sign and, if required, a decimal point. e.g.: P'-1234567' -> C'12345.67-' Notes: 1) One position is always reserved for the sign and, in the event of a positive number, a blank is output. 2) Leading zeros are output as blanks. 3) If g is too short, the blank representing the sign in the case of positive numbers is omitted; if this is insufficient, the number is truncated on the left - this is indicated by an asterisk (*). Examples (the P field f has the length 2, the C field g the length 3): P'123' -> C'123', P'-123' -> C'*3-' 4) If you do not want to reserve a position for the sign, use the WRITE TO statement with the addition NO-SIGN. 5) To convert with leading zeros and without formatting characters, use the UNPACK statement. P -> D The value in f is the absolute date (i.e. the number of days since 01.01.0001) and is moved to g in the YYYYMMDD format. This takes into account that the Julian Calendar was replaced by the Gregorian Calendar on 15.10.1582. The value 0 (and negative values) are transferred into the initial date '00000000'. P -> F The field f is moved to g as a floating point number. P -> N Right-justified transfer without sign; padded with zeros on the left. P -> P If g is too short, an overflow error can occur. P -> T The value in f is an absolute time (i.e. the number of seconds since midnight modulo 24 hours = 86.400 seconds) and is moved to g in HHMMSS format. P -> X The value in f is stored in g as a hexadecimal number. E.g.: P'15' -> X'0F'. Negative numbers are represented by the two's complement. e.g.: P'-153' -> X'FF67'. If the length of g is greater than 4, only the last 4 Bytes are provided for according to the value of f; the Bytes before them are padded with Hex-0. If g is too short, the number is truncated on the left. T -> C As for D -> C T -> D Not supported: Error message T -> F As for T -> P and then P -> F T -> N As for T -> C T -> P Inverse of P -> T T -> T Transfer without conversion T -> X Inverse of X -> T X -> C f is converted to hexadecimal format. The result is transferred left-justified and padded with blanks or truncated on the right. e.g.: X'0F' -> C'0F' X -> D The value in f is an absolute date (number of days since 01.01.0001) and is moved to g in YYYYMMDD format. (See also P -> D.) X -> F As for X -> P and then P -> F X -> N As for X -> P and then P -> N X -> P f is treated as a hexadecimal number and moved to g in decimal packed format. e.g.: X'0F' -> P'15' If f is longer than 4, only the last 4 bytes are processed. If g is too short, an overflow error can occur. X -> T The value in f is an absolute time (i.e. the number of seconds since midnight modulo 24 hours = 86,400 seconds) and is moved to g in HHMMSS format. (See also P -> T.) X -> X Left-justified transfer; padded with X'00' on the right or truncated. Note Runtime errors: - BCD_BADDATA: Source field (type P) does not contain the correct BCD format - BCD_FIELD_OVERFLOW: Result field defined too small (type P) - BCD_OVERFLOW: Arithmetic operation overflow (type P) - CONVT_NO_NUMBER: Source field cannot be interpreted as a number - CONVT_OVERFLOW: Source field conversion overflow - MOVE_COMPLEX_OVERLAP: Assignment not allowed for deep structures in case they overlap - MOVE_NOT_SUPPORTED: Assignment between types involved is not supported - MOVE_TO_LIT_NOTALLOWED: Constants and literals must not be overwritten Related COMPUTE, WRITE TO Variant 2 MOVE f+off1(len1) TO g+off2(len2). Effect With offset off2 and length len2, field g receives the contents of field f with offset off1 and length len1. Therefore, the offset and length specifications can also be variable. Example DATA: FIELD1(10) VALUE '1234567890', OFF1 TYPE I VALUE 1, LEN1 TYPE I VALUE 2, FIELD2(8) VALUE 'abcdefgh', OFF2 TYPE I VALUE 3, LEN2 TYPE I VALUE 4. MOVE FIELD1+OFF1(LEN1) TO FIELD2+OFF2(LEN2). FIELD2 now has the value 'abc23 h'. Variant 3 MOVE c1 TO c2 PERCENTAGE n. Additions: 1. ... LEFT 2. ... RIGHT Effect c1 and c2 must be type C fields; n is a field with a numeric value between 0 and 100. The left part of field c1 (n percent) is moved to field c2 and is left-justified. c2 is filled with blanks if necessary. Addition 1 ... LEFT Effect This is the standard. With this statement, you can make clear that transfer is to be left-justified. Addition 2 ... RIGHT Effect Transfer is right-justified, the left part of field c1 as standard. Note Performance: The runtime required to transfer a C(1) field to a C(1) field is 1 msn (standard microseconds). Conversions should be avoided for performance reasons, i.e. the fields should have the same type and length. For example, a MOVE of a C(10) field to a C(10) field takes about 2 msn, while a MOVE of a C(10) field to a type I field needs about 10 msn. MOVE-CONDITIONAL is not an ABAP/4 key word (in R/3). MOVE-CORRESPONDING Basic form MOVE-CORRESPONDING rec1 TO rec2. Effect Interprets rec1 and rec2 as field strings. If, for example, rec1 and rec2 are tables, executes the statement for their header lines. Searches for the sub-fields which occur both in rec1 and rec2 and then generates, for all relevant field pairs which correspond to the sub-fields ni, statements of the form MOVE rec1-ni TO rec2-ni. The other fields remain unchanged. With complex structures, the full names of the corresponding field pairs must be identical. Example DATA: BEGIN OF INT_TABLE OCCURS 10, WORD(10), NUMBER TYPE I, INDEX LIKE SY-INDEX, END OF INT_TABLE, BEGIN OF RECORD, NAME(10) VALUE 'not WORD', NUMBER TYPE I, INDEX(20), END OF RECORD. ... MOVE-CORRESPONDING INT_TABLE TO RECORD. This MOVE-CORRESPONDING statement is equivalent to both the following statements: MOVE INT_TABLE-NUMBER TO RECORD-NUMBER. MOVE INT_TABLE-INDEX TO RECORD-INDEX. Example TYPES: BEGIN OF ROW1_3, CO1 TYPE I, CO2 TYPE I, CO3 TYPE I, END OF ROW1_3. TYPES: BEGIN OF ROW2_4, CO2 TYPE I, CO3 TYPE I, CO4 TYPE I, END OF ROW2_4. TYPES: BEGIN OF MATRIX1, R1 TYPE ROW1_3, R2 TYPE ROW1_3, R3 TYPE ROW1_3, END OF MATRIX1. TYPES: BEGIN OF MATRIX2, R2 TYPE ROW2_4, R3 TYPE ROW2_4, R4 TYPE ROW2_4, END OF MATRIX2. DATA: ROW TYPE ROW1_3, M1 TYPE MATRIX1, M2 TYPE MATRIX2. ROW-CO1 = 1. ROW-CO2 = 2. ROW-CO3 = 3. MOVE: ROW TO M1-R1, ROW TO M1-R2, ROW TO M1-R3. MOVE-CORRESPONDING M1 TO M2. The last MOVE-CORRESPONDING statement is equivalent to the statements: MOVE: M1-R2-CO2 TO M2-R2-CO2, M1-R2-CO3 TO M2-R2-CO3, M1-R3-CO2 TO M2-R3-CO2, M1-R3-CO3 TO M2-R3-CO3. Related MOVE, ADD-CORRESPONDING, SUBTRACT-CORRESPONDING, MULTIPLY-CORRESPONDING, DIVIDE-CORRESPONDING MOVE-DYNPRO is not an ABAP/4 key word (in R/3). MOVE-TEXT is not an ABAP/4 key word (in R/3). MULTIPLY Basic form MULTIPLY n1 BY n2. Effect Multiplies the contents of n1 by the contents of n2 and places the result in n1. This is equivalent to: n1 = n1 * n2. Example DATA: DAYS_PER_YEAR TYPE P VALUE 365, HOURS_PER_DAY TYPE F VALUE '24.0', MINUTES_PER_YEAR TYPE I VALUE 1. MULTIPLY MINUTES_PER_YEAR BY DAYS_PER_YEAR. MULTIPLY MINUTES_PER_YEAR BY HOURS_PER_DAY. MULTIPLY MINUTES_PER_YEAR BY 60. MINUTES_PER_YEAR now contains 525600. Note The details about conversions and performance given under COMPUTE also apply to MULTIPLY. Note Runtime errors: - BCD_BADDATA: P field contains no correct BCD format - BCD_FIELD_OVERFLOW: Result field too small (type P) - BCD_OVERFLOW: Overflow with arithmetic operation (type P) - COMPUTE_INT_TIMES_OVERFLOW: Whole number overflow with multiplication Related COMPUTE, MULTIPLY-CORRESPONDING MULTIPLY-CORRESPONDING Basic form MULTIPLY-CORRESPONDING rec1 BY rec2. Effect Interprets rec1 and rec2 as field strings. If, for example, rec1 and rec2 are tables, executes the statement for their header lines. Searches for all sub-fields which occur both in rec1 and rec2 and then generates, for all field pairs corresponding to the sub-fields ni, statements of the form MULTIPLY rec1-ni BY rec2-ni. The other fields remain unchanged. With complex structures, the full names of the corresponding field pairs must be identical. Example DATA: BEGIN OF MONEY, VALUE_IN(20) VALUE 'German marks'. USA TYPE I VALUE 100, FRG TYPE I VALUE 200, AUT TYPE I VALUE 300, END OF MONEY, BEGIN OF CHANGE, DESCRIPTION(30) VALUE 'DM to national currency'. USA TYPE F VALUE '0.6667', FRG TYPE F VALUE '1.0', AUT TYPE F VALUE '7.0', END OF CHANGE. MULTIPLY-CORRESPONDING MONEY BY CHANGE. MONEY-VALUE_IN = 'National currency'. The above MULTIPLY-CORRESPONDING statement is equivalent to the following three statements: MULTIPLY MONEY-USA BY CHANGE-USA. MULTIPLY MONEY-FRG BY CHANGE-FRG. MULTIPLY MONEY-AUT BY CHANGE-AUT. Note All fields with identical names are multiplied, whether numeric or not. The conversions performed are similar to those for MULTIPLY and the same runtime errors can also occur. Related MULTIPLY, MOVE-CORRESPONDING, ADD-CORRESPONDING, SUBTRACT-CORRESPONDING, DIVIDE-CORRESPONDING NEW-LINE Basic form NEW-LINE. Addition: ... NO-SCROLLING ... SCROLLING Effect Generates a new line during list processing. Terminates the current list line and moves the cursor to the next list line. If there has been no output (with WRITE or SKIP) since the last NEW-LINE, the NEW-LINE is ignored, i.e. no new line is started. Notes You can also generate a new line with WRITE AT /.... The following key words implicitly generate a new line: NEW-PAGE, CALL SCREEN. Addition ... NO-SCROLLING Effect Flags the new line as "not movable" (i.e. horizontal scrolling has no effect). This allows you to keep title lines and indented comment lines or areas in the same position. Notes - The system does not automatically flag the standard title line (text elements, NEW-PAGE WITH-TITLE) as "not movable". - SET_SCROLL-BOUNDARY allows you to flag columns in a list so that they cannot be scrolled horizontally. In this case, using NEW-LINE NO-SCROLLING means that lines which are not subject to the division of the page into fixed and movable column areas remain visible and are not moved during horizontal scrolling. Example Scattered comment lines - unmovable NEW-PAGE LINE-SIZE 255. WRITE: / 'This line will be moved'. NEW-LINE NO-SCROLLING. WRITE: / 'This line will n o t be moved'. WRITE: / 'This line will be moved'. Addition 2 ... SCROLLING Effect Flags the new line as "not movable". Since SCROLLING is the default setting of NEW-LINE, it can normally be omitted. You only have to use NEW-LINE SCROLLING after NEW-LINE NO-SCROLLING, which is not followed by any output. This ensures that the next line introduced with NEW-LINE also has the attribute SCROLLING. Example Conditional comment lines: NEW-PAGE LINE-SIZE 255. WRITE: / 'This line will be moved'. NEW-LINE NO-SCROLLING. IF 0 = 1. WRITE: / 'Conditional comment line'. ENDIF. NEW-LINE. "Incorrect WRITE: / 'This line will n o t be moved'. WRITE: / 'This line will be moved'. NEW-LINE NO-SCROLLING. IF 0 = 1. WRITE: / 'Conditional comment line'. ENDIF. NEW-LINE SCROLLING. "Correct WRITE: / 'This line will be moved'. NEW-PAGE Basic form NEW-PAGE. Additions: 1. ... NO-TITLE 2 ... WITH-TITLE 3. ... NO-HEADING 4. ... WITH-HEADING 5. ... LINE-COUNT lin 6. ... LINE-SIZE col Effect Starts a new page during list processing. Terminates the current page and continues output on a new page. Notes - NEW-PAGE does not generate blank pages, i.e. it ignores pages containing no output. - NEW-PAGE increments the page counter (the system field SY-PAGNO). - The event END-OF-PAGE is not processed. - To start a new page depending on the number of unused lines remaining on the current page, use the RESERVE statement. Addition 1 ... NO-TITLE Effect Starts a new page but no longer outputs the standard header (title, date and page number). This is the default setting for secondary lists. Addition 2 ... WITH-TITLE Effect Starts a new page and continues to output of the standard header (title, date and page number). This is the default setting for basic lists (see REPORT ... NO STANDARD PAGE HEADING). Addition 3 ... NO-HEADING Effect Starts a new page but no longer outputs column headings (text elements). This is the default setting for secondary lists. Addition 4 ... WITH-HEADING Effect Starts a new page and continues to output the column headings (text elements). This is the default setting for basic lists (see REPORT ... NO STANDARD PAGE HEADING). Addition 5 ... LINE-COUNT lin Effect Starts a new page containing the number of lines specified by lin (in the exceptional case of LINE-COUNT 0, the number of lines per page is unlimited). Note The default setting is taken from the addition ... LINE-COUNT in the REPORT statement. Further notes about the use of LINE-COUNT. Addition 6 ... LINE-SIZE col Effect Formats the new page with the number of columns specified in col. The exception to this is LINE-SIZE = 0 which indicates line length set by the system according to the standard window width. The addition ... LINE-SIZE col is only effective on the new page if it is also the first page of a new list level. Note The addition works only before initialization of the new list level (with WRITE, SKIP, ...). The default setting is also taken from the addition ... LINE-SIZE in the REPORT statement. NEW-PAGE Additions: 7. ... PRINT ON ... ... DESTINATION dest ... COPIES cop ... LIST NAME name ... LIST DATASET dsn ... COVER TEXT text ... LIST AUTHORITY auth ... IMMEDIATELY flag ... KEEP IN SPOOL flag ... NEW LIST IDENTIFICATION flag ... DATASET EXPIRATION days ... LINE-COUNT lin ... LINE-SIZE col ... LAYOUT layout ... SAP COVER PAGE mode ... RECEIVER rec ... DEPARTMENT dep ... ARCHIVE MODE armode ... ARCHIVE PARAMETERS arparams ... NEW-SECTION ... NO DIALOG 8. ... PRINT ON ... ... PARAMETERS params ... ARCHIVE PARAMETERS arparams ... NEW-SECTION ... NO DIALOG 9. ... PRINT OFF Addition 7 ... PRINT ON ... ... DESTINATION dest (Output device) ... COPIES cop (Number of copies printed) ... LIST NAME name (Name of the list) ... LIST DATASET dsn (Name of the spool dataset) ... COVER TEXT text (Title of the spool request) ... LIST AUTHORITY auth (Authorization required for display) ... IMMEDIATELY flag (Print immediately?) ... KEEP IN SPOOL flag (Keep list after printing?) ... NEW LIST IDENTIFICATION flag (New spool request?) ... DATASET EXPIRATION day (Keep the list for day days) ... LINE-COUNT lin (lin lines per page) ... LINE-SIZE col (col columns per line) ... LAYOUT layout (Print layout) ... SAP COVER PAGE mode (Print SAP cover sheet?) ... RECEIVER rec (SAP user name of recipient) ... DEPARTMENT dep (Name of department) ... ARCHIVE MODE armode (Archiving mode) ... ARCHIVE PARAMETERS arparams (Structure with achiving parameters) ... NEW-SECTION (Start of a new section) ... NO DIALOG (Omit print control screen) In the case of the IMMEDIATELY, KEEP IN SPOOL and NEW LIST IDENTIFICATION parameters, the flag must be a literal or character field of length 1. If the flag contains no value, the parameter is switched off. Any other character switches the parameter on. Any of the sub-parameters for PRINT ON can be omitted. The specification mode for SAP COVER PAGE can take any of the values ' ', 'X' and 'D'. These values have the following meanings: ' ' : Do not output cover sheet. 'X' : Output cover sheet. 'D' : Printer setting determines whether cover sheet is printed. The specification armode for ARCHIVE MODE can take any of the values '1', '2' and '3'. These values have the following meanings: '1' : Print only. '2' : Archive only. '3' : Print and archive. The specification arparams for ARCHIVE PARAMETERS must have the structure of ARC_PARAMS. This parameter should be edited only using the function module GET_PRINT_PARAMETERS. Effect New page. All WRITE statements (similarly SKIP, ULINE, ...) from the new page onwards are interpreted as printer instructions. Before the first page is printed, the user sees a screen for determining the print parameters, provided NO DIALOG was not specified. The values defined in NEW-PAGE PRINT ON for LINE-SIZE and LINE-COUNT are used by this screen. Default values are also available if no others exist. The specifications for LINE-COUNT and LINE-SIZE in the report header have no meaning here. The various print parameters can be proposed or (in the case of NO DIALOG) determined for the specifications of the other additions. If you use NEW-SECTION, the page numbering is set back to 1. If printing is currently in progress, the current spool request is closed. If the newly specified print parameters are compatible with the previously specified print parameters, the new spool request is added to the end of the request just closed. Notes - Records cannot be placed in the spool across events (AT LINE-SELECTION, AT PFx, AT USER-COMMAND)! In this case, a new NEW-PAGE PRINT OFF statement (see addition 8) is be executed, even if it is not programmed! - For LINE-SIZE, you should not specify values greater than 132 because most printers cannot handle wider lists. Addition 8 ... PRINT ON ... ... PARAMETERS params (Structure with print parameters) ... ARCHIVE PARAMETERS arparams (Structure with archiving parameters) ... NEW-SECTION (Start of a new section) ... NO DIALOG (Omits print control screen) Effect New page. All WRITE statements (similarly SKIP, ULINE, ...) from the new page onwards are interpreted as printer instructions. Before the first page is printed, the user sees a screen for determining the print parameters, provided NO DIALOG was not specified. The print parameters are passed via the field string params which must have the same structure as PRI_PARAMS. The field string can be filled and modified with the function module GET_PRINT_PARAMETERS. The specification arparams for ARCHIVE PARAMETERS must have the same structure as ARC_PARAMS. This parameter should only be edited with the function module GET_PRINT_PARAMETERS. See addition 7 for information on the meaning of NEW-SECTION Note - Records cannot be placed in the spool across events (AT LINE-SELECTION, AT PFx, AT USER-COMMAND)! In this case, a new NEW-PAGE PRINT OFF statement (see addition 8) is be executed, even if it is not programmed! Example * Printing without archiving DATA PARAMS LIKE PRI_PARAMS. DATA: DAYS(1) TYPE N VALUE 2, COUNT(3) TYPE N VALUE 1, VALID TYPE C. CALL FUNCTION 'GET_PRINT_PARAMETERS' EXPORTING DESTINATION = 'LT50' COPIES = COUNT LIST_NAME = 'TEST' LIST_TEXT = 'Test NEW-PAGE PRINT ON' IMMEDIATELY = 'X' RELEASE = 'X' NEW_LIST_ID = 'X' EXPIRATION = DAYS LINE_SIZE = 79 LINE_COUNT = 23 LAYOUT = 'X_PAPER' SAP_COVER_PAGE = 'X' RECEIVER = 'SAP*' DEPARTMENT = 'System' NO_DIALOG = ' ' IMPORTING OUT_PARAMETERS = PARAMS VALID = VALID. IF VALID <> SPACE. NEW-PAGE PRINT ON PARAMETERS PARAMS NO DIALOG. WRITE / 'First line'. ENDIF. Example * Printing with archiving DATA: PARAMS LIKE PRI_PARAMS, ARPARAMS LIKE ARC_PARAMS, DAYS(1) TYPE N VALUE 2, COUNT(3) TYPE N VALUE 1, VALID TYPE C. CALL FUNCTION 'GET_PRINT_PARAMETERS' EXPORTING DESTINATION = 'LT50' COPIES = COUNT LIST_NAME = 'TEST' LIST_TEXT = 'Test NEW-PAGE PRINT ON' IMMEDIATELY = 'X' RELEASE = 'X' NEW_LIST_ID = 'X' EXPIRATION = DAYS LINE_SIZE = 79 LINE_COUNT = 23 LAYOUT = 'X_PAPER' SAP_COVER_PAGE = 'X' RECEIVER = 'SAP*' DEPARTMENT = 'System' SAP_OBJECT = 'RS' AR_OBJECT = 'TEST' ARCHIVE_ID = 'XX' ARCHIVE_INFO = 'III' ARCHIVE_TEXT = 'Description' NO_DIALOG = ' ' IMPORTING OUT_PARAMETERS = PARAMS OUT_ARCHIVE_PARAMETERS = ARPARAMS VALID = VALID. IF VALID <> SPACE. NEW-PAGE PRINT ON PARAMETERS PARAMS ARCHIVE PARAMETERS ARPARAMS NO DIALOG. WRITE / 'First line'. ENDIF. Addition 9 ... PRINT OFF Effect New page. From the new page onwards, all WRITE statements are again output to the screen. The completed page is output to the spool file. NEW-SECTION NEW-SECTION continues to be supported only for reasons of compatibility, but it is processed internally after NEW-PAGE PRINT ON. Instead of "NEW-SECTION", use "NEW-PAGE PRINT ON". You can select the previous standard function of NEW-SECTION - i.e. resetting the page counter to 1 - with the addition "NEW-SECTION" of NEW-PAGE PRINT ON. ABAP/4 changes since Release 1.1 Date 18.5.93 Changes: 1. Cross-client ABAP/4 Open SQL 2. Cross-client EXPORT/IMPORT 3. Country-specific decimal point / date display 4. Lists as modal dialog boxes 5. Line length for each list / list level 6. New key word DESCRIBE LIST Change 1 Cross-client ABAP/4 Open SQL You can now use the addition CLIENT SPECIFIED in conjunction with the ABAP/4 Open SQL key words SELECT, UPDATE and DELETE to access tables which are not client-specific. Change 2 Cross-client EXPORT/IMPORT You can now use the addition CLIENT in conjunction with the key words EXPORT, IMPORT and DELETE to access cluster databases, whether they are independent or client-specific. Change 3 Country-specific decimal point / date display You can now use the key word SET COUNTRY to determine the decimal point and date display for all subsequent output (with WRITE). Change 4 Lists as modal dialog boxes You can now display lists as modal dialog boxes if you are using LEAVE TO LIST-PROCESSING to format the list in a screen that (a) has the "modal dialog box" attribute, (b) is called with CALL SCREEN (or better, with the addition ... STARTING AT ... ENDING AT ...) Change 5 Line length for each list / list level Until now, the line length in lists was determined by the LINE-SIZE specification in the main program (i.e. the program started first in a transaction). It was not possible to do this yourself for lists generated by function modules. Now, each list uses the LINE-SIZE specification of the currently active "screen program" (the screen program is always the program where the active screen calls its modules). You can change this specification explicitly for each list level by using the ... LINE-SIZE addition of the NEW-PAGE statement Change 6 New key word DESCRIBE LIST Until now, it was possible to describe the attributes of fields, field strings and internal tables with DESCRIBE. Now, you can also do this for lists by using DESCRIBE LIST. No documentation. No documentation. No documentation. ON Basic form ON CHANGE OF f. Addition: ... OR f1 Effect Executes the processing block enclosed by the "ON CHANGE OF f" and "ENDON" statements whenever the contents of the field f change (control break processing). Normally, you use the statement to manipulate database fields during GET events or SELECT/ENDSELECT processing. Note There are special control structures for processing control breaks in LOOPs on internal tables or extract datasets (AT). ON CHANGE OF is unsuitable for recognizing control levels in loops of this type because it always creates a global auxiliary field which is used to check for changes. This global auxiliary field can only be changed in the relevant ON CHANGE OF statement. It is not reset when the processing goes into loops or subroutines, so unwanted effects can occur if the loop or subroutine is executed again. Also, since it is set to its initial value when created (like any other field), any ON CHANGE OF processing will be executed after the first test, unless the contents of the field concerned happen to be identical to the initial value. Example TABLES T100. SELECT * FROM T100 WHERE SPRSL = SY-LANGU AND MSGNR < '010' ORDER BY PRIMARY KEY. ON CHANGE OF T100-ARBGB. ULINE. WRITE: / '***', T100-ARBGB, '***'. ENDON. WRITE: / T100-MSGNR, T100-TEXT. ENDSELECT. Displays all messages with their numbers in the logon language, provided the number is less than '010'. Each time the message class changes, it is output. Addition ... OR f1 Effect Also executes the code whenever the contents of the field f1 changes. You can use this addition several times. Example * Logical database F1S TABLES: SPFLI, SFLIGHT, SBOOK. GET SBOOK. ON CHANGE OF SPFLI-CARRID OR SPFLI-CONNID OR SFLIGHT-FLDATE. ULINE. WRITE: /5 SPFLI-CARRID, SPFLI-CONNID, 5 SFLIGHT-FLDATE, SPFLI-FLTIME, 5 SFLIGHT-SEATSMAX, SFLIGHT-SEATSOCC. ENDON. WRITE: / SBOOK-CUSTOMID. The code between ON CHANGE OF and ENDON is executed only if at least one of the fields SPFLI-CARRID, SPFLI-CONNID or SFLIGHT-FLDATE has changed, i.e. there is a different flight connection (which also has bookings). Notes 1. Between ON CHANGE OF and ENDON, you can use ELSE for case distinction. 2. You can also use ELSEIF statements in conjunction with special implementation of ON, but should always try to avoid this because they may not be supported in future. Related AT - control breaks with internal tables AT - control breaks with extracts OPEN Basic forms: 1. OPEN DATASET dsn. 2. OPEN CURSOR [WITH HOLD] c FOR SELECT ... . OPEN Basic form 2 OPEN CURSOR [WITH HOLD] c FOR SELECT ... . Effect Opens a database cursor c in a database table or view for a SELECT command. The variable c must be of the type CURSOR. You can use any SELECT command that returns a table, but not a single record, as a result. When the cursor has been opened, the dataset specified with SELECT can be read with FETCH until the cursor is closed. OPEN CURSOR belongs to the Open SQL command set. If you attempt to open a cursor that has already been opened, you get a runtime error. The following events close a cursor: 1. The CLOSE CURSOR command. 2. The Open SQL command. COMMIT WORK 3. A database commit in Native SQL. In this case, a cursor opened with WITH HOLD is not closed. 4. The Open SQL command ROLLBACK WORK 5. A database rollback in Native SQL 6. A screen change, in particular the commands CALL SCREEN, CALL DIALOG, CALL TRANSACTION, MESSAGE 7. A Remote Function Call. Example Open the database cursor C1 in the database table SFLIGHT for the SELECT command - SELECT * FROM SFLIGHT WHERE CARRID = 'LH '. TABLES SFLIGHT. DATA C1 TYPE CURSOR. OPEN CURSOR C1 FOR SELECT * FROM SFLIGHT WHERE CARRID = 'LH '. Notes 1. In the above example, the OPEN command contains no INTO clause. With cursor processing, you must always specify the target area for the selected data in the FETCH command. 2. The OPEN CURSOR command allows you to open several cursors at the same time in a table. Unlike with SELECT, you thus have several independent access paths to this table. 3. Since you can open only a restricted number of cursors at the same time, you should close cursors that are no longer required with CLOSE CURSOR. 4. Since the OPEN statement does not support authorization checks, you must program these yourself. Related SELECT, FETCH und CLOSE. OPEN Basic form 1 OPEN DATASET dsn. Additions: 1. ... FOR OUTPUT 2. ... FOR INPUT 3. ... FOR APPENDING 4. ... IN BINARY MODE 5. ... IN TEXT MODE 6. ... AT POSITION pos 7. ... TYPE attr 8. ... MESSAGE msg 9. ... FILTER filter Effect Opens the specified file. If no addition is specified, the file is opened for reading and in binary mode (see below). The return code value is set as follows: SY-SUBRC = 0: The file was opened. SY-SUBRC = 8: The file could not be opened. Example DATA: DSN(20) VALUE '/usr/test', RECORD(80). OPEN DATASET DSN. DO. READ DATASET DSN INTO RECORD. IF SY-SUBRC NE 0. EXIT. ELSE. WRITE: / RECORD. ENDIF. ENDDO. CLOSE DATASET DSN. Notes 1. The file must be accessible from the application server. You cannot use OPEN DATASET to process files on the current presentation server (whether PC or workstation). The function modules WS_DOWNLOAD and WS_UPLOAD exist for this purpose. 2. The format of file names depends largely on the operating system. You can access portable programs by using the function module FILE_GET_NAME which returns the physical file name for a given logical file name. Notes For the UNIX operating system - You should specify the path name of any file you wish to open in its absolute form ('/usr/test'), not in its relative form ('test'). Otherwise, the file may be opened in the directory where the SAP System is already running. - When you create a file, it exists under the user name used to start the SAP System. This user name is not normally identical with the user's UNIX name. To be able to create the file, the user must have the appropriate write authorization. Addition 1 ... FOR OUTPUT Effect Opens the file for writing. If the file already exists, its contents are deleted unless it is already open. If it is open, the positioning is set back to the start of the file. If the file does not exist, it is generated. Addition 2 ... FOR INPUT Effect Opens an existing file for writing. If the file is already open, the positioning is set back only to the start of the file. The addition FOR INPUT does not have to be specified explicitly. Addition 3 ... FOR APPENDING Effect Opens the file for writing to the end of the file. If the file does not exist, it is generated. If the file is already open, positioning is only set back to the end. Note The additions 1 to 3 are mutually exclusive. Addition 4 ... IN BINARY MODE Effect The contents of the file are not interpreted by the read and write operations READ DATASET and TRANSFER. The data areas specified with these key words are directly input or output. The addition IN BINARY MODE does not have to be specified explicitly. Addition 5 ... IN TEXT MODE Effect If a file is opened with this addition, the system assumes that the file has a line structure. Each time READ DATASET or TRANSFER occurs, exactly one line is input or output. If the data area is too big for the line read, the remaining area is padded with blanks. If it is too small, the remainder of the line is lost. Note The additions 4 and 5 are mutually exclusive. Addition 6 ... AT POSITION pos Effect This addition allows you to specify an explicit file position pos in bytes from the start of the file. The next read or write operation then occurs there. You cannot specify a position before the start of the file. Although this addition can also be used with the addition IN TEXT MODE, it makes little sense, because the physical format of a text file depends largely on the operating system. Addition 7 ... TYPE attr Effect In the field attr, you can specify further file attributes. The contents of this field are passed unchanged to the operating system. No checks are performed. See the documentation of the fopen command for the relevant operating system. Example Generate a MVS file "'QXX.YYY'" with the specified attributes. (The apostrophes ['] are part of the file name.): OPEN DATASET '''QXX.YYY''' TYPE 'lrecl=80, blksize=8000, recfm=F' FOR OUTPUT. Example Generate an OpenVMS file 'TEST.LOG' with the specified attributes. The individual parameters must be separated by blanks: OPEN DATASET 'TEST.LOG' TYPE 'alq=100 deq=100 fop=cif,ctg' FOR OUTPUT. Addition 8 ... MESSAGE msg Effect Stores the relevant operating system message in the field msg if an error occurs when opening the file. Example DATA: DSN(20) VALUE '/usr/test', MSG(100). OPEN DATASET DSN FOR INPUT MESSAGE MSG. IF SY-SUBRC <> 0. WRITE: / MSG. STOP. ENDIF. Addition 9 ... FILTER filter Effect Under UNIX and Windows NT, you can specify an operating system command in the field filter. Example Under UNIX DATA DSN(20) VALUE '/usr/test.Z'. OPEN DATASET DSN FOR OUTPUT FILTER 'compress'. opens the file DSN and writes the output data to this file via the UNIX command 'compress'. OPEN DATASET DSN FOR INPUT FILTER 'uncompress'. reads the file in again. ORDER BY clause Variants: 1. ... ORDER BY PRIMARY KEY 2. ... ORDER BY f1 ... fn 3. ... ORDER BY (itab) Effect Orders the records in a SELECT command. Without the ORDER-BY clause, the order in which the selected lines are supplied is undefined. This means that two similar SELECT commands may produce lines in a different order. Variant 1 ...ORDER BY PRIMARY KEY Effect Sorts the selected lines in ascending order by the primary key of the database table. This variant is only permitted for SELECT * .... Example Output the passenger list for the Lufthansa flight 0400 on 28.02.1995: TABLES SBOOK. SELECT * FROM SBOOK WHERE CARRID = 'LH ' AND CONNID = '0400' AND FLDATE = '19950228' ORDER BY PRIMARY KEY. WRITE: / SBOOK-BOOKID, SBOOK-CUSTOMID, SBOOK-CUSTTYPE, SBOOK-SMOKER, SBOOK-LUGGWEIGHT, SBOOK-WUNIT, SBOOK-INVOICE. ENDSELECT. Notes Since views do not have a primary key, specifying ORDER BY PRIMARY KEY only makes sense with database tables. If, however, you do specify ORDER BY PRIMARY KEY with a view, all fields of the view are sorted in ascending order. Variant 2 ORDER BY f1 ... fn Effect Sorts the selected records in ascending order by the specified database fields f1 ... fn. If a list is also specified in the SELECTclause, the fields f1, ..., fn must appear in this list. By supplementing the statement with DESCENDING, you can sort in descending order using any of the fields f1, ..., fn. The default sort sequence is ascending order, but you can make this explicit by adding the addition ASCENDING. Examples Output Lufthansa flights from 27.02.1995 to 05.03.1995, sorted by plane type and number of occupied seats: TABLES: SFLIGHT. SELECT * FROM SFLIGHT WHERE CARRID = 'LH' AND FLDATE BETWEEN '19950227' AND '19950305' ORDER BY PLANETYPE ASCENDING SEATSOCC DESCENDING. WRITE: / SFLIGHT-PLANETYPE, SFLIGHT-SEATSOCC, SFLIGHT-CONNID, SFLIGHT-FLDATE. ENDSELECT. Notes 1. Pooled and cluster tables can only be sorted by their primary key. 2. With a SELECT * ..., the client field automatically becomes the first sort criterion in client-specific tables, unless the addition CLIENT SPECIFIED is specified in the FROM clause. 3. Specifying FOR ALL ENTRIES IN itab WHERE ... in the WHERE clause excludes ORDER BY f1 ... fn. Notes Performance: Notes 1. In contrast to ... ORDER BY PRIMARY KEY, ORDER BY f1 ... fn is not automatically supported by a (sorted) index. Without an index, you must sort the result set at runtime. Because of the SAP architecture, this should not be performed on the database server, but on the applications server. If it does not make sense to create an index, you should not sort the result set with ... ORDER BY f1 ... fn on the database server, but with SORT on the applications server. 2. With larger datasets, you should only use the variant ORDER BY f1 ... fn if the order of the database fields f1 ... fn is exactly the same as the order of the indexes. Variant 3 ... ORDER BY (itab) Effect Works like ORDER BY f1 ... fn if the internal table itab contains the list f1 ... fn as ABAP/4 source code. The internal table itab must only have one field. This must be a type C field and must not be more than 72 characters long. itab must be specified in parentheses. There must be no blanks between the parentheses and the table name. Note The same restrictions apply to this variant as to ORDER BY f1 ... fn. Example Output all Lufthansa points of departure with the number of destinations: TABLES: SPFLI DATA: BEGIN OF WA. INCLUDE STRUCTURE SPFLI. DATA: COUNT TYPE I: DATA: END OF WA. DATA: GTAB(72) OCCURS 5 WITH HEADER LINE, FTAB(72) OCCURS 5 WITH HEADER LINE, OTAB(72) OCCURS 5 WITH HEADER LINE, COUNT TYPE I. REFRESH: GTAB, FTAB, OTAB. FTAB = 'CITYFROM COUNT( * ) AS COUNT'. APPEND FTAB. GTAB = 'CITYFROM'. APPEND GTAB. OTAB = 'CITYFROM'. APPEND OTAB. SELECT DISTINCT (FTAB) INTO CORRESPONDING FIELDS OF WA FROM SPFLI WHERE CARRID = 'LH' GROUP BY (GTAB) ORDER BY (OTAB). WRITE: / WA-CITYFROM, WA-COUNT. ENDSELECT. OVERLAY Basic form OVERLAY c1 WITH c2. Addition: ... ONLY c3 Note As with any string processing statement, all the operands are processed here as type C fields (regardless of tyep). No internal conversion is performed. Effect The contents of the field c2 overlay the field c1 in all positions where c1 has the value SPACE; c2 itself remains unchanged. The return code value is set as follows: SY-SUBRC = 0: At least one character in c1 is overlaid by a character from c2. SY-SUBRC = 4: No character in c1 was overlaid by a character from c2. Example DATA: WORK(20) VALUE 'Th t h s ch ng d.', HELP(20) VALUE 'Grab a pattern'. OVERLAY WORK WITH HELP. WORK now contains 'That has changed.' and the system field SY-SUBRC is set to 0. Note If c1 is longer than c2, c1 is only overlaid by the length of c2. The result for overlapping fields c1 and c2 is undefined. Addition ... ONLY c3 Effect The contents of the field c2 overlay the field c1 only in those positions where c1 has one of the characters existing as a value in c3; the fields c2 and c3 remain unchanged. Example Linking field selection templates: DATA: ONE(16), TWO(16). ONE = '----****++++....'. TWO = '-*+.-*+.-*+.-*+.'. OVERLAY ONE WITH TWO ONLY '.'. OVERLAY TWO WITH ONE ONLY '.+'. OVERLAY ONE WITH TWO ONLY '+*'. Field ONE now contains '-----***-*++-*+.' and field TWO contains '-*---***-*++-*+.'. Note Performance: The runtime required for the OVERLAY command in the example of the basic form is about 45 msn (standardized microseconds). To execute the addition ... ONLY c3, about 40 msn are needed. Related REPLACE, SEARCH, SHIFT, TRANSLATE PACK Basic form PACK f TO g. Effect Places the character field f in packed format in the field g. Reverse of the UNPACK command. Example DATA C_FIELD(4) TYPE C VALUE '0103', P_FIELD(2) TYPE P. PACK C_FIELD TO P_FIELD. C_FIELD: C'0103' --> P_FIELD: P'103C' Note The field f can contain up to 16 characters. PARAMETERS Basic form PARAMETERS p Additions: 1. ... DEFAULT f 2. ... TYPE typ 3. ... DECIMALS 4. ... LIKE g 5. ... MEMORY ID pid 6. ... MATCHCODE OBJECT mobj 7. ... MODIF ID key 8. ... NO-DISPLAY 9. ... LOWER CASE 10. ... OBLIGATORY 11. ... AS CHECKBOX 12 ... RADIOBUTTON GROUP radi 13. ... FOR TABLE dbtab 14. ... AS MATCHCODE STRUCTURE 15. ... VALUE-REQUEST 16. ... HELP-REQUEST Effect Definition of report parameters. This statement only makes sense in report programs, i.e. in programs defined as type '1' in the attributes. You execute report programs with the SUBMIT statement. When this takes place, the parameters and selection options (SELECT-OPTIONS) specified in the report program shape the interface which determines what the user sees on the selection screen. These parameters and selection options are then presented to the user who can enter values (see the addition NO-DISPLAY or SUBMIT without the addition VIA SELECTION-SCREEN). Creates internal fields like the DATA statement. By making the appropriate entry in the attributes, you can assign a report to a logical database ldb. In this case, both the logical database ldb and the report can define parameters (and selection options). You define the database-specific parameters (i.e. those belonging to the logical database) in an ABAP/4 INCLUDE program DBldbSEL (in the logical database maintenance transaction). Since the system then integrates this INCLUDE program in the logical database access program SAPDBldb and (partially) in the report, the database-specific parameters (and selection options) are available to both. The ("report-specific") parameters defined in the report are known only in the report (not in the SAPDBldb). Some additions of PARAMETERS are allowed only in the DBldbSEL. Example PARAMETERS: SUM(1). Notes 1. The name of a parameter can be up to 8 characters long. 2. By selecting Goto -> Text elements and then choosing Selection texts followed by Display, you can enter a description for each parameter; this is then displayed on the selection screen. You define the report-specific parameter texts with the text elements of the report and the database-specific parameter texts with the text elements of the database program SAPDBldb. Addition 1 ... DEFAULT f Effect Assigns the default value f to the parameter. Note You must specify the default value f in internal format, e.g. PARAMETERS DATE LIKE SY-DATUM DEFAULT '19931224', not ... DEFAULT '24.12.1993'. Addition 2 ... TYPE typ Effect Assigns the type typ to the internal field. Example PARAMETERS: NUMBER(4) TYPE P DEFAULT '999'. Addition 3 ... DECIMALS dec Effect Assigns dec decimal places to the internal field. dec must be numeric. Note You can only use the addition DECIMALS dec with the addition TYPE P, i.e. it is only allowed with parameters of type P. Example PARAMETERS: NUMBER (4) TYPE P DECIMALS 2 DEFAULT '123.45'. Addition 4 ... LIKE g Effect Creates the field p with the same attributes as the field g which is already defined. g can be either a database field or an existing internal field. Note You cannot use the addition ... LIKE g with the addition ... TYPE typ. No explicit length may be specified for the parameter (for example, a statement such as PARAMETERS p(len) LIKE g is not allowed). Example PARAMETERS PROGRAM LIKE SY-REPID. Note 1. If g is an ABAP/4 Dictionary field of the type CHAR, length 1 and default values 'X' and ' ' (according to the relevant domain), the parameter is always displayed as a checkbox on the selection screen (see also AS CHECKBOX). 2. Field attributes on the selection screen: The input/output field which appears on the selection screen for the parameter has the attributes of the field g specified after LIKE. These include type, length or - with ABAP/4 Dictionary fields - conversion exit. If g is an ABAP/4 Dictionary field, the selection screen is automatically regenerated after most field attribute changes. An excception to this rule are the attributes "Check table" and "Fixed values". If these change, you must generate the program in the ABAP/4 Development Workbench. This also generates the selection screen. 3. The maximum permitted length of a parameter on the selection screen is 45 (scrollable up to length 132). If you have defined it longer than this (either explicitly with p(200) or implicitly with LIKE), the parameter is truncated on the selection screen after the 132nd character. However, you can use SUBMIT to pass longer parameters to a report (particularly if these are not displayed on the selection screen at all because of the addition NO-DISPLAY). Addition 5 ... MEMORY ID pid Effect On the selection screen, assigns the memory ID pid to the parameter, i.e. when you execute the report, the selection screen displays the last value which the user entered in a field with the memory ID pid. Note The memory ID must be a constant, i.e. a value specified without quotation marks, and can be up to 3 characters long. Addition 6 ... MATCHCODE OBJECT mobj Effect On the selection screen, assigns the matchcode object mobj to the parameter. Note The name of the matchcode object must be a constant, i.e. a value specified without quotation marks, and can be up to 4 characters long. Addition 7 ... MODIF ID key Effect The screen fields contain the specified modification group (SCREEN-GROUP1) which you can use for screen modifications (e.g. set to "not ready for input") under AT SELECTION-SCREEN. Note The name of the modification group must be a constant, i.e. a value specified without quotation marks, and can be up to 3 characters long. Example PARAMETERS CHARLY MODIF ID ABC. ... AT SELECTION-SCREEN OUTPUT. LOOP AT SCREEN. IF SCREEN-GROUP1 = 'ABC'. SCREEN-INPUT = '0'. MODIFY SCREEN. ENDIF. ENDLOOP. ... Effect The parameter is not ready for input on the selection screen. Addition 8 ... NO-DISPLAY Effect Does not display the parameter on the selection screen. With "normal" parameters, the associated data object is created and the parameter can be passed when SUBMIT is executed. These parameters are the part of the report interface not presented to the user on the selection screen. You can set the parameter values either internally (with the routine INIT in the SAPDBldb or at INITIALIZATION) or pass them when SUBMIT is executed. These parameters are also stored along with the variants. If, under certain circumstances (e.g. because of the values of other parameters or due to the selection options), you want to present the parameter to the user for input, you can do this in the PAI modlue of the database program SAPDBldb (for database-specific parameters) or under AT SELECTION-SCREEN (for report-specific parameters) by calling a function module (CALL FUNCTION ) or your own screen (CALL SCREEN< />). Note Since the parameter is not generated on the selection screen, the NO-DISPLAY parameters do not allow you to use any of the additions concerning the display and handling of parameters on the selection screen. Addition 9 ... LOWER CASE Effect The parameter is not case-sensitive (i.e. allows both upper and lower case). Addition 10 ... OBLIGATORY Effect Makes an entry on the selection screen compulsory. Addition 11 ... AS CHECKBOX Effect Displays the parameter as a checkbox on the selection screen. Since you are not allowed to specify type or length when defining this parameter, it always has the type C and the length 1 as default values. The checkbox is displayed on the left and the associated text on its right. To define any order other than this, use the SELECTION-SCREEN statement. Note If LIKE refers to an ABAP/4 Dictionary field, you cannot use the addition AS CHECKBOX. If the ABAP/4 Dictionary field has the type CHAR, a length of 1 and the fixed values 'X' and ' ' (according to the relevant domain), the parameter is always displayed as a checkbox on the selection screen. Addition 12 ... RADIOBUTTON GROUP radi Effect Displays the parameter on the selection screen as a radio button (selection field). All parameters assigned in this way to the same group radi (which can be up to 4 characters long) form a group of radio buttons on the selection screen, i.e. if the user presses one of these buttons, the others are set to "not pressed". When you define one of these parameters, you are not allowed to make type or length specifications. However, you can use LIKE to point to a field of length 1 and type C. The addition has no effect on the ordering of the parameter (as is the case with the addition AS CHECKBOX). You can make changes to the order with the SELECTION-SCREEN. Note A RADIOBUTTON group must contain at least two parameters. One of these can have a DEFAULT addition and the DEFAULT value must be 'X'. In the database INCLUDE DBldbSEL, a RADIOBUTTON parameter must include the addition FOR TABLE dbtab just like any other parameter. All parameters in a group must belong to the same table dbtab. A group name radi used in the DBldbSEL cannot be used in the report. In contrast to "normal" parameters, the event AT SELECTION-SCREEN ON p is not executed (it is not even allowed syntactically). Instead, the event AT SELECTION-SCREEN ON RADIOBUTTON GROUP radi exists for the entire group. If an E message or a W message is output, all radio buttons in the group are ready for input. Addition 13 ... FOR TABLE dbtab Effect Assigns the database-specific parameter p to the table dbtab. This addition only makes sense in a logical database access program. With database-specific parameters, you need this addition to ensure that the selection screen for a report contains only database-specific parameters which belong to a table from the currently active report. Addition 14 ... AS MATCHCODE STRUCTURE Effect Creates the database-specific parameter p as a field string according to the Dictionary structure MCPARAMS with the fields MCID (matchcode ID) and STRING (search string). Used for data selection through matchcode entry. On the selection screen, both sub-fields are displayed in a box with the text "Matchcode selection". You can get a list of possible entries for the matchcode ID and the search string by pressing F4. If you choose a matchcode ID and press F4 in the field "Search string", you see a dialog box where you can enter a search criterion for each field of the matchcode ID. The system interprets what you enter generically for each sub-field. Note The addition AS MATCHCODE STRUCTURE only makes sense in a logical database access program and must therefore be used together with the addition FOR TABLE. It can also be combined with the addition MODIF ID, but not with any other additions. The matchcode object to which the matchcode ID and the search string refer is determined when you define the logical database. Example Input on the selection screen: Matchcode ID: Customers Search string: Daniel The effect of this is to select all customers whose names begin with "Daniel". Note Performance: Matchcode selection can improve program performance considerably. This is because specifying a search string often describes the required set of data records more accurately than the key fields of the table. For example, it is easier to select by name ("Daniel") than by customer number ("000043010") and far fewer records are read from the database. Note If a logical database (e.g. ldb) contains a parameter p defined with AS MATCHCODE STRUCTURE, the system always creates an internal table ldb_MC which includes all the key fields of the selected records. The structure of ldb_MC is determined by the matchcode object and generated automatically. In the maintenance transaction for logical databases, the structure is displayed as a comment in the database program. Example Matchcode object for table T1 with key field T1-K1. The table ldb_MC then has the following structure: DATA: BEGIN OF ldb_MC OCCURS 100, T1_K1 LIKE T1-K1, END OF ldb_MC. Note If the user has entered values in the matchcode parameter fields, the program reads the selected data from the matchcode table after START-OF-SELECTION and makes it available to the logical database program in the internal table ldb_MC. Then, the database program processes the records in the subroutine PUT_ldb_MATCHCODE and, with the help of PUT, triggers the appropriate GET events in the report. Subsequent processing is exactly the same as that for data selection direct from the database. Example FORM PUT_ldb_MATCHCODE. SELECT * FROM T1 WHERE K1 = ldb_MC-T1_K1 FOR ALL ENTRIES IN ldb_MC. PUT T1. ENDSELECT. ENDFORM. Note In matchcode selection, the system flags all fields in the internal table MC_FIELDS which are filled with values by the matchcode (the field name is in MC_FIELDS-FIELDNAME and the flag is in MC_FIELDS-SUPPLIED). Example A field F0 is supplied with a value by the matchcode if the following condition is satisfied: IF MC_FIELDS-FIELDNAME EQ 'F0' AND MC_FIELDS-SUPPLIED NE SPACE. Note Further documentation: - In the maintenance transaction for logical databases, select Help -> Extended help - In the editor: logical databases (LDB) Addition 15 ... VALUE-REQUEST Effect This addition is only allowed for database-specific parameters in the INCLUDE DBldbSEL. It permits self-programmed value help (for report-specific parameters, this is achieved by specifying the event key word AT SELECTION-SCREEN ON VALUE-REQUEST FOR ...). The addition has the following effect: 1. On the selection screen, the parameter has a button for requesting possible entries. 2. When the user presses this button or F4, this starts the FORM routine p_VAL in the database access program SAPDBldb (if it exists). Then - even if the parameter with LIKE points to a Dictionary field - this FORM routine is processed rather than displaying the check table or the fixed values of the Dictionary field. You can also branch from the routine p_VAL to a function module which offers a selection list of possible values. At the end of the FORM routine, the contents of the field p are copied to the appropriate input/output field. Example * INCLUDE DBXYZSEL ... PARAMETERS PL_TYPE LIKE SAPLANE-PLANETYPE VALUE-REQUEST. ... REPORT SAPDBXYZ DEFINING DATABASE XYZ. ... TABLES SAPLANE. ... FORM PL_TYPE_VAL. ... CALL FUNCTION ... ... ENDFORM. Addition 16 ... HELP-REQUEST Effect Like VALUE-REQUEST, this addition is only allowed for database-specific parameters in the INCLUDE DBldbSEL. It permits self-programmed value help (for report-specific parameters, this is achieved by specifying the event key word AT SELECTION-SCREEN ON VALUE-REQUEST FOR ...). When the user presses F1, this starts the FORM routine p_HLP in the database access program SAPDBldb (if it exists). Then - even if the parameter with LIKE points to a Dictionary field - this FORM routine is processed rather than displaying the data element documentation of the Dictionary field. You can also branch from the routine p_HLP to a function module which displays its own documentation. Example * INCLUDE DBXYZSEL ... PARAMETERS PL_TYPE LIKE SAPLANE-PLANETYPE HELP-REQUEST. ... REPORT SAPDBXYZ DEFINING DATABASE XYZ. ... TABLES SAPLANE. ... FORM PL_TYPE_HLP. ... CALL FUNCTION ... ... ENDFORM. PERFORM Variants: 1. PERFORM form. 2. PERFORM form(prog). 3. PERFORM form IN PROGRAM prog. 4. PERFORM n OF form1 form2 form3 ... . 5. PERFORM n ON COMMIT. Variant 1 PERFORM form. Additions: 1. ... USING p1 p2 p3 ... 2. ... CHANGING p1 p2 p3 ... 3. ... TABLES itab1 itab2 ... Effect Calls the subroutine form specified in the FORM statement. On completion, processing in the main program resumes. Example PERFORM HELP_ME. ... FORM HELP_ME. ... ENDFORM. The PERFORM statement calls the subroutine HELP_ME. Notes 1. Nested calls are allowed (i.e. PERFORM within a FORM ... ENDFORM). 2. Recursive calls are also possible. 3. To define local data, use the DATA statement after FORM. Each time you enter the subroutine, the data is recreated (with an initial value) and released at the end (from the stack). 4. To define global data used within a subroutine, use the LOCAL statement after FORM. The values are saved when you enter the subroutine and then released at the end (from the stack). Note Runtime errors: - PERFORMANCE_PARAMETER_MISSING: The called form expects more parameters than were specified. - PERFORM_PARAMETER_COUNT, - PERFORM_TOO_MANY_PARAMETERS: More parameters were given than the FORM expected. - PERFORM_CONFLICT_TYPE, - PERFORM_CONFLICT_GENERIC_TYPE, - PERFORM_BASE_WRONG_ALIGNMENT, - PERFORM_PARAMETER_TOO_SHORT, - PERFORM_TABLE_REQUIRED: The parameter type does not match the type specified in the FORM definition. - PERFORM_BASE_LITL: A literal was passed to a structured parameter. Addition 1 ... USING p1 p2 p3 ... Addition 2 ... CHANGING p1 p2 p3 ... Effect These additions are equivalent to each other. For documentation reasons however, you should use the same one as with the associated FORM definition. Both additions pass the parameters p1 p2 p3 ... to the called subroutine. You can use as many parameters as you like. Sequence is important here because the first parameter of the PERFORM call is passed to the first parameter of the FORM definition, the second to the second and so on. You can use the following as parameters: - DATA fields (see DATA) - Field strings (see DATA BEGIN OF) - Literals - Field symbols (see FIELD-SYMBOLS) Parameter offset and length can be passed as variables. The addition '...USING p1+off(*)' causes parameter p1 to be passed with offset off so that the field limits of p1 are not exceeded. Example DATA: NUMBER_I TYPE I VALUE 5, NUMBER_P TYPE P VALUE 4, BEGIN OF PERSON, NAME(10) VALUE 'Paul', AGE TYPE I VALUE 28, END OF PERSON, ALPHA(10) VALUE 'abcdefghij'. FIELD-SYMBOLS . ASSIGN NUMBER_P TO . PERFORM CHANGE USING 1 NUMBER_I NUMBER_P PERSON ALPHA+NUMBER_I(). FORM CHANGE USING VALUE(PAR_1) PAR_NUMBER_I PAR_NUMBER_P PAR_POINTER PAR_PERSON STRUCTURE PERSON PAR_PART_OF_ALPHA. ADD PAR_1 TO PAR_NUMBER_I. PAR_NUMBER_P = 0. PAR_PERSON-NAME+4(1) = ALPHA. PAR_PERSON-AGE = NUMBER_P + 25. ADD NUMBER_I TO PAR_POINTER. PAR_PART_OF_ALPHA = SPACE. ENDFORM. Field contents after the PERFORM call are as follows: NUMBER_I = 6 NUMBER_P = 6 = 6 PERSON-NAME = 'Paula' PERSON-AGE = 25 ALPHA = 'abcde j' Note 1. The field type and length of the parameters remain. If parameter values change within the subroutine, these new values remain after you leave the subroutine. However, this does not apply to parameters passed with VALUE (see FORM). 2. If you pass literals, you must either leave them unchanged or pass them in the FORM definition with the USING VALUE statement. Addition 3 ... TABLES itab1 itab2 ... Effect You use TABLES to pass internal tables to subroutines. Example DATA: BEGIN OF ITAB OCCURS 100, TEXT(50), NUMBER TYPE I, END OF ITAB. STRUC LIKE T005T. ... PERFORM DISPLAY TABLES ITAB USING STRUC. FORM DISPLAY TABLES PAR_ITAB STRUCTURE ITAB USING PAR STRUCTURE T005T. DATA LOC_COMPARE LIKE PAR_ITAB-TEXT. WRITE: / PAR-LAND1, PAR-LANDX. ... LOOP AT PAR_ITAB WHERE TEXT = LOC_COMPARE. ... ENDLOOP. ... ENDFORM. Within the subroutine DISPLAY, you can apply all the available table operations to the internal tables passed. Note TABLES must always appear first in the PERFORM call. It must not be preceded by an addition. Variant 2 PERFORM form(prog). Additions: 1. ... USING p1 p2 p3 ... 2. ... CHANGING p1 p2 p3 ... 3. ... TABLES itab1 itab2 ... 4. ... IF FOUND Effect Calls the subroutine form defined in the program prog (i.e. external PERFORM). Notes 1. Parameter passing to the external subroutine is the same as in variation 1. 2. Parameter passing can be implemented by using a common data area (see DATA BEGIN OF COMMON PART). 3. Nested calls are possible, even with several external subroutines from different programs. 4. If you call a subroutine of a program prog, the system loads the program progSE_VALID contains ' '. Field contents (header lines) during the third loop pass: SE-FROM = '01101991' SE-TO = '04101991' SE-NAME = ' ' SE-AGE = 0 PR-START = '01101991' PR-END = '04101991' PR-PRICE = 0 PR-NAME = 'Car' SH-CLOSED = '04101991' SH-STR = 'Gold Avenue' SH-OPENED = '01101991' Notes 1. Strictly speaking, if you imagine each range as a short way of writing a set of single values, this is an "outer join" of the tables. 2. After ENDPROVIDE, the contents of the system fields SY-INDEX, SY-TABIX and SY-SUBRC are undefined. 3. Neither the header lines nor the actual table lines of the table specified with PROVIDE should be changed between PROVIDE and ENDPROVIDE. Otherwise, the PROVIDE results are undefined. Related LOOP AT itab PUT Basic form PUT dbtab. Effect This statement is only to be used in the access program of the logical database where the table dbtab occurs. "PUT dbtab." triggers the event "GET dbtab." in the relevant report. Then, it calls the PUT suroutines of the immediately following tables in the structure, provided that GET events exist for subsequent tables in the report. Note The work areas of the tables defined in the database program and in the report are used together. As a result, the contents of dbtab at the time of the PUT statement are also automatically available in the corresponding GET event. Related GET, CHECK, REJECT RAISE Basic form RAISE except. Effect This statement only makes sense if used in conjunction with function modules. It triggers the exception except. If the program calling the function module is to handle the exception (see CALL FUNCTION), control returns immediately to that program and the EXPORT parameters of the function module are not assigned values. Otherwise, the program terminates with a suitable error message. Example The function module STRING_SPLIT would look something like the code specified below (see also the example for CALL FUNCTION): FUNCTION-POOL CSTR. FUNCTION STRING_SPLIT. ... IF STRING NA DELIMITER. RAISE NOT_FOUND. ENDIF. ... ENDFUNCTION. The calling program may then contain the code: PROGRAM EXAMPLE. ... CALL FUNCTION 'STRING_SPLIT' * ... EXCEPTIONS NOT_FOUND = 7. IF SY-SUBRC = 7. WRITE / 'There is a problem.'. ELSE. ... ENDIF. If the RAISE statement in the function module STRING_SPLIT triggers the exception NOT_FOUND, processing of the function module terminates and returns to the calling program. In this case, the return code, which you read directly after the CALL FUNCTION statement, contains the value 7. Related MESSAGE ... RAISING RANGES Basic form RANGES sel FOR f. Effect Defines an internal table similar to a selection criterion sel defined using the SELECT-OPTIONS sel FOR f statement. The above statement is identical to: DATA: BEGIN OF sel OCCURS 10, SIGN(1), OPTION(2), LOW LIKE f, HIGH LIKE f, END OF sel. Note If you use the IN operator in conjunction with SUBMIT, CHECK, IF, WHILE or SELECT, always define the associated internal table using SELECT-OPTIONS or RANGES (never directly). Addition ... OCCURS occ Effect Changes the OCCURS value 10 to the value of occ. READ Read an internal table - READ TABLE itab. / READ TABLE itab INTO wa. Read a list line - READ LINE lin. - READ LINE lin OF CURRENT PAGE. - READ LINE lin OF PAGE pag. - READ CURRENT LINE. Read a program - READ REPORT prog INTO itab. Read text elements - READ TEXTPOOL prog ...INTO itab ...LANGUAGE lg. Read a file - READ DATASET dsn INTO f. Read a database table - READ TABLE dbtab. Determine calendar information - In R/2: READ CALENDAR. READ - Determine calendar information The READ CALENDAR statement exists only in the R/2 System. In the R/3 System, the following function modules are substituted: - DATE_COMPUTE_DAY: Returns the day for a date - DATE_CONVERT_TO_FACTORYDATE: Returns the factory calendar date for a date - DATE_GET_WEEK: Returns the week in which a date occurs - EASTER_GET_DATE: Returns the Easter dates for a year - FACTORYDATE_CONVERT_TO_DATE: Returns the date for a factory calendar date - HOLIDAY_CHECK_AND_GET_INFO: Checks whether a date is a public holiday and, if necessary, returns information - WEEK_GET_FIRST_DAY: Returns the first day of a week READ - Read a file Basic form READ DATASET dsn INTO f. Addition: ... LENGTH len Effect Reads a record from the sequential file specified in dsn (a field or a literal) and stores it in the field f (usually a field string). - Binary mode (addition IN BINARY MODE in the OPEN DATASET statement: Read from file in length of field f. - Text mode (addition IN TEXT MODE in the OPEN statement): Read a line. If the specified file is not open, READ DATASET attempts to open the file dsn (IN BINARY MODE FOR INPUT or with the specifications of the last OPEN command for this file). Any errors result in the termination of the program. To read all the records in a file, you are recommended to place READ DATASET in a DO loop that you leave with EXIT. The return code value is set as follows: SY-SUBRC = 0: Record read from file. SY-SUBRC = 4: End of file reached. Example Define the field string REC: DATA: BEGIN OF REC, TEXT(30), NUMBER TYPE I, END OF REC. Read the file "/usr/test": DO. READ DATASET '/usr/test' INTO REC. IF SY-SUBRC <> 0. EXIT. ENDIF. WRITE: / REC-TEXT, REC-NUMBER. ENDDO. Notes - You can use TRANSFER to output records to a sequential dataset. - The format of file names depends largely on the operating system. You can access portable programs by using the function module FILE_GET_NAME which returns the physical name for a given logical file name. Addition ... LENGTH len Effect Stores the length of the record read from the file in the field len. READ - Read a list line Variants: 1. READ LINE lin. 2. READ LINE lin OF CURRENT PAGE. 3. READ LINE lin OF PAGE pag. 4. READ CURRENT LINE. Variant 1 READ LINE lin. Additions: 1. ... INDEX idx 2. ... FIELD VALUE f1 INTO g1 ... fm INTO gm Effect Reads line no. lin in the list, for instance by line selection (AT LINE-SELECTION, AT PFxx, AT USER-COMMAND). Places the read line in the field SY-LISEL and automatically restores all 'hidden' information (see HIDE) to the original fields. Sets the output format of the read line for all subsequent MODIFY LINE and WRITE statements. The return code value is set as follows: SY-SUBRC = 0: Line exists SY-SUBRC <> 0: Line does not exist Addition 1 ... INDEX idx Effect With multiple line selection, reads the line from the list generated in level idx (0,1,2,...). Addition 2 ... FIELD VALUE f1 INTO g1 ... fm INTO gm Effect Transports the contents of the fields f1, f2, ... from the read list line to the fields g1, g2, ... . (The field contents stored in the list line always have the type C; type conversion is the same as for MOVE.) Note All formatting characters in the list output of f1, f2, ... count as field contents. If a field is output several times on the selected line, only the first occurrence is taken into account. If the field (such as f2) is not output on the line at all, the field g2 remains unchanged. The addition INTO g2, for example, can be omitted if the field contents are to be restored to the original field (e.g. f2), i.e. ... FIELD VALUE ... f2 has the same effect as ... FIELD VALUE ... f2 INTO f2 Since the return code value in SY-SUBRC is not affected by the addition FIELD VALUE, it depends only on the existence of the selected list line. Note The addition FIELD VALUE is especially suitable for processing user input in list fields (see FORMAT, WRITE) in the program. (Field contents entered by the user cannot be addressed with HIDE.) Example You can make a line "selectable" with DATA MARKFIELD(1) TYPE C. ... WRITE: / MARKFIELD INPUT, 'Text'. After line selection, you can use CLEAR MARKFIELD. READ LINE SY-CUROW FIELD VALUE MARKFIELD. in the program to check whether the user has selected the line or not (IF MARKFIELD = SPACE ...). Variant 2 READ LINE lin OF CURRENT PAGE. Additions: As with variant READ LINE Effect As with variant READ LINE lin. The line number lin refers to the current page (as specified in the system field SY-CPAGE at the beginning of the current event. If the contents of SY-CPAGE is changed by the application program, this does not affect the display.) Notes 1. With multiple level line selection, the read operation is always take place in the list where line selection was performed. 2. When returning from line selection, the system always resets the positioning to the last page displayed. (For scrolling purposes, you can use the SCROLL statement.) Variant 3 READ LINE lin OF PAGE pag. Additions: As with variant READ LINE Effect As with variant 2, but reads the page pag instead of the current page. Variant 4 READ CURRENT LINE. Addition: ... FIELD VALUE f1 INTO g1 ... fm INTO gm Effect Reads the last line to be read (by line selection or with READ LINE) once again. You can use this variant, for example, in connection with the addition FIELD VALUE (see below) .u.) if you want to retrieve field contents from the selected line (in cases where you cannot retrieve from the HIDE area). Addition ... FIELD VALUE f1 INTO g1 ... fm INTO gm Effect See addition 2 of the variant READ LINE lin READ - Read a program Basic form READ REPORT prog INTO itab. Effect Reads the program prog from the database into the internal table itab. Table itab should be at least 72 lines long. The return code value is set as follows: SY-SUBRC = 0: Program was read. SY-SUBRC <> 0: Program could not be read. Example DATA: PROGRAM LIKE SY-REPID VALUE 'PROGNAME', BEGIN OF T OCCURS 500, LINE(72), END OF T. READ REPORT PROGRAM INTO T. IF SY-SUBRC <> 0. ... ENDIF. READ - Read an internal table Basic form READ TABLE itab. READ TABLE itab INTO wa. Additions: 1a. ... WITH KEY k1 = v1 ... kn = vn 1b. ... WITH KEY = value 1c. ... WITH KEY key 2. ... BINARY SEARCH 3. ... INDEX idx 4a. ... COMPARING f1 f2 ... 4b. ... COMPARING ALL FIELDS 5a. ... TRANSPORTING f1 f2 ... 5b. ... TRANSPORTING NO FIELDS Effect Reads an internal table entry. An entry can be chosen using a key or its index. With "READ TABLE itab.", the header line of the internal table itab is used as the output area; with "READ TABLE itab INTO wa." the explicity specified work area wa is used for this purpose. The return code value of SY-SUBRC specifies whether a suitable entry was found. In turn, this determines the value of the table index SY-TABIX. SY-SUBRC = 0: Entry found SY-TABIX is set to the index of the found entry. SY-SUBRC <> 0: Entry not found The value of SY-TABIX is undefined. The output area remains unchanged. Note In the case of internal tables with a header, a table line can be accessed without specifying an explicit key (addition: WITH KEY ...) or index (addition: INDEX idx). The system then uses (as an implicit key) all table header fields that are not number fields (type I, F, P), are not tables themselves (compare default keysof internal tables) and whose contents are unequal to SPACE. It searches for the first entry which matches the header in all key fields and transfers this entry into the output area. The implicit key is only set up (dynamically) at runtime. If the search key is already known at the time of generation (static), the read with an explicit key is faster than with an implicit key, and is therefore preferable. Addition 1a ... WITH KEY k1 = v1 ... kn = vn Effect Accesses the first entry which matches v1 ... vn in the components specified with k1 ... kn. Here, the component type forms the basis for the comparison between the components and the values. If the type of a value and the type of a component are not compatible, the value is converted to the type of the component before the read access is performed. Notes 1. If a component is not determined until runtime, you can use WITH KEY ... (ni) = vi ... to specify it dynamically as the contents of the field ni. If ni is empty at runtime, the component is ignored. If ni contains an invalid component name, a runtime error occurs. 2. You can use offset and/or length specifications to further restrict components, regardless of whether they have been specified statically or dynamically. Addition 1b ... WITH KEY = value Effect Accesses the first entry which matches value. In this case, the type of the table line forms the basis for the comparison between table lines and the specified value. If the type of the specified value and the type of the table line are not compatible, the specified value is converted to the type of the table line before the read access is performed. Note Even with internal tables containing lines with no components, the addition WITH KEY = value allows you to access an entry via an explicity specified key. Internal tables without line components result when you define internal tables directly via an elementary data type or a table type, but not via a field string. Addition 1c ... WITH KEY key Effect Accesses the first entry which begins with key (left-justified). The type of the specified key forms the basis for the comparison between table lines and the specified key. Note The key key can be neither a table nor a structure that contains tables as components. Note Runtime error (only when using addition 1c): - READ_BAD_KEY_ALIGN: The alignment requirements of the key take priority over those of individual table lines. - READ_BAD_KEY_PARTIAL: The key is longer than a table line and cannot be shortened. Addition 2 ... BINARY SEARCH Effect The addition BINARY SEARCH only makes sense with one of the WITH-KEY additions (1a-1c). The read access is performed using a binary search method and is non-sequential. It is assumed that the internal table is sorted in ascending order according to the specified key, with addition 1a in the order of the specified key fields. If the specified key is not unique, the entry with the lowest index is placed in the output area. The return code value of SY-SUBRC specifies whether a suitable entry was found. In turn, this determines the value of the table index SY-TABIX. SY-SUBRC = 0: Entry found SY-TABIX is set to the index of the found entry SY-SUBRC <> 0: Entry not found The output area remains unchanged. SY-SUBRC = 4: SY-TABIX points to the next largest entry. SY-SUBRC = 8: The key sought is greater than that of the last table entry. SY-TABIX is set to (number of all entries + 1). Example DATA: BEGIN OF INT_TABLE OCCURS 100, COMP1, COMP2, COMP3, END OF INT_TABLE. FORM PUT_ENTRY USING ENTRY LIKE LINE OF INT_TABLE. READ TABLE INT_TABLE WITH KEY COMP2 = ENTRY-COMP2 BINARY SEARCH TRANSPORTING NO FIELDS. IF SY-SUBRC <> 0. INSERT ENTRY INTO INT_TABLE INDEX SY-TABIX. ENDIF. ENDFORM. The method used in this subroutine makes it easy (and desirable for performance) to add new entries to a table and sort them. Before PERFORM PUT_ENTRY, you fill the transferred work area ENTRY with the new values. The READ statement checks (in the sorted internal table INT_TABLE) whether an entry with the specified key already exists. The system fields SY-SUBRC and SY-TABIX are set accordingly. Then, if (SY-SUBRC <> 0), the new entry is inserted at the appropriate place. Addition 3 ... INDEX idx Effect Accesses the entry with the index idx of an internal table. The return code value of SY-SUBRC specifies whether a suitable entry was found. In turn, this determines the value of the table index SY-TABIX. SY-SUBRC = 0: Entry found SY-TABIX is set to the index of the found entry. SY-SUBRC <> 0: Entry not found The value of SY-TABIX is undefined. The output area remains unchanged. Addition 4a ... COMPARING f1 f2 ... Effect This addition has no effect on the read process itself, i.e. it is normally used together with one of the additions 1, 2 or 3. Only when an entry - regardless of the read method - already exists does this addition cause the contents of the sub-fields f1, f2, ... of the found entry to be compared with the corresponding fields of the output area before transporting the found entry to the output area. The return code value of SY-SUBRC specifies whether the value sought was found and, if so, the result of the comparison: SY-SUBRC = 0: Entry found, field contents identical SY-SUBRC = 2: Entry found, field contents different SY-SUBRC > 2: Entry not found If you want to indicate explicitly that no fields are compared (even though this is the default), you can use COMPARING NO FIELDS. Notes 1. If you use COMPARING together with an explicitly specified work area, the lattter must be compatible with the line type of the internal table. 2. If a comparison criterion is not known until runtime, you can use COMPARING ... (name) ... to specify it dynamically as the contents of the name. If name is blank at runtime, the comparison criterion is ignored. If name contains an invalid component name, a runtime error occurs. 3. You can use offset and/or length specifications to further restrict comparison criteria, regardless of whether they have been specified statically or dynamically. 4. If you use READ TABLE itab in its basic form (i.e. without one of its additions 1, 2 or 3, the addition COMPARING f1 f2 ... makes sense only if the fields f1, f2, ... are not part of the read key, i.e. if f1, f2, ... are number fields (type I, F or P). Addition 4b ... COMPARING ALL FIELDS Effect As with addition 4a, but compares all sub-fields. Addition 5a ... TRANSPORTING f1 f2 ... Effect If an entry is found, not all sub-fields are transported to the output area (default), but only the specified sub-fields f1, f2, ...; the other sub-fields remain unchanged. If you want to indicate explicitly that all fields are transported (even though this is the default), you can use TRANSPORTING ALL FIELDS. Notes 1. If you use TRANSPORTING f1 f2 ... together with an explicitly specified output area, the latter must be compatible with the line type of the internal table. 2. If a transport field is not known until runtime, you can use TRANSPORTING ... (name) ... to specify it dynamically as the contents of the name. If name is blank at runtime, the transport criterion is ignored. If name contains an invalid component name, a runtime error occurs. 3. You can use offset and/or length specifications to further restrict transport fields, regardless of whether they have been specified statically or dynamically. 4. If you use the additions "COMPARING" and "TRANSPORTING" together, "COMPARING" must come before "TRANSPORTING". Addition 5b ... TRANSPORTING NO FIELDS Effect Does not change the output area of the internal table. The only purpose of the access is to set the system fields SY-SUBRC and SY-TABIX. Note Performance: 1. The fastest way of reading a single record from an internal table is to make a direct access by specifying an index, because this is not dependent on the number of table entries and is much the same as the cost of transporting one line. If you use a key to access the table, the required runtime increases with the number of lines and the size of the search key. A binary search is considerably faster than a linear search. Therefore, it is usually advisable to keep the table sorted and to use the addition BINARY SEARCH. Reading a record from a table with 100 entries with an index specification requires about 7 msn (standardized microseconds). Access with a 30-byte wide key takes about 25 msn. with a binary search, and about 100 msn. without a binary search. 2. If you use statements with an explicit work area for internal tables with a header line, you can avoid unnecessary assignments. READ - Read a database table Basic form READ TABLE dbtab. Additions: 1. ... SEARCH FKEQ 2. ... SEARCH FKGE 3. ... SEARCH GKEQ 4. ... SEARCH GKGE 5. ... WITH KEY key 6. ... VERSION vers Note This variant is no longer maintained and should therefore not be used (see also obsolete lanuguage elements). Please use a SELECT (SINGLE) statement instead. Effect Accesses the database table dbtab The table dbtab must be declared under TABLES in the program. dbtab is a table name which begins with "T" and comprises no more than five characters altogether. You must fill the argument fields of the table first; then you can use READ TABLE to make direct access to the table entry. Example Declare table: TABLES T006. Fill argument fields: MOVE: '001' TO T006-MANDT, 'STD' TO T006-MSEHI. Access: READ TABLE T006. Process fields: WRITE T006-DIMID. Addition 1 ... SEARCH FKEQ Full Key Equal (Default) Addition 2 ... SEARCH FKGE Full Key Greater or Equal Addition 3 ... SEARCH GKEQ Generic Key Equal Addition 4 ... SEARCH GKGE Generic Key Greater or Equal Effect Access table using one of the above search methods. Note You can only specify one of the additions 1 - 4 Addition 5 ... WITH KEY key Effect Access table with the key key. Addition 6 ... VERSION vers Note You should use this addition only if absolutely necessary. In some cases, it is possible (and it makes sense) to avoid this READ addition by using a generation program. Effect Specifies a dynamically definable table name. The field vers must be a 4-character C field which contains the table name. It is generally declared under PARAMETERS and evaluated at runtime. The entry read is always made available in the permanently assigned table T... The return code value of SY-SUBRC specifies whether a suitable entry was found: SY-SUBRC = 0: Entry found SY-SUBRC <> 0: Entry not found If the entry is not found, the system automatically sets the function part of the table entry to SPACE. READ - Read text elements Basic form READ TEXTPOOL prog ... INTO itab ... LANGUAGE lg. Parts marked with " ..." are interchangeable Effect Reads the text elements for the program prog and the language lg from the library into the internal table itab. The line structure of the table itab is described in the section on text elements The return code value is set as follows: SY-SUBRC = 0: Text elements were read. SY-SUBRC <> 0: Unable to read text elements. Example Read text elements for the program PROGNAME: DATA: PROGRAM(8) VALUE 'PROGNAME', TAB LIKE TEXTPOOL OCCURS 50 WITH HEADER LINE. READ TEXTPOOL PROGRAM INTO TAB LANGUAGE SY-LANGU. Related INSERT TEXTPOOL, DELETE TEXTPOOL RECEIVE Basic form RECEIVE RESULTS FROM FUNCTION func. Additions: 1. ... IMPORTING p1 = f1 ... pn = fn 2. ... TABLES p1 = itab1 ... pn = itabn 3. ... EXCEPTIONS except1 = rc1 ... exceptn = rcn Effect Used within a FORM routine to receive the results of an asynchronous function module call (CALL FUNCTION func STARTING NEW TASK task name) as IMPORTING or TABLES parameters. In addition, the FORM routine must have a placeholder to receive the task name (e.g. when you use USING task name). See example below. Notes This key word occurs only with the function module call CALL FUNCTION func STARTING NEW TASK task name. If the function module returns no results, this part need not be defined. This key word is new from Release 3.0. Therefore, both partner systems (client and server) must have Release 3.0 of the R/3 System. Addition 1 ... IMPORTING p1 = f1 ... pn = fn Effect IMPORTING returns the values of fields and field strings from the function module to the calling program. In the function module, the formal parameters are defined as export parameters. You can pass any number of export parameters. Addition 2 ... TABLES p1 = itab1 ... pn = itabn Effect The TABLES statement contains references to internal tables. All table parameters of the function module must be covered. Addition 3 ... EXCEPTIONS except1 = rc1 ... exceptn = rcn Effect Under EXCEPTIONS, you execute the exceptions handled by the calling program itself. At the end of the exception list, you can use OTHERS to refer to all remaining exceptions. If one of the listed exceptions occurs, SY-SUBRC is set to the assigned value rc (number literal!) and control passes to the calling program. By specifying a return code, you can group exceptions into classes. With the second form, without "= rc", SY-SUBRC is set to a value other than 0 if an exception occurs. If the function module triggers an exception (RAISE and MESSAGE ... RAISING) not meant to be handled by the program itself, - RAISE terminates the program with a runtime error; - MESSAGE ... RAISING outputs the message. Note The following EXCEPIONS are predefined by the system and have a special meaning: - OTHERS: Covers all user-defined exceptions in the calle function module - ERROR_MESSAGE: Specifcation of this exception means that S messages, I messages and W messages are ignored until return from the function module (although, in the case of background jobs, thery appear in the log). If an E message or an A message occurs, the called function module terminates, as if the exception ERROR_MESSAGE had been triggered. Example DATA: INFO LIKE RFCSI, * Result of RFC_SYSTEM_INFO function SYSTEM_MSG(80) VALUE SPACE. * Exception handling CALL FUNCTION 'RFC_SYSTEM_INFO' STARTING NEW TASK 'INFO' PERFORMING 'RETURN_INFO' ON END OF TASK. WRITE: 'Wait for reply'. ... AT USER-COMMAND. * Return from FORM routine RETURN_INFO IF SYSTEM_MSG = SPACE. WRITE: 'Destination =', INFO-RFCDEST. ELSE. WRITE SYSTEM_MSG. ENDIF. ... FORM RETURN_INFO USING TASKNAME. RECEIVE RESULTS FROM FUNCTION 'RFC_SYSTEM_INFO' IMPORTING RFCSI_EXPORT = INFO EXCEPTIONS SYSTEM_FAILURE MESSAGE SYSTEM_MSG. REFRESH SCREEN. "Simulate command field = return key ENDFORM. RECEIVE_ILLEGAL_SWITCH REFRESH Delete an internal table - REFRESH itab. - REFRESH itab FROM TABLE dbtab. - REFRESH itab FROM SELECT-OPTIONS. Refresh the SAPGUI interface - REFRESH SCREEN. Initialize a control - REFRESH CONTROL ctrl FROM SCREEN scr. REFRESH - Initialize a control Basic form REFRESH CONTROL ctrl FROM SCREEN scr. Effect Initializes the control ctrl defined by a CONTROLS statement according to its description in the screen scr. The screen scr does not have to match the initial screen for the control (see also ABAP/4 table control). Related CONTROLS REFRESH - Delete an internal table Variants: 1. REFRESH itab. 2. REFRESH itab FROM TABLE dbtab. 3. REFRESH itab FROM SELECT-OPTIONS. Variant 1 REFRESH itab. Effect The internal table itab is reset to its initial state, i.e. all table entries are deleted. The return code value SY-SUBRC is undefined Notes - The header entry of a table with a header line remains unchanged. It can be reset to its initial value using CLEAR. - FREE itab can be used to free up the memory allocated to the table. Variant 2 REFRESH itab FROM TABLE dbtab. Note This variant is no longer maintained and should no longer be used (see also obsolete language constructs). Please use the SELECT ... INTO TABLE statement instead. Effect The internal table itab is deleted and it is then filled with the contents of the database table dbtab. A generic argument can be used to specify a restriction to a particular part of the database table when filling (LOOP AT dbtab, READ TABLE dbtab). The table dbtab must be declared in the program using TABLES. The return code value SY-SUBRC is undefined Example Deleting an internal table MESSAGES, followed by filling the table with all messages from the table T100 with language key 'D' and ID 'RF'. TABLES T100. DATA BEGIN OF MESSAGES OCCURS 200. INCLUDE STRUCTURE T100. DATA END OF MESSAGES. MESSAGES-TEXT = 'Delete me'. APPEND MESSAGES. T100-SPRSL = 'D'. T100-ARBGB = 'RF'. REFRESH MESSAGES FROM TABLE T100. Variant 3 REFRESH itab FROM SELECT-OPTIONS. Note This variant is no longer supported (see also obsolete language constructs). The equivalent functionality is now available in the function module RS_REFRESH_FROM_SELECTOPTIONS. Effect Deletes the internal table itab and then transfers the database selections and the selection parameters together with the values entered by the user. Notes Performance: The runtime for the execution of the REFRESH statement is around 5 ms (standard microseconds). REFRESH - Refresh the SAPGUI interface Basic form REFRESH SCREEN. Note This statement is no longer maintained and should therefore not be used (see also Obsolete key words). Instead, please use a SET USER-COMMAND f statement. Effect Refreshes the SAPGUI interface after receiving the results of the asynchronous Remote Function Call via RECEIVE RESULTS FROM FUNCTION func. This form of the REFRESH statement simulates pressing the return key. Notes 1. Using this variant only makes sense in connection with the asynchronous Remote Function Call (CALL FUNCTION func ...STARTING NEW TASK taskname) after receiving the results of such a call within the FORM routine (RECEIVE RESULTS FROM FUNCTION func). It has no effect in other environments. 2. It ensures that the last screen is processed again with the commad '%_RS'. You can see this value in the command field in the top left corner of the current screen. REJECT Variants: 1. REJECT. 2. REJECT dbtab. Variant 1 REJECT. Effect Stops processing the current database table line and resumes with the next line of the table on the same hierarchy level. Unlike the CHECK statement, you can also use REJECT within a subroutine or loop for table selection. Variant 2 REJECT dbtab. Effect Similar to variation 1. In this case, however, dbtab is a table from the database hierarchy on a level no deeper than the current database table. Processing continues by reading the next record of the table dbtab. Example Logical database F1S Hierarchy: SPFLI -> SFLIGHT -> SBOOK TABLES: SFLIGHT, SBOOK. GET SFLIGHT. ... GET SBOOK. ... REJECT 'SFLIGHT'. ... REJECT cancels processing of the event 'GET SBOOK' and resumes with the processing of the event 'GET SFLIGHT'. Note The name of the subroutine containing the "PUT dbtab" statement must begin with PUT_dbtab. Related CHECK, EXIT, STOP REPLACE Basic form REPLACE f WITH g INTO h. Addition: ... LENGTH len (length specification for field f) Parts marked with " ..." are interchangeable Note As with any string processing statement, all the operands are processed here as type C fields (regardless of tyep). No internal conversion is performed. Effect Replaces the first occurrence of the contents of field f in field h with the contents of field g. All fields are handled in their defined length; this means that closing blanks are not ignored. The return code value indicates whether the string f was found in h and replaced by g: SY-SUBRC = 0: String replaced. SY-SUBRC = 4: String not replaced. Example DATA FIELD(10). MOVE 'ABCB' TO FIELD. REPLACE 'B' WITH 'string' INTO FIELD. returns: FIELD = 'AstringCB', SY-SUBRC = 0 Note The fields f and g in the REPLACE statement should not overlap. Otherwise, the result is undefined. Addition ... LENGTH len ... (length specification for field f) Effect Searches for the string f in the field h not in its (full) field length, but in the length len. Example DATA: PATTERN(5) VALUE 'ABC', LEN TYPE I, REPL_STRING(5) VALUE '12345', FIELD(12) VALUE 'abcdeABCDE'. REPLACE PATTERN WITH REPL_STRING INTO FIELD. does not change FIELD, since 'ABC ' does not occur in abcdeABCDE '. LEN = STRLEN( PATTERN ). REPLACE PATTERN LENGTH LEN WITH REPL_STRING INTO FIELD. changes FIELD to 'abcde12345DE'. Related SEARCH, TRANSLATE, OVERLAY REPORT Basic form REPORT rep. Additions: 1. ... NO STANDARD PAGE HEADING 2. ... LINE-SIZE col 3. ... LINE-COUNT lin(n) 4. ... MESSAGE-ID xx 5. ... DEFINING DATABASE ldb Effect Introduces the report. You can choose any name you like up to 8 characters long. Example REPORT ZREPNAME. Note Only standard SAP reports should begin with 'R'. Addition 1 ... NO STANDARD PAGE HEADING Effect Suppresses output of the standard page header (see NEW-PAGE). Addition 2 ... LINE-SIZE col Effect Creates a report with col columns per line. The maximum line length permitted is 255 characters. If the LINE-SIZE specification is missing, the line length corresponds to the current screen width. The system field SY-LINSZ contains the current line size for generating reports (see NEW-PAGE ... LINE-SIZE). Notes - The specified LINE-SIZE must not appear in quotation marks. - If the you want the report list (i.e. the output) to be printable, do not define a LINE-SIZE with a value greater than 132 because most printers cannot handle wider lists. Example REPORT ZREPNAME LINE-SIZE 132. Addition 3 ... LINE-COUNT lin(n) Effect Creates a report with lin lines per page, of which n lines are reserved for the END-OF-PAGE processing. If you omit the "(n)", the default value 0 applies. The system field SY-LINCT contains the current number of lines per page for generating reports. If the LINE-COUNT specification is missing, the number of lines per page is calculated dynamically from the number of lines actually output on this page. Here, a page break no longer occurs automatically, but must be specified explicitly with NEW-PAGE, and the system field SY-LINCT is set to 0. (NEW-PAGE ... LINE-COUNT) Note The LINE-COUNT must not be enclosed in quotation marks. Further information about using LINE-COUNT. Examples REPORT ZREPNAME LINE-COUNT 65. The page has 65 lines. REPORT ZREPNAME LINE-COUNT 65(8). The page has 65 lines, of which the last 8 are only defined by END-OF-PAGE. Addition 4 ... MESSAGE-ID xx Effect Takes the messages output by MESSAGE under the specified 2-character ID xx from table T100. Note This ID must not be enclosed in quotation marks. Example REPORT RSTEST00 MESSAGE-ID SY. Addition 5 ... DEFINING DATABASE ... Effect All the database programs must specify in the REPORT statement the three-character name of the logical database to which they belong. This addition is generated automatically (in the REPORT statement) when you create a logical database by selecting Utilities -> Development/test -> Logical databases. Example REPORT SAPDBKDF DEFINING DATABASE KDF. RESERVE Basic form RESERVE n LINES. Effect If there is not enough space left on the current page for at least n lines, this statement starts a new page. n can be a constant (1,2,3,...) or a variable. Notes - Before starting a new page, the END-OF-PAGE processing is executed. This differs from NEW-PAGE. - If the RESERVE statement does not trigger a new page, output is continued on the current page. - Use BACK to return to the first line you can display after RESERVE. Note Performance: The runtime required to execute a RESERVE statement is approx. 1 msn (standardized microseconds). RESTORE is not an ABAP/4 key word (in R/3). If required, the return code value is stored in the system field SY-SUBRC. @(#)rfcapi.txt 20.3 SAP 93/10/01 RFC API The Remote Function Call API (RFC API) allows - remotely or locally - calling ABAP/4 function modules from C programs as well as receiving call request issued from an ABAP/4 program by the CALL FUNCTION interface. Libraries and include files The RFC API of SAP consist of 3 parts. * The include files saprfc.h. The include file saprfc.h contains the following data type and structure definitions as well as the prototypes (declarations) of the functionsforming the API. * The include file sapitab.h. This include file defines an interface for manipulating ABAP/4 internal tables. * The library librfc.a (librfc.dll, etc.), which contains the functions of the API. Controlling connections The following functions allow to open and close RFC connections. RFC_HANDLE RfcOpen( RFC_OPTIONS * options ) open a connection according to the given options. If an error occurs RFC_HANDLE_NULL is returned. The structure RFC_OPTIONS contains the necessary data for opening the connection: typedef struct { char * destination; /* Name of destination */ /* connection data */ RFC_MODE mode; /* connection mode (seebelow) */ void * connopt; /* If connopt = NULL, the * 'sideinfo' * file is used to determine the * the connection parameters. * (see CPIC documentation) * * Without 'sideinfo' file * 'connopt' must point to a * structure * of type RFC_CONNOPT_R3ONLY * or RFC_CONNOPT_CPIC depending * on the value of 'mode'. */ /* sign on data */ char * client; /* client */ char * user; /* user id */ char * password; /* password */ char * language; /* language */ /* options */ inttrace; /* trace (written to 'dev_rfc') */ } RFC_OPTIONS; The field destination points to a logical name for the destination. The fields client, user, password and language are the necessary sign on data for the receiving SAP system. The field mode contains the RFC protocol type that is to be used. There are now two values supported : RFC_MODE_R3ONLY and RFC_MODE_CPIC. The value RFC_MODE_R3ONLY can only be used for connecting to R/3 systems, whereas RFC_MODE_CPIC can be used for R/2- and R/3-connections, but only with user id of type CPIC. 1 If the field trace contains a non zero value, the outgoing and incoming data are written to a trace file dev_rfc in the actual directory. Also a trace file is written by the target system.2 If connopt is NULL, the destination name is used to determine the data being necessary for establishing the connection (see the documentation of SAP CPIC and the description of the sideinfo file therein). If connopt is not NULL, it must point to some data structure depending on the value of mode. If mode is RFC_MODE_R3ONLY, then connopt must point to typedef struct { char * hostname; /* Hostname of the target system */ int sysnr; /* System number (0-99) of the * target */ char * gateway_host; /* Hostname of the SAP gateway * (if NULL, the gateway runs on * 'hostname') */ char * gateway_service; /* TCP/IP-Service of the * gateway * (If NULL, the service is * sapgwXX, * where XX is 'sysnr') */ } RFC_CONNOPT_R3ONLY; If mode is RFC_MODE_CPIC, then connopt must point to typedef struct { char * gateway_host; /* Hostname of the SAP gateway */ char * gateway_service; /* TCP/IP-Service of the * gateway */ } RFC_CONNOPT_CPIC; and the connection parameters are defined at the SAP gateway. Only connections thru SNA are possible then. The structures RFC_OPTIONS, RFC_CONNOPT_R3ONLY and RFC_CONNOPT_CPIC should always be cleared by memset( address, 0, sizeof( .... ) ); before filling them, because they may be increased in future releases. The function void RfcClose( RFC_HANDLE handle ) closes a connection and void RfcAbort( RFC_HANDLE handle , char * text ) closes the connection with error. If handle is RFC_HANDLE_NULL all connections are closed. If a text is supplied with RfcAbort, this text is used as error message on the receiving side. The function RFC_HANDLE RfcAccept( char ** argv ) accepts an incoming connection and has to be used, if the program was started by an RFC call issued by a SAP system or an other program using this API. The command line (argv) has to be passed to this function. To build up thestructures RFC_OPTIONS, RFC_CONNOPT_R3ONLY and RFC_CONNOPT_CPIC from the command line there is a function int RfcConnArgv( char ** argv, RFC_OPTIONS * rfc_opt, RFC_CONNOPT_CPIC * connopt_cpic, RFC_CONNOPT_R3ONLY * connopt_r3only ); which allows filling the options structures from a command line. The following tokens are recognized in the argv array, which must terminate by a NULL entry : * -d the name of the destination * -c client (sign on data) * -u user id * -p password * -l language * -3 R/3 mode * -2 CPIC mode * -t turn trace on * -h the name of the target host * -s the system number of the target SAP system * -g the gateway host (if not specified, the -h option is used) * -x the TCP/IP service of the gateway ( default is sapgwNN, where NN is the system number (-s) All tokens that were interpreted by RfcConnArgv are removed from the argv array. Calling an RFC function An RFC function is called by RFC_RC RfcCall( RFC_HANDLE handle, char * function, RFC_PARAMETER * parameters, RFC_TABLE * tables ); The return value is RFC_OK or RFC_FAILURE. The structures RFC_PARAMETER and RFC_TABLE contain the name and the description of the parameters and tables (internal ABAP/4 table) of the function's interface. The function RfcCall returns after the call request is send. Receiving an answer The function RFC_RC RfcReceive( RFC_HANDLE handle, RFC_PARAMETER * parameters, RFC_TABLE * tables, char ** exception ); allows to receive the answer to an RFC call and must be called after RfcCall was issued. The tables' description (RFC_TABLE) must be identical to the one used in RfcCall. The function RfcReceive waits till the answer is received and returns RFC_OK, RFC_FAILURE, RFC_EXCEPTION, RFC_SYS_EXCEPTION or RFC_CALL. The return codes have the following meaning. * RFC_OK means that the call was successfully completed and that the values of the returned parameters were filled into the fields being supplied by the RFC_PARAMETER array. * RFC_FAILURE means that an internal error has occurred. RfcLastError may give more information. * RFC_EXCEPTION means that the callee has raised an exception. The field '*exception' points to the name of the exception. No data were transported. * RFC_SYS_EXCEPTION means that the local or remote RFC system has raised an exception. Also '*exception' points to the name of the exception. The connection was automatically closed by the system and RfcLastError may give more information on the origin of the error. Two exceptions may occur now: SYSTEM_FAILURE and COMMUNICATION_FAILURE. * RFC_CALL means that the callee has issued an RFC call tothe caller of RfcReceive. No data are transported. The call request must be handled by using the functions RfcDispatch or by RfcGetName, RfcGetData and RfcSendData before an other call to RfcReceive can be done. Calling and receiving by one function call There also is a function that does an RFC call synchronously: RFC_RC RfcCallReceive( RFC_HANDLE handle, char * function, RFC_PARAMETER * exporting, RFC_PARAMETER * importing, RFC_TABLE * tables, char ** exception ) is waiting till the returned answer was received. The return values are the same than for RfcReceive. Parameters and internal tables Almost all the RFC send and receive functions have two parameters, where the exported or imported fields and the referenced 'internal tables' are specified. The parameters are pointers to arrays of the following structure (the arrays have to be terminated by an entry with 'name' equal to NULL ): typedef struct { void * name; /* Name of the field (in the interface * definition of the function) */ unsigned nlen; /* Length of the name * (should be strlen(name)) */ unsigned type; /* Datatype of the field */ void * addr; /* Address of the field to be exported * or imported */ unsigned leng; /* Length of the field in Bytes */ } RFC_PARAMETER; The supported ABAP/4 data types are defined in saprfc.h. Data type C typedef Length Description in Bytes TYPC RFC_CHAR[ ] 1-65535 Characters, blank padded at the end TYPX RFC_BYTE[ ] 1-65535 Binary data TYPP RFC_BCD[ ] 1-16 BCD numbers ('packed decimals') TYPINT RFC_INT 4 Integer TYPFLOAT RFC_FLOAT 8 Floating point TYPDATE RFC_DATE 8 Date ( "YYYYMMDD" ) TYPTIME RFC_TIME 6 Time ( "HHMMSS" ) Only scalar data types are supported in the moment. The support for records (structures) will be added later. The structure of RFC_TABLE is similar. typedef struct { void * name; /* Name of the table (in the interface * definition of the function) */ unsigned nlen; /* Length of the name * (should be strlen(name)) */ unsigned type; /* Data type of the lines of the * table */ unsigned leng; /* Width of the table */ ITAB_H itab_h; /* Table handle (type ITAB_H), * i.e. the address of * the control structure of the * internal table. 3 itab_h must be * supplied * by the calling program in RfcCall * etc. * When receiving a call via * RfcGetData * itab_h is filled by RfcGetData. */ IT_MODE itmode; /* Only for RfcGetData. Here one * specifies * if the table shall be passed by * reference * (ITMODE_BYREFERENCE) or by value * (ITMODE_BYVALUE). */ } RFC_TABLE; Here also one can enter only scalar data types, so only one column tables and tables with similar columns (only TYPC or only TYPX fields) are supported in the moment. Listening for RFC events If one does not always want to wait for the answer to an RFC call by RfcReceive one has to call the function RFC_RC RfcListen( RFC_HANDLE handle ); to listen for incoming RFC events. The function returns RFC_OK, if there is an RFC event pending (call or return) and RFC_RETRY, ifnothing has arrived yet. The function returns RFC_FAILURE, if an error has occurred . The function always returns immediately. If RfcListen returns RFC_OK, RfcReceive has to be called to handle the event. It only is possible to listen for one incoming RFC message at a time. Receiving an RFC call For receiving an RFC call there are two possible ways. The most simple way to receive an RFC call in an external program is to register a C function to be called if a call request is received. The function RFC_RC RfcInstallFunction( RFC_FUNCTIONNAME functionname, RFC_ONCALL function_pointer, char * description ); with typedef RFC_RC ( * RFC_ONCALL ) ( RFC_HANDLE handle ); registers a C function to be called when receiving the request for an RFC call. function_pointer points to a function of type RFC_RC function ( RFC_HANDLE handle ), which contains the functionality being offered as an RFC function module. functionname is the name of the offered RFC function module and description should contain a description of the functionality as well as a description of the interface. Newline characters can be used to start new lines. The recommended format for a description is general functionality........... IMPORTING FIELD_NAME_X Type Default Value description of parameter........ ... EXPORTING FIELD_NAME_1 Type description of parameter........ ... TABLES TABLE_NAME_1 Type description of table The descriptions of the registered functions can be requested by calling the function module RFC_DOCU. After RfcAccept or after receiving the return code RFC_CALL when calling RfcReceive the program has to call RFC_RC RfcDispatch ( RFC_HANDLE handle ); which internally calls the corresponding registered function. The return code of the registered function is again returned by RfcDispatch. The function module RFC_DOCU is always offered by this function automatically. 4 Receiving an RFC call directly It is also possible to receive RFC call directly. The function RfcGetName is used to get the name of the called function. typedef char RFC_FUNCTIONNAME[31]; void RfcGetName( RFC_HANDLE handle, RFC_FUNCTIONNAME name ); The calling program then has to determine the interface of the requested function module and to receive the parameters as within a function being installed via RfcInstallFunction. Receiving the parameters Within a registered function or after receiving the name of the called function by RfcGetName the function RfcGetData can be used to receive theparameters of the function call. void RfcGetData( RFC_HANDLE handle, RFC_PARAMETER * parameters, RFC_TABLE * tables ); Here the ITAB_H field in the RFC_TABLE record has to be initialized to NULL. The function RfcGetData fills in the corresponding table handle, which is either a newly created table or an already existing table, which was send to the caller via another RFC call. The field itmode in an RFC_TABLE record determines if a received table is passed by reference or by value. Sending back the answer To send back the answer to a caller the function RfcSendData is used. void RfcSendData( RFC_HANDLE handle, RFC_PARAMETER * parameters, RFC_TABLE * tables ); The tables description (RFC_TABLE) must be the same than in the previous RfcGetData call. Raising an exception To raise an exception while processing a received RFC call the function void RfcRaise( RFC_HANDLE handle, char * exception ); can be used. Environment The following function allows to supply functions for memory allocation and error handling to the RFC engine : void RfcEnvironment( RFC_ENV * new_env ) typedef struct { void * (* allocate )( void * old_ptr, size_t new_size ); void (* errorhandler )( void ); /* more ....? */ } RFC_ENV; If an allocate function is supplied (that is the address is not NULL), this function is called always if memory is allocated, resized or freed within the RFC engine. Memory is allocated by 'allocate( NULL, size )', freed by 'allocate( address, 0 ) and reallocated by allocate(old_address,new_size ). The default memory allocation function, which is used, if RfcEnvironment was not called or if no allocate function is supplied, uses malloc, realloc and free of the standard C library. A supplied errorhandler function is called always if an error occurs within the RFC engine. The function RfcEnvironment shall be called with a completely cleared record RFC_ENV, either implicitly by static RFC_ENV rfcenv; rfcenv.allocate = ....; RfcEnvironment( &rfcenv ); or explicitly by RFC_ENV rfcenv; memset( &rfcenv, 0, sizeof( rfcenv ) ); rfcenv.allocate = ....; RfcEnvironment( &rfcenv ); to allow future increasing of the structure by SAP. There is an additional function in the RFC API to get more information on the last error that occurred : int RfcLastError( RFC_ERROR_INFO * errorinfo ); with typedef struct { char key[32]; char status[128]; char message[256]; char intstat[128]; } RFC_ERROR_INFO; The function returns 1 if no error has occurred and 0 elsewhere. The structure RFC_ERROR_INFO is filled by the function with the following values: * Key contains an error key to identify the error. * Status contains the state of the connection (CPIC error code and state, conversation id, etc.) * Message is a short message text describing the error (in English). * Intstat tells the internal state of the RFC engine, when the error occurred. Some values may not be available for dedicated errors. 1 For connecting to R/3-systems with RFC_MODE_CPIC a 'sideinfo' file is necessary. 2 If the target system is an R/3 system you can view the trace file by the ABAP/4 program RSRFCTRC. 3 ITAB_H typedef's to void * . 4 RfcInstallFunction and RfcDispatch are not available for WINDOWS 3.1. ROLLBACK Basic form ROLLBACK WORK. Effect Closes a logical processing unit by reversing all database changes made since the last COMMIT. You use this statement if you cannot be certain that all the database changes have been executed correctly. The update routines are not performed. ROLLBACK WORK belongs to the Open SQL command set. Note If the ROLLBACK statement occurs within a SELECT loop, the processing cannot continue because the database cursor is invalid. After the ROLLBACK statement, you should therefore ensure that all SELECT processing has been explicitly terminated. Note Runtime errors: - ROLLBACK_IN_PERFORM_ON_COMMIT: ROLLBACK WORK is not allowed in a FORM called with PERFORM ... ON COMMIT. - ROLLBACK_IN_POSTING: ROLLBACK WORK is not allowed in the update task. SCAN Note This statement is for internal use only. Incompatible changes or further developments may occur at any time without warning or notice. Basic form SCAN ABAP-SOURCE itab1 TOKENS INTO itab2 STATEMENTS INTO itab3. Parts marked with " ..." are interchangeable Additions: 1. ... FROM n1 2. ... TO n2 3. ... KEYWORDS FROM itab4 4. ... LEVELS INTO itab5 5. ... OVERFLOW INTO c1 6. ... WITH ANALYSIS 7. ... WITH COMMENTS 8. ... WITH INCLUDES 9. ... WITHOUT TRMAC 10. ... PROGRAM FROM c2 11. ... INCLUDE INTO c3 12. ... MESSAGE INTO c4 13. ... WORD INTO c5 14. ... LINE INTO n3 15. ... OFFSET INTO n4 Effect Breaks down the ABAP/4 source code in the source code table itab1 into tokens according to the rules of the ABAP/4 scanner. The tokens are written - one per line - to the token table itab2 . The token table itab2 must have the structure STOKEN. (If you specify the addition WITH ANALYSIS, the token table must have the extended structure STOKEX.) Normally, comments are filtered out and subordinate source code units (included programs, called macros) are ignored. If you want to include these items, use the additions WITH COMMENTS and WITH ANALYSIS. In addition to classifying the source code by token, the scanner organizes the tokens themselves into statements - using the colon-comma logic to form chain records - and the statement table itab3 contains a statement description on each line. Here, a three-part chain record "a: b, c1 c2, d." results in three entries "a b,", "a c1 c2," and "a d." in the statement table itab3. The statement table itab3 must have the structure SSTMNT. The statement classification characters colon, comma and period are not written to the token table itab2. Instead, the table itab3 contains details about the position of a colon or the type (comma or period and position of the end marker in the statement description. The return code value is set as follows: SY-SUBRC = 0: Source code table is not empty, contains no errors and is broken down into tokens. SY-SUBRC = 1: Source code table is not empty and is broken down into tokens, but at least one include program does not exist (can occur only in connection with the addition WITH INCLUDES). SY-SUBRC = 2: Source code table itab1 is empty or a blank line range was selected (applies to the additions FROM and TO). SY-SUBRC = 4: Scanner detects error in source code. SY-SUBRC = 8: Other error or RABAX in scanner. The fields of the structure STOKEN, and thus the columns of the token table itab2, have the following meaning: TYPE Type of token with possible values: I (Identifier) S (String, i.e. character literal) L (List, enclosed in parentheses) C (Comment) ROW Number of line where token occurs or where it begins (>= 1) COL Offset of first character of token relative to start of line (>= 0) LEN Length of token STR Character string forming the token (or just first part) OVFL Overflow flag for field STR with the following possible values: SPACE (no overflow, token fits completely in field STR) X (overflow, either not resolved (no overflow are specified) or token fits in overflow area c1)) O (overflow of token and overflow of overflow area c1) OFF1 Offset in overflow area, if token does not fit completely in field STR and an overlfow area c1 is specified and token fits completely in overflow area c1. The fields of the structure SSTMNT, and thus the columns of the statement table itab3, have the following meaning: TYPE Type of statement with the following possible values: E (Native SQL statement between EXEC SQL and ENDEXEC) I (INCLUDE prog) J (INCLUDE prog, prog does not exist, can occur only in connection with the addition WITH INCLUDES) R (Call a macro from table TRMAC) D (Call an internally defined macro with DEFINE) M (Macro definition between DEFINE and END-OF-DEFINITION) C (COMPUTE statement, sometimes without COMPUTE as first token) K (Other ABAP/4 key word) N (Blank statement) U (Unknown, non-blank statement) LEVEL Index of source code unit in the level table itab5 (>= 1, if level table specified, otherwise 0) FROM Index of first token of statement in the token table itab2 TO Index of last token of statement in the token table itab2 (the end marker of the statement - comma or period - counts as no more then a token) NUMBER Statement counter in a source code unit. Covers all statements, regardless of how many are actually selected - in cases where a key word table itab4 is specified PREFIXLEN Number of tokens before the colon (with chain statements >= 1, otherwise 0) COLONROW Line number of colon (with chain statements >= 1, otherwise 0) COLONCOL Column position of colon (with chain statements >= 0, otheriwse 0) TERMINATOR End marker of a statement (normally a period or a comma, but SPACE in the case of native SQL statements and internal macro definitions) TROW Line number of end marker (>= 1, if TERMINATOR <> SPACE, otherwise 0) TCOL Column position of end marker (>= 0, if TERMINATOR <> SPACE, otherwise 0) Notes 1. When expanding macro calls, no position specifications are available. The relevant fields in the token table itab2 and in the statement table itab3 are then set to 0. 2. Unlike the usual syntax check, the following are not treated as errors: - Comma without preceding colon (the comma then acts as an end marker), - Open chain statement sequence at end of source code, i.e. the last statement is closed by a comma, not by a period, - Open statement at end of source code, i.e. the last statement is closed neither by a period nor by a comma. 3. To be able to analyze errors without modifying programs, use the additions INCLUDE, MESSAGE, WORD, LINE and OFFSET. These provide information about the errors which have occurred. Addition 1 ... FROM n1 Addition 2 ... TO n2 Effect Breaks down the source code table itab1 into tokens not from start to finish, but only from line n1 to line n2. The additions FROM n1 and TO n2 must follow specification of the source code table itab1 - in this order. Notes 1. When using the start specification n1, use the addition WITHOUT TRMAC to ensure that there are no unnecessary database accesses to the table TRMAC. 2. The end specification n2 is treated as "soft", i.e. a statement that begins on a line <= n2, but ends only on a line > n2, is not returned completely. 3. If the end specification n2 is split in a chain statment, only the split part up to the next comma is returned completely, not the entire chain statement up to the next period. 4. Negative line specifications are not allowed and result in a runtime error. 5. A line specification of 0 amounts essentially to no specification. 6. If n1 number of lines in source code table, the scanner is not called (SY-SUBRC = 2). 7. If n1 > n2 and n2 > 0, the scanner is not called (SY-SUBRC = 2). Addition 3 ... KEYWORDS FROM itab4 Effect Does not return all statements, only those specified in the key word table itab4. If the key word table is empty (i.e. it contains 0 lines), all the statements are selected. The lines of the key word table are treated as a character field. To select a native SQL statement or a macro definition, you can specify the pseudo key words EXEC_SQL or DEFINE_MACRO. It makes no difference whether these are intercepted. Native SQL statements and macro definitions are returned as statements (of type E or M whenever the expansion of a macro definition results in more than one statement. If the key word contains a blank line, blank statements are also selected. Addition 4 ... LEVELS INTO itab5 Effect Stores details about each edited source code unit (source code table itab1 itself, expanded include programs, expanded macro definitions) in the level table itab5. Specification of a level table makes sense only with the addition WITH INCLUDES. The level table itab5 must have the structure SLEVEL. The fields of the structure SLEVEL - and consequently the columns of the level table itab5 have the following meaning: TYPE Type of source code unit with the following possible values: P (Program) D (Internal DEFINE macro) R (Macro from table TRMAC) NAME Name of source code unit (name of include program, macro name) DEPTH Current nesting depth of source code unit (>= 1) LEVEL Index of superior (i.e. included or called) source code unit in the level table (>= 1, if DEPTH >= 2, otherwise 0) STMNT Index of superior (d.h. included or called) statement in the statement table (>= 1, if DEPTH >= 2, otherwise 0) FROM Index of first statement of source code unit in the statement table (>= 1) TO Index of last statement of source code unit in the statement table (>= 1) If the source code unit contains include programs or macro calls, the line range [FROM, TO] in the statement table also covers the statements in subordinate source code units. Addition 5 ... OVERFLOW INTO c1 Effect If a token is too large to be stored in the token table in the field STR, it is placed in the overflow area c1. The offset of the token in the overflow area then lies in the token table in the field OFF1. Addition 6 ... WITH ANALYSIS Effect Breaks down each token t = a+b(c) according to the logic of the RSYN key word >ANALY into its three components a, b and c. Offset and length of components a, b and c are stored in the fields OFF1, LEN1, OFF2, LEN2, OFF3 and LEN3 in the token table. If you specify the addition WITH ANALYSIS, the token table itab2 must have the structure STOKEX, so that the fields LEN1, OFF2, LEN2, OFF3 and LEN3 are available. If the whole token exists in the token table, the offset specifications are relative to the token start. If the token is in the overflow area c1, the offset specifications are relative to the start of the overflow area. Addition 7 ... WITH COMMENTS Effect Returns comments also, with each individual comment representing a token. Note The addition ... WITH COMMENTS is unfortunately not supported at present! Addition 8 ... WITH INCLUDES Effect Also breaks down subordinate source code units (included programs, called macros) into tokens. You should normally combine the addition WITH INCLUDES with the addition LEVELS INTO itab5. Note 1. If (at least) one included program does not exist, SY-SUBRC is set to 1 and the relevant INCLUDE statement is flagged in the statement table itab3 by the statement type J (instead of I). Otherwise, the breakdown process continues. The level table itab5 contains no entry for include programs that do not exist. 2. If you combine WITH INCLUDES with WITHOUT TRMAC, TRMAC macros are not expanded because the system does not recognize them as subordinate source code units. 3. When macro calls are expanded, no position specifications are available. The fields in the token table itab2 and the statement table itab3 are then set to 0. Addition 9 ... WITHOUT TRMAC Effect If a statement begins neither with an ABAP/4 key word nor with a DEFINE macro, the system does not check whether this is a TRMAC macro, but assumes an unknown statement. (Unknown statements are flagged in the statement table itab3 with a U in the field TYPE.) To avoid unnecessary database accesses to the table TRMAC, you should use the addition WITHOUT TRMAC whenever you want to assume that the source code to be scanned contains unknown statements. Unknown statements are particularly likely to occur if you use the addition FROM n1. In this case, the scanner does not start at the beginning of the source code, but from a specified point. Note If you use WITHOUT TRMAC with WITH INCLUDES, TRMAC macros are not expanded because the system does not recognize them as subordinate source code units. Addition 10 ... PROGRAM FROM c2 Addition 11 ... INCLUDE INTO c3 Addition 12 ... MESSAGE INTO c4 Addition 13 ... WORD INTO c5 Addition 14 ... LINE INTO n3 Addition 15 ... OFFSET INTO n4 Effect The above additions have the same meaning as the those for the SYNTAX-CHECK statement: c2 is an input field for a program name to be assigned to the source code, while the fields c3, c4, c5, n3 and n4 are output fields in case an error occurs. To be able to analyze errors without modifying programs, use the additions INCLUDE, MESSAGE, WORD, LINE and OFFSET. These provide information about the errors which have occurred. SCROLL Program-driven scrolling in lists Variants: 1. SCROLL LIST TO FIRST PAGE. 2. SCROLL LIST TO LAST PAGE. 3. SCROLL LIST TO PAGE pag. 4. SCROLL LIST TO COLUMN col. 5. SCROLL LIST FORWARD. 6. SCROLL LIST BACKWARD. 7. SCROLL LIST LEFT. 8. SCROLL LIST RIGHT. Note The return code value is set as follows: SY-SUBRC = 0: O.K. SY-SUBRC = 4: List limits have been reached - scrolling not possible SY-SUBRC = 8: List does not exist - scrolling not possible Variant 1 SCROLL LIST TO FIRST PAGE. Additions: 1. ... INDEX idx 2. ... LINE lin Effect Scrolls up to the first page of the report displayed on the screen (corresponds to a command field entry, P-- and PP--). When a basic list is created, the current list is itself the basic list; When a details list is created, it is the list directly below it. Addition 1 ... INDEX idx. Effect Scrolls to the list level idx. idx corresponds to the value of system field SY-LSIND when creating the report. Example Scroll to the beginning of the report at list level 1. SCROLL LIST INDEX 1 TO FIRST PAGE. Note If a new list (which is to replace the last list displayed) is created at an event (AT USER-COMMAND , AT LINE-SELECTION...), and if you want to scroll to a particular place in this new list, note the following: A change made to the system field SY-LSIND is only ever taken into account after the event. Therefore, SY-LSIND should be manipulated using the last command belonging to the event (e.g. SY-LSIND = SY-LSIND - 1). A SCROLL command with the addition ...INDEX idx must therefore be used for scrolling in this new list. In this way, scrolling in the old list (instead of the new list) is avoided. Addition 2 ... LINE lin Effect Displays the report from the line lin (corresponds to the command field entry PLnn). The standard page header and TOP-OF-PAGE area are not moved vertically and are therefore ignored when line lin is determined. Variant 2 SCROLL LIST TO LAST PAGE. Additions: 1. ... INDEX idx (see addition 1 of variant 1) 2. ... LINE lin (see addition 2 of variant 1) Effect Scrolls to the last page of the report displayed on the screen (corresponds to the command field entries P++ and PP++). Variant 3 SCROLL LIST TO PAGE pag. Additions: 1. ... INDEX idx (see addition 1 of variant 1) 2. ... LINE lin (see addition 2 of variant 1) Effect Scrolls to the specified page of the report displayed on the screen (corresponds to the command field entry PPnn). Examples Scroll report on list level 1 to page 7. SCROLL LIST INDEX 1 TO PAGE 7. Scroll report on list level 1 to page 7 and display from line 5. SCROLL LIST INDEX 1 TO PAGE 7 LINE 5. Note Although the list is now displayed from page 7 and line 5, it is precisely this line which is overlayed by the page header, if a header exists for page 7 (standard header and/or TOP-OF-PAGE lines). If you want to display a particular line immediately after the page header, you can use the function module 'LIST_SCROLL_LINE_TOPMOST' which makes the necessary calculations (according to DESCRIBE LIST ...). Variant 4 SCROLL LIST TO COLUMN col. Additions: 1. ... INDEX idx (see addition 1 of variant 1) 2. ... LINE lin (see addition 2 of variant 1) Effect Displays the current page from column col (corresponds to the command field entry PSnn). The current page is the last page to be seen on the screen or the page that was scrolled with a preceding SCROLL LIST TO...PAGE... statement. Example Scroll to page 5 of current report and display this page from column 20. SCROLL LIST TO PAGE 5. SCROLL LIST TO COLUMN 20. Variant 5 SCROLL LIST FORWARD. Additions: 1. ... INDEX idx (see addition 1 of variant 1) 2. ... n PAGES Effect Scrolls down 1 screen page (but no further than the last page; corresponds to the command field entry P+). Example Scroll report last displayed one page down. SCROLL LIST FORWARD. Addition 2 ... n PAGES Effect Scrolls n pages (corresponds to the command field entry PP+n). Note When you use the addition ... n PAGES, scrolling is by page, not by screen section. Variant 6 SCROLL LIST BACKWARD. Additions: 1. ... INDEX idx (see addition 1 of variant 1) 2. ... n PAGES (see addition 2 of variant 5) Effect Scrolls one screen page back (but no further than the first page; corresponds to the command field entry P-). Addition 2 ... n PAGES Effect Scrolls n pages backwards (corresponds to the command field entry PP-n). Note When you use the addition ... n PAGES, scrolling is by page, not by screen section. Variant 7 SCROLL LIST LEFT. Additions: 1. ... INDEX idx (see addition 1 of variant 1) 2. ... BY n PLACES Effect The display begins with column 1 of the report (i.e. left-justified; corresponds to the command field entry PS--). Addition 2 ... BY n PLACES Effect Shifts the report n columns. You determine the direction using the parameters ...LEFT... or ...RIGHT... (corresponds to the command field entries PS+n and PS-n). Example Scroll report at last list level displayed 2 columns to the left. SCROLL LIST LEFT BY 2 PLACES. Variant 8 SCROLL LIST RIGHT. Additions: 1. ... INDEX idx (see addition 1 of variant 1) 2. ... BY n PLACES (see addition 2 of variant 7) Effect Shifts the display to the right until that side of the report so far not visible on the screen is fully visible (i.e. right- justified). This only makes sense with reports that are defined wider than the standard screen size by REPORT ... LINE-SIZE corresponds to the command field entry PS++). Note Horizontal scrolling is also affected by the area boundaries set (SET SCROLL-BOUNDARY) and by "unmovable" lines (NEW-LINE NO-SCROLLING). SEARCH Variants: 1. SEARCH f FOR g. 2. SEARCH itab FOR g. Variant 1 SEARCH f FOR g. Additions: 1. ... ABBREVIATED 2. ... STARTING AT n1 3. ... ENDING AT n2 4. ... AND MARK Effect Searches the field f for the string in the field g. This string can have any of the following formats: 'str' a character string (trailing blanks are ignored) '.str.' any character string between the periods '*str' a word ending with "str", including the word "str" 'str*' a word beginning with "str", including the word "str" You can use the following characters as delimiters: ' ', ',', ';', ':', '.', '!', '?', '(', ')', '+', '/' and '='. The return code value is set as follows: SY-SUBRC = 0: The search string g was found in the field f. SY-FDPOS contains the offset of the found string or the found word within the field. SY-SUBRC = 4: The search string g was not found in the field f. Addition 1 ... ABBREVIATED Effect Searches the field f for a word containing the character string specified in the field. Here, the characters specified in g may be separated by other characters in a word. If the string g occurs in a word, the return code in system field SY-SUBRC is set to 0. The first letter of the search string g and the word must match. Example DATA F(50). MOVE 'Alaska Texas California' TO F. SEARCH F FOR 'Clfrn' ABBREVIATED. Here, SY-SUBRC is set to 0, since not only does the string 'Clfrn' occur (separated by other characters) in 'California', but 'Clfrn' and 'California' begin with the same letter. Addition 2 ... STARTING AT n1 Effect Searches the field f starting from the position n1. Here, a field can be anything containing the corresponding value. The first character in the field f is in position 1. When you use the addition STARTING AT, the position specified for the found pattern in SY-FDPOS does not refer to the start of the field, but to the position n1. Addition 3 ... ENDING AT n2 Effect Searches the field f up to the position n2. Addition 4 ... AND MARK Effect If the search string g is found, all the characters of the search string and all the characters occurring in between (in the case of SEARCH ABBREVIATED) are converted to upper case in the field f. Example DATA F(20) VALUE 'Peter Paul Mary'. SEARCH F FOR '*UL' AND MARK. SY-SUBRC is now set to 0, since the search string was found in 'Paul'. SY-FDPOS has the value 6, since the character string found starts at the offset 6. Also, the search string is marked, so that the new contents of f are as follows: 'Peter PAUL Mary' Variant 2 SEARCH itab FOR g. Additions: 1. ... ABBREVIATED 2. ... STARTING AT lin1 3. ... ENDING AT lin2 4. ... AND MARK Effect Searches the internal table itab for the string in field g. The string can have the same format as in variant 1. The value of SY-SUBRC is set to 0, if the search string in the field or table is found. The system field SY-TABIX then contains the number of the table line where the string was found. Meanwhile, SY-FDPOS specifies the offset of the found string within the table line. Note The statement does not search the header line of an internal table itab. Addition 1 ... ABBREVIATED Effect As with SEARCH ABBREVIATED, searches the internal table itab for a word that contains the character string specified in the field g. Here, the characters specified in g can be separated by other characters. The return code value of the system field SY-SUBRC is set to 0, if the string g occurs in a word. The first letter of the search string g and the word must match. Addition 2 ... STARTING AT lin1 Effect Searches the internal table itab starting from line lin1 to the end. lin1 can be a field that contains the corresponding values. Addition 3 ... ENDING AT lin2 Effect Searches the internal table itab up to the line lin2. Addition 4 ... AND MARK Effect If the search string g is found, all the characters of that search string and all the characters occurring in between (in the case of SEARCH ABBREVIATED) are converted to upper case in the internal table itab. Example Let T be an internal table which is empty: DATA: BEGIN OF T OCCURS 100, LINE(80), END OF T. MOVE 'Alaska Texas ' TO T. APPEND T. MOVE 'California Arizona ' TO T. APPEND T. SEARCH T FOR '*ONA' AND MARK. SY-SUBRC is now set to 0 because the search string was found in 'Arizona'. SY-TABIX contains the value 2 because 'Arizona' appears in the second line of the table T. SY-FDPOS is set to 11 because the found character string begins at the offset 11. Also, the search string was marked in the second line in such a way that the contents of that line now look as follows: 'California ARIZONA' Related REPLACE, OVERLAY, SHIFT, SPLIT, TRANSLATE Note Performance: Searching for the string '*str' in an internal table is much more runtime-intensive (approx. 500000 msn (standardized microseconds)) than searching for 'str*' (approx. 10000 msn) or 'str' (approx. 35 msn). The latter involves searching a table with 230 entries and 15 fields. If you perform a search in a field which is 35 bytes long for '*str' or 'str*', the runtime consumption is approx. 600 msn, whereas searching for 'str' takes about 25 msn. SECURITY is not an ABAP/4 key word (in R/3). SEGMENTS is not an ABAP/4 key word (in R/3). SELECT Basic form SELECT result [target] FROM source [where] [GROUP BY fields] [ORDER BY order]. Effect Retrieves an extract and/or a set of data from a database table or view (see Relational database). SELECT belongs to the OPEN SQL command set. Each SELECT command consists of a series of clauses specifying different tasks: The SELECT result clause specifies - whether the result of the selection is a table or a single record, - which columns the result is meant to have and - whether the result is allowed to include identical lines. The INTO target clause specifies the target area into which the selected data is to be read. If the target area is an internal table, the INTO clause specifies - whether the selected data is to overwrite the contents of the internal table or - whether the selected data is to be appended to the contents and - whether the selected data is to be placed in the internal table all at once or in several packets. The INTO clause can also follow the FROM clause. You can omit the INTO clause. The system then makes the data available in the table work area (see TABLES) dbtab. If the SELECT clause includes a "*", the command is processed like the identical SELECT * INTO dbtab FROM dbtab statement. If the SELECT clause contains a list a1 ... an, the command is executed like SELECT a1 ... an INTO CORRESPONDING FIELDS OF dbtab FROM dbtab. If the result of the selection is meant to be a table, the data is usually (for further information, see INTO-Klausel) read line by line within a processing loop introduced by SELECT and concluded by ENDSELECT. For each line read, the processing passes through the loop once. If the result of the selection is meant to be a single record, the closing ENDSELECT is omitted. The FROM source clause the source (database table or view) from which the data is to be selected. It also determines - the type of client handling, - the behavior for buffered tables and - the maximum number of lines to be read. The WHERE where clause specifies the conditions which the result of the selection must satisfy. It thus determines the lines of the result table. Normally - i.e. unless a client field is specified in the WHERE clause - only data of the current client is selected. If you want to select across other clients, the FROM clause must include the addition ... CLIENT SPECIFIED. The GROUP-BY fields clause combines groups of lines together into single lines. A group is a set of lines which contain the same value for every database field in the GROUP BY clause. The ORDER-BY order clause stipulates how the lines of the result table are to be ordered. Each time the SELECT statement is executed, the system field SY-DBCNT contains the number of lines read so far. After ENDSELECT, SY-DBCNT contains the total number of lines read. The return code value is set as follows: SY-SUBRC = 0: At least one line was read. SY-SUBRC = 4: No lines were read. SY-SUBRC = 8: The search key was not fully qualified. (nur bei SELECT SINGLE). The returned single record is any line of the solution set. Example Output the passenger list for the Lufthansa flight 0400 on 28.02.1995: TABLES SBOOK. SELECT * FROM SBOOK WHERE CARRID = 'LH ' AND CONNID = '0400' AND FLDATE = '19950228' ORDER BY PRIMARY KEY. WRITE: / SBOOK-BOOKID, SBOOK-CUSTOMID, SBOOK-CUSTTYPE, SBOOK-SMOKER, SBOOK-LUGGWEIGHT, SBOOK-WUNIT, SBOOK-INVOICE. ENDSELECT. Note Performance: In client/server environments, storing database tables in local buffers (see SAP buffering) can save considerable amounts of time because the time required to make an access via the network is much more than that needed to access a locally buffered table. Notes 1. A SELECT command on a table for which SAP buffering is defined in the ABAP/4 Dictionary is normally satisfied from the SAP buffer by bypassing the database. This does not apply with - SELECT SINGLE FOR UPDATE - SELECT DISTINCT in the SELECT clause, - BYPASSING BUFFER in the FROM clause, - ORDER BY f1 ... fn in the ORDER-BY clause, - aggregate functions in the SELECT clause, - when using IS [NOT] NULL WHERE condition, or if the generic key part is not qualified in the WHERE-Bedingung for a generically buffered table. 2. Authorization checks are not supported by the SELECT statement, so you must program these yourself. 3. In dialog systems, the database system locking mechanism cannot always guarantee to synchronize the simultaneous access of several users to the same dataset. In many cases, it is therefore advisable to use the SAP locking mechanism. 4. Changes to data in a database are only finalized after a database commit (see LUW). Prior to this, any database update can be reversed by a database rollback (see Programming transactions). At the lowest isolation level (see the section on the "uncommitted read" under Locking mechanism), this can result in the dataset selected by the SELECT command not really being written to the database. While a program is selecting data, a second program can add, change or delete lines at the same time. Then, the changes made by the second program are reversed by rolling back the database system. The selection of the first program thus reflects only a very temporary state of the database. If such "phantom data" is not acceptable for a program, you must either use the SAP locking mechanism or at least set the isolation level of the database system to "committed read" (see Locking mechanism). 5. In a SELECT-ENDSELECT loop, the CONTINUE statement terminates the current loop pass prematurely and starts the next. 6. If one of the statements in a SELECT ... ENDSELECT loop results in a database commit, the cursor belonging to the SELECT ... ENDSELECT loop is lost and the processing terminates with a runtime error. Since each screen change automatically generates a database commit, statements such as CALL SCREEN, CALL DIALOG, CALL TRANSACTION or MESSAGE are not allowed within a SELECT ... ENDSELECT loop. Related OPEN CURSOR, FETCH und CLOSE CURSOR SELECT-OPTIONS Basic form SELECT-OPTIONS sel FOR f. Additions: 1. ... DEFAULT g 2. ... DEFAULT g ... OPTION xx ... SIGN s 3. ... DEFAULT g TO h 4. ... DEFAULT g TO h ... OPTION xx ... SIGN s 5. ... MEMORY ID pid 6. ... MATCHCODE OBJECT mobj 7. ... MODIF ID key 8. ... NO-DISPLAY 9. ... LOWER CASE 10. ... OBLIGATORY 11. ... NO-EXTENSION 12. ... NO INTERVALS 13. ... NO DATABASE SELECTION 14. ... VALUE-REQUEST 15. ... VALUE-REQUEST FOR LOW/HIGH 16. ... HELP-REQUEST 17. ... HELP-REQUEST FOR LOW/HIGH Effect Declares a variable selection option. This statement only makes sense in reports, i.e. in programs defined as type 1 in the attributes. You can execute reports with the SUBMIT statement. The statements SELECT-OPTIONS and PARAMETERS determine the technical interface and the user interface. The parameters and selection options you specify are displayed on the selection screen for the user to enter values (see also the addition NO-DISPLAY or SUBMIT without the addition VIA SELECTION-SCREEN. sel must be 1 - 8 characters long. Note - This statement defines an internal table sel with a fixed structure which consists of the fields sel-SIGN, sel-OPTION, sel-LOW and sel-HIGH. - A report can (by means of an entry in the attributes) be assigned to a logical database ldb. This means that both the logical database ldb and the report can define selection options (and parameters). You define the (database-specific) selection options in an ABAP/4 include program DBldbSEL (in logical database maintenance). The system then imports this include program into the actual logical database access program SAPDBldb and (partially) into the report. As a result, the database-specific selection options (and parameters) relevant to the report are available both to the database program SAPDBldb and to the report. The 'report-specific' selection options are known only in the report (not in SAPDBldb). Some SELECT-OPTIONS additions are allowed only in DBldbSEL. The addition 'NO DATABASE SELECTION' can only be used in the report. - Each line of the internal table sel formulates a condition. If you require precise details about how to formulate these conditions, see the section on the IN operator under Logical expressions. - If the user enters a value set on the selection screen, the internal table sel is automatically filled. You can use normal ABAP/4 statements to read and manipulate the internal table sel. - The values you enter for the database-specific selection options are passed directly to the database for data selection (i.e. no unwanted records are read). This also applies to report-specific SELECT-OPTIONS that refer to a field in a logical database table defined for dynamic selections (see also the addition "NO DATABASE SELECTION"). You must check report-specific selections that refer to other fields with the CHECK statement (i.e. unwanted records must first be read from the database and discarded afterwards). This process is therefore not as efficient as the process described above. - Under "Text elements/selection texts", you should enter a description for each selection criterion sel. This description is displayed on the selection screen. If no such text exists, the name sel of the selection option is displayed instead. - The LOW and HIGH fields of a selection option are displayed in a length up to 18 bytes long (scrollable up to 45 bytes). If you define a length longer than 45, fields are truncated on the selection screen after the 45th character. This affects the first line of the SELECT-OPTIONS table. You can, however, pass longer selection options to a report if they are specified with the addition NO-DISPLAY and thus do not appear on the selection screen. Without NO-DISPLAY, the fields are then truncated whenever the selection screen is processed in the background (SUBMIT without VIA SELECTION-SCREEN). Example SELECT-OPTIONS PROGRAM FOR SY-REPID. Suppose you create an internal table PROGRAM with the header line fields PROGRAM-SIGN, PROGRAM-OPTION, PROGRAM-LOW and PROGRAM-HIGH. PROGRAM-LOW and PROGRAM-HIGH have the same field attributes as SY-REPID. When the report is executed, a line on the selection screen contains the text 'PROGRAM' or the associated selection text as well as input fields for PROGRAM-LOW and PROGRAM-HIGH. At the end of the line, there is a pushbutton with an arrow. When you press this button, you branch to the 'Complex Selections' screen where you can enter more selection lines for sel. Here, you can formulate very complicated selection conditions. For further information about how these entries determine the result set, see Logical expressions or select Utilities -> Help sel. screen on the 'Complex Selections' screen. Note - Field attributes on the selection screen. The input/output fields displayed on the selection screen for entry of upper and lower limits have the same attributes for type, length or conversion exits as the field f specified after FOR. If f is a Dictionary field, the selection screen is regenerated automatically after most changes to its attributes. The attributes 'Check table' and 'Fixed values' are exceptions to this rule. If these are changed, you have to generate the program in the ABAP/4 Editor. This also generates the selection screen. Addition 1 ... DEFAULT g Effect Proposes the single value g as the default selection when the report is called. Notes - For each SELECT-OPTION, you can only specify one DEFAULT. - You must specify the default value g in its internal format, e.g. "SELECT-OPTIONS DATE FOR SY-DATUM DEFAULT '19931224'", not "... DEFAULT '24.12.1993'". - The default value g should normally be a literal because, at runtime, it is transferred to the selection options table sel so early that no value can be assigned to the field g. System fields are an exception here because the system usually assigns values to them as soon as the report processing starts. Example SELECT-OPTIONS DATE FOR SY-DATUM DEFAULT SY-DATUM. Addition 2 ... DEFAULT g ... OPTION xx ... SIGN s (xx is OPTION, i.e. one of the values EQ,NE,CP,NP,GE,LT,LE,GT); s is SIGN, i.e. one of the values I or E) Effect Similar to "... DEFAULT g", except that the system also proposes the specified selection option and SIGN. You can specify the additions OPTION and SIGN in any order or omit them. The standard OPTION is EQ, the standard SIGN is I. Example DATA CITY(20). SELECT-OPTIONS SO_CITY FOR CITY DEFAULT 'SAN*' OPTION CP SIGN E. On the selection screen, this results in an entry specifying that cities not beginning with "SAN" are selected. Notes - For each SELECT-OPTION, you can only specify one DEFAULT. - The option xx and SIGN s must be specified without quotation marks. Addition 3 ... DEFAULT g TO h Effect Proposes the range from g to h when the report is called. Note For each SELECT-OPTION, you can only specify one DEFAULT. Addition 4 ... DEFAULT g TO h ... OPTION xx ... SIGN s (xx is OPTION, i.e. one of the values EQ,NE,CP,NP,GE,LT,LE,GT); s is SIGN, i.e. one of the values I or E) Effect Similar to "DEFAULT g TO h", except that the system proposes the specified selection option and SIGN. You can specify the additions OPTION and SIGN in any order or omit them. The default OPTION is BT, the default SIGN is I. Example DATA WORD(20). SELECT-OPTIONS SO_WORD FOR WORD DEFAULT 'SPRING' TO 'SUMMER' OPTION NB SIGN I. On the selection screen, this results in an entry specifying that the words between "SPRING" and "SUMMER" are excluded. Notes - For each SELECT-OPTION, you can only specify one DEFAULT. - The option xx and SIGN s must be specified without quotation marks. Addition 5 ... MEMORY ID pid Effect On the selection screen, the SET/GET ID pid is assigned to the left range limit of the selection criterion. Note You must specify the memory ID without quotation marks. It can be up to 3 characters long. Addition 6 ... MATCHCODE OBJECT mobj Effect On the selection screen, the matchcode object mobj is assigned to the left range limit of the selection criterion. Note You must specify the name of the matchcode object without quotation marks. It can be up to 4 characters long. Addition 7 ... MODIF ID key Effect The specified modification group (SCREEN-GROUP1), which can be used for screen modifications, is assigned to the screen fields. Note You must specify the name of the modification group without quotation marks. It can be up to 3 characters long. Example TABLES SAPLANE. ... SELECT-OPTIONS S_PTYPE FOR SAPLANE-PLANETYPE MODIF ID ABC. ... AT SELECTION-SCREEN OUTPUT. LOOP AT SCREEN. IF SCREEN-GROUP1 = 'ABC'. SCREEN-INTENSIFIED = '1'. MODIFY SCREEN. ENDIF. ENDLOOP. Addition 8 ... NO-DISPLAY Effect Does not display the selection on the selection screen. Creates the internal table sel as with 'normal' selection options and you can then transfer the selection option with SUBMIT. These selection options represent a part of the interface which the user does not see on the selection screen. You can set the values either internally (through the routine INIT in SAPDBldb or INITIALIZATION in the report) or with SUBMIT. These selection options are also stored for variants. Sometimes, (e.g. when the user has entered particular values for other selection options or parameters), you may want to display these undisplayed selection options on the screen so that the user can enter values. You can do this in the routine PAI of the database program SAPDBldb (for database-specific selection options) or under AT SELECTION SCREEN (for report-specific selection options) by calling a function module (see CALL FUNCTION) or your own screen (CALL SCREEN. Addition 9 ... LOWER CASE Effect The selection is not case-sensitive (i.e. allows upper and lower case letters). Addition 10 ... OBLIGATORY Effect The user must enter a value for this selection (in the LOW field). Addition 11 ... NO-EXTENSION Effect The user can only make an entry on one line. Calling the additional "Multiple Selection" screen is not supported and no pushbutton for this appears on the selection screen. Addition 12 ... NO INTERVALS Effect The selection option is displayed on the selection screen without a 'to' field. The pushbutton for calling the "Multiple Selection" screen appears immediately after the 'from' field. This addition thus allows you to generate a simplified display on the selection screen. This is particularly useful if you are not making any range selections for this selection option. Notes - On the "Multiple Selection" screen, you can also enter ranges for selection options with "NO INTERVALS". - By combining this addition with "NO-EXTENSION", you can restrict the user to entry of a single value for the selection option, but with the possibility of also choosing single value options like 'Greater than' or 'Less than or equal'. - By using the addition "NO INTERVALS" with SELECTION-SCREEN BEGIN OF BLOCK, you can activate the simplified display for all selection options in a block. - The function module SELECT_OPTIONS_RESTRICT allows you to restrict the set of selection options available for a SELECT-OPTION (for example, only single values and patterns, i.e. 'EQ' and 'CP' are allowed). You can also forbid the leading sign 'E' (= 'Exclude from selection'). This means that you can considerably restrict the selections which can be entered on the selection screen. Addition 13 ... NO DATABASE SELECTION Effect This addition is allowed only for report-specific SELECT-OPTIONS which refer to a field f belonging to a table dbtab of the logical database. Here, the selections entered by the user are not passed directly to the logical database unless the logical database supports dynamic selections for dbtab (if dynamic selections for dbtab are not supported, the addition has no effect. This addition can be useful if you only want the selections entered by the user for this SELECT-OPTION to be effective under certain conditions. However, you should be careful when using it: Since the selections have to be checked with CHECK after the records have been read, this has a considerable effect on performance. Addition 14 ... VALUE-REQUEST Addition 15 ... VALUE-REQUEST FOR LOW/HIGH Effect This addition is allowed only for database-specific SELECT-OPTIONS in the include program DBxyzSEL (where xyz = logical database name). It allows you to implement self-programmed value help. (To implement self-programmed value help for report-specific SELECT-OPTIONS, you can use the event key word AT SELECTION-SCREEN ON VALUE-REQUEST FOR ....) If you specify only VALUE-REQUEST (without FOR ...), the value help refers to both input/output fields of the SELECT-OPTION (i.e. to sel-LOW and sel-HIGH). Otherwise, it refers only to the specified field. The addition has two effects: 1. The affected input/output fields are displayed on the selection screen with the pushbutton for F4 (possible entries). 2. When the user presses this button or F4, this triggers the FORM routine sel-LOW_VAL or sel-HIGH_VAL in the database access program SAPDBxyz (if it exists). If this addition is specified - and even if the SELECT-OPTION with FOR points to a Dictionary field - this FORM routine is executed when the user presses F4 and the check table or the fixed values of the Dictionary field are not displayed. You can, for example, branch from the routine sel-LOW_VAL or sel-HIGH_VAL to a function module which offers a selection list of possible values. At the end of this FORM routine, the contents of the field sel-LOW or sel-HIGH are copied to the appropriate input/output field. Example * INCLUDE DBXYZSEL ... SELECT-OPTIONS S_PTYPE FOR SAPLANE-PLANETYPE VALUE-REQUEST FOR LOW. ... REPORT SAPDBXYZ DEFINING DATABASE XYZ. ... TABLES SAPLANE. ... FORM S_PTYPE-LOW_VAL. ... CALL FUNCTION '...'. ... ENDFORM. Addition 16 ... HELP-REQUEST Addition 17 ... HELP-REQUEST FOR LOW/HIGH Effect Like VALUE-REQUEST, this addition is allowed only for database-specific SELECT-OPTIONS in the include program DBxyzSEL (where xyz = logical database name). It allows you to implement self-programmed value help. (To implement self-programmed value help for report-specific SELECT-OPTIONS, you can use the event key word AT SELECTION-SCREEN ON HELP-REQUEST FOR ....) If you specify only HELP-REQUEST (without FOR ...), the help refers to both input/output fields of the SELECT-OPTION (i.e. to sel-LOW and sel-HIGH). Otherwise, it refers only to the specified field. When the user presses F1, this triggers the FORM routine sel-LOW_HLP or sel-HIGH_HLP in the database access program SAPDBxyz (if it exists). If this addition is specified - and even if the SELECT-OPTION with FOR points to a Dictionary field - this FORM routine is executed when the user presses F1 and the documentation of the Dictionary field is not displayed. You can, for example, branch from the routine sel-LOW_HLP or sel-HIGH_HLP to a function module which displays its own documentation. Example * INCLUDE DBXYZSEL ... SELECT-OPTIONS S_PTYPE FOR SAPLANE-PLANETYPE HELP-REQUEST. ... REPORT SAPDBXYZ DEFINING DATABASE XYZ ... TABLES SAPLANE. ... FORM S_PTYPE-LOW_HLP. ... CALL FUNCTION '...'. ... ENDFORM. FORM S_PTYPE-HIGH_HLP. ... CALL FUNCTION '...'. ... ENDFORM. SELECTION-SCREEN Variants: 1. SELECTION-SCREEN BEGIN OF LINE. 2. SELECTION-SCREEN END OF LINE. 3. SELECTION-SCREEN SKIP n. 4. SELECTION-SCREEN ULINE. 5. SELECTION-SCREEN POSITION pos. 6. SELECTION-SCREEN COMMENT fmt name. 7. SELECTION-SCREEN PUSHBUTTON fmt name USER-COMMAND ucom. 8. SELECTION-SCREEN BEGIN OF BLOCK block. 9. SELECTION-SCREEN END OF BLOCK block. 10. SELECTION-SCREEN FUNCTION KEY n. 11. SELECTION-SCREEN BEGIN OF VERSION ver TEXT-xxx. 12. SELECTION-SCREEN END OF VERSION ver. 13. SELECTION-SCREEN EXCLUDE ... . 14. SELECTION-SCREEN DYNAMIC SELECTIONS FOR TABLE dbtab. 15. SELECTION-SCREEN FIELD SELECTION FOR TABLE dbtab. Effect The key word SELECTION-SCREEN only makes sense in reports, i.e. programs specified as type "1" in the attributes. You use it to design the selection screen in the program or logical database access routine. The selection screen is normally generated from the SELECT-OPTIONS and PARAMETERS statements in the report and logical database access routine. Each of these objects occupies a separate line on the selection screen. SELECTION-SCREEN allows you to form blocks, combine several parameters and comments together on one line, generate pushbuttons on the screen or activate them in the application toolbar, as well as insert blank lines, underscore lines and comments. Like SELECT-OPTIONS and PARAMETERS, you can use SELECTION-SCREEN statements in reports and in the include program DBldbSEL of the logical database ldb assigned to the report in the attributes. Some variants are defined only for logical databases and can therefore only be used in the include program DBldbSEL. Variant 1 SELECTION-SCREEN BEGIN OF LINE. Variant 2 SELECTION-SCREEN END OF LINE. Effect Allows you to combine several parameters and comments specified between the SELECTION-SCREEN BEGIN OF LINE and SELECTION-SCREEN END OF LINE statements and output them on one line. As a result, there is no automatic new line for each PARAMETER and no selection texts are displayed. Example SELECTION-SCREEN BEGIN OF LINE. SELECTION-SCREEN COMMENT 1(10) TEXT-001. PARAMETERS: P1(3), P2(5), P3(1). SELECTION-SCREEN END OF LINE. Selection screen: Comment ___ _____ _ Note You cannot order SELECT-OPTIONS between SELECTION-SCREEN BEGIN OF LINE and SELECTION-SCREEN END OF LINE because several objects are generated on the selection screen for a SELECT-OPTION (e.g. fields for the lower and upper limits of ranges). Variant 3 SELECTION-SCREEN SKIP n. Additions: 1. ... FOR TABLE dbtab 2. ... ID id Effect Generates n blank lines (see also SKIP). You must specify a value for n between 1 and 9. If you want to output just one blank line, you can omit n. Addition 1 ... FOR TABLE dbtab Effect This addition is allowed only in the database include program DBldbSEL. It is, in fact, a requirement. If you use SELECTION-SCREEN SKIP in DBldbSEL, you must assign the statement to a table (or to a field - see the variant COMMENT. This assignment is necessary in order to restrict the SELECTION-SCREEN statements for a report selection screen to those relevant for the tables used in the report, i.e. those which refer to a table used in the report. Any SELECTION-SCREEN statement assigned to a table not used in the report with the addition FOR TABLE dbtab are ignored when the report selection screen is generated. Note A table dbtab of the logical database ldb is considered as "used in the report" if it is either declared in a TABLES statement or its position in the database hierarchy lies somewhere between the root and a table dbtab_2 declared in the report. Example Hierarchy of logical database ldb: SPFLI | ---- SAPLANE | ---- SFLIGHT | ---- SBOOK In the report: TABLES SFLIGHT. Tables considered as "used" include SFLIGHT (since it is declared directly), as well as SAPLANE and SPFLI (since they lie on the path from the hierarchy root "SPFLI" to the declared table SFLIGHT). The table SBOOK is not considered as used, i.e. all the SELECTION-SCREEN statements qualified with the addition "FOR TABLE SBOOK" in DBldbSEL are ignored. Addition 2 ... ID id Effect This addition is allowed only in the database include program DBldbSEL. It is used to identify a SELECTION-SCREEN object (in this case blank lines) via an ID which can be up to 3 characters long. This ID is then specified in SELECTION-SCREEN EXCLUDE IDS id in order to exclude the object from a selection screen version. Variant 4 SELECTION-SCREEN ULINE. Additions: 1. ... fmt 2. ... FOR TABLE dbtab 3. ... MODIF ID mod 4. ... ID id Effect Generates an underline (see also ULINE). Addition 1 ... fmt Effect Format specification with the form /pos(len), pos(len) or (len). The slash (/) generates a new line and is therefore not allowed between BEGIN OF LINE and END OF LINE. The effect of the statement is to underscore the current line starting from the position pos for the length len. The variant (len) (without position specification) is allowed only between BEGIN OF LINE and END OF LINE. In this case, the current position in the line is used. See also WRITE. You can specify the position pos as a number (in this case, it is relative to the frame if the statement comes between SELECTION-SCREEN BEGIN OF BLOCK ... WITH FRAME ... and SELECTION-SCREEN END OF BLOCK ...). Also allowed are the symbolic positions POS_LOW and POS_HIGH. These are the positions at which the input fields of the SELECT-OPTI ONS are output (POS_LOW is also the position of PARAMETERS. Note Format specifications which do not generate a new line can produce overlapping objects on the selection screen. Therefore, you should be particularly careful with position and length specifications. Example SELECTION-SCREEN ULINE /1(10). SELECTION-SCREEN ULINE POS_LOW(10). SELECTION-SCREEN ULINE POS_HIGH(10). This generates three underscore blocks, each with a length of 10, on one line. Addition 2 ... FOR TABLE dbtab Effect See variant 3 (SELECTION-SCREEN SKIP). Addition 3 ... MODIF ID mod Effect The specified modification group (SCREEN-GROUP1) is assigned to the underscore. You can use this under AT SELECTION-SCREEN in the report or in the PAI routine of the database program SAPDBldb to modify the screen. Note The name of the modification group must be specified without quotation marks. It can be up to three characters long. Addition 4 ... ID id Effect See variant 3 (SELECTION-SCREEN SKIP) Variant 5 SELECTION-SCREEN POSITION pos. Addition: ... FOR TABLE dbtab Effect Outputs the parameter starting from the position pos. This variant is allowed only between SELECTION-SCREEN BEGIN OF LINE< /> and SELECTION-SCREEN END OF LINE. As with the addition ULINE, you can specify the position as fixed (if necessary relative to the frame) or symbolically in the form POS_LOW or POS_HIGH. Addition ... FOR TABLE dbtab Effect See variant 3 (SELECTION-SCREEN SKIP) Variant 6 SELECTION-SCREEN COMMENT fmt name. Additions: 1. ... FOR TABLE dbtab 2. ... FOR FIELD f 3. ... MODIF ID mod 4. ... ID id Effect Generates a comment on the selection screen. For the name name, there are two options: 1. name takes the form TEXT-xxx where xxx is a three-character name for a text symbol. In this case, the contents of the text symbol are displayed at runtime, i.e. the text cannot be changed dynamically. 2. name is another eight-character name. Here, you create a field with the name name in the length specified in the format fmt< /> and it is then generated as an output field on the selection screen. The contents of these comments must therefore be set at runtime (e.g. at INITIALIZATION or - in the case of comments in the database include program DBldbSEL - in the routine INIT of the database program SAPDBldb. They can also be changed when the selection screen is being processed. Note The field name is generated automatically and so cannot be defined with DATA. With comments, you must always specify a format fmt (see variant ULINE). Note You must program a new line yourself via the format fmt. Addition 1 ... FOR TABLE dbtab Note See variation 3 (SELECTION-SCREEN SKIP). Addition 2 ... FOR FIELD f Effect Since the comment is assigned to a parameter or a selection option, the help display shows the documentation of the reference field if this parameter or selection option. In addition, the comment is suppressed if the reference object was set to 'invisible' via a selection variant. Note In database access routines, the comment is generated whenever the reference field is output. Therefore, you should not use the addition FOR TABLE with this variant. Example SELECTION-SCREEN BEGIN OF LINE. SELECTION-SCREEN COMMENT 10(20) TEXT-001 FOR FIELD PARM. SELECTION-SCREEN POSITION POS_LOW. PARAMETERS PARM LIKE SAPLANE-PLANETYPE. SELECTION-SCREEN END OF LINE. This code displays a 20-byte long comment followed by the parameter at the normal position (POS_LOW) on the same line. If the user presses F1 for both objects, the documentation of SAPLANE-PLANETYPE is displayed. Addition 3 ... MODIF ID mod Effect See variant 4 (SELECTION-SCREEN ULINE) Addition 4 ... ID id Effect See variant 3 (SELECTION-SCREEN SKIP) Variant 7 SELECTION-SCREEN PUSHBUTTON fmt name USER-COMMAND ucom. Additions: 1. ... FOR TABLE dbtab 2. ... MODIF ID mod 3. ... ID id Effect Generates a pushbutton on the selection screen. Also specified is the user command ucom (without quotation marks) which can be up to 4 characters long. This is generated when the user presses the button. Apart from this, the syntax is largely similar to that of SELECTION-SCREEN COMMENT: For the name name, there are two options: 1. name takes the form TEXT-xxx where xxx is a three-character name for a text symbol. In this case, the contents of the text symbol are displayed at runtime, i.e. the text cannot be changed dynamically. 2. name is another eight-character name. Here, you create a field with the name name in the length specified in the format fmt< /> and it is then generated as an output field on the selection screen. The contents of these comments must therefore be set at runtime (e.g. at INITIALIZATION or - in the case of comments in the database include program DBldbSEL - in the routine INIT of the database program SAPDBldb. They can also be changed when the selection screen is being processed. Note The field name is generated automatically and so cannot be defined with DATA. With pushbuttons, you must always specify a format fmt (see variant ULINE). Note You must program a new line yourself via the format fmt. 1. The best way to respond to the user pressing the pushbutton is in the event AT SELECTION-SCREEN or - in the case of pushbuttons in the database include program DBldbSEL - in the routine PAI (with FNAME = '*' and MARK = SPACE) in the database program SAPDBldb. Here, the field SSCRFIELDS-UCOMM contains the user command ucom (the table SSCRFIELDS must be declared with the TABLES statement). Addition 1 ... FOR TABLE dbtab Effect See variant 3 (SELECTION-SCREEN SKIP) Addition 2 ... MODIF ID mod Effect See variant 4 (SELECTION-SCREEN ULINE) Addition 3 ... ID id Effect See variant 3 (SELECTION-SCREEN SKIP) Example TABLES SSCRFIELDS. ... SELECTION-SCREEN PUSHBUTTON /10(20) CHARLY USER-COMMAND ABCD. ... INITIALIZATION. MOVE 'My text' TO CHARLY. ... AT SELECTION-SCREEN. IF SSCRFIELDS-UCOMM = 'ABCD'. ... ENDIF. The selection screen displays a pushbutton with the text 'My text'. With AT SELECTION-SCREEN, the field SSCRFIELDS-UCOMM contains ABCD after the user has pressed the button. Variant 8 SELECTION-SCREEN BEGIN OF BLOCK block. Additions: 1. ... WITH FRAME 2. ... TITLE title 3. ... NO INTERVALS Effect Starts a logical block on the selection screen. If you use the addition WITH FRAME, a frame is generated around the block. The addition TITLE title is allowed only in conjunction with WITH FRAME. For the title title,there are two options (see also the variants COMMENT and PUSHBUTTON): 1. title takes the form TEXT-xxx where xxx is a three-character name for a text symbol. In this case, the contents of the text symbol are displayed at runtime, i.e. the text cannot be changed dynamically. 2. title is another eight-character name. Here, you create a field with the name title in the length specified in the format fmt< /> and it is then generated as an output field on the selection screen. The contents of these comments must therefore be set at runtime (e.g. at INITIALIZATION or - in the case of comments in the database include program DBldbSEL - in the routine INIT of the database program SAPDBldb. They can also be changed when the selection screen is being processed. Note The field title is generated automatically and so cannot be defined with DATA. At runtime, the event AT SELECTION-SCREEN ON BLOCK block is executed for every block in the PAI module of the selection screen (with database- specific blocks, the PAI module in the program SAPDBldb is also executed with the parameters FNAME = BLOCK_block and MARK = SPACE). If this produces an error message, just the fields of this block are ready for input. You can nest blocks. The maximum nesting depth for blocks with frames is 5. Addition 3 ... NO INTERVALS Effect Displays all SELECT-OPTIONS within the block in simplified form without a 'to' field on the selection screen (like the addition "NO INTERVALS" with SELECT-OPTIONS). If the block has a frame, this is correspondingly small. Note In the case of blocks without frames, the attribute "NO INTERVALS" is not inherited by subordinate blocks. However, all subordinate blocks of blocks with frames inherit this attribute because the generated frame is smaller and there is no space for the 'to' field. Variant 9 SELECTION-SCREEN END OF BLOCK block. Effect Closes the block opened by SELECTION-SCREEN BEGIN OF BLOCK block. If the block has a frame, the frame is closed here. Blocks opened in the include program DBldbSEL must also be closed there. Note Blocks defined in the database include program DBldbSEL must also be close there. As with SELECTION-SCREEN BEGIN OF LINE and SELECTION-SCREEN END OF LINE, you cannot use the addition FOR TABLE with blocks. Instead, the objects in the blocks (selection options, parameters, comments, underscores ...) are omitted if the table to which they belong is not used in the report (see note under variant SELECTION-SCREEN SKIP). Empty blocks (possibly with frames) are also omitted. Example TABLES SAPLANE. SELECTION-SCREEN BEGIN OF BLOCK CHARLY WITH FRAME TITLE TEXT-001. PARAMETERS PARM(5). SELECT-OPTIONS SEL FOR SAPLANE-PLANETYPE. SELECTION-SCREEN END OF BLOCK CHARLY. (Let TEXT-001 contain 'Block Charly'). Selection screen: --Block Charly----------------------------------- | PARM _____ | | SEL ________ bis ________ | ------------------------------------------------- Variant 10 SELECTION-SCREEN FUNCTION KEY n. Additions: 1. ... FOR TABLE dbtab 2. ... ID id Effect With this variant, you can activate up to 5 function keys in the application toolbar on the selection screen (n is one of the numbers 1 to 5). At runtime, the text must be placed in the Dictionary field SSCRFIELDS-FUNCTXT_01 or ... SSCRFIELDS-FUNCTXT_05. The function code placed in the field SSCRFIELDS-UCOMM is 'FC01' or ... 'FC05'. You can read this function code under AT SELECTION-SCREEN or in the PAI module of the database access program SAPDBldb. Addition 1 ... FOR TABLE dbtab Effect See variant 3 (SELECTION-SCREEN SKIP) Addition 2 ... ID id Effect See variant 3 (SELECTION-SCREEN SKIP) Example TABLES SSCRFIELDS. ... SELECTION-SCREEN FUNCTION KEY 1. ... INITIALIZATION. MOVE 'My text' TO SSCRFIELDS-FUNCTXT_01. ... AT SELECTION-SCREEN. IF SSCRFIELDS-UCOMM = 'FC01'. ... ENDIF. The selection screen displays a pushbutton with the text 'My text'. With AT SELECTION-SCREEN, the field SSCRFIELDS-UCOMM contains FC01 after the user has pressed the button. Variant 11 SELECTION-SCREEN BEGIN OF VERSION ver TEXT-xxx. Variant 12 SELECTION-SCREEN END OF VERSION ver. Variant 13 SELECTION-SCREEN EXCLUDE ... . Effect Defines a selection screen version (with a three-character name ver). These variants are only allowed in the database include program DBldbSEL. Between BEGIN OF VERSION and END OF VERSION, you can exclude selection screen objects for the version ver, i.e. remove them from the selection screen with SELECTION-SCREEN EXCLUDE.. For a report, you activate a selection screen by making an entry in the attributes. If the database access program SAPDBldb itself has a selection screen version in the attributen, this applies for all reports which use this logical database and have attributes where no separate selection screen version is declared. The text symbol TEXT-xxx is used merely to facilitate selection of a selection screen version via F4 help when maintaining the attributes. Additions: (to SELECTION-SCREEN EXCLUDE) 1. ... PARAMETERS par 2. ... SELECT-OPTIONS sel 3. ... RADIOBUTTON GROUPS radi 4. ... BLOCKS block 5. ... IDS id Effect Excludes selection screen objects between SELECTION-SCREEN BEGIN and END OF VERSION. This allows you to exclude individual parameters or selection options, radiobutton groups, blocks defined by SELECTION-SCREEN BEGIN/END OF BLOCK and other objects such as comments and underscores specified by the addition ID id. Note The database program SAPDBldb can get the active version for the current report with the function module RS_SELSCREEN_VERSION. Example PARAMETERS PAR_1 LIKE dbfield_1 FOR TABLE dbtab_1. SELECT-OPTIONS SEL_1 FOR dbfield_01. SELECT-OPTIONS SEL_2 FOR dbfield_02. SELECT-OPTIONS SEL_3 FOR dbfield_03. SELECTION-SCREEN COMMENT /10(20) TEXT-100 FOR TABLE dbtab_1 ID 001. SELECTION-SCREEN COMMENT /8(30) TEXT-200 FOR TABLE dbtab_2 ID 002. PARAMETERS PAR_2 LIKE dbfield_1 FOR TABLE dbtab_2. PARAMETERS PAR_3 LIKE dbfield_1 FOR TABLE dbtab_2. ... SELECTION-SCREEN BEGIN OF VERSION ABC TEXT-008. SELECTION-SCREEN EXCLUDE PARAMETERS: PAR_1, PAR_3. SELECTION-SCREEN EXCLUDE SELECT-OPTIONS: SEL_2. SELECTION-SCREEN EXCLUDE IDS: 001. SELECTION-SCREEN END OF VERSION ABC. If the report attributes (or the attributes of the database program SAPDBldb) contain the selection screen version ABC, the parameters PAR_1 and PAR_3, the selection option SEL_2 and the comment with the text number 100 (ID 001) are not displayed on the selection screen. When you maintain the attributes, the text symbol 008 of SAPDBldb is displayed if you press F4 on the field 'Selection screen version'. Variant 14 SELECTION-SCREEN DYNAMIC SELECTIONS FOR TABLE dbtab. Addition: ... ID id Effect This variant is allowed only in the database include program DBldbSEL. It informs you for which logical database tables additional selections are supported. If one of these tables is active in the report (i.e. it is declared under TABLES or lies somewhere on the path from the root of the database hierarchy to a table declared with TABLES), a psuhbutton called 'Dynamic selections' appears on the selection screen. On pressing this button, the user branches to a dialog Taste where it is possible to enter selections for the fields of the relevant tables in the logical database. You can define the field list in two different ways: 1. Via a selection view defined for the purpose: You can maintain selection views within the logical database maintenance transaction. They consist of a set of fields from logical database tables which are divided into groups. It is also possible to preselect fields. Customers can overlay these selection views with their own (i.e. in this case, the system searches first for the customer selection view and only accesses the SAP selektion view if no customer-specific view exists). If a preselection has already been made in the selection view, the user immediately sees the selection screen for the preselected fields and can enter selections. Otherwise, a fields must be selected first. 2. Via all fields of all tables In this case, the user must first choose the tables and then select the fields for which additional selections are to be made before branching to the selection screen to enter the dynamic selections. The database access programm SAPDBldb then receives the WHERE clauses generated from the user entries in the form of a complex data object DYN_SEL. Addition ... ID id Effect Similar to the addition 2 (SKIP). This allows you to exclude tables from the possibility of dynamic selection via the selection screen versions. Note The exact definition of the object DYN_SEL is stored in the TYPE-POOL RSDS and is as follows: TYPES: BEGIN OF RSDS_WHERE, TABLENAME LIKE RSDSTABS-PRIM_TAB, WHERE_TAB LIKE RSDSWHERE OCCURS 5, END OF RSDS_WHERE. ... TYPES: BEGIN OF RSDS_TYPE, CLAUSES TYPE RSDS_WHERE OCCURS 5, TEXPR TYPE RSDS_TEXPR, TRANGE TYPE RSDS_TRANGE, END OF RSDS_TYPE. DATA DYN_SEL TYPE RSDS_TYPE. The object DYN_SEL thus contains a component (CLAUSES) which is an internal table. Each line of this internal table contains a table name (TABLENAME) and another table (WHERE_TAB) which contains the WHERE clauses for the table (TABLENAME). You can find the structure of the other components in the type pool RSDS. TEXPR contains the selections in a format which allows storage and can be used for the "freely callable" function modules when entering dynamic selections (FREE_SELECTIONS_INIT, FREE_SELECTIONS_DIALOG). TRANGE contains the selections in the form of RANGES tables which can be used with the IN operator in SELECT, CHECK and IF. Note Neither the TYPE-POOL RSDS nor the declaration of DYN_SEL must appear in the database program. Both are automatically included by the system. In the database program SAPDBldb, an access to a table XXXX could look something like below: FORM PUT_XXXX. DATA L_DS_CLAUSES TYPE RSDS_WHERE. MOVE 'XXXX' TO L_DS_CLAUSES-TABLENAME. READ TABLE DYN_SEL-CLAUSES WITH KEY L_DS_CLAUSES-TABLENAME INTO L_DS_CLAUSES. SELECT * FROM XXXX WHERE field1 IN ... AND field2 .... ... AND (L_DS_CLAUSES-WHERE_TAB). PUT XXXX. ENDSELECT. ENDFORM. Note If the table L_DS_CLAUSES-WHERE_TAB is empty, i.e. if no dynamic selections are entered for the table XXXX, the addition ... AND (L_DS_CLAUSES-WHERE_TAB) is ignored during the SELECT. Variant 15 SELECTION-SCREEN FIELD SELECTION FOR TABLE dbtab. Addition: ... ID id Effect This variant is allowed only in the database include program DBldbSEL. It informs you for which logical database tables field selection is supported. For these tables, you can fill just those database fields which the report actually needs. In the report, you determine these fields with GET dbtab FIELDS f1 ... fn or GET dbtab LATE FIELDS f1 ... fn (the field list is then supplemented by the key fields of the table dbtab). By restricting to the really necessary field, you considerably improve performance. The database access program SAPDBldb receives the desired fields for the dynamic field selection in the form of an internal table SELECT_FIELDS. Note The exact definition of the object SELECT_FIELDS is stored in the TYPE-POOL RSFS and looks something like below: TYPES: BEGIN OF RSFS_TAB_FIELDS, TABLENAME LIKE RSDSTABS-PRIM_TAB, FIELDS LIKE RSFS_STRUC OCCURS 10, END OF RSFS_TAB_FIELDS. ... TYPES: RSFS_FIELDS TYPE RSFS_TAB_FIELDS OCCURS 10. DATA SELECT_FIELDS TYPE RSFS_FIELDS. SELECT_FIELDS is thus an internal table. Each line of this internal table contains a table name (TABLENAME) and another internal table (FIELDS) which contains the desired fields of the table (TABLENAME). Note Neither the TYPE-POOL RSFS nor the declaration of SELECT_FIELDS has to appear in the database program. Both are automatically included by the system. Unlike the objects connected with the addition DYNAMIC SELECTIONS, SELECT_FIELDS is also available in the report. In the database program SAPDBldb, an access to a table XXXX could look something like below: FORM PUT_XXXX. DATA L_TAB_FIELDS TYPE RSFS_TAB_FIELDS. MOVE 'XXXX' TO L_TAB_FIELDS-TABLENAME. READ TABLE SELECT_FIELDS WITH KEY L_TAB_FIELDS-TABLENAME INTO L_TAB_FIELDS. SELECT (L_TAB_FIELDS-FIELDS) INTO CORRESPONDING FIELDS OF XXXX FROM XXXX WHERE field1 IN ... AND field2 .... ... PUT XXXX. ENDSELECT. ENDFORM. Note 1. If the table L_TAB_FIEDLS is empty, i.e. if no dynamic selections are entered for the table XXXX, SELECT (L_TAB_FIELDS) ... works like SELECT * ..., i.e. all fields of the table XXXX are filled. 2. The internal table SELECT_FIELDS already contains values when the routine INIT is executed in the database program or when the INITIALIZATION processing is executed in the report. It can be manipulated by the appropriate program if it is absolutely necessary to fill another field for the logical database. SELECT clause Variants: 1. SELECT [SINGLE [FOR UPDATE] | DISTINCT] * 2. SELECT [SINGLE [FOR UPDATE] | DISTINCT] s1 ... sn 3. SELECT [SINGLE [FOR UPDATE] | DISTINCT] (itab) Effect The result of a SELECT statement is itself a table. The SELECT clause describes which columns this table is supposed to have. In addition, you can use the optional addition SINGLE or DISTINCT if you want only certain lines of the solution set to be visible for the calling program: SINGLE The result of the selection is a single record. If this record cannot be uniquely identified, the first line of the solution set is selected. The addition FOR UPDATE protects the selected record against parallel changes by other transactions until the next database commit occurs (see LUW and Database locking). If the database system detects a deadlock, the result is a runtime error. DISTINCT Any lines which occur more than once are automatically removed from the selected dataset. Note To ensure that a record is uniquely determined, you can fully qualify all fields of the primary key by linking them together with AND in the WHERE condition. Note Performance: 1. The additions SINGLE FOR UPDATE and DISTINCT exclude the use of SAP buffering. 2. The addition DISTINCT requires sorting on the database server and should therefore only be specified if duplicates are likely to occur. Variant 1 SELECT [SINGLE [FOR UPDATE] | DISTINCT] * Effect In the result set, the columns correspond exactly in terms of order, ABAP/4 Dictionary type and length to the fields of the database table (or view) specified in the FROM clause . Example Output all flight connections from Frankfurt to New York: TABLES SPFLI. SELECT * FROM SPFLI WHERE CITYFROM = 'FRANKFURT' AND CITYTO = 'NEW YORK'. WRITE: / SPFLI-CARRID, SPFLI-CONNID. ENDSELECT. Example Output all free seats on the Lufthansa flight 0400 on 28.02.1995: TABLES SFLIGHT. DATA SEATSFREE TYPE I. SELECT SINGLE * FROM SFLIGHT WHERE CARRID = 'LH ' AND CONNID = '0400' AND FLDATE = '19950228'. SEATSFREE = SFLIGHT-SEATSMAX - SFLIGHT-SEATSOCC. WRITE: / SFLIGHT-CARRID, SFLIGHT-CONNID, SFLIGHT-FLDATE, SEATSFREE. Variant 2 SELECT [SINGLE [FOR UPDATE] | DISTINCT] s1 ... sn Effect The order, ABAP/4 Dictionary type and length of the columns of the result set are explicitly defined by the list s1 ... sn. Each si has the form ai or ai AS bi. Here, ai stands either for - a field f of the database table or - a aggregate print. bi is an alternative name for the i-th column of the result set. When using INTO CORRESPONDING FIELDS OF wa in the INTO clause, you can specify an alternative column name to assign a column of the result set uniquely to a column of the target area. An aggregate print uses an aggregate function to group together data from one or all columns of the database table. Aggregate prints consist of three or four components: 1. An aggregate function immediately followed by an opening parenthesis 2. DISTINCT (optional) 3. The database field f 4. A closing parenthesis All components of a print must be separated by at least one blank. The following aggregate functions are available: MAX Returns the greatest value in the column determined by the database field f for the selected lines. Specifying DISTINCT does not change the result. NULL values are ignored unless all values in a column are NULL values. In this case, the result is NULL. MIN Returns the smallest value in the column determined by the database field f for the selected lines. Specifying DISTINCT does not change the result. NULL values are ignored unless all values in a column are NULL values. In this case, the result is NULL. AVG Returns the average value in the column determined by the database field f for the selected lines. AVG can only apply to a numeric field. NULL values are ignored unless all values in a column are NULL values. In this case, the result is NULL. SUM Returns the sum of all values in the column determined by the database field f for the selected lines. SUM can only apply to a numeric field. NULL values are ignored unless all values in a column are NULL values. In this case, the result is NULL. COUNT Returns the number of different values in the column determined by the database field f for the selected lines. Specifying DISTINCT is obligatory here. NULL values are ignored unless all values in a column are NULL values. In this case, the result is 0 COUNT( * ) Returns the number of selected lines. If the SELECT command contains a GROUP BY clause, it returns the number of lines for each group. The form COUNT(*) is also allowed. If ai is a field f, MAX( f ), MIN( f ) or SUM( f ), the corresponding column of the result set has the same ABAP/4 Dictionary format as f. With COUNT( f ) or COUNT( * ), the column has the type INT4, with AVG( f ) the type FLTP. If you specify aggregate functions together with one or more database fields in a SELECT clause, all database fields not used in one of the aggregate functions must be listed in the GROUP-BY clause. Here, the result of the selection is a table. If only aggregate functions occur in the SELECT clause, the result of the selection is a single record. Here, the SELECT command is not followed later by an ENDSELECT. Notes 1. This variant is not available for pooled tables and cluster tables. 2. If the SELECT clause contains a database field of type LCHAR or LRAW, you must specify the appropriate length field immediately before. Notes Performance: 1. Specifying aggregate functions excludes the use of SAP buffering. 2. Since many database systems do not manage the number of table lines and therefore have to retrieve this at some cost, the function COUNT( * ) is not suitable for checking whether a table contains a line or not. To do this, it is best to use SELECT SINGLE f ... for any table field f. 3. If you only want to select certain columns of a database table, you are recommended to specify a list of fields in the SELECT clause or to use a View. Examples Output all flight destinations for Lufthansa flights from Frankfurt: TABLES SPFLI. DATA TARGET LIKE SPFLI-CITYTO. SELECT DISTINCT CITYTO INTO TARGET FROM SPFLI WHERE CARRID = 'LH ' AND CITYFROM = 'FRANKFURT'. WRITE: / TARGET. ENDSELECT. Output the number of airline carriers which fly to New York: TABLES SPFLI. DATA COUNT TYPE I. SELECT COUNT( DISTINCT CARRID ) INTO COUNT FROM SPFLI WHERE CITYTO = 'NEW YORK'. WRITE: / COUNT. Output the number of passengers, the total weight and the average weight of luggage for all Lufthansa flights on 28.02.1995: TABLES SBOOK. DATA: COUNT TYPE I, SUM TYPE P DECIMALS 2, AVG TYPE F. DATA: CONNID LIKE SBOOK-CONNID. SELECT CONNID COUNT( * ) SUM( LUGGWEIGHT ) AVG( LUGGWEIGHT ) INTO (CONNID, COUNT, SUM, AVG) FROM SBOOK WHERE CARRID = 'LH ' AND FLDATE = '19950228' GROUP BY CONNID. WRITE: / CONNID, COUNT, SUM, AVG. ENDSELECT. Variant 3 SELECT [SINGLE [FOR UPDATE] | DISTINCT] (itab) Effect Works like SELECT [SINGLE [FOR UPDATE] | DISTINCT] s1 ... sn if the internal table itab contains the list s1 ... sn as ABAP/4 source code, and like SELECT [SINGLE [FOR UPDATE] | DISTINCT] *, if itab is empty. The internal table itab can only have one field which must be of type C and cannot be more than 72 characters long. itab must appear in parentheses and there should be no blanks between the parentheses and the table name. Note With this variant, the same restrictions apply as for SELECT [SINGLE [FOR UPDATE] | DISTINCT] s1 ... sn. Example Output all Lufthansa flight routes: TABLES: SPFLI. DATA: FTAB(72) OCCURS 5 WITH HEADER LINE. REFRESH FTAB. FTAB = 'CITYFROM'. APPEND FTAB. FTAB = 'CITYTO'. APPEND FTAB. SELECT DISTINCT (FTAB) INTO CORRESPONDING FIELDS OF SPFLI FROM SPFLI WHERE CARRID = 'LH'. WRITE: / SPFLI-CITYFROM, SPFLI-CITYTO. ENDSELECT. SET Effect Sets different processing parameters Basic forms: 1. SET PF-STATUS pfstat. 2. SET TITLEBAR f. 3. SET SCREEN scr. 4. SET CURSOR ... 5. SET PARAMETER ID pid FIELD f. 6. SET LANGUAGE lg. 7. SET COUNTRY f. 8. SET BLANK LINES ON/OFF. 9. SET MARGIN x y. 10. SET USER-COMMAND f. 11. SET LEFT SCROLL-BOUNDARY. 12. SET EXTENDED CHECK ON/OFF. 13. SET PROPERTY OF obj p = f. 14. SET RUN TIME ANALYZER ON/OFF. SET Basic form 8 SET BLANK LINES ON. SET BLANKS LINES OFF. Effect These statements allow you to specify whether you want to output blank lines or not. Use SET BLANK LINES ON to output blank lines or SET BLANK LINES OFF to suppress them. The default setting is SET BLANK LINES OFF. Example When outputting texts, include blank lines: DATA: BEGIN OF TEXTTAB OCCURS 100, LINE(72), END OF TEXTTAB. SET BLANK LINES ON. LOOP AT TEXTTAB. WRITE / TEXTTAB-LINE. ENDLOOP. Suppress blank lines again with the statement: SET BLANK LINES OFF. SET COUNTRY Basic form 7 SET COUNTRY f. Effect Displays the decimal point and date in all subsequent output (WRITE) according to the settings specified in the table T005X for the country ID f. The return code value is set as follows: SY-SUBRC = 0: The statement was successful. SY-SUBRC = 4: The country ID was not found in table T005X. Notes 1. The country must exist in table T005X. Otherwise, the formats used are "." for the decimal point and "MM/DD/YYYY" for the date. 2. The special form SET COUNTRY SPACE (or f contains SPACE) resets the decimal point and date display formats to the setting contained in the current user's master record. In this case, table T005X is not read and the return code value is always 0. 3. The effect of SET COUNTRY is not restricted to the current program, but applies at once to all programs in the current roll area. Example When outputting documents, display the decimal point and date in the format specified for the country of the recipient: DATA: RECEIVER_COUNTRY LIKE T005X-LAND, DATE LIKE SY-DATUM, AMOUNT TYPE P DECIMALS 2. ... SET COUNTRY RECEIVER_COUNTRY. IF SY-SUBRC = 4. WRITE: / RECEIVER COUNTRY, ' is unknown'. ENDIF. WRITE: / DATE, AMOUNT. Then, you can say SET COUNTRY SPACE. to display the decimal point and date according to the specification for the user again. SET CURSOR Variants: 1. SET CURSOR FIELD f. 2. SET CURSOR LINE lin. 3. SET CURSOR col lin. Effect Sets the cursor dynamically in display (screen program or list). Variant 1 SET CURSOR FIELD f. Additions: 1. ... OFFSET off 2. ... LINE lin Effect Places the cursor dynamically at the start of the field g which is specified in the field f. Note With step loops and in list processing, you also need the addition ... LINE lin. Addition 1 ... OFFSET off Effect Offsets the cursor position by off columns from the start of the field g which is specified in the field f (1st column = 0). Addition 2 ... LINE lin Effect Places the cursor in the field g (specified in the field f) of the loop line lin with step loops, or of the absolute list line lin (SY-LILLI) in the case of list processing. Notes 1. Specifying LINE lin is possible only with step loops and in list processing. In these cases, it is necessary. 2. The name specified in the field f must be a global field. For field symbols and reference parameters, you must use the name of the global field which is assigned to the field symbol or parameter at the time of output (i.e. with "WRITE"). Examples 1. Place the cursor on a screen field. DATA F(5) VALUE 'MODUS'. DATA MODUS(10) VALUE '1234567890'. ... MODULE set_cursor OUTPUT. ... SET CURSOR FIELD F. or SET CURSOR FIELD 'MODUS'. Both statements place the cursor at the beginning of the field MODUS. SET CURSOR FIELD F OFFSET 2. or SET CURSOR FIELD 'MODUS' OFFSET 2. Both statements place the cursor on the third character (in this case the digit "3") of the field MODUS. ... ENDMODULE. 2. Place the cursor at the beginning of a field when selecting a line in list processing. MOVE 'MODUS' TO F. MOVE '1234567890' TO MODUS. DO 10 TIMES. NEW-LINE. POSITION SY-INDEX WRITE MODUS. ENDDO. AT LINE-SELECTION. SET CURSOR FIELD F LINE SY-LILLI. or SET CURSOR FIELD 'MODUS' LINE SY-LILLI. Both statements place the cursor at the beginning of the field MODUS on this line when the user double-clicks. SET CURSOR FIELD F LINE SY-LILLI OFFSET 2. or SET CURSOR FIELD 'MODUS' LINE SY-LILLI OFFSET 2. Both statements place the cursor on the third character (in this case the digit "3") of the field MODUS on this line when the user double-clicks. Variant 2 SET CURSOR LINE lin. Additions: 1. ... OFFSET off Effect Places the cursor dynamically in the loop line lin with step loops or in the absolute list line lin (SY-LILLI) in list processing. This variant is only possible with step loops and in list processing. Addition 1 ... OFFSET off Effect Places the cursor off columns from the beginning of the line. Example Place the cursor at the beginning of the line when selecting a line in list processing. DATA MODUS(10) VALUE '1234567890'. DO 10 TIMES. NEW-LINE. WRITE MODUS. ENDDO. AT LINE-SELECTION. SET CURSOR LINE SY-LILLI. This statement sets the cursor at the beginning of the line when the user double-clicks. SET CURSOR LINE SY-LILLI OFFSET 2. This statement sets the cursor on the third column (in this case the digit "3" of the field MODUS) on this line when the user double-clicks. Variant 3 SET CURSOR col lin. Effect Places the cursor dynamically on the column col and the line lin of the current screen. Example SET CURSOR 60 5. Positions the cursor on line 5, column 60. Related GET CURSOR SET Basic form 12 SET EXTENDED CHECK OFF. SET EXTENDED CHECK ON. Effect You use these statements tot switch the extended syntax check off or on. If the extended syntax check (Transaction SLIN) reports errors which you do not consider to be errors, and you want to suppress them in future, you can insert the above statements at the appropriate places in the program. A "SET EXTENDED CHECK OFF." should be followed as soon as possible by a "SET EXTENDED CHECK ON.", so that the check is only switched off for a short time. These statements are not interpreted at runtime. You use them only to mark the source code. During the extended syntax check, you can ignore these statements by using the additional function Include suppressed fields. SET Basic form 6 SET LANGUAGE lg. Effect Initializes all text elements TEXT-nnn and all language-specific text literals 'abcd.....'(nnn) (nnn = text number) in the specified language. If the text pool does not exist in the desired language, searches in the system language. If the text pool does not exist in the system language either, searches in the secondary language. Notes 1. The length of the texts must be the same in all languages. 2. The effect is restricted to the current program and is neither extended by an external PERFORM nor by a SUBMIT from another program. SET Basic form SET MARGIN x y. Effect Applies only to list output: Produces a Print with a margin of x columns on the left and (if specified) y lines from the top of the page. x and y can be constants or variables. Note The MARGIN specification is always effective on the current page. SET Basic form 5 SET PARAMETER ID pid FIELD f. Effect Writes the contents of the field f to the global SAP memory under the key pid. If the key already contains a value, it is overwritten. The key pid must consist of three characters. You can find a list of the keys (parameters) used in the SAP system description or in the ABAP/4 Development Workbench. Notes - The global SAP memory remains available to the user during the entire terminal session. This means that set values are retained when you leave a program. - You should not use the SAP memory for temporary storage of values because other modes use the same global memory. - If you need a new key (parameter), you can create this in the ABAP/4 Development Workbench. Example DATA: REPID(8) VALUE 'RFSCHU01'. SET PARAMETER ID 'RID' FIELD REPID. Sets the program name, e.g. for transfer to another program. Notes Runtime errors: - SET_PARAMETER_ID_TOO_LONG: Key longer than 3 characters. - SET_PARAMETER_ID_WRONG_TYPE: Key neither type C nor type N. - SET_PARAMETER_VALUE_TOO_LONG: Value longer than 250 characters. Related GET PARAMETER SET Basic form 1 SET PF-STATUS pfstat. Additions: 1. ... EXCLUDING f or ... EXCLUDING itab 2. ... IMMEDIATELY Effect Sets a GUI (Graphical User Interface) status pfstat which can be up to 8 characters long. There are many of these statuses in the GUI of a program. Each one describes which functions are available and how you can select these via menus and menu bars or by pressing function keys or pushbuttons. For further information about this, refer to the Menu Painter documentation. Setting a status makes the functions contained therein selectable. This method allows you to vary the available functions according to the current screen, list level and/or previous program flow. The current status is stored in the system field SY-PFKEY. A status remains valid until reset. Example Event in program: START-OF-SELECTION. SET PF-STATUS 'MAIN'. WRITE SY-PFKEY. AT USER-COMMAND. CASE SY-UCOMM. WHEN 'F001'. SET PF-STATUS '0001'. WRITE SY-PFKEY. ... ENDCASE. Produces a list (contents MAIN) with a GUI framework which allows you to select functions assigned to the the status MAIN. If you choose the function code F001 (e.g. from the menu or by pressing a pushbutton), you trigger the event AT USER-COMMAND. This generates a details list (contents 0000) with a GUI framework which allows you to select functions assigned to the status 0001. On returning from the details list to the basic list the status MAIN is reactivated. Example PBO module: MODULE PBO_100 OUTPUT. SET PF-STATUS 'S001'. ENDMODULE. Displays the screen 100 with a GUI framework which allows you to select functions assigned to the status S001. Notes - If no GUI is defined in the list processing (or it is deactivated with SET PF-STATUS SPACE), the system supplies a standard user interface. - This statement converts the contents of the field pfstat to type C. The converted value is used to search for the desired status. Since the conversion employs the standard conversion rules as for MOVE, you should use a field similar to type C (e.g. type C or N) for pfstat to avoid unwanted conversions. In this case, a field of type I with a value of 12 would give the key ' 12 '. Addition 1 ... EXCLUDING f ... EXCLUDING itab Effect Deactivates one or more of the status functions, so that they cannot be selected. Specify the appropriate function codes using one of the following: - a field f or a literal which contains a function code - an internal table itab which contains several function codes This method allows you simply to modify the selectable functions of a status at runtime. Example DATA: BEGIN OF TAB OCCURS 10, FCODE(4), END OF TAB. REFRESH TAB. MOVE 'DELE' TO TAB-FCODE. APPEND TAB. MOVE 'AUSW' TO TAB-FCODE. APPEND TAB. SET PF-STATUS 'STA3' EXCLUDING TAB. Sets the status STA3 which renders the functions with the function codes DELE and AUSW inactive. Addition 2 ... IMMEDIATELY Effect List processing: The status becomes effective for the last list displayed and is not flagged for the next details list. In screen processing, this addition has no effect because every status becomes immediately effective anyway. Example Event in program: START-OF-SELECTION. SET PF-STATUS 'MAIN'. WRITE SY-PFKEY. AT USER-COMMAND. CASE SY-UCOMM. WHEN 'F002'. SET PF-STATUS '0002' IMMEDIATELY. EXIT. ... ENDCASE. Selecting the function F002 in the basic list (contents MAIN, status MAIN) redisplays the basic list, but this time with the status 0002. Note Without the addition ... IMMEDIATELY, the old status MAIN becomes active again. SET Basic form 13 SET PROPERTY OF obj p = f. Addition: ... NO FLUSH Effect Sets the property p of the object obj according to the contents of the field f. The object obj must be of type OLE2_OBJECT. Normally, all consecutive OLE statements are buffered by the ABAP/4 processor and sent to the presentation server in bundled form. This means that it is possible for a statement to refer to the results of preceding statements. In debugging, however, you should remember that the values of the return parameters cannot be displayed until directly before execution of the first ABAP/4 statement external to OLE. Even a command which refers to an object not yet generated by any OLE statement terminates the bundling. The return code value of SY-SUBRC indicates whether all the bundled commands have been successfully executed. The return code value is set as follows: SY-SUBRC = 0: All commands were successfully executed. SY-SUBRC = 1: When communicating with the presentation server, a system error occurred. The system field SY-MSGLI contains a short description of the error. SY-SUBRC = 2: A method call resulted in an error. SY-SUBRC = 3: Setting a property resulted in an error. SY-SUBRC = 4: Reading a property resulted in an error. In the last 3 cases, a dialog box containing an error note is displayed on the presentation server. SET PROPERTY belongs to a group of key words which allow you to process external objects with ABAP/4. At present, only the object model OLE2 is supported, i.e. all objects must be of type OLE2_OBJECT. This type and other necessary data are defined in the include program OLE2INCL. Addition ... NO FLUSH The addition NO FLUSH continues the collection process, even if the next command is not an OLE statement. This means that you can set a series of properties in a loop and download them to the presentation server in a single transport operation. If you do not use NO FLUSH, you must ensure that you do not rely on the contents of return parameters not yet filled. Also, all objects must be initialized in a bundle, i.e. they must be generated by an OLE call that has already been executed. Every FREE statement always causes a download of the buffer. Example Sets the property 'Visible' of an EXCEL worksheet. INCLUDE OLE2INCL. DATA EXCEL TYPE OLE2_OBJECT. CREATE OBJECT EXCEL 'Excel.Application'. SET PROPERTY OF EXCEL 'Visible' = 1. Related GET PROPERTY CALL METHOD CREATE OBJECT FREE OBJECT SET RUN TIME ANALYZER ON/OFF Note This statement is for internal use only. Incompatible changes or further developments may occur at any time without warning or notice. Variants: 1. SET RUN TIME ANALYZER ON. 2. SET RUN TIME ANALYZER OFF. Variant 1 SET RUN TIME ANALYZER ON. Addition: ... MODE mode Effect Switches on runtime analysis. The return code value is set as follows: SY-SUBRC = 0: Runtime analysis was switched on. SY-SUBRC <> 0: Runtime analysis was not switched on because the performance data file was not open. Addition ... MODE mode Effect Writes certain records to the performance data file and assigns the associated performance data to the superior entry. This ensures that the performance data file does not become too big through entries that cannot be used individually. The processing mode mode controls write behavior when an object is measured. You can assign a whole value to the processing mode mode. MODE 0 is optional. MODE 0 has the following meaning: - MODE 0 <-> Standard setting All records are written to the performance data file. Certain flags are set depending on the binary format of mode whose value is other than zero. If any of the following bits are of the binary value are set, the procedure is different: - 1st bit <-> With internal tables is switched off. The records für APPEND, COLLECT and SORT are omitted. - 2nd bit <-> With technical DB information is switched off. Database operations (OPEN, FETCH, CLOSE, LOAD, GET, MODIFY) and buffer operations (PREPARE, OPEN, FETCH, CLOSE, INSERT, UPDATE, DELETE, COMMIT, ROLLBACK) are not written to the performance data file. - 3rd bit <-> With subroutines is switched off. The records for PERFORM are omitted. Examples a) SET RUN TIME ANALYZER ON MODE 3. b) SET RUN TIME ANALYZER ON MODE 11. a) and b) have the same effect because the 1st and 2nd bits are set in both cases (see the explanantions above). Variant 2 SET RUN TIME ANALYZER OFF. Effect 1. Closes the performance data file. 2. Switches off runtime analysis. Example DO 2 TIMES. IF SY-UNAME = 'SMITH'. CALL FUNCTION 'S_ABAP_TRACE_OPEN_FILE'. SET RUN TIME ANALYZER ON. ENDIF. * >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> * The modularization unit to be measured is called * here. * <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< IF SY-UNAME = 'SMITH'. SET RUN TIME ANALYZER OFF. ENDIF. ENDDO. SET Basic form 3 SET SCREEN scr. Effect In ABAP/4 dialogs, this sets the next screen number. In addition to the current screen, processes the screen with the number scr. Example SET SCREEN 200. Note To leave a screen called with CALL SCREEN or to return from a branch to the transaction selection screen, you must use the statement SET SCREEN 0. or LEAVE TO SCREEN 0. Related LEAVE TO SCREEN LEAVE SCREEN SET Basic form 11 SET LEFT SCROLL-BOUNDARY. Addition: ... COLUMN col Effect When you create a list, the current write position (system field SY-COLNO, see WRITE) is set as the left boundary of the movable area. When this list page is displayed on the screen, you can scroll horizontally with the scrollbar only from this list column - all list column to the left of this are fixed at the left edge. Addition: ... COLUMN col Effect Sets the column col as the left boundary of the movable area. Note The last value set by SET SCROLL-BOUNDARY affects the entire page display and must be reset for each list page (usually in the event TOP-OF-PAGE) - although it can be different for each list page. The NEW-LINE NO-SCROLLING statement allows you to exclude individual list lines from horizontal scrolling (e.g. title lines and indented comment blocks). Example Fix the leading column DATA: NUMBER TYPE I, SUB_NUMBER TYPE I. NEW-PAGE NO-TITLE NO-HEADING. DO 10 TIMES. NUMBER = SY-INDEX. DO 10 TIMES. SUB_NUMBER = SY-INDEX. WRITE: /(10) NUMBER, '|', (10) SUB_NUMBER, '|'. SET LEFT SCROLL-BOUNDARY. Not really necessary here because it was already set in the event TOP-OF-PAGE. WRITE: 'Data 1', '|', 'Data 2', '|', 'Data 3', '|'. " ... 'Data n' ENDDO. ENDDO. ULINE. TOP-OF-PAGE. ULINE. WRITE: /(10) 'No', '|', (10) 'Sub_No', '|'. SET LEFT SCROLL-BOUNDARY. WRITE: 'DATA 1', '|', 'DATA 2', '|', 'DATA 3', '|'. " ... 'DATA n' ULINE. This produces the following list: ------------------------------------------------------ No | Sub_No | DATA 1 | DATA 2 | DATA 3 | ------------------------------------------------------ 1 | 1 | Data 1 | Data 2 | Data 3 | 1 | 2 | Data 1 | Data 2 | Data 3 | 1 | 3 | Data 1 | Data 2 | Data 3 | ... 10 | 8 | Data 1 | Data 2 | Data 3 | 10 | 9 | Data 1 | Data 2 | Data 3 | 10 | 10 | Data 1 | Data 2 | Data 3 | ------------------------------------------------------ Only the columns DATA 1, DATA 2 and DATA 3 are moved with horizontal scrolling. Example Reset the leading column for a new page: NEW-PAGE. SET LEFT SCROLL-BOUNDARY COLUMN 0. SET Basic form 2 SET TITLEBAR f. Addition: ... WITH g1 g2 ... gn Effect Sets a screen title You use the Menu Painter to edit these program-driven screen headers. If there is a text for the three-character title, it is displayed in the title bar of the next screen. If the program is in an external subroutine, the name of the main program is used as the program name. In contrast, a function module sets a title belonging to the function group. A set title remains valid within a transaction until you call SET TITLEBAR again. After SET TITLEBAR, the system field SY-TITLE contains the current screen header. SY-TITLE can be up to 70 characters long. Note Here, the contents of the field f are converted to a value of type C (according to the standard conversion rules) and the desired title is found using this value. It is therefore advisable to use a field similar to type C (e.g. type C or N) to avoid unwanted conversions. For example, a field of type I with a value of 9 would give the key ' 9 '. Addition ... WITH g1 g2 ... gn Effect Allows you to build up to 9 parameters into the header, using the variables &1 to &9. Starting on the left, all & characters are replaced by the corresponding parameter (i.e. the first & is replaced by the first parameter specified under WITH and so on). If you do not want a & character to be replaced, you must specify it twice ( && ). If a parameter is missing for one of the title variables, it is replaced by a blank. On account of the upper limit of 70 characters (the length of SY-TITLE, &1 characters can be lost when replacing with WITH. Example DATA: PAR1(4) VALUE 'par1', PAR2(4) VALUE 'par2'. SET TITLEBAR 'ABC' WITH PAR1 PAR2 'par3'. If the title "ABC" contains "Title & &1&3 intermediate text & &2 && & &4" the above example would produce a title bar with the text "Title par1 par1par3 intermediate text par2 par2 & par3 ". SET Basic form SET UPDATE TASK LOCAL. Effect Switches on the local update task. This means that when you specify CALL FUNCTION ...IN UPDATE TASK, the update data is not stored in the database, but in ABAP/4 memory. The update works as before. The only difference is that it is not performed in a separate process, but in the same process as the calling program, i.e. when a COMMIT WORK occurs, processing does not continue until all the update requests have been performed. In the standard setting, the normal update task is always active. The switch status is not passed on to programs. This means that CALL TRANSACTION and SUBMIT use the standard setting. In contrast to this, a module called with CALL DIALOG inherits the switch setting. This is because CALL TRANSACTION and SUBMIT run in their own LUW, whereas CALL DIALOG does not. On COMMIT WORK and ROLLBACK WORK the switch is reset. Update requests with a delayed start (V2) cannot be processed locally. Like in the normal update task, all messages apart from type 'S' result in termination and rollback. Note Unlike the normal update task, the local update task does not run in its own LUW. If a rollback occurs, any changes made in the dialog part are also reset. The return code value is set as follows: SY-SUBRC = 0: The local update task was switched on. SY-SUBRC = 1: The local update task could not be switched on because a CALL FUNCTION ... IN UPDATE TASK has already been started. The system continues in the normal update mode. Example Switch on local update task: SET UPDATE TASK LOCAL. SET Basic form SET USER-COMMAND f. Effect Only valid with report list output: Sets the contents of the field f as USER-COMMAND and executes them immediately when the list is next displayed (i.e. the system suppresses the list display und immediately processes the event AT LINE-SELECTION, AT USER-COMMAND or, in the case of a system function code (list of reserved function codes, see AT USER-COMMAND), this system function). The effect is exactly as if the user had entered the function in the command field and pressed ENTER. This means that the current positioning of the list (SCROLL) and the cursor (SET CURSOR) is taken into account. Note You can specify SET USER-COMMAND several times in the same event. If you set several functions one after the other with USER-COMMAND when creating a list, only the last one is effective. If the function key ENTER in the GUI status of the relevant list itself contains a function code, this is executed rather than that specified with SET USER-COMMAND. Example Process a line selection immediately: WRITE: 'List'... "Create a list SET CURSOR LINE 7. SET USER-COMMAND 'PICK'. The event AT LINE-SELECTION is processed immediately for list line 7. Example Process a function immediately: WRITE: 'List'... "Create a list SET USER-COMMAND 'FUN'. Processes the event AT USER-COMMAND immediately; the system field SY-UCOMM contains the function code FUN. Example Leave list immediately: WRITE: 'List'... "Create a list SET USER-COMMAND 'BACK'. The list is not displayed, but is left immediately. Example Create list with dialog box 'Find by...': WRITE: 'List'... "Create a list SET USER-COMMAND '%SC'. The list is displayed with the dialog box 'Find by...'. SET USER-COMMAND Basic form SET USER-COMMAND f. Effect Only with report output: Interprets the contents of the field f as a user command and executes it as soon as the list is next displayed, i.e. the list display is suppressed and the event AT LINE-SELECTION or AT USER-COMMAND is processed or, in the case of a system function code (list of reserved function codes), the appropriate system function is executed. The effect is exactly as if the user had entered the function in the command field and pressed ENTER. This means in particular that the current position of the list (SCROLL) and the cursor (SET CURSOR) are taken into account. Note You can use SET USER-COMMAND recursively, i.e. request the statement again within the event processed by SET USER-COMMAND. If a list of several consecutive functions is defined when creating a list, only the last of these is effective. If the ENTER function key itself contains a function code in the GUI status of the relevant list, the system executes this and not the function requested with SET USER-COMMAND. Example Processing a block of selected lines immediately WRITE ... "create a list SET CURSOR LINE 7. SET USER-COMMAND 'PICK'. The event AT LINE-SELECTION is processed at once for the list line 7. Example Immediate processing of a function WRITE ... "create a list SET USER-COMMAND 'FUN'. The event AT USER-COMMAND is processed and the system field SY-UCOMM contains the function code 'FUN'. Example Leave list immediately WRITE ... "create a list SET USER-COMMAND 'BACK'. The list is not displayed and the user leaves it immediately. Example Generate list with pop-up 'Find by...' WRITE ... "create a list SET USER-COMMAND '%SC'. The list is displayed with the system pop-up 'Find by...'. SHIFT Variants: 1. SHIFT c. 2. SHIFT c BY n PLACES. 3. SHIFT c UP TO c1. 4. SHIFT c LEFT DELETING LEADING c1. 5. SHIFT c RIGHT DELETING TRAILING c1. Note As with any string processing statement, all the operands are processed here as type C fields (regardless of tyep). No internal conversion is performed. Variant 1 SHIFT c. Additions: 1. ... CIRCULAR 2. ... RIGHT 3. ... LEFT Effect Shifts the field c one position to the left. Omits the first letter and inserts a blank on the right. Example DATA ALPHABET(10) VALUE 'ABCDEFGHIJ'. SHIFT ALPHABET. ALPHABET now contains 'BCDEFGHIJ '. Addition 1 ... CIRCULAR Effect Shifts the field c, so that the "lost" character on the left appears on the right. Example DATA ALPHABET(10) VALUE 'ABCDEFGHIJ'. SHIFT ALPHABET CIRCULAR. ALPHABET now contains 'BCDEFGHIJA'. Addition 2 ... RIGHT Effect Shifts the field c to the right instead of the left. Example DATA ALPHABET(10) VALUE 'ABCDEFGHIJ'. SHIFT ALPHABET RIGHT CIRCULAR. ALPHABET now contains 'JABCDEFGHI'. The additional specifications can also be combined. Addition 3 ... LEFT Effect Shifts the field c to the left. Since this is the default, you can omit this addition. Variant 2 SHIFT c BY n PLACES. Additions: Similar to variant 1. Effect Shifts the field c by n positions to the left and inserts blanks on the right. Example DATA ALPHABET(10) VALUE 'ABCDEFGHIJ', FIVE TYPE I VALUE 5. SHIFT ALPHABET BY FIVE PLACES. ALPHABET now contains 'FGHIJ '. Note If n = 0 or has a negative value, c remains unchanged. If n is greater than the field length of c, c is padded with blanks. Variant 3 SHIFT c UP TO c1. Additions: Similar to variant 1. Effect Searches c for the character string in c1 (starting on the left!). If it finds a match, it shifts the contents of c to the left until the character string concerned appears on the left. If no match is found, c remains unchanged. The return code value is set as follows: SY-SUBRC = 0: c1 was found in c. SY-SUBRC = 4: c1 was not found in c; c remains unchanged. Example DATA ALPHABET(10) VALUE 'ABCDEFGHIJ', THREE(3) VALUE 'DEF', FOUR(4) VALUE 'DEF '. SHIFT ALPHABET UP TO FOUR. SY-SUBRC is now set to 4 and the field ALPHABET remains unchanged. SHIFT ALPHABET UP TO THREE CIRCULAR. SY-SUBRC is now set to 0 and the field ALPHABET contains 'DEFGHIJABC'. Note The operation searches c for the full length of the string in c1, together with any existing blanks. Variant 4 SHIFT c LEFT DELETING LEADING c1. Variant 5 SHIFT c RIGHT DELETING TRAILING c1. Effect Shifts the field c to the left or right so that it begins or ends with a character which occurs in c1 and pads it with blanks accordingly. If c does not begin or end with a character from c1, c remains unchanged. Example DATA: ALPHABET(15) VALUE ' ABCDEFGHIJ', M1(4) VALUE 'ABCD', M2(6) VALUE 'BJJCA '. SHIFT ALPHABET LEFT DELETING LEADING M1. The field ALPHABET is unchanged. SHIFT ALPHABET LEFT DELETING LEADING SPACE. The field ALPHABET now contains 'ABCDEFGHIJ '. SHIFT ALPHABET RIGHT DELETING TRAILING M2. The field ALPHABET now contains ' ABCDEFGHI'. Note Performance: The use of the SHIFT command in WHILE loops should be avoided for performance reasons. Shifting a field one position to the right or left requires approx. 5 msn (standardized microseconds), while cyclical shifting requires approx. 7 msn. The variant ... LEFT DELETING LEADING ... needs about 3,5 msn, the variant ...RIGHT DELETING TRAILING ... about 4,5 msn. Related CONCATENATE, SEARCH, SPLIT SKIP Variants: 1. SKIP. 2. SKIP n. 3. SKIP TO LINE lin. Variant 1 SKIP. Effect Outputs a blank line. Example The statements WRITE: 'Text 1 ......'. SKIP. WRITE: 'Text 2 ......'. produce the following output: Text 1 ...... Text 2 ...... Variant 2 SKIP n. Effect Outputs n blank lines. Note The SKIP statement is only executed if there are still enough lines on the current page. Otherwise, a new page is started (see NEW-PAGE LINE-COUNT). At the beginning of a new page, SKIP only generates blank lines if this page is the first page of the list or if this page was explicitly requested by NEW-PAGE. Otherwise, SKIP statements are ignored at the beginning of a page. At the end of the last list page, SKIP only generates blank lines if there is more output (WRITE, ULINE). Otherwise, SKIP statements are ignored at the end of the last page. Variant 3 SKIP TO LINE lin. Effect Moves the output position to the line lin. You can move up or down to any position on the current page. The line count starts at 1. Example The statement REPORT TEST NO STANDARD PAGE HEADING. DATA: ROW TYPE I VALUE 3. WRITE 'Line 1'. SKIP TO LINE 5. WRITE 'Line 5'. SKIP TO LINE ROW WRITE 'Line 3'. produces the following output: Line 1 Line 3 Line 5 Note The statement SKIP TO LINE lin is executed only if the contents of lin lie between 1 and the maximum number of lines per page (see NEW-PAGE LINE-COUNT). SORT Variants: 1. SORT itab. 2. SORT. Variant 1 SORT itab. Additions: 1. ... DESCENDING 2. ... ASCENDING 3. ... BY f1 f2 ... fi Effect Sorts the entries of the internal table itab in ascending order. The default key is used as the sort key for internal tables. Notes 1. The number of sort fields is restricted to 250. 2. The sorting process is not stable, i.e. if no sort is performed for a predefined sequence of fields, the sequence is not retained. 3. To delete all duplicate entries from a sorted internal table, you can specify DELETE ADJACENT DUPLICATES FROM itab after SORT. 4. The sort itself uses the Quicksort process where the key fields for all the data records are retrieved and placed in an area of main memory. 5. If there is not enough space in memory, the key fields are written to a temporary file and sorted by an external sort program. You can modify the directory which the SORT uses to store such auxiliary files by modifying the SAP profile parameter DIR_SORTTMP. Normally, auxiliary files are created in the SAP data directory (SAP profile parameter DIR_DATA). Addition 1 ... DESCENDING Effect Sorts itab in descending order. Addition 2 ... ASCENDING Effect Sorts itab in ascending order (default). Addition 3 ... BY f1 f2 ... fi Effect Sorts itab by the sub-fields f1, f2, ..., fi which form the sort key. These fields can be any type (even number fields or tables). Unless you specify otherwise, the sort is in ascending order. You can also use additions 1 and 2 before BY if you want all sub-fields to apply. To change the sort sequence for each individual field, specify DESCENDING or ASCENDING after each of the sub-fields f1, f2, ..., fi. Example DATA: BEGIN OF PEOPLE OCCURS 5, NAME(10), AGE TYPE I, NATIONALITY(3), END OF PEOPLE. PEOPLE-NAME = 'Sally'. PEOPLE-AGE = 22. PEOPLE-NATIONALITY = 'USA'. APPEND PEOPLE. PEOPLE-NAME = 'Peter'. PEOPLE-AGE = 25. PEOPLE-NATIONALITY = 'FRG'. APPEND PEOPLE. PEOPLE-NAME = 'Paula'. PEOPLE-AGE = 22. PEOPLE-NATIONALITY = 'USA'. APPEND PEOPLE. PEOPLE-NAME = 'Peter'. PEOPLE-AGE = 23. PEOPLE-NATIONALITY = 'USA'. APPEND PEOPLE. SORT PEOPLE. The sequence of table entries now reads: 'Paula', 'Peter' from 'FRG', 'Peter' from 'USA', 'Sally'. SORT PEOPLE DESCENDING BY NATIONALITY AGE NAME. The sequence now reads: 'Peter' from 'USA', 'Sally', 'Paula', 'Peter' from 'FRG'. SORT PEOPLE DESCENDING BY AGE ASCENDING NAME. The sequence now reads: 'Sally', 'Paula', 'Peter' from 'USA', 'Peter' from 'FRG'. Notes 1. If a sort criterion is not known until runtime, you can use SORT itab BY ... (name) ... to specify it dynamically as the contents of the field name. If name is blank at runtime, the sort criterion is ignored. If name contains an invalid component name, a runtime error occurs. 2. You can use offset and length specifications to further restrict sort criteria, regardless of whether they are specified statically or dynamically. 3. If itab is an internal table with a header line, you can also use a field symbol pointing to the header line of itab as a dynamic sort criterion. If the field symbol does not point to the header line of the internal table, a runtime error occurs. Note Performance: 1. The runtime required to sort an internal table increases with the number of entries and the width of the sort key. Sorting an internal table with 100 entries and the 50-byte wide default key would take about 1300 msn (standardized microseconds). A 30-byte wide sort key would need about 950 msn. 2. If one of the specified sort criteria is itself an internal table, the SORT may sometimes take longer. Runtime errors: - SORT_ITAB_FIELD_INVALID:A field symbol used as a dynamic sort criterion does not point to the header line of the internal table to be sorted. - SORT_TOO_MANY_FIELDS: More than 250 sort criteria. Related APPEND ... SORTED BY Variant 2 SORT. Additions: 1. ... DESCENDING (similar to variant 1) 2. ... ASCENDING (similar to variant 1) 3. ... BY f1 f2 ... fi 4. ... BY fg Effect Sorts the dataset generated with EXTRACT by the fields in the field group HEADER (see FIELD-GROUPS). Here, blank fields (i.e. fields not defined with EXTRACT) are inserted before all non-blank fields, regardless of whether the sort sequence is in ascending or descending order. Notes 1. The number of sort criteria is restricted to 50. 2. As with variant 1, any sequence of fields you specify for sorting purposes does not remain fixed. Any sequence of records which belongs to different field groups, but has the same HEADER field contents, is arbitrary. 3. Again like variant 1, sorting takes place in main memory if at all possible. If there is insufficient space there, ABAP/4 calls an external sort program. You can modify the directory used to create the temporary auxiliary file by modifying the SAP profile parameter DIR_SORTTMP. 4. As soon as a dataset has been processed with SORT or LOOP ... ENDLOOP, you cannot extract any more records with EXTRACT. Addition 3 ... BY f1 f2 ... fi Effect Can sort only by fields in the field group HEADER. Otherwise, the effect is similar to variant 1. Addition 4 ... BY fg Effect Sorts by the fields in field group fg. However, the only fields which can be sorted are those in the field group HEADER, i.e. the field group fg can consist only of fields from the field group HEADER (see INSERT ... INTO). Example DATA: ONR(7), DATE TYPE D, POSITION(3) TYPE N, CUSTOMER(16), PNR(5) TYPE N, NAME(10), UNITS TYPE I, ORDERS TYPE I. FIELD-GROUPS: HEADER, ORDER, PRODUCT, DATE_FIRST. INSERT ONR DATE POSITION INTO HEADER. INSERT CUSTOMER INTO ORDER. INSERT PNR NAME UNITS INTO PRODUCT. INSERT DATE ONR POSITION INTO DATE_FIRST. ONR = 'GF00012'. DATE = '19921224'. POSITION = '000'. CUSTOMER = 'Good friend (2.)'. EXTRACT ORDER. ADD 1 TO POSITION. PNR = '12345'. NAME = 'Screw'. UNITS = 100. EXTRACT PRODUCT. ADD 1 TO POSITION. PNR = '23456'. NAME = 'Nail'. UNITS = 200. EXTRACT PRODUCT. ONR = 'MM00034'. DATE = '19920401'. POSITION = '000'. CUSTOMER = 'Moneymaker'. EXTRACT ORDER. ADD 1 TO POSITION. PNR = '23456'. NAME = 'Nail'. UNITS = 300. EXTRACT PRODUCT. ADD 1 TO POSITION. PNR = '34567'. NAME = 'Hammer'. UNITS = 4. EXTRACT PRODUCT. ONR = 'GF00011'. DATE = '19921224'. POSITION = '000'. CUSTOMER = 'Good friend (1.)'. EXTRACT ORDER. ADD 1 TO POSITION. PNR = '34567'. NAME = 'Hammer'. UNITS = 5. EXTRACT PRODUCT. SORT BY DATE_FIRST. LOOP. AT ORDER. WRITE: /, / DATE, ONR, POSITION, CUSTOMER, 'ordered:'. ENDAT. AT PRODUCT. WRITE: / DATE, ONR, POSITION, PNR, NAME, UNITS. ENDAT. ENDLOOP. This generates the following output: 01041992 MM00034 000 Moneymaker ordered: 01041992 MM00034 001 23456 Nail 300 01041992 MM00034 002 34567 Hammer 4 24121992 GF00011 000 Good friend (1.) ordered: 24121992 GF00011 001 34567 Hammer 5 24121992 GF00012 000 Good friend (2.) ordered: 24121992 GF00012 001 12345 Screw 100 24121992 GF00012 002 23456 Nail 200 Note Performance: The runtime required to sort an internal table increases with the number of entries and the width of the sort key. Note Runtime errors: - SORT_EXTRACT_TOO_MANY_FIELDS: More than 50 sort criteria - SORT_FIELD_NOT_IN_HEADER: Sort criterion not in field group HEADER - SORT_NO_HEADER: Field group HEADER not created - SORT_WITHIN_LOOP: SORT on extract dataset within LOOP on extract dataset SPLIT Variants: 1. SPLIT f AT g INTO h1 ... hn. 2. SPLIT f AT g INTO TABLE itab. Note As with any string processing statement, all the operands are processed here as type C fields (regardless of tyep). No internal conversion is performed. Variant 1 SPLIT f AT g INTO h1 ... hn. Effect Splits the contents of the f according to the delimiter g and places them in the fields h1 to hn (n >= 2). g is used in its defined length. The return code value is set as follows: SY-SUBRC = 0: All hi fields (1 <= i <= n) were big enough. SY-SUBRC = 4: One of the hi fields was not big enough and had to be truncated. Examples DATA: NAMES(30) VALUE 'Charly, John, Peter', ONE(10), TWO(10), DELIMITER(2) VALUE ','. SPLIT NAMES AT DELIMITER INTO ONE TWO. Now, ONE has the value "Charly" and TWO has the value "John, Pete". SY-SUBRC is set to 4, since TWO was not big enough to include "John, Peter". DATA: NAMES2(30) VALUE 'Charly, John, Peter', THREE(10) VALUE 'New York', FOUR(10), FIVE(10), SIX(10) VALUE 'SAP'. SPLIT NAMES2 AT ',' INTO THREE FOUR FIVE SIX. IF THREE = 'Charly' AND FOUR = ' John' AND FIVE = ' Peter' AND SIX = SPACE. WRITE 'SPLIT is OK'. ENDIF. Outputs "SPLIT is OK". Note - Unless the number of target fields is greater than the number of delimiters in the source field, very little information ought to be lost. Therefore, the last target field in this case contains the "rest", including the delimiters (see first example). - If the source field does not contain the separator sequence at all, it is copied incomplete to the first target field. Variant 2 SPLIT f AT g INTO TABLE itab. Effect Like variant 1. Stores the components of f in the internal table itab. For each part of f, a "special" table line is created. f is considered without trailing blanks. Example DATA: BEGIN OF ITAB OCCURS 10, WORD(20), END OF ITAB. SPLIT 'STOP Two STOP Three STOP ' AT 'STOP' INTO TABLE ITAB. Now, ITAB has three lines. The first line is blank, the second contains 'Two' and the third contains 'Three'. Note Performance: The runtime required for the SPLIT command in the first example for variant 1 is about 15 msn (standardized microseconds). If the sub-fields of f are written to an internal table, about 30 msn are needed. Related CONCATENATE, SEARCH, SHIFT START-OF-SELECTION Basic form START-OF-SELECTION. Effect This is an event key word. Before the first logical database table access, it introduces any initial processing to be executed prior to the block specified under the next event key word Note The REPORT statement automatically starts the START-OF-SELECTION processing. Any processing between the REPORT statement and the subsequent event key word is executed at START-OF-SELECTION. Immediately after, the processing block introduced by an explicit START-OF-SELECTION is executed. Related INITIALIZATION, END-OF-SELECTION STATICS Variants: 1. STATICS f. 2. STATICS f(len). 3. STATICS: BEGIN OF rec, ... END OF rec. 4. STATICS: BEGIN OF itab OCCURS n, ... END OF itab. Effect The STATICS statement is a variation of the DATA statement. It allows you to define variables in a procedure (i.e. a FORM or FUNCTION) with local visibility, but static validity. Static validity means that, unlike normal local variables, the life of static variables does not depend on the defining procedure, but on the program at runtime. Static variables are thus not redefined on the stack each time the defining procedure is called, but exist independently of this in the program and keep their value, regardless of calls to the defining procedure. Like all other data objects, static variables always have a particular data type. Data types and data objects are important components of the ABAP/4 type concept. Example DATA RESULT TYPE I. PERFORM RANDOM CHANGING RESULT. FORM RANDOM CHANGING P_RESULT TYPE I. STATICS L_STATE TYPE I. L_STATE = ( L_STATE * 113 + 34 ) MOD 256. P_RESULT = L_STATE. ENDFORM. STOP Basic form STOP. Effect Cancels all data selection. No further tables are read. Note STOP is followed immediately by the END-OF-SELECTION processing. If you do not want this, you may have to use EXIT instead. Related EXIT, CHECK, REJECT SUBMIT Basic form SUBMIT rep. Additions: 1. ... LINE-SIZE col 2. ... LINE-COUNT lin 3. ... TO SAP-SPOOL List output to the SAP spool database 4. ... VIA SELECTION-SCREEN 5. ... AND RETURN 6. ... EXPORTING LIST TO MEMORY 7. ... USER user VIA JOB job NUMBER n 8. ... Various additions for parameter transfer to rep 9. ... USING SELECTION-SETS OF PROGRAM prog Effect Calls the report rep. Leaves the active program and starts the new report rep. Addition 1 ... LINE-SIZE col Effect Prints the report with the line width col. Addition 2 ... LINE-COUNT lin Effect Prints the report with lin lines (per page). Addition 4 ... VIA SELECTION-SCREEN Effect Displays the selection screen for the user. In this case, the selection screen is redisplayed after return from the report list display - the user's entries are retained. Addition 5 ... AND RETURN Effect Returns to the calling transaction or program after the called program has been executed. SUBMIT ... AND RETURN creates a new internal mode. Addition 6 ... EXPORTING LIST TO MEMORY Effect Does not display the output list of the called report, but saves it in SAP memory and leaves the called report immediately. Since the calling program can read the list from memory and process it further, you need to use the addition ... AND RETURN. Also, since the called report cannot be requested for printing, the addition ... TO SAP-SPOOL is not allowed here. You can read the saved list from SAP memory with the function module 'LIST_FROM_MEMORY' and then (for example) store it in the database with EXPORT. You can process this list further with the function modules 'WRITE_LIST', 'DISPLAY_LIST' ... of the function group "SLST". Addition 7 ... USER user VIA JOB job NUMBER n Effect Schedules the specified report in the job specified by the job name job and the job number n. The job runs under the user name user and you can omit the addition USER user. The assignment of the job number occurs via the function module JOB_OPEN (see also the documentation for the function modules JOB_CLOSE and JOB_SUBMIT. This addition can only be used with the addition ...AND RETURN. Note When scheduling a report with the SUBMIT ... VIA JOB job NUMBER n statement, you should always use the addition ...TO SAP-SPOOL to pass print and/or archive parameters. Otherwise, default values are used to generate the list and this disturbs operations in a production environment. Addition 9 ... USING SELECTION-SETS OF PROGRAM prog Effect Uses variants of the program prog when executing the program rep. Note Important The programs prog and rep must have the same SELECT-OPTIONS and PARAMETERs. Otherwise, variants of the program prog may be destroyed. Note When using this addition, the specified variant vari of the program prog is taken in USING SELECTION-SET vari. On the other hand, all variant-related actions on the selection screen of rep (Get, Save as variant, Display, Delete) refer to the variants of prog. Example SUBMIT REPORT01 VIA SELECTION-SCREEN USING SELECTION-SET 'VARIANT1' USING SELECTION-SETS OF PROGRAM 'REPORT00' AND RETURN. Effect Executes the program REPORT01 with the variant VARIANT1 of the program REPORT00. Note Runtime errors: - LOAD_PROGRAM_NOT_FOUND: The specified program was not found. - SUBMIT_WRONG_TYPE: The specified program is not a report. - SUBMIT_IMPORT_ONLY_PARAMETER: Only one value passed to a report parameter. - SUBMIT_WRONG_SIGN: Invalid value passed to a selection with the addition SIGN. - SUBMIT_IN_ITAB_ILL_STRUCTURE: Table passed to a selection with WITH sel IN itab had an unexpected structure. Passing parameters with SUBMIT Variants: 1. ... USING SELECTION-SET vari 2. ... WITH p op f SIGN s 3. ... WITH p BETWEEN f1 AND f2 SIGN s 4. ... WITH p NOT BETWEEN f1 AND f2 SIGN s 5. ... WITH p IN sel 6. ... WITH SELECTION-TABLE seltab 7. ... WITH FREE SELECTIONS texpr Effect Passes values to the SELECT-OPTIONS and PARAMETERS of the program rep (these can also be defined in the database program SAPDBldb of the relevant logical database ldb). p is the name of a parameter or selection criterion. Variant 1 ... USING SELECTION-SET vari Effect The variable vari contains the name of a variant used to start the report. Variant 2 ... WITH p op f SIGN s Effect op is one of the operations EQ, NE, CP, NP, GE, LT, LE, GT. s is a variable which must contain one of the values 'I' or 'E' (any other values result in a runtime error). The addition SIGN is optional and the default is 'I'. If p is a selection criterion (SELECT-OPTIONS), an entry with LOW = f, OPTION = op and SIGN = s is generated in the relevant internal table. If p is a parameter (PARAMETERS), the system treats all options like EQ, i.e. it always transfers a single value. The field f is passed to the parameter p or to the field p-LOW of the selection criterion (xxx in the above list) in internal format. If p is not the same type as f, a type conversion is performed in the target report when data is passed. Variant 3 ... WITH p BETWEEN f1 AND f2 SIGN s Effect Passes the range with the lower limit f1 and the upper limit f2 to the selection criterion p. As with variant 2, f1 and f2 are passed in internal format and the handling of SIGN is also the same. The system thus generates an entry with LOW = f1, HIGH = f2, OPTION = BT and SIGN = s. When data is passed, a type conversion is performed. Variant 4 ... WITH p NOT BETWEEN f1 AND f2 SIGN s Effect Similar to 3, except that OPTION NB is generated instead of OPTION BT. Variant 5 ... WITH p IN sel Effect p is a selection criterion and sel is an internal table which is compatible with p and contains the transfer values. You are recommended to define sel with RANGES. The lines of sel must have exactly the same structure as the lines of a sdlection table (see SELECT-OPTIONS). Variant 6 ... WITH SELECTION-TABLE seltab Effect seltab is an internal table with the structure RSPARAMS. This variant allows you to set the names and contents of the parameters and selection options dynamically at runtime. You can use the function module RS_REFRESH_FROM_SELECTOPTIONS to read the contents of the parameters and selection options of the current program into an internal table seltab with the structure RSPARAMS. By using SUBMIT ... WITH SELECTION-TABLE seltab, you can then pass these values on directly. Variant 7 ... WITH FREE SELECTIONS texpr Effect Passes dynamic selections. texpr is an internal table of the type RSDS_TEXPR (see type pool RSDS). Note You can, for example, fill the object texpr in one of the following ways: - While processing a report with dynamic selections, call the function module RS_REFRESH_FROM_DYNAMICAL_SEL. This returns an object of the type RSDS_TRANGE which a subsequent function module FREE_SELECTIONS_RANGE_2_EX then converts to an object of the type RSDS_TEXPR. In this way, you can pass on the dynamic selections of the current report with SUBMIT. - Call the function modules FREE_SELECTIONS_INIT and FREE_SELECTIONS_DIALOG in order to offer the user a dialog for entering dynamic selections. These function modules return an object of the type RSDS_TEXPR. Notes 1. You can combine the variants 1-7 in any permutation. The same selection criterion may be addressed several times with WITH. This generates several lines in the internal table assigned to the selection criterion p. You can also combine parameter transfer using a variant with explicit parameter passing via the WITH clause. In the event of a conflict, the parameter passed explicitly overwrites the corresponding parameter or selection criterion from the variant. Addition 6 (WITH SELECTION-TABLE) can be combined with parameter transfer using a variant (like directly written WITH clauses), but not with direct WITH clauses. 2. The values passed during SUBMIT are not taken over until the event INITIALIZATION has been processed, i.e. default values set at INITIALIZATION are overwritten if values are passed for the PARAMETER or SELECT-OPTION during SUBMIT. Example 1st combination - variant and WITH RANGES RANGE_LANGU FOR SY-LANGU. PARAMETERS: MSG_FR LIKE T100-MSGNR, MSG_TO LIKE T100-MSGNR. MOVE: 'I' TO RANGE_LANGU-SIGN, 'BT' TO RANGE_LANGU-OPTION, 'D' TO RANGE_LANGU-LOW, 'I' TO RANGE_LANGU-HIGH. APPEND RANGE_LANGU. MOVE: 'EQ' TO RANGE_LANGU-OPTION, 'E' TO RANGE_LANGU-LOW. APPEND RANGE_LANGU. SUBMIT REPORT00 USING SELECTION-SET 'VARIANT1' WITH MSG BETWEEN MSG_FR AND MSG_TO WITH LANGU IN RANGE_LANGU. Example 2nd combination - variant and WITH SELECTION-TABLE DATA: BEGIN OF SELTAB OCCURS 5. INCLUDE STRUCTURE RSPARAMS. DATA: END OF SELTAB. MOVE: 'LANGU' TO SELTAB-SELNAME, 'S' TO SELTAB-KIND, " SELECT-OPTION 'I' TO SELTAB-SIGN, 'BT' TO SELTAB-OPTION, 'D' TO SELTAB-LOW, 'I' TO SELTAB-HIGH. APPEND SELTAB. MOVE: 'E' TO SELTAB-SIGN, 'EQ' TO SELTAB-OPTION, 'F' TO SELTAB-LOW, SPACE TO SELTAB-HIGH. APPEND SELTAB. CLEAR SELTAB. MOVE: 'ARBGB' TO SELTAB-SELNAME, 'P' TO SELTAB-KIND, " PARAMETER 'XX' TO SELTAB-LOW. APPEND SELTAB. SUBMIT REPORT00 USING SELECTION-SET 'VARIANT1' WITH SELECTION-TABLE SELTAB AND RETURN. SUBMIT TO SAP-SPOOL Basic form SUBMIT rep ... TO SAP-SPOOL. Additions: 1. ... DESTINATION dest ... COPIES cop ... LIST NAME name ... LIST DATASET dsn ... COVER TEXT text ... LIST AUTHORITY auth ... IMMEDIATELY flag ... KEEP IN SPOOL flag ... NEW LIST IDENTIFICATION flag ... DATASET EXPIRATION days ... LINE-COUNT lin ... LINE-SIZE col ... LAYOUT layout ... SAP COVER PAGE mode ... COVER PAGE flag ... RECEIVER rec ... DEPARTMENT dep ... ARCHIVE MODE armode ... ARCHIVE PARAMETERS arparams ... WITHOUT SPOOL DYNPRO 2. ... SPOOL PARAMETERS params ... ARCHIVE PARAMETERS arparams ... WITHOUT SPOOL DYNPRO Effect Calls the report rep with list output to the SAP spool database. Additions ... DESTINATION dest (output device) ... COPIES cop (number of copies) ... LIST NAME name (name of list) ... LIST DATASET dsn (name of spool dataset) ... COVER TEXT text (title of spool request) ... LIST AUTHORITY auth (authorization for display) ... IMMEDIATELY flag (print immediately ?) ... KEEP IN SPOOL flag (keep list after print ?) ... NEW LIST IDENTIFICATION flag (new spool request ?) ... DATASET EXPIRATION days (number of days list retained) ... LINE-COUNT lin (lin lines per page) ... LINE-SIZE col (col columns per line) ... LAYOUT layout (print format) ... SAP COVER PAGE mode (SAP cover sheet ?) ... COVER PAGE flag (selection cover sheet ?) ... RECEIVER rec (SAP user name of recipient) ... DEPARTMENT dep (name of department) ... ARCHIVE MODE armode (archiving mode) ... ARCHIVE PARAMETERS arparams (structure with archiving parameters) ... WITHOUT SPOOL DYNPRO (skip print control screen) With the parameters IMMEDIATELY, KEEP IN SPOOL, NEW LIST IDENTIFICATION and COVER TEXT, flag must be a literal or character field with the length 1. If flag is blank, the parameter is switched off, but any other character switches the parameter on. You can also omit any of the sub-options of PRINT ON. mode with SAP COVER PAGE can accept the values ' ', 'X' and 'D'. These values have the following meaning: ' ' : Do not output cover sheet 'X' : Output cover sheet 'D' : Cover sheet output according to printer setting armode with ARCHIVE MODE can accept the values '1', '2' and '3'. These values have the following meaning: '1' : Print only '2' : Archive only '3' : Print and archive arparams with ARCHIVE PARAMETERS must have the same structure as ARC_PARAMS. This parameter should only be processed with the function module GET_PRINT_PARAMETERS. Effect Output is to the SAP spool database with the specified parameters. If you omit one of the parameters, the system uses a default value. Before output to the spool, you normally see a screen where you can enter and/or modify the spool parameters. However, you can suppress this screen with the following statement: ... TO SAP-SPOOL WITHOUT SPOOL DYNPRO This you could use this option if all the spool parameters have already been set! Note When specifying the LINE-SIZE, you should not give any value > 132 because most printers cannot print wider lists. Addition 2 ... SPOOL PARAMETERS params (structure with print parameters) ... ARCHIVE PARAMETERS arparams (Structure with archive parameters) ... WITHOUT SPOOL DYNPRO (skip print parameters screen) Effect Output is to the SAP spool database with the specified parameters. The print parameters are passed by the field string params which must have the structure of PRI_PARAMS. The field string can be filled anf modified with the function module GET_PRINT_PARAMETERS. The specification arparams with ARCHIVE PARAMETERS must have the structure of ARC_PARAMS. This parameter should only be processed with the function module GET_PRINT_PARAMETERS. Before output to the spool, you normally see a screen where you can enter and/or modify the spool parameters. However, you can suppress this screen with the following statement: ... WITHOUT SPOOL DYNPRO Example * Without archiving DATA: PARAMS LIKE PRI_PARAMS, DAYS(1) TYPE N VALUE 2, COUNT(3) TYPE N VALUE 1, VALID TYPE C. CALL FUNCTION 'GET_PRINT_PARAMETERS' EXPORTING DESTINATION = 'LT50' COPIES = COUNT LIST_NAME = 'TEST' LIST_TEXT = 'SUBMIT ... TO SAP-SPOOL' IMMEDIATELY = 'X' RELEASE = 'X' NEW_LIST_ID = 'X' EXPIRATION = DAYS LINE_SIZE = 79 LINE_COUNT = 23 LAYOUT = 'X_PAPER' SAP_COVER_PAGE = 'X' COVER_PAGE = 'X' RECEIVER = 'SAP*' DEPARTMENT = 'System' NO_DIALOG = ' ' IMPORTING OUT_PARAMETERS = PARAMS VALID = VALID. IF VALID <> SPACE. SUBMIT RSTEST00 TO SAP-SPOOL SPOOL PARAMETERS PARAMS WITHOUT SPOOL DYNPRO. ENDIF. Example * With archiving DATA: PARAMS LIKE PRI_PARAMS, ARPARAMS LIKE ARC_PARAMS, DAYS(1) TYPE N VALUE 2, COUNT(3) TYPE N VALUE 1, VALID TYPE C. CALL FUNCTION 'GET_PRINT_PARAMETERS' EXPORTING DESTINATION = 'LT50' COPIES = COUNT LIST_NAME = 'TEST' LIST_TEXT = 'SUBMIT ... TO SAP-SPOOL' IMMEDIATELY = 'X' RELEASE = 'X' NEW_LIST_ID = 'X' EXPIRATION = DAYS LINE_SIZE = 79 LINE_COUNT = 23 LAYOUT = 'X_PAPER' SAP_COVER_PAGE = 'X' COVER_PAGE = 'X' RECEIVER = 'SAP*' DEPARTMENT = 'System' SAP_OBJECT = 'RS' AR_OBJECT = 'TEST' ARCHIVE_ID = 'XX' ARCHIVE_INFO = 'III' ARCHIVE_TEXT = 'Description' NO_DIALOG = ' ' IMPORTING OUT_PARAMETERS = PARAMS OUT_ARCHIVE_PARAMETERS = ARPARAMS VALID = VALID. IF VALID <> SPACE. SUBMIT RSTEST00 TO SAP-SPOOL SPOOL PARAMETERS PARAMS ARCHIVE PARAMETERS ARPARAMS WITHOUT SPOOL DYNPRO. ENDIF. SUBTRACT Basic form SUBTRACT n1 FROM n2. Effect Subtracts the contents of n1 from the contents of n2 and stores the result in n2. This is equivalent to: n2 = n2 - n1. Example DATA NUMBER TYPE P VALUE 3, RESULT TYPE I VALUE 7. SUBTRACT NUMBER FROM RESULT. The field RESULT now contains 4; the value of NUMBER remains unchanged at 3. Note Performance: The remarks about conversions and performance under COMPUTE apply equally to SUBTRACT. The runtime required to subtract two numbers of type I or F is approx. 2 msn (standardized microseconds). For numbers of type P, about 9 msn are needed. Note Runtime errors: - BCD_BADDATA: P field contains no correct BCD format - BCD_FIELD_OVERFLOW: Result field is too small (type P) - BCD_OVERFLOW: Overflow with arithmetic operation (type P) - COMPUTE_INT_MINUS_OVERFLOW: Whole number overflow during subtraction Related COMPUTE, SUBTRACT-CORRESPONDING SUBTRACT-CORRESPONDING Basic form SUBTRACT-CORRESPONDING rec1 FROM rec2. Effect Interprets rec1 and rec2 as field strings. If, for example, rec1 and rec2 are tables, executes the statement for their header lines. Searches for all sub-fields which occur both in rec1 and rec2 and then generates, for all relevant field pairs corresponding to the component fields ni, statements of the form SUBTRACT rec1-ni FROM rec2-ni. The other fields remain unchanged. With complex structures, the full names of the field pairs must be identical. Example DATA: BEGIN OF PERSON, NAME(20) VALUE 'Paul', MONEY TYPE I VALUE 5000, END OF PERSON, BEGIN OF PURCHASES OCCURS 10, PRODUCT(10), MONEY TYPE I, END OF PURCHASES. PURCHASES-PRODUCT = 'Table'. PURCHASES-MONEY = 100. APPEND PURCHASES. PURCHASES-PRODUCT = 'Chair'. PURCHASES-MONEY = 70. APPEND PURCHASES. LOOP AT PURCHASES. SUBTRACT-CORRESPONDING PURCHASES FROM PERSON. ENDLOOP. The value of PERSON-MONEY is now 4830. The above SUBTRACT-CORRESPONDING statement (executed twice here) is equivalent to: SUBTRACT PURCHASES-MONEY FROM PERSON-MONEY. Note All fields of the same name are subtracted, whether they are numeric or not. Here, the conversions performed are the same as with SUBTRACT and the same runtime errors can occur. Related SUBTRACT MOVE-CORRESPONDING ADD-CORRESPONDING MULTIPLY-CORRESPONDING DIVIDE-CORRESPONDING SUM Basic form SUM. Effect When processing an internal table in a block starting with LOOP and concluded by ENDLOOP, SUM calculates the control totals of all fields of type I, F and P (see also ABAP/4 number types) and places them in the LOOP output area (header line of the internal table or an explicitly specified work area). You can use the SUM statement both at the end and the beginning of a control group (see also AT FIRST/LAST). Example Display the table T with sub-totals: DATA: BEGIN OF T OCCURS 100, CODE(4), SALES TYPE P, DISCOUNT TYPE P, END OF T. ... LOOP AT T. AT FIRST. SUM. WRITE: /4 'Grand Total:', 20 T-SALES, 40 T-DISCOUNT. ULINE. SKIP. ENDAT. WRITE: / T-CODE, 20 T-SALES, 40 T-DISCOUNT. AT END OF CODE. SUM. WRITE: / T-CODE, 10 'Total:', 20 T-SALES, 40 T-DISCOUNT. SKIP. ENDAT. ENDLOOP. Notes 1. When you use SUM in a LOOP with an explicitly specified output area, this output area must be compatible with the line type of the internal table. 2. When using LOOP to process a sorted extract (see SORT), the control total of f at the end of the group appears in the field SUM(f) - - if f is type I, F or P. Note Runtime errors: - SUM_OVERFLOW: Value too large when calculatng totals in internal table, field too small. - SUM_NO_INTERNAL_TABLE: The SUM statement was used outside a LOOP on an internal table. - SUM_ON_FOREIGN_INTERNAL_TABLE: The SUM statement was used in a LOOP belonging to another ABAP/4 program. SUMMARY Basic form SUMMARY. This key word corresponds to FORMAT INTENSIFIED ON which should be used instead for the sake of clarity. Note When outputting data to a list, you can use the addition INTENSIFIED ON of the WRITE statement to modify the output format for individual fields. Related FORMAT SUMMING Basic form SUMMING f. Note The key word SUMMING is no longer maintained and should therefore not be used (see also Obsolete key words). Effect Specifies fields to be summed. Creates an internal summing field called SUM_f for the field f. Whenever f is output with a WRITE statement, the current f are added to SUM_f. At END-OF-SELECTION, SUM_f contains the overall total but only the total so far at earlier stages. When using the logical database table dbtab (see Logical databases), you can address another internally created field called dbtabSUM_f in the event GET dbtab LATE. This field contains the total resulting from WRITE statements in logically dependent events. Example Output list with single items and overall total: TYPES: BEGIN OF CUSTOMER, NAME(10) TYPE C, SALESA TYPE I, END OF CUSTOMER. DATA: WA_CUSTOMER TYPE CUSTOMER, CUSTOMERS TYPE CUSTOMER OCCURS 50. SUMMING WA_CUSTOMER-SALES INITIALIZATION. WA_CUSTOMER-NAME = 'Tom'. WA_CUSTOMER-SALES = 10. APPEND WA_CUSTOMER TO CUSTOMERS. ... START-OF-SELECTION. LOOP AT CUSTOMERS INTO WA_CUSTOMER. WRITE: / WA_CUSTOMER-NAME, WA_CUSTOMER-SALES. ENDLOOP. ULINE. WRITE SUM_WA_CUSTOMER-SALES UNDER WA_CUSTOMER-SALES. Note The field f takes on the attributes of the summing field (type, length, decimal places, output length). If the output length is too short for the total, you must use DATA to create a larger field. Instead of using summing fields, you are recommended to create an extract dataset (see EXTRACT). When processing this dataset in a LOOP, the control totals appear in the summing fields SUM(f) (see also SUM). Related MINIMUM, MAXIMUM SUM Basic form ... SUM(g) .... Effect SUM(g) is not a statement, but a field which is automatically created and filled when g is a sub-field of an extract dataset. SUM(g) can only be addressed from within a LOOP on a sorted extract dataset. If g is a numeric field in an extract dataset (see also ABAP/4 number types), SUM(g) contains the appropriate control total at the end of a control level (AT END OF, AT LAST). Related CNT(h) SUPPRESS Basic form SUPPRESS DIALOG. Effect Suppresses output of the current screen. However, flow control continues normally and dialog resumes on the next screen. Note SUPPRESS DIALOG should only be used in a PBO (PROCESS BEFORE OUTPUT) module. SYNTAX-CHECK Note This statement is for internal use only. Incompatible changes or further developments may occur at any time without warning or notice. Basic forms: 1. SYNTAX-CHECK FOR itab ...MESSAGE f ...LINE g ...WORD h. 2. SYNTAX-CHECK FOR DYNPRO h f e m ...MESSAGE f1 ...LINE f2 ...WORD f3. SYNTAX-CHECK Basic form SYNTAX-CHECK FOR DYNPRO h f e m ...MESSAGE f1 ...LINE f2 ...WORD f3. Parts marked with " ..." are interchangeable Additions: 1. ... OFFSET f1 2. ... TRACE-TABLE t1 Effect Syntax check for screen The screen description is taken from the field string h and the internal tables f, e and m. The field string h (screen header) should correspond to the structure D020S, the internal table f (field list) to the structure D021S, the internal table e (flow logic) to the structure D022S and the internal table m (matchcode information) to the structure D023S. Example DATA: DHEAD LIKE D020S, "screen header DFIELDS LIKE D021S OCCURS 20, "field list DFLOWL LIKE D022S OCCURS 20, "flow logic MCINFO LIKE D023S OCCURS 20. "matchcode information If a syntax error is detected during the check, the fields f1, f2 and f3 are filled as follows: - f1 contains the error message text - f2 contains the screen line where the error occurred - f3 contains the incorrect word in the screen The return code value is set as follows: SY-SUBRC = 0: The screen contains no syntax errors. SY-SUBRC = 4: The screen contains syntax errors. Addition 1 ... OFFSET f1 Effect When a systax error occurs, this field contains the position of the incorrect word in the incorrect line. Addition 2 ... TRACE-TABLE t1 Effect Any trace output is stored in this table. Trace output is automatically switched on when you specify this addition. SYNTAX-CHECK Note This statement is for internal use only. Incompatible changes or further developments may occur at any time without warning or notice. Basic form SYNTAX-CHECK FOR itab ...MESSAGE f ...LINE g ...WORD h. Parts marked with " ..." are interchangeable Additions: 1. ... PROGRAM f1 2. ... INCLUDE f2 3. ... OFFSET f3 4. ... TRACE-TABLE t1 5. ... DIRECTORY ENTRY f4 6. ... REPLACING f5 7. ... FRAME ENTRY f6 8. ... MESSAGE-ID f7 9. ... ID tabid TABLE itab Effect Syntax check for programs The program code is taken from the internal table itab. If a syntax error is detected during the check, the fields f, g and h are filled as follows: - f contains the error message text - g contains the program line where the error occurred - h contains the incorrect word in the program Example f and h are declared as text fields and g as a whole number (integer). DATA: f(240), g TYPE I, h(72). The return code value is set as follows: SY-SUBRC = 0: The program contains no syntax errors. SY-SUBRC = 4: The program contains syntax errors. SY-SUBRC = 8: Other errors hav occurred. Addition 1 ... PROGRAM f1 Effect Specifies a program name If the addition DIRECTORY ENTRY is missing, the program name is used to determine the program attributes required for the check, e.g.: - include or program - the logical database The field f1 is meant to contain the field attributes of SY-REPID. Addition 2 ... INCLUDE f2 Effect If there is a syntax error, this field contains the name of the include program where the error occurred. The field f2 is meant to contain the field attributes of SY-REPID. Addition 3 ... OFFSET f3 Effect If there is a syntax error, this field contains the position of the incorrect word in the incorrect line. The field f3 should be declared as a whole number (integer). Addition 4 ... TRACE-TABLE t1 Effect Trace output is stored in this table. To switch trace output on or off during program checks, you use the SYNTAX-TRACE ON and SYNTAX-TRACE OFF statements. Addition 5 ... DIRECTORY ENTRY f4 Effect The program attributes required for the check are taken from the field f4 which must correspond to the structure of the table TRDIR. Addition 6 ... REPLACING f5 The field f5 is meant to contain the field attributes of SY-REPID. Effect The program code placed in the internal table is an include, not the main program. Therefore, it is the main program specified under PROGRAM which is to be checked. If this program contains an include name f5, the contents of the internal table should be taken into account instead. You should use this addition only with PROGRAM. Addition 7 ... FRAME ENTRY f6 Effect The main program attributes required for the check (e.g. logical database, program type) are taken from the field f6. f6 should have the structure of the table TRDIR. Addition 8 ... MESSAGE-ID f7 Effect If a syntax error occurs, the field f7 contains the relevant message key which has a structure similar to the table TRMSG. Addition 9 ... ID tabid TABLE itab Effect Returns syntax check information. tabid contains the type of information written to the internal table itab. For correction proposals (ID 'CORR'), the type group SLIN must be included, for other information the tyep group SYNT. Both these type groups contain the necessary type specifications. Please do not use this addition. It is intended only for internal use! tabid outputs the following information from the program code: ID 'MSG ' ... warning messages ID 'CORR' ... correction proposals ID 'SYMB' ... technical symbol table dump ID 'DATA' ... data objects from the program ID 'DPAR' ... data object parameters ID 'TYPE' ... type objects from the program ID 'FOTY' ... type objects used by FORM routines ID 'FUTY' ... type objects used by function modules ID 'TYCH' ... components of type objects ID 'CROS' ... referenced data objects ID 'STR ' ... identifiers ID 'FORM' ... FORM routines ID 'FPAR' ... FORM parameters ID 'PERF' ... PERFORM calls ID 'APAR' ... PERFORM parameters ID 'FUNC' ... function modules ID 'FFPA' ... function module parameters ID 'CALL' ... CALL FUNCTION calls ID 'FAPA' ... CALL FUNCTION parameters ID 'HYPH' ... data objects with a hyphen in the name ID 'INCL' ... includes in the program SYNTAX-TRACE Note This statement is for internal use only. Incompatible changes or further developments may occur at any time without warning or notice. Variants: 1. SYNTAX-TRACE ON. 2. SYNTAX-TRACE ON OPTION CODING. 3. SYNTAX-TRACE ON OPTION EXPAND. 4. SYNTAX-TRACE OFF. Variant 1 SYNTAX-TRACE ON. Effect This statement has no effect at runtime except to switch on the syntax check or the generation of the program it specifies. If the syntax check or generation was called in the test environment, this statement switches on a syntax trace. Variant 2 SYNTAX-TRACE ON OPTION CODING. Effect This statement has the same effect as SYNTAX-TRACE ON, but the syntax trace is restricted to the processed program lines. Variant 3 SYNTAX-TRACE ON OPTION EXPAND. Effect This statement has no effect at present. Variant 4 SYNTAX-TRACE OFF. Effect Switches off the syntax trace switched on with SYNTAX-TRACE ON. TABLES Basic form TABLES dbtab. Effect Makes the database table, view or structure dbtab known to the program. These objects are created by selecting Development -> ABAP/4 Dictionary. This transaction automatically defines an identical field string - the table work area - in the program. The names and the sequence of the fields of the table work area dbtab correspond exactly to the names and the sequence of the fields when declaring the database table or view in the ABAP/4 Dictionary. The ABAP/4 data type (see DATA) and the length of the fields are derived from the data types in the ABAP/4 Dictionary as follows: Dict. data type ABAP/4 data type ACCP -> N(6) CHAR n -> C(n) CLNT -> C(3) CUKY -> C(5) CURR n, m, s -> P((n + 2) / 2) DECIMALS m [NO-SIGN] DEC n, m, s -> P((n + 2) / 2) DECIMALS m [NO-SIGN] DATS -> D FLTP -> F INT1 -> No correspondence INT2 -> No correspondence INT4 -> I LCHR n -> C(n) LRAW n -> X(n) LANG -> C(1) NUMC n -> N(n) PREC -> X(2) QUAN n, m, s -> P((n + 2) / 2) DECIMALS m [NO-SIGN] RAW n -> X(n) TIMS -> T UNIT n -> C(n) VARC n -> C(n) The fields of the table work area are set to the initial values for their ABAP/4 data types (see DATA). For the ABAP/4 Dictionary data types INT1 and INT2, whole number fields of length 1 or 2 are created with the initial value 0 in the table work area. The length of the table work area is not just the sum of the lengths of the individual fields. Depending on how different fields have to be aligned (Alignment), the structure can contain nameless "holes". Example TABLES SPFLI. SELECT * FROM SPFLI. WRITE: / SPFLI-CARRID, SPFLI-CONNID. ENDSELECT. Notes 1. You can display the structure of the table work area in the ABAP/4 Editor by double-clicking on the table name. 2. The divisions for determining ABAP/4 field lengths are whole number divisions without rounding. The field of the table work area can accept numbers which contain one digit more than the ABAP/4 Dictionary data type allows. Such a situation results in a runtime error when writing to the database. 3. The table work area always has a global validity area. Even if the TABLES statement is specified in a FORM or FUNCTION, the work area is known when the subroutine has been defined. However, changes to the work area in a subroutine remain local to the FORM or FUNCTION. Therefore, it is advisable to specify the TABLES statement globally. You can keep changes to the table work area local to the subroutine with LOCAL. Related DATA, TYPES TELEX is not an ABAP/4 key word (in R/3). No documentation available. No documentation available. Text elements You use text elements to store texts that cannot be defined in the program code. You can maintain them outside the program where they are used (in the ABAP/4 Editor, select Goto -> Text elements. They are particularly useful for maintaining texts intended for multi-language applications. The following text element types exist: - Report or program titles - List headings - Column headings - Selection texts (text belonging to selection criteria and program parameters) - Text symbols (constant text passages) The structure of text elements is determined by the structure TEXTPOOL which contains the following fields: ID: A single character for the text element type. Possible values are: R - Report or program titles T - List headings H - Column headings S - Selection texts I - Text symbols KEY: Key field that contains the following values depending on the text element type: H - Number of a line with column headings (001 - 004) S - Max. 8-character name of a selection criterion or program parameter I - 3-character number of a text symbol For report or program titles and list headings, the field is blank. ENTRY: Text belonging to the text element, max. 255 characters. LENGTH: Length of text Examples The following table shows typical values for text elements. ID KEY ENTRY LENGTH ----------------------------------------------------- H 001 'Name Age' 10 I 100 'Tax' 10 R 'Test program' 12 S CUST 'Customer' 8 T 'Sales' 10 Notes 1. LENGTH contains the text length. If the text is to be translated into other languages, it is usual to choose a value for LENGTH that is greater than in the original language. In this way, you create extra space for text that may be longer in translation. 2. You can address text symbols in two different ways - with TEXT-xxx or with '...'(xxx). Here, xxx stands for the number and ... for the text of the text symbol. The second form makes programs easier to read. The text enclosed in quotation marks should match the text stored under the text symbol. If it does not, the text stored under the text symbol is used. Exception: If the number xxx contains no text, the text enclosed in quotation marks is used. Example If the text symbol with the number 001 contains the text 'Please enter your name', the command WRITE: / TEXT-001, / 'Please enter your name'(001), / 'What is your name?'(001). produces the same output (i.e. "Please enter your name") three times. When you are in the ABAP/4 program editor, you can compare the texts used in the program with the texts stored in text symbols by selecting Goto -> Text elements -> Compare text symbols. 3. If the LENGTH value you specify for text symbols is greater than the actual length of the text, the system pads the text up to the length LENGTH with blanks. This means that when you use the notation '...'(xxx), the text enclosed by quotation marks must be explicitly padded with blanks up to the length LENGTH. Otherwise, the text stored under the text symbol would not match the text specified in quotation marks (see note 2). Example If the text symbol with the number 036 contains the text 'Name', but the length is 10, the command WRITE: / SY-VLINE, TEXT-036, SY-VLINE, / SY-VLINE, 'Tax '(036), SY-VLINE, / SY-VLINE, 'Tax'(036), SY-VLINE. produces the same output (i.e. "| Tax |" three times. In the third line, the text stored under the number 036 is output with a length of 8 and not just the 3-character long text "Tax". If you perform a text element comparison here, (see note 2), the text symbols in the second and third lines would be shown as different. The ABAP/4 key words used for text processing in R/2 have been replaced in R/3 by the following SAPscript function modules: - TEXTS: The text header and the line table must be defined individually with include structures: DATA: HEADER LIKE THEAD. DATA: LINES LIKE TLINE OCCURS 0 WITH HEADER LINE. - READ TEXT -> CALL FUNCTION 'READ_TEXT' - INSERT TEXT, UPDATE TEXT -> CALL FUNCTION 'SAVE_TEXT' - DELETE TEXT -> CALL FUNCTION 'DELETE_TEXT' - EDITOR-CALL FOR TEXT -> CALL FUNCTION 'EDIT_TEXT' - MOVE-TEXT: SAPscript does not require a function module for this because the formatted print lines are not returned to an internal table, but direct to the the print output. This is done with the function modules WRITE_FORM or WRITE_FORM_LINES. TOP-OF-PAGE Basic form TOP-OF-PAGE. Addition: ... DURING LINE-SELECTION Effect TOP-OF-PAGE is a list processing event which is executed before the the first data is output on a new page. Notes - Without the addition ... DURING LINE-SELECTION, TOP-OF-PAGE is processed only when generating basic lists, not when creating secondary lists. - TOP-OF-PAGE allows you to define output which supplements the standard page header at the beginning of the page or. Alternatively, if the standard page header is suppressed (with (REPORT ... NO STANDARD PAGE HEADING.), it allows you to design your own page header. - TOP-OF-PAGE is only executed before outputting the first line on a new page. It is not triggered by a NEW-PAGE statement Example PROGRAM DOCUEXAM NO STANDARD PAGE HEADING. START-OF-SELECTION. WRITE: / 'line 1'. WRITE: / 'line 2'. WRITE: / 'line 3'. TOP-OF-PAGE. WRITE: / 'Heading'. ULINE. This program produces the following output: Heading ------------------------------- line 1 line 2 line 3 Addition ... DURING LINE-SELECTION Effect Ensures that TOP-OF-PAGE is executed when generating secondary lists. (AT LINE-SELECTION, AT USER-COMMAND). Note The event TOP-OF-PAGE DURING LINE-SELECTION. is executed when generating each secondary list. If you want to generate different page headers for different secondary lists, you must specify this in the program (e.g. by using status variables). Related END-OF-PAGE TRANSFER Basic form TRANSFER f TO dsn. Addition: ... LENGTH len Effect Transfers the field f (usually a field string) to the sequential file specified in dsn (this may be a literal or a field). - Binary mode (addition IN BINARY MODE of the OPEN DATASET statement): Write to the file in the length of field f. - Text mode (addition IN TEXT MODE of the OPEN DATASET statement): Write a line. If the specified file is not open, TRANSFER attempts to open the file dsn FOR OUTPUT (IN BINARY MODE or using the further specifications of the last OPEN command for this file). If this fails, a runtime error occurs. Example DATA REC(80). TRANSFER REC TO '/usr/test'. Notes - You can read sequential datasets with READ DATASET. - The structure of file names depends very much on the operating system you are using. You can access portable programs with the function module GET_FILE_NAME. This returns the relevant physical name for a given logical file name. Addition ... LENGTH len Effect Transfers the length of the record to be output in the length len. TRANSFER-DYNPRO is not an ABAP/4 key word (in R/3). To create batch input sessions, please use the function modules BDC_... in the function group SBDC. TRANSLATE Variants: 1. TRANSLATE c TO UPPER CASE. 2. TRANSLATE c TO LOWER CASE. 3. TRANSLATE c USING c1. 4. TRANSLATE c FROM CODE PAGE g1 TO CODE PAGE g2. 5. TRANSLATE c FROM NUMBER FORMAT n1 TO NUMBER FORMAT n2. Note As with any string processing statement, all the operands are processed here as type C fields (regardless of tyep). No internal conversion is performed. Variant 1 TRANSLATE c TO UPPER CASE. Variant 2 TRANSLATE c TO LOWER CASE. Effect In the field c, converts all lower case letters to upper case or all upper case letters to lower case, as specified. Example DATA LETTERS(3). MOVE 'abc' TO LETTERS. TRANSLATE LETTERS TO UPPER CASE. The field LETTERS now contains 'ABC'. Variant 3 TRANSLATE c USING c1. Effect Replaces the letters in the field c according to the contents of c1. If a character in c also exists in c1, it is replaced by the letter that f o l l o w s it in c1. If a character from c is not found in c1, it remains unchanged. Example DATA: LETTERS(10) VALUE 'abcX', CHANGE(6) VALUE 'aXBY'. TRANSLATE LETTERS USING CHANGE. The field LETTERS now contains 'XbcX'. Variant 4 TRANSLATE c ...FROM CODE PAGE g1 ...TO CODE PAGE g2. Parts marked with " ..." are interchangeable TRANSLATE F TO CODE PAGE G2. TRANSLATE F FROM CODE PAGE G1. Effect Performs a character code conversion in the field F. To achieve this, the SAP character code is determined from the conversion table G1 and a new character code derived from G2. You can use the Transaction SPAD to maintain the conversion tables TCP00 - TCP02. Example DATA F(72). TRANSLATE F FROM CODE PAGE '1110' TO CODE PAGE '0100'. translates the contents of F from the HP character set to EBCDIC (IBM 274). Note Type I, P, F and X fields remain unchanged. Field strings and work areas of internal tables are converted to the correct type for each individual field. At present, table work areas (as defined in TABLES ...) are not treated according to type, but are converted as a whole. If necessary, declare a field string with INCLUDE STRUCTURE and then perform a conversion. Variant 5 TRANSLATE c ...FROM NUMBER FORMAT n1 ...TO NUMBER FORMAT n2. Parts marked with " ..." are interchangeable TRANSLATE F TO NUMBER FORMAT N1. TRANSLATE F FROM NUMBER FORMAT N1. Effect Performs a number format conversion in the field F. The number formats supported at present are '0000' (HP, SINIX, IBM) and '0101' (DEC alpha OSF). Any attempt to enter formats other than these results in a runtime error. If you omit FROM NUMBER FORMAT or TO NUMBER FORMAT, the system number format is used for the omitted part. Example DATA: F TYPE F, HEX (2) TYPE X, NFORM LIKE TCP00-CPCODEPAGE. ... * In /ARCHIV was stored by another platform from HEX and F. * HEX contains the valid number format and can be read on all * platforms. READ DATASET '/ARCHIV' INTO HEX. READ DATASET '/ARCHIV INTO F. NFORM = HEX. "Conversion of machine-independent HEX to NUMC(4) TRANSLATE F FROM NUMBER FORMAT NFORM. Effect Converts the contents of F from the format NFORM of a platform to the system format. Note Type I and F fields are converted. Field strings and work areas of internal tables are converted to the correct type for each individual field. Table work areas (as defined with TABLES ...) are treated as type C at present and are not converted. If necessary, declare a field string with INCLUDE STRUCTURE and then perform a conversion. In the interests of storing additional information for archiving purposes, you can use the function module SYSTEM_FORMAT to display the system code page and system number format. Note Performance: Converting lower case letters to upper case letters or upper case letters to lower case letters in a 10-byte long character field takes approx. 7 msn (standardized microseconds). Replacing two letters in a 10-byte long field with the variant ... c USING c1 ... takes approx. 9 msn. Note Runtime errors: - TRANSLATE_WRONG_NUM_FORMAT: Invalid number format. Related REPLACE, OVERLAY TYPE-POOL Basic form TYPE-POOL typepool. Effect Introduces a type group. You can only maintain a type group via the ABAP/4 Dictionary (using Transaction SE11). The name typepool must match the name in the ABAP/4 Dictionary. You can only define types and constants in type groups. The names of all these types and constants must begin with the name of the type group and an underscore. Example TYPE-POOL ABCDE. TYPES: ABCDE_PACKED TYPE P, ABCDE_INT TYPE I. TYPE-POOLS Basic form TYPE-POOLS typepool. Effect Includes the types and constants of a type group. If the type group typepool has already been included, the statement is ignored. You can only maintain a type group via the ABAP/4 Dictionary (using Transaction SE11). You introduce a type group with the TYPE-POOL statement. Since the types and constants specified in a type group have global validity, you cannot use the statement within a FORM or FUNCTION. Example TYPE-POOLS VERI1. DATA X TYPE VERI1_TYP1. TYPES Variants: 1. TYPES typ. 2. TYPES typ(len). 3. TYPES: BEGIN OF rectyp, ... END OF rectyp. Effect The TYPES statement introduces user-defined data types. As with standard data types, you can use them when creating data objects and when assigning types to formal parameters and field symbols. User-defined data types are an essential component of the ABAP/4 type concept. Variant 1 TYPES f. Additions: 1. ... TYPE typ1 2. ... LIKE f 3. ... TYPE typ1 OCCURS n 4. ... LIKE f OCCURS n 5. ... TYPE LINE OF itabtyp 6. ... LIKE LINE OF itab 7. ... DECIMALS n Effect Creates a new type. If the TYPE addition is not used, the new type points to the standard type C. The type name typ can be up to 30 characters long. Apart from the special characters '(', ')', '+', '.', ',', ':', '-', '<' and '>', you can use any characters. Numbers are allowed, but the name cannot consist of numbers alone. Recommendations for type names: 1. Always use a letter as the first character. 2. Use the underscore as the link in multiple word names (e.g. NEW_PRODUCT). Addition 1 ... TYPE typ1 Effect Defines the new type with the type typ1. typ1 can be one of the predefined types specified below or a type you define yourself with TYPES. The length (SL) of the type typ is the same as the type typ1. Type Description Std len. Initial value C Text (character) 1 Blank N Numeric text 1 '00...0' D Date (YYYYMMDD) 8 '00000000' T Time (HHMMSS) 6 '000000' X Hexadecimal 1 X'00' I Whole number (integer) 4 0 P Packed number 8 0 F Floating point number 8 '0.0' Example TYPES NUMBER TYPE I. This defines the type NUMBER NUMBER with the type I. It can then be used in the program. Notes 1. The data type I is the whole number type for the hardware you are using. Its value range is -2**31 to 2**31-1 (-2.147.483.648 to 2.147.483.647). While type P is used for money amount fields, you should use type I for number fields, index fields, position specifications, etc. 2. Apart from zero, type F allows you to display positive and negative numbers in the range from 1E-307 to 1E+307 with 15 decimal places. (The ABAP/4 processor uses the floating point operations of the relevant hardware and does not attempt to standardize them.) Floating point literals must be enclosed in quotation marks. The standard output length is 22. Input in type F fields can be formatted differently: Decimal number with or without sign, with or without decimal point. In the form E, where the mantissa is a decimal number and the exponent can be specified with or without a sign. (Examples of floating point literals: '1', '-12.34567', '-765E-04', '1234E5', '+12E+34', '+12.3E-4', '1E160'). Floating point arithmetic is fast on our hardware platforms. It is ideal when you require a large value range and can take rounding errors into account when making calculations. Such rounding errors can occur when converting from external (decimal) format to internal format (base 2 or 16) or vice-versa (see ABAP/4 number types). Addition 2 ... LIKE f Effect Defines the type typ with the type of the field f. f may be a database field or an already defined internal field. Example TYPES TABLE_INDEX_TYP LIKE SY-TABIX. The type TABLE_INDEX_TYP now points to the type of the field SY-TABIX (index for internal tables). Note This addition is useful in a number of cases, since any field type changes are automatically known to the program. Also, any unnecessary and unwanted conversions are not performed. Addition 3 ... TYPE typ1 OCCURS n Effect Defines the type of an internal table without a header line. An internal table without a header line consists of any number of table lines that have the same structure as that specified by TYPE. You fill and process an internal table with statements such as APPEND, READ TABLE, LOOP and SORT. The OCCURS parameter n specifies how many table lines of storage is required. This storage reservation process does not happen until the first line is inserted in the table. The value n of the OCCURS specification has no effect on type checking, i.e. data objects which have types with different OCCURS specifications are type-compatible. Example TYPES: TAB_TYPE TYPE I OCCURS 20. DATA: TAB TYPE TAB_TYPE, TAB_WA TYPE I. TAB_WA = 1. APPEND TAB_WA TO TAB. TAB_WA = 2. APPEND TAB_WA TO TAB. The internal table TAB now consists of two table entries. Addition 4 ... LIKE f OCCURS n Effect Defines the type of an internal table without a header line. This table consists of any number of table lines which have the structure specified by the data object f. Processing is the same as for addition 3. Example DATA: BEGIN OF PERSON, NAME(20), AGE TYPE I, END OF PERSON. TYPES TYPE_PERSONS LIKE PERSON OCCURS 20. DATA PERSONS TYPE TYPE_PERSONS. PERSON-NAME = 'Michael'. PERSON-AGE = 25. APPEND PERSON TO PERSONS. PERSON-NAME = 'Gabriela'. PERSON-AGE = 22. APPEND PERSON TO PERSONS. The internal table PERSONS now consists of two table entries. Addition 5 ... TYPE LINE OF itabtyp Effect The specified type itabtyp must be the type of an internal table with or without a header line. The statement creates a type corresponding to the line type of the specified table type. Example TYPES TAB_TYP TYPE I OCCURS 10. TYPES MY_TYPE TYPE LINE OF TAB_TYP. The type MY_TYPE now has the same attributes as a line of the table type TAB_TYP and is thus type I. Addition 6 ... LIKE LINE OF itab Effect The data object itab must be an internal table with or without a header line. The statement defines a type which corresponds to the line type of the specified table. Example DATA TAB TYPE I OCCURS 10. TYPES MY_TYPE LIKE LINE OF TAB. The type MY_TYPE now has the same attributes as the line type of the table TAB and thus has the type I. Addition 7 ... DECIMALS n Effect This addition only makes sense with the field type P. When making calculations and outputting data, a field of this type has n decimal places. n must be a value between 0 and 14. Normally, the attribute for fixed point arithmetic is set with newly created programms. If you switch this attribute off, the DECIMALS-specification is taken into account on output, but not when making calculations. In this case, the programmer must take care that the decimal point is in the right place by multiplying or dividing (COMPUTE) by the appropriate power of ten. When making calculations, you should always have fixed point arithmetic switched on. Then, even intermediate results (division!) are calculated with the greatest possible accuracy (31 decimal places). To decide whether the fixed point type P or the floating point type F is more suitable, see also "ABAP/4 number types". Variant 2 TYPES typ(len). Additions: Similar to variant 1 Effect Creates the type typ with the length len. This variant should only be used with the types C, N, P and X. Other types can only be created in the standard length (see table under effect of variant 1). The permitted lengths depend on the type being pointed to: Type Permitted lengths C 1 - 65535 N 1 - 65535 P 1 - 16 X 1 - 65535 Note For each byte, you can display one character, two decimal digits or two hexadecimal digits. With P fields, one place is reserved for the leading sign, so that a P field of the length 3 can contain 5 digits, while an X field of the length 3 can contain 6 digits. Both have an output length of 6. Variant 3 TYPES: BEGIN OF rectyp, ... END OF rectyp. Effect Defines the field string type rectyp by grouping together all fields of the type rectyp defined between "BEGIN OF rectyp" and "END OF rectyp". Each name is prefixed by "rectyp-". Example TYPES: BEGIN OF PERSON, NAME(20) TYPE C, AGE TYPE I, END OF PERSON. ULINE Variants: 1. ULINE. 2. ULINE AT pl. Variant 1 ULINE. Effect Outputs an unbroken underline. Note The underline extends across the entire line depending on the list width. Then, the cursor is positioned at the beginning of the next line. Variant 2 ULINE pl. Effect Outputs an underline with a position and length determined by pl. The position and length specification can consist of three parts: / New line p Output position (one- to three-character number or variable) (l) Output length (one- to three-character number or variable) Any of these components can be omitted (see WRITE). Note If the position and length specification contains exclusively direct values, it can be specified without an introductory AT. The statement ULINE AT 3(10). corresponds to the statement WRITE AT 3(10) SY-ULINE. UNPACK Basic form UNPACK f TO g. Effect Unpacks the packed field f and places it in the field g with leading zeros. If g is too short, it is truncated on the left. Example DATA: P_FIELD(2) TYPE P VALUE 103, C_FIELD(4) TYPE C. UNPACK P_FIELD TO C_FIELD. P_FIELD: P'103C' --> C_FIELD: C'0103' Notes 1. If f is not type P, it is converted to type P (see MOVE). 2. g should always be type C. Otherwise, unwanted side effects may occur. 3. The sign in the packed number is ignored. UPDATE Variants: 1. UPDATE dbtab SET s1 ... sn. 2. UPDATE dbtab. or UPDATE *dbtab. or UPDATE (dbtabname) ... . 3. UPDATE dbtab FROM TABLE itab. or UPDATE (dbtabname) FROM TABLE itab. Effect Updates values in a database table (see Relational database). You can specify the name of the database table either directly in the form dbtab or at runtime as contents of the field dbtabname. In both cases, the table must be known to the ABAP/4 Dictionary. If you specify the name of the database table directly, the program must also contain an appropriate TABLES statement. Normally, lines are updated only in the current client. Data can only be updated using a view if the view refers to a single table and was created in the ABAP/4 Dictionary with the maintenance status "No restriction". UPDATE belongs to the Open SQL command set. Notes 1. Authorization checks are not supported by the UPDATE statement. You must include these in the program yourself. 2. Changes to lines made with the UPDATE command only become final after a database commit (see LUW). Prior to this, any database update can be canceled by a database rollback (see Programming transactions). 3. In the dialog system, you cannot rely on the database system locking mechanism alone to synchronize simultaneous access to the same database by several users. Therefore, it is often necessary to use the SAP locking mechanism. Variant 1 UPDATE dbtab SET s1 ... sn. Additions: 1. ... WHERE condition 2. ... CLIENT SPECIFIED Effect Updates values in a database table. If there is no WHERE clause, all lines (in the current client) are updated. If a WHERE condition is specified, only those records which satisfy the condition are updated. The SET clause s1 ... sn identifies the columns to be updated and assigns values to them. Three types of SET statements si are supported: f = g In all selected lines, the database table column determined by f receives the values of the ABAP/4 field or literal g. f = f + g In all selected lines, the contents of the ABAP/4 field or literal g is added to the value in the database table column determined by f. The NULL value remains unchanged. This statement can only be applied to a numeric field. f = f - g In all selected lines, the contents of the ABAP/4 field or literal g is subtracted from the value in the database table column determined by f. The NULL value remains unchanged. This statement can only be applied to a numeric field. When the command has been executed, the system field SY-DBCNT contains the number of updated lines. The return code value is set as follows: SY-SUBRC = 0: At least one line was updated, SY-SUBRC = 4: No line was updated because no line could be selected. Note With pooled and cluster tables, an UPDATE cannot change any primary key field. Examples Update discount for all customers (in the current client) to 3 percent: TABLES SCUSTOM. UPDATE SCUSTOM SET DISCOUNT = '003'. Note The 'colon and comma' logic in the program fragment UPDATE SCUSTOM SET: DISCOUNT = '003', TELEPHONE = '0621/444444' WHERE ID = '00017777'. defines record chains, - not through a single statement which updates the discount and the telephone number of the customer with the customer number '00017777', - but by means of two statements where the first updates the discount for all customers and the second changes the telephone number of the customer with the customer number '00017777'. Addition 1 ... WHERE condition Effect Updates only those lines which satisfy the WHERE clause condition. Example Increase the number of occupied seats on Lufthansa flight 0400 on 28.02.1995 by 3 (in the current client): TABLES SFLIGHT. UPDATE SFLIGHT SET SEATSOCC = SEATSOCC + 3 WHERE CARRID = 'LH' AND CONNID = '0400' AND FLDATE = '19950228'. Addition 2 ... CLIENT SPECIFIED Effect Switches off automatic client handling. This allows you to update across all clients when using client-specific tables. The client field is treated like a normal table field, for which you can formulate suitable conditions in the WHERE clause. This addition must immediately follow the database table name. Example Increase the number of occupied seats on Lufthansa flight 0400 on 28.02.1995 by 3 in client 2: TABLES SFLIGHT. UPDATE SFLIGHT CLIENT SPECIFIED SET SEATSOCC = SEATSOCC + 3 WHERE MANDT = '002' AND WHERE CARRID = 'LH' AND CONNID = '0400' AND FLDATE = '19950228'. Variant 2 UPDATE dbtab. or UPDATE *dbtab. or UPDATE (dbtabname) ... . Additions: 1. ... FROM wa 2. ... CLIENT SPECIFIED Effect These are SAP-specific short forms which update one single line of a database table. The primary key for identifying the line to be updated and the values to be changed when specifying the database table name in the program are taken from the table work area - dbtab or *dbtab. If the database table name is determined at runtime, you need to use the addition ... FROM wa. When the command has been executed, the system field SY-DBCNT contains the number of updated lines (0 or 1). The return code value is set as follows: SY-SUBRC = 0: The specified line was updated, SY-SUBRC = 4: No line was updated because no line with the specified primary key exists. Examples Update discount for the customer with the customer number '00017777' to 3 percent (in the current client): TABLES SCUSTOM. SCUSTOM-ID = '00017777'. SCUSTOM-DISCOUNT = '003'. UPDATE SCUSTOM. Addition 1 ... FROM wa Effect Takes the values for the line to be updated not from the table work area dbtab, but from the explicitly specified work area wa. Here, the data is taken from wa, moving from left to right according to the structure of the table work area dbtab (defined with TABLES). Since the structure of wa is ignored, the work area wa must be at least as wide (see DATA) as the table work area dbtab and the alignment of the work area wa must correspond to the alignment of the table work area. Otherwise, a runtime error occurs Example Update the telephone number of the customer with the customer number '12400177' in the current client: TABLES SCUSTOM. DATA WA LIKE SCUSTOM. WA-ID = '12400177'. WA-TELEPHONE = '06201/44889'. UPDATE SCUSTOM FROM WA. Note If you do not explicitly specify a work area, the values for the line to be updated are taken from the table work area dbtab, even if the statement appears in a FORM or FUNCTION where the table work area is held in a formal parameter or a local variable. Addition 2 ... CLIENT SPECIFIED Effect Like variant 1. Variant 3 UPDATE dbtab FROM TABLE itab. or UPDATE (dbtabname) FROM TABLE itab. Addition: ... CLIENT SPECIFIED Effect Mass update of several lines in a database table. Here, the primary key for identifying the lines to be updated and the values to be changed are taken from the lines of the internal table itab. The lines of the internal table must satisfy the same conditions as the work area wa in addition 1 to variant 2. The system field SY-DBCNT contains the number of updated lines, i.e. the number of lines in the internal table itab which have key values corresponding to lines in the database table. The return code value is set as follows: SY-SUBRC = 0: All lines from itab could be used to update the database table. SY-SUBRC = 4: At least one line of the internal table itab in the database table, had no line with the same primary key. The other lines of the database table were updated. Note If the internal table itab is empty, SY-SUBRC and SY-DBCNT are set to 0. Addition ... CLIENT SPECIFIED Effect Like variant 1. UPLOAD is not an ABAP/4 key word (in R/3). WHEN Variants: 1. WHEN f. 2. WHEN OTHERS. Effect See CASE. WHERE clause Variants: 1. ... WHERE f op g 2. ... WHERE f [NOT] BETWEEN g1 AND g2 3. ... WHERE f [NOT] LIKE g 4. ... WHERE f [NOT] IN (g1, ..., gn) 5. ... WHERE f [NOT] IN itab 6. ... WHERE f IS [NOT] NULL 7. ... WHERE NOT cond 8. ... WHERE cond1 AND cond2 9. ... WHERE cond1 OR cond2 10. ... WHERE (itab) 11. ... WHERE cond AND (itab) 12. ... FOR ALL ENTRIES IN itab WHERE cond Effect If a WHERE clause is specified with the commands SELECT, OPEN CURSOR, UPDATE and DELETE, only the lines of the database table (or view) which satisfy the specified condition(s) are selected. With Open SQL key words, automatic client handling is normally active. This ensures that only data from the current client is processed when you are working with client-specific tables. Therefore, specifying a client in the WHERE clause does not make sense and is rejected as an error by the syntax check. If you use the addition ... CLIENT SPECIFIED in the FROM clause to switch off automatic client handling, the client field is treated like a normal table field and you can formulate conditions for it in the WHERE clause. Notes 1. If, when using transparent tables, there are frequent accesses without a complete primary key or the data is sorted in an order other than by the primary key, you should consider whether it is worth creating an index. 2. If no WHERE condition is specified, all lines (in the current client) are selected. Variant 1 ...WHERE f op g Effect The condition is true if the comparison f op g is true. The condition is false if the comparison f op g is false. Here, f is the name of a database field (without a prefix) and g is the name of any field or literal. You can use any of the following comparison operators: , = EQual NE, <>, >< Not Equal LT, < Less Than LE, <= Less than or Equal GT, > Greater Than GE, >= Greater than or Equal Examples Select all Lufthansa flight connections: ... WHERE CARRID = 'LH' Select passenger planes with fewer than 200 seats: ... WHERE SEATSMAX LT 200 Notes 1. If the database field f contains the NULL value, the result of evaluating the condition is neither "true" nor "false", but "unknown". 2. You can reverse the effect of a comparison operator by prefixing it with NOT, i.e. NOT EQ corresponds to NE, while NOT LE corresponds to GT, etc. Example If a line contains the NULL value for the field TELEPHONE, you cannot use any of the following conditions to select this line: ... WHERE TELEPHONE = ' ' ... WHERE TELEPHONE <> ' ' ... WHERE NOT TELEPHONE = ' ' Variant 2 ... WHERE f [NOT] BETWEEN g1 AND g2 Effect The condition is true, if the contents of the table field f (do not) lie between g1 and g2. Otherwise, the condition is false. Examples Select all passenger planes with between 200 and 250 seats: ... WHERE SEATSMAX BETWEEN 200 AND 250 Note If the database field f contains the NULL value, the result of evaluating the condition is neither "true" nor "false", but "unknown". Variant 3 ... WHERE f [NOT] LIKE g Addition: ... ESCAPE h Effect The condition is true, if the contents of the table field f (do not) correspond to the contents of the field g. Within the search pattern, two characters have a particular meaning: - '_' stands for any one character. - '%' stands for any character string, including a blank string. If the statement does not apply, the condition is false. Examples Select all customers whose names begin with 'M': ... WHERE NAME LIKE 'M%' Select all texts which contain the word 'customer': ... WHERE TEXT LIKE '%customer%' Select all customers whose names do not contain 'n' as the second letter: ... WHERE NAME NOT LIKE '_n%' Notes 1. You can apply LIKE only to alphanumeric database fields, i.e. the table field f must be one of the Dictionary types ACCP, CHAR, CLNT, CUKY, LCHR, NUMC, UNIT, VARC, TIMS or DATS. The comparison field g must always be type C. 2. The pattern can consist of up to 2n - 1 characters, if n is the same length as the field f. 3. Trailing blanks in the comparison field g are ignored. If a pattern contains trailing blanks, you must enclose it in quotation marks. If a quotation mark is part of the pattern, you must double the opening and closing quotation marks. 4. If the database field f contains the NULL value, the result of evaluating the condition is neither "true" nor "false", but "unknown". Addition ... ESCAPE h Effect The field h contains an escape symbol. Within the pattern g, this makes a special character following the escape symbol lose its special meaning. Example Select all function modules whose names begin with 'EDIT_': ... WHERE FUNCNAME LIKE 'EDIT#_%' ESCAPE '#' Notes 1. An escape symbol can only precede one of the special characters '%' and '_' or itself. 2. The addition ESCAPE g refers only to the immediately preceding LIKE condition. If a WHERE clause contains several LIKE conditions, you must specify ESCAPE as many times as required. 3. The field g which contains the escape symbol is always treated like a type C field of length 1. 4. The addition ESCAPE g is not supported with pooled and cluster tables. Variant 4 ... WHERE f [NOT] IN (g1, ..., gn) Effect The condition is true, if the contents of the table field f are (not) the same as the contents of one of the fields or literals g1, ..., gn. Otherwise, the condition is false. Examples Select the flight connections of American Airlines, Lufthansa and Singapore Airlines: ... WHERE CARRID IN ('AA', 'LH', 'SQ') Select all flight connections apart from those of Lufthansa and Lauda Air: ... WHERE CARRID NOT IN ('LH', 'NG') Notes 1. There must be no blanks between the opening parenthesis which introduces the field list and the name g1 of the first field in the field list. 2. If the database field f contains the NULL value, the result of evaluating the condition is neither "true" or "false", but "unknown". Variant 5 ... WHERE [NOT] in itab Effect The condition is true, if the contents of the database table field f are (not) found in the internal table itab. Otherwise, the condition is false. The internal table itab must have the structure of a RANGES table for f. You can define it with RANGES itab FOR f, SELECT-OPTIONS itab FOR f or DATA. If itab is defined with SELECT-OPTIONS, it is automatically filled with the user's predefined values. Otherwise, you must specify it explicitly in the program. This is a method of specifying parts of the WHERE condition at runtime. Each line of itab contains an elementary condition where the columns have the following meaning: SIGN Specifies whether the condition is inclusive or exclusive. Possible values are: I Inclusive E Exclusive OPTION Contains the operator for the elementary condition. Possible values are: EQ, NE EQual, Not Equal BT, NB BeTween, Not Between CP, NP Contains Pattern, does Not contain Pattern LT, LE Less Than, Less than or Equal GT, GE Greater Than, Greater than or Equal LOW With EQ, NE, LT, LE, GT and GE, this field contains the compare value. With BT and NB, it contains the lower limit of a range. With CP and NP, it can extend beyond LOW and HIGH. HIGH With BT and NB, this field contains the upper limit of a range. With CP and NP, it contains the end of the specification begun in LOW. The elementary conditions in itab are combined together to form a complex condition in the following manner: - If itab is empty, the condition f IN itab is always true. - If itab contains only the inclusive elementary conditions i1, ..., in, the resulting condition is ( i1 OR ... OR in ) - If itab contains only the exclusive elementary conditions e1, ..., em, the resulting condition is ( NOT e1 ) AND ... AND ( NOT em ) - If itab contains the inclusive elementary conditions i1, ..., in and the exclusive elementary conditions e1, ..., em, the resulting condition is ( i1 OR ... OR in ) AND ( NOT e1 ) AND ... AND ( NOT em ) Example Select the customer numbers - '10000000' to '19999999', - '01104711' as well as - all customer numbers greater than or equal to '90000000', but not the customer numbers - '10000810' to 10000815', - '10000911 as well as - all customer numbers where the fifth character is a '5'. TABLES: SCUSTOM. SELECT-OPTIONS: R FOR SCUSTOM-ID. * RANGES: R FOR SCUSTOM-ID. * Let R be filled as follows (the order of lines is * of no significance): * * SIGN OPTION LOW HIGH * I EQ 01104711 * I BT 10000000 19999999 * I GE 90000000 * E EQ 10000911 * E BT 10000810 10000815 * E CP ++++5* * * This generates the condition * * ( ID = '01104711' OR * ID BETWEEN '10000000' AND '19999999' OR * ID >= '90000000' ) AND * ID <> '10000911' AND * ID NOT BETWEEN '10000810' AND '10000815' AND * ID NOT LIKE '____5%' * SELECT * FROM SCUSTOM WHERE ID IN R. ... ENDSELECT. Notes 1. Since a condition of the form f IN itab triggers a complex condition at runtime, but the size of the SQL statement is restricted by the underlying database system (e.g. no more than 8 K), the internal table itab must not contain too many lines. 2. If the database field f contains the NULL values, the result of evaluating the condition is neither "true" nor "false", but "unknown". Variant 6 ... WHERE f IS [NOT] NULL Effect The condition is true if the contents of the table field f (do not) contain the NULL value. Example Select all customers with customer numbers for which no telephone number is specified: ... WHERE TELEPHONE IS NULL Performance: The SAP buffer does not support this variant. Therefore, the effect of each SELECT command on a buffered table or on a view of fields from buffered tables that contains ... WHERE f IS [NOT] NULL is as if the addition BYPASSING BUFFER was specified in the FROM clause. Variant 7 ... WHERE NOT cond Effect NOT cond is true if cond is false. The condition is false of cond is true. This produces the following truth table: NOT true false false true unknown unknown cond can be any condition according to the WHERE variants 1 - 9. NOT takes priority over AND and OR. You can also determine the evaluation sequence by using parentheses. Note Parentheses which determine the evaluation sequence must be preceded and followed by a blank. Example Select the customers with customer numbers who do not live in postal code area 68: ... WHERE NOT POSTCODE LIKE '68%' Variant 8 ... WHERE cond1 AND cond2 Effect cond1 AND cond2 is true if cond1 and cond2 are true. The condition is false if cond1 or cond2 is false. This produces the following truth table: AND true false unknown true true false unknown false false false false unknown unknown false unknown cond1 and cond2 can be any conditions according to the WHERE variants 1 - 9. AND takes priority over OR, but NOT takes priority over AND. You can also determine the evaluation sequence by using prenetheses. Note Parentheses which determine the evaluation sequence must be preceded and followed by a blank. Example Select the customers with customer numbers which are less than '01000000' and do not live in the postal code area 68. ... WHERE ID < '01000000' AND NOT POSTCODE LIKE '68%' Variant 9 ... WHERE cond1 OR cond2 Effect cond1 OR cond2 is true if cond1 or cond2 is true. The condition is false if cond1 and cond2 are false. This produces the following truth table: OR true false unknown true true true true false true false unknown unknown true unknown unknown cond1 and cond2 can be any conditions according to the WHERE variants 1 - 9. Both NOT and AND take priority over OR. You can also determine the evaluation sequence by using parentheses. Note Parentheses which determine the evalutation sequence must be preceded and followed by a blank. Example Select the customers with customer numbers which are less than '01000000' or greater than '02000000': ... WHERE ID < '01000000' OR ID > '02000000'. Select the customers with customer numbers which are less than '01000000' or greater than '02000000' and do not live in the postal code areas 68 or 69 ... WHERE ( ID < '01000000' OR ID > '02000000' ) AND NOT ( POSTCODE LIKE '68%' OR POSTCODE LIKE '69%' ) Variant 10 ... WHERE (itab) Effect The condition is true if the contents of the table fields satisfy the condition stored in the internal table itab. itab is filled at runtime, i.e. the condition for the fields is specified dynamically. Notes 1. This variant is exclusively for use with SELECT. The internal table itab can only have one field which must be of type C and not be greater than 72 characters. itab must be specified in parentheses with no blanks between the parentheses and the table name. The condition specified in the internal table itab must have the same form as a condition in the ABAP/4 source code. The following restrictions apply: - You can only use literals as values, not variables. - The operator IN cannot be used in the form f1 IN itab1. 2. The internal table itab can be empty. Note Performance: Since the syntax check may not be performed until runtime, a WHERE condition needs more execution time than a corresponding specification in the program code. Example Display flight connections after entry of airline carrier and flight number: TABLES: SPFLI. PARAMETERS: CARR_ID LIKE SPFLI-CARRID, CONN_ID LIKE SPFLI-CONNID. DATA: WTAB(72) OCCURS 100 WITH HEADER LINE, AND(3). REFRESH WTAB. IF NOT CARR_ID IS INITIAL. CONCATENATE 'CARRID = ''' CARR_ID '''' INTO WTAB. APPEND WTAB. AND = 'AND'. ENDIF. IF NOT CONN_ID IS INITIAL. CONCATENATE AND ' CONNID = ''' CONN_ID '''' INTO WTAB. APPEND WTAB. ENDIF. SELECT * FROM SPFLI WHERE (WTAB). WRITE: / SPFLI-CARRID, SPFLI-CONNID, SPFLI-CITYFROM, SPFLI-CITYTO, SPFLI-DEPTIME. ENDSELECT. Variant 11 ... WHERE cond AND (itab) Effect Like variant 10. For the condition to be true, the table fields must also satisfy the condition cond. Note When specifying a condition cond in the program code together with a condition in an internal table itab, the table name must appear in parentheses after the condition cond and be linked with AND. There must be no blanks between the name of the internal table and the parentheses. Variant 12 ... FOR ALL ENTRIES IN itab WHERE cond Effect Selects only those lines of the database table which satisfy the WHERE condition cond where each occurring replacement symbol itab-f is replaced by the value of the component f in the internal table itab for at least one line. Clearly, a SELECT command with ... FOR ALL ENTRIES IN itab WHERE cond forms the union of solution sets for all SELECT commands which result when, for each line of the internal table itab, each symbol itab-f addressed in the WHERE condition is replaced by the relevant value of the component f in this table line. Duplicate lines are eliminated from the result set. If the internal table itab contains no entries, the processing continues as if the WHERE condition cond has failed. Example Display a full list of flights on 28.02.1995: TABLES SFLIGHT. DATA: BEGIN OF FTAB OCCURS 10, CARRID LIKE SFLIGHT-CARRID, CONNID LIKE SFLIGHT-CONNID, END OF FTAB, RATIO TYPE F. * Let FTAB be filled as follows: * * CARRID CONNID * -------------- * LH 2415 * SQ 0026 * LH 0400 SELECT * FROM SFLIGHT FOR ALL ENTRIES IN FTAB WHERE CARRID = FTAB-CARRID AND CONNID = FTAB-CONNID AND FLDATE = '19950228'. RATIO = SFLIGHT-SEATSOCC / SFLIGHT-SEATSMAX. WRITE: / SFLIGHT-CARRID, SFLIGHT-CONNID, RATIO. ENDSELECT. Notes 1. ... FOR ALL ENTRIES IN itab WHERE cond can only be used with a SELECT command. 2. In the WHERE condition ... FOR ALL ENTRIES IN itab WHERE cond, the symbol itab-f always has the meaning of a replacement symbol and must not be confused with the component f of the header line in the internal table itab. The internal table itab does not have to have a header line. 3. The line structure of the internal table itab must be a field string. Each component of this field string which occurs in a replacement symbol in the WHERE condition must be of exactly the same type and length as the corresponding component in the table work area (see TABLES). 4. Replacement symbols must not occur in comparisons with the operators LIKE, BETWEEN and IN. 5. FOR ALL ENTRIES IN itab excludes ORDER BY f1 ... fn in the ORDER-BY clause. 6. The internal table itab cannot be used at the same time in the INTO clause. Notes Performance: 1. Conditions should always be checked with the WHERE clause, not with CHECK, because the data can then be selected with an index. Also, this reduces the load on the network. 2. For frequently used SELECT statements, you should employ an index. In the WHERE clause, the fields of the index should be specified in the defined order and linked by the logical AND with comparisons for equality. 3. Complex WHERE clauses are unsuitable for the statement optimizer of a database system because they must be broken down into several single statements. 4. In a WHERE clause, the logical NOT cannot be supported by an index. WHILE Basic form WHILE logexp. Addition: ... VARY f FROM f1 NEXT f2. Effect Repeats the processing enclosed between the WHILE and ENDWHILE statements as long as the logical expression logexp is true. Checks the condition before each loop pass. If it is no longer true, processing resumes after ENDWHILE. You can use the CONTINUE statement to leave the current loop pass prematurely and skip to the next loop pass. Example DATA: SEARCH_ME TYPE I, MIN TYPE I VALUE 0, MAX TYPE I VALUE 1000, TRIES TYPE I, NUMBER TYPE I. SEARCH_ME = 23. WHILE NUMBER <> SEARCH_ME. ADD 1 TO TRIES. NUMBER = ( MIN + MAX ) / 2. IF NUMBER > SEARCH_ME. MAX = NUMBER - 1. ELSE. MIN = NUMBER + 1. ENDIF. ENDWHILE. The above code performs a (binary) search for the "unknown" number SEARCH_ME which lies between MIN and MAX. TRIES contains the number of attempts needed to find it. Notes 1. WHILE loops can be nested any number of times within themselves and other loops. 2. The termination condition and the processing you want to perform in the loop should be well thought out beforehand, so as to avoid the occurrence of endless loops. Addition ... VARY f FROM f1 NEXT f2. Effect Varies the value of the field f during loop processing. At the start of each loop pass, f receives a new value. During the first loop pass, f has the value of the field f1; on the second loop pass, it has the value of the field f2, and so on. The difference between the fields f1 and f2 determines the size of the step varying the value of the variable f in all subsequent loop passes, i.e. it is important that the fields you want to process within the loop have the same distance between each other in memory (see also DO VARYING). If the value of f changes when processing passes through the loop, the new value is placed in the field fn just assigned (transfer type: by value and result) at the end of the relevant loop pass. If the loop pass is terminated by a dialog message, any changed value of f is not transported back for this loop pass. VARY can declare any number of variables. Example DATA: BEGIN OF WORD, ONE VALUE 'E', TWO VALUE 'x', THREE VALUE 'a', FOUR VALUE 'm', FIVE VALUE 'p', SIX VALUE 'l', SEVEN VALUE 'e', EIGHT VALUE '!', END OF WORD, LETTER1, LETTER2. WHILE LETTER2 <> '!' VARY LETTER1 FROM WORD-ONE NEXT WORD-THREE VARY LETTER2 FROM WORD-TWO NEXT WORD-FOUR. WRITE: LETTER1, LETTER2. ENDWHILE. This code outputs the character string "E x a m p l e !". Note If VARY fields (i.e. fields which are filled with a new value on every loop pass) also occur in the WHILE condition, you must ensure that the WHILE condition is evaluated first. Then, if the WHILE condition is (still) true, the VARY fields can be reset. Related DO, LOOP. WINDOW Basic form WINDOW STARTING AT x1 y1. Addition: ... ENDING AT x2 y2 Effect Displays the current secondary list as a modal dialog box (see CALL SCREEN). The same rules apply as for displaying a list on the full screen, i.e. the page size corresponds to the window size. The left upper edge of the window appears at column x1 and line y1. If you do not specify the addition ENDING AT, the position of the right lower edge corresponds to the coordinates of the current screen. You can use variables to specify the coordinates. All the functions for secondary lists are supported. These include: - Scrolling in the window. - Hiding field contents (see HIDE). - Line selection in the window (see AT LINE-SELECTION, ...) - Set the window title (see SET TITLEBAR) Addition ... ENDING AT x2 y2 Effect Positions the right lower edge of the window in column x2 and line y2. You can use variables to specify the coordinates. Example Define a window covering columns 1 to 79 and lines 15 to 23: WINDOW STARTING AT 1 15 ENDING AT 79 23. WRITE 'Text'. Note Inserts a window on the normal screen. You can insert the windows described above only within the context of list processing, i.e. not until after an interactive event (see AT LINE-SELECTION). You can use the technique shown in the example below to insert a window containing a list during a dialog (see CALL SCREEN). Example Display a list as a modal dialog box: CALL SCREEN 100. "Screen of modal dialog box type * STARTING AT 10 10 "... can be started as * ENDING at 60 15. "... separate window with * "... these additions In the flow logic of the screen 100, the processing branches to list processing in the PBO (Process Before Output) module (see LEAVE TO LIST-PROCESSING). Flow logic: PROCESS BEFORE OUTPUT. MODULE LIST. Program: MODULE LIST OUTPUT. LEAVE TO LIST-PROCESSING. * AND RETURN TO SCREEN 0. "Alternative to LEAVE SCREEN * "at end PERFORM OUTPUT. "Output list LEAVE SCREEN. ENDMODULE. WRITE Output to a list - WRITE f. Output to a field or internal table - WRITE f TO g. - WRITE f TO itab INDEX idx. WRITE - Output to a list Basic form WRITE f. Additions: 1. ... AT pl (position and length specification, before the field) 2. ... option (formatting option) 3. ... ofmt (output format by field) 4. ... AS CHECKBOX (output as checkbox) 5. ... AS SYMBOL (output as symbol) 6. ... AS ICON (output as icon) 7. ... AS LINE (output as line) Effect Outputs the field f in the correct format for its type to the current list. The field f can be: - a field declared by DATA, - a component of a structure declared by TABLES, - a field symbol (FIELD-SYMBOLS), - a text literal which is not language-specific - a language-specific text literal (text symbol). Examples TABLES SPFLI. DATA N TYPE I VALUE 123. ... WRITE N. WRITE SPFLI-FLTIME. FIELD-SYMBOLS . ASSIGN 'NEW YORK' TO . WRITE . WRITE: '---->', SPFLI-DISTANCE. WRITE: TEXT-001, SPFLI-ARRTIME. or WRITE: 'Time:'(001), SPFLI-ARRTIME. Text symbols can be addressed in two different ways (TEXT-001 or'Time:'(001)). Notes If no explicit position is specified for a field on a new line, it is output on the left (in column 1). Otherwise, output is one column removed from the previously output field. If a field does not fit on one line, a new line is started. You can perform explicit positioning with a position and length specification (see addition 1) or with ABAP/4 statements (e.g. POSITION). In this case, the field is always output at the defined position, even if the line is not quite long enough for it to fit completely. If a field is too long to fit completely on the line, the excess characters are truncated. Each field occupies a number of characters in the list. If this number is not explicitly defined (see addition 1), the system uses a type-specific standard length or the output length specified in the ABAP/4 Dictionary. Type-specific output: (len = field length) Type Standard output length Output C len left-justified D 8 left-justified F 22 right-justified I 11 right-justified N len left-justified P 2*len or 2*len+1 right-justified T 6 left-justified X 2*len left-justified Number fields (types P, I and F) are always output right-justified, but all other types are left-justified; if required, blanks are used for padding. With number fields, leading zeros are replaced by blanks. If there is enough space, types P and I have thousands separators. To accommodate the decimal point, the output length of type P fields is 1 byte longer. Addition 1 WRITE AT pl (position and length specification before the field) Effect You can use the position and length specification pl to define the precise output position and length of a field. The specification consists of: / New line c Output position (1-3 character number or variable) (l) Output length (1-3 character number or variable) Combinations are possible. Examples DATA: WORD(16), VALUE '0123456789ABCDEF', COL TYPE I VALUE 5, LEN TYPE I VALUE 10. WRITE AT / WORD. "new line WRITE AT 5 WORD. "column 5 WRITE AT (10) WORD. "output length 10 WRITE AT /5(10) WORD. "new line, column 5, length 10 WRITE AT COL WORD. "column = contents of COL WRITE AT (LEN) WORD. "output length = contents of LEN WRITE AT /COL(LEN) WORD. "new line, column = contents of COL "output length = contents of LEN Note 1. The position and length specification must appear before the field. 2. If the position and length specification contains only constants, you the introductory AT is unnecessary. (In the first four of the above examples, you can therefore omit AT.) 3. Always write the position and length specification without gaps and in the specified order. 4. Leave at least one space between the position and length specification and the field name. 5. For dynamic positioning, see also POSITION. 6. No output results from positioning to the right of the far right edge of the page. 7. With explicit column specifications, the field is output from this column, even if it no longer completely fits on the line or overwrites another field. 8. If the output length is too short, number fields (types P, I and F are prefixed with an asterisk ('*'), while all other types are truncated on the right. 9. If you want the abbreviated output of a variable, you should always use WRITE (10) T100-TEXT rather than WRITE T100-TEXT(10) (sub-field access). On the one hand, the first form is always allowed and the second form can be forbidden for certain data types (e.g. TYPE P). On the other hand, only the first form guarantees the identity of the variables for GET CURSOR ... FIELD and F1 help. Addition 2 ... option (formatting option) Effect You can modify the output of the field f by using one of the special formatting options. Addition 3 ... ofmt (output format by field) Effect Outputs the field with the specified output formats (color, intensity, ready for input, ...). You can use the same output options as for FORMAT. If no specifications are made, the field is output with the standard formats or with the format set by a preceding FORMAT statement. Example DATA F. FORMAT INTENSIFIED OFF INPUT. WRITE F INPUT OFF INVERSE COLOR 3. Note The format specifications with WRITE apply only for output of the field f. They modify the currently valid format for this field. This means that, in the above example, the non-highlighted output remains for the field F. When f has been output, the system reverts to the old format. Addition 4 ... AS CHECKBOX (output as checkbox) WRITE - Output as checkbox Effect Outputs the field f as a checkbox. The contents of the first character of f is interpreted as the "status": ' ' = not selected 'X' = selected The user can change this as required. Note To prevent the user changing the contents of the checkbox, you can use the addition ... INPUT OFF. The checkbox is then nothing more than a status display and can only be changed by programming. In technical terms, a checkbox behaves exactly like an input field with a length of 1 (FORMAT INPUT). Examples DATA: MARKFIELD(1) TYPE C VALUE 'X'. ... WRITE MARKFIELD AS CHECKBOX. "checkbox selected MARKFIELD = SPACE. WRITE MARKFIELD AS CHECKBOX. "deselected WRITE MARKFIELD AS CHECKBOX INPUT OFF. "deselected, protected Addition 5 ... AS SYMBOL (output as symbol) WRITE - Output as symbol Effect You can output certain characters as symbols using the addition ... AS SYMBOL. You should only address these characters with their system-defined names. The include (or the more comprehensive include ) contains the relevant identifiers as constants, e.g. SYM_PHONE, SYM_CIRCLE. Example INCLUDE . WRITE: / SYM_RIGHT_HAND AS SYMBOL, " output as symbol 'Tip, Note', SYM_LEFT_HAND AS SYMBOL. " output as symbol Note An output length of one character is enough for most symbols, but some (e.g. SYM_FAX) are twice as long. You can determine the length of a symbol with DESCRIBE FIELD SYM_... OUTPUT-LENGTH ... Addition 6 ... AS ICON (output as icon) WRITE - Output as icon Effect You can output certain characters as icons using the addition ...AS ICON. You should only address these characters with their system-defined names. The include (or the more comprehensive include ) contains the relevant identifiers as constants, e.g. ICON_OKAY (see List of icons). Example INCLUDE . WRITE: / ICON_OKAY AS ICON, "output as icon 'Text line'. Note Although an output length of 2 characters is enough for most icons, some (e.g. the traffic light icons ICON_RED_LIGHT, ...) have a greater output length. You can determine the length of an icon with DESCRIBE FIELD ICON_... output length .... You cannot print out all list icons. The printable icons are flagged as such in the 'list of icons' mentioned above. Addition 7 ... AS LINE (output as line) WRITE - Output as line Effect On list output, automatically links certain characters together to form continuous lines or boxes, if there is no space between them: - vertical lines, output with the system field SY-VLINE or using a field with the contents "|" (vertical line) - horizontal lines, output with the system field SY-ULINE or using a field with at least 2 consecutive minus signs "--". Exactly how each line segment is output (e.g. whether as straight line, corner, T-piece or cross) depends on the adjoining characters. A good rule of thumb sipulates that if the cell adjacent to a line character also contains a line character, the missing piece required to form a connection is added. If an adjacent cell does not also contain a line character, the line character is truncated on that side. Line characters standing on their own remain unchanged. This technique is sufficient to cope with most cases (e.g. tables, boxes, simple hierarchies). However, no matter how carefully you use some empty characters and lines, it is not possible to stop adjacent line characters being joined in an inappropriate way (e.g. very compact hierarchy diagrams, or densely boxes). The solution here is to output the required line segment explicitly using the addition ... AS LINE. The include (or the more comprehensive include ) contains the relevant identifiers for lines as constants, e.g. LINE_TOP_LEFT_CORNER, LINE_BOTTOM_MIDDLE_CORNER. Note Lines cannot have any other display attributes. If attributes such as color (COLOR), reverse video (INVERSE) or intensified (INTENSIFIED) are set, these are ignored on output. If the ready for input attribute (INPUT) is set, the actual characters (minus sign, vertical line) are displayed. Example Output two nested corner segments: INCLUDE . ULINE /1(50). WRITE: / SY-VLINE NO-GAP, LINE_TOP_LEFT_CORNER AS LINE. ULINE 3(48). WRITE: / SY-VLINE NO-GAP, SY-VLINE NO-GAP. Note General notes on outputting boxes to lists When you output a list, this is sometimes combined with vertical and horizontal lines to form closed boxes: - Vertical lines are output by the system field SY-VLINE or by a field containing "|" (vertical bar), - Horizontal lines are output by the system field SY-ULINE or by a field containing only "-" (minus sign), - Vertical and horizontal lines converge (without gaps). WRITE - Output as checkbox Effect Outputs the field f as a checkbox. The contents of the first character of f is interpreted as the "status": ' ' = not selected 'X' = selected The user can change this as required. Note To prevent the user changing the contents of the checkbox, you can use the addition ... INPUT OFF. The checkbox is then nothing more than a status display and can only be changed by programming. In technical terms, a checkbox behaves exactly like an input field with a length of 1 (FORMAT INPUT). Examples DATA: MARKFIELD(1) TYPE C VALUE 'X'. ... WRITE MARKFIELD AS CHECKBOX. "checkbox selected MARKFIELD = SPACE. WRITE MARKFIELD AS CHECKBOX. "deselected WRITE MARKFIELD AS CHECKBOX INPUT OFF. "deselected, protected WRITE - Output as icon Effect You can output certain characters as icons using the addition ...AS ICON. You should only address these characters with their system-defined names. The include (or the more comprehensive include ) contains the relevant identifiers as constants, e.g. ICON_OKAY (see List of icons). Example INCLUDE . WRITE: / ICON_OKAY AS ICON, "output as icon 'Text line'. Note Although an output length of 2 characters is enough for most icons, some (e.g. the traffic light icons ICON_RED_LIGHT, ...) have a greater output length. You can determine the length of an icon with DESCRIBE FIELD ICON_... output length .... You cannot print out all list icons. The printable icons are flagged as such in the 'list of icons' mentioned above. WRITE - Output as line Effect On list output, automatically links certain characters together to form continuous lines or boxes, if there is no space between them: - vertical lines, output with the system field SY-VLINE or using a field with the contents "|" (vertical line) - horizontal lines, output with the system field SY-ULINE or using a field with at least 2 consecutive minus signs "--". Exactly how each line segment is output (e.g. whether as straight line, corner, T-piece or cross) depends on the adjoining characters. A good rule of thumb sipulates that if the cell adjacent to a line character also contains a line character, the missing piece required to form a connection is added. If an adjacent cell does not also contain a line character, the line character is truncated on that side. Line characters standing on their own remain unchanged. This technique is sufficient to cope with most cases (e.g. tables, boxes, simple hierarchies). However, no matter how carefully you use some empty characters and lines, it is not possible to stop adjacent line characters being joined in an inappropriate way (e.g. very compact hierarchy diagrams, or densely boxes). The solution here is to output the required line segment explicitly using the addition ... AS LINE. The include (or the more comprehensive include ) contains the relevant identifiers for lines as constants, e.g. LINE_TOP_LEFT_CORNER, LINE_BOTTOM_MIDDLE_CORNER. Note Lines cannot have any other display attributes. If attributes such as color (COLOR), reverse video (INVERSE) or intensified (INTENSIFIED) are set, these are ignored on output. If the ready for input attribute (INPUT) is set, the actual characters (minus sign, vertical line) are displayed. Example Output two nested corner segments: INCLUDE . ULINE /1(50). WRITE: / SY-VLINE NO-GAP, LINE_TOP_LEFT_CORNER AS LINE. ULINE 3(48). WRITE: / SY-VLINE NO-GAP, SY-VLINE NO-GAP. WRITE - Output formatting options Options: ... NO-ZERO ... NO-SIGN ... DD/MM/YY ... MM/DD/YY ... DD/MM/YYYY ... MM/DD/YYYY ... DDMMYY ... MMDDYY ... YYMMDD ... CURRENCY w ... DECIMALS d ... ROUND r ... UNIT u ... EXPONENT e ... USING EDIT MASK mask ... USING NO EDIT MASK ... UNDER g (only with WRITE) ... NO-GAP (only with WRITE) ... LEFT-JUSTIFIED ... CENTERED ... RIGHT-JUSTIFIED Note The formatting options UNDER g and NO-GAP are intended only output to lists and therefore cannot be used with WRITE ... TO. Option ... NO-ZERO Effect If the contents of f are equal to zero, only blanks are output; if f is of type C or N, leading zeros are replaced by blanks. Option ... NO-SIGN Effect The leading sign is not output if f is of type I, P or F. Option ... DD/MM/YY Option ... MM/DD/YY Effect If f is a date field (type D), the date is output with a 2-character year as specified in the user's master record. Both of these formatting options have the same value. Option ... DD/MM/YYYY Option ... MM/DD/YYYY Effect If f is a date field (type D), the date is output with a 4-character year as specified in the user's master record. Both of these formatting options have the same value. Option ... DDMMYY Option ... MMDDYY Effect Date formatting like the additions ... DD/MM/YY and ... MM/DD/YY, but without separators. Option ... YYMMDD Effect If f is a date field (type D), the date is output in the format YYMMDD (YY = year, MM = month, DD = Day). Option ... CURRENCY w Effect Correct format for currency specified in the field w. Treats the contents of f as a currency amount. The currency specified in w determines how many decimal places this amount should have. The contents of w are used as a currency key for the table TCURX; if there is no entry for w, the system assumes that the currency amount has 2 decimal places. Option ... DECIMALS d Effect d specifies the number of decimal places for a number field (type I, P or F) in d. If this value is smaller than the number of decimal places in the number, the number is rounded. If the value is greater, the number is padded with zeros. Since accuracy with floating point arithmetic is up to about 15 decimal places (see ABAP/4 number types), up to 17 digits are output with floating point numbers (type F). (In some circumstances, 17 digits are needed to differentiate between two neighboring floating point numbers.) If the output length is not sufficient, as many decimal places as possible are output. Negative DECIMALS specifications are treated as DECIMALS 0. Example Effect of different DECIMALS specifications: DATA: X TYPE P DECIMALS 3 VALUE '1.267', Y TYPE F VALUE '125.456E2'. WRITE: /X DECIMALS 0, "output: 1 /X DECIMALS 2, "output: 1.27 /X DECIMALS 5, "output: 1.26700 /Y DECIMALS 1, "output: 1.3E+04 /Y DECIMALS 5, "output: 1.25456E+04 /Y DECIMALS 20. "output: 1.25456000000000E+04 Option ... ROUND r Effect Scaled output of a field of type P. The decimal point is first moved r places to the left (r > 0) or to the right (r < 0); this is the same as dividing with the appropriate exponent 10**r. The value determined in this way is output with the valid number of digits before and after the decimal point. If the decimal point is moved to the left, the number is rounded. For further information about the interaction between the formatting options CURRENCY and DECIMALS, see the notes below. Effect of different ROUND specifications: DATA: X TYPE P DECIMALS 2 VALUE '12493.97'. WRITE: /X ROUND -2, "output: 1,249,397.00 /X ROUND 0, "output: 12,493,97 /X ROUND 2, "output: 124.94 /X ROUND 5, "output: 0.12 Option ... UNIT u Effect Formats a value according to the unit specified in the field u. The contents of f are treated as a quantity. The unit specified in u determines how many decimal places should be output. If f has more places after the decimal point than determined in u, the output value will only have the number of decimal places determined by u, unless the operation truncates digits other than zero. If f has fewer places after the decimal point than determined by u, the option has no effect. The contents of u are used as a unit in the table T006, but if there is no entry, the formatting option has no effect. The field f which is to be output must have the type P. This option is used for table fields which have the Dictionary type QUAN, or for fields defined with reference to such fields (DATA ... LIKE ...). This formatting option excludes the options DECIMALS and ROUND. Example Suppose the unit 'STD' has 3 decimals DATA HOUR TYPE P DECIMALS 3 VALUE '1.200'. WRITE (6) HOUR UNIT 'STD'. "output: 1,2 HOUR = '1.230'. WRITE (6) HOUR UNIT 'STD'. "output: 1,230 Option ... EXPONENT e Effect The field e defines a fixed exponent for a floating point number (type F). The mantissa is adjusted to the exponent by moving the decimal point and padding with zeros. With EXPONENT 0, the exponent specification is suppressed. However, if the output length is too short to accommodate all digits before the decimal point, the standard output format is used. Example Effect of different EXPONENT specifications: DATA: X TYPE P VALUE '123456789E2'. WRITE: /X EXPONENT 0, "output: 12345678900,000000 /X(10) EXPONENT 0, "output: 1,235E+10 /X EXPONENT 3, "output: 12345678,90000000E+03 /Y EXPONENT -3, "output: 12345678900000,00E-03 /Y EXPONENT 9, "output: 12,34567890000000E+09 /Y EXPONENT 2 /Y DECIMALS 4. "output: 123456789,0000E+02 Option ... USING EDIT MASK mask Effect Outputs f according to the formatting template mask. Without this addition, f is output in the standard format for that particular type or with a format defined in the ABAP/4 Dictionary. The addition allows you to define a different format. You can specify the formatting template as follows: - '_' represents one character of the field f or one digit with type P or I - 'V' only with fields of type P or I: output of leading sign - 'LL' at beginning of template: - left justify (standard) - 'RR' at beginning of template: - right justify - '==conv' perform output conversion conv - ':', ... separator - (all other characters) When formatting, the characters '_' in the template are replaced from the left ('LL') or from the right ('RR') by the characters or digits (type P or I) of the field f. Notes 1. When using a template, you must specify the an explicit output length because otherwise the implicit output length of the field f is used. Usually, the template is longer than the implicit output length. 2. If the leading sign is to be output with a field of type P or I, you must specify the wildcard character V at the desired place. If this character does not appear in the template, no leading sign will be output if the value of f is negative. 3. When formatting a field of type P with decimal places, the value is not aligned with a character in the template representing the decimal point (either a period or a comma). If you want to have this character in the output, you must insert it in the correct position in the template and define the formatting from the right. If there is no character for the decimal point in the template, no such character is output. 4. Fields of type F are first converted to the standard format and the resulting sequence is then copied to the template in the case of a field of type C. 5. You implement the user-specific conversion conv with a function module called CONVERSION_EXIT_conv_OUTPUT, e.g. COONVERSION_EXIT_ALPHA_OUTPUT for the conversion of numeric values with leading zeros to a format without leading zeros for type C fields. If a Dictionary field is output and the domain of that field defines a conversion routine, this is executed automatically. For a description of the conversion, refer to the documentation of the appropriate function module. Example Formatted output of the time: DATA TIME TYPE T VALUE '154633'. WRITE (8) TIME USING EDIT MASK '__:__:__'. "Output: 15:46:33 If the output length "(8)" was not specified here, the output would be "15:46:" because the implicit output length for the type T is 6. Option ... USING NO EDIT MASK Effect Switches off a conversion routine specified in the ABAP/4 Dictionary. Option ... UNDER g Effect Output of the field f begins at the column from which the field g was output. If this happens in the same output line, the output of the field g is overwritten. Note After UNDER, the field g must be written exactly as the reference field in the previous WRITE statement, i.e. with an offset and length if necessary. The exception to this rule is if g is a text symbol. In this case, the reference field is determined by the number of the text symbol (not by the text stored there). Example Align output to the reference fields: FIELD-SYMBOLS . ASSIGN 'First Name' TO . WRITE: /3 'Name'(001), 15 , 30 'RoomNo', 40 'Age'(002). ... WRITE: / 'Peterson' UNDER 'Name'(001), 'Ron' UNDER , '5.1' UNDER 'RoomNo', (5) 24 UNDER TEXT-002. This produces the following output (numbers appear right-justified in their output fields!): Name First Name RoomNo Age Peterson Ron 5.1 24 Option ... NO-GAP Effect Suppresses the blank after the field f. Fields output one after the other are then displayed without gaps. Example Output several literals without gaps: WRITE: 'A' NO-GAP, 'B' NO-GAP, 'C'. "Output: ABC If NO-GAP was not specified here, the output would have been "A B C" because one blank is always implicitly generated between consecutive output fields. Option ... LEFT-JUSTIFIED ... CENTERED ... RIGHT-JUSTIFIED Effect Left-justified, centered or right-justified output. For number fields (types I, P and F), RIGHT-JUSTIFIED is the standard output format, but LEFT-JUSTIFIED is used for all other types, as well as for templates. Examples Output to a list (WRITE): DATA: FIELD(10) VALUE 'abcde'. WRITE: / '|' NO-GAP, FIELD LEFT-JUSTIFIED NO-GAP, '|', / '|' NO-GAP, FIELD CENTERED NO-GAP, '|', / '|' NO-GAP, FIELD RIGHT-JUSTIFIED NO-GAP, '|'. * Output: |abcde | * | abcde | * | abcde| Formatting in a program field (WRITE...TO...) DATA: TARGET_FIELD1(10), TARGET_FIELD2 LIKE TARGET-FIELD1, TARGET_FIELD3 LIKE TARGET-FIELD1. WRITE: '123' LEFT-JUSTIFIED TO TARGET-FIELD1, '456' CENTERED TO TARGET-FIELD2, '789' RIGHT-JUSTIFIED TO TARGET-FIELD3. WRITE: / '|' NO-GAP, TARGET_FIELD1 NO-GAP, '|', / '|' NO-GAP, TARGET-FIELD2 NO-GAP, '|', / '|' NO-GAP, TARGET_FIELD3 NO-GAP, '|'. * Output: |123 | * | 456 | * | 789| Notes Specifying several formatting options You can use the additions of the first group (NO-ZERO, NO-SIGN, DD/MM/YY etc., CURRENCY, DECIMALS, ROUND, EXPONENT) simultaneously, provided it makes sense. You can combine the additions UNDER and NO-GAP with all other additions in any permutation; however, they are not taken into account until the field f has been formatted according to all the other options. Templates, conversion routines and alignment If you want to format a field using a special conversion routine, all the other additions (apart from UNDER and NO-GAP) are ignored. This also applies if the conversion routine is not explicitly specified, but comes from the ABAP/4 Dictionary. If you want to format a field using a template, the system first takes into account the options of the first group, and then places the result in the template. However, if you specify one of the date-related formatting options (DD/MM/YY etc.), the template is ignored. Finally, the formatted field or the template is copied to the target field according to the requested alignment. For type C fields, it is the occupied length that is relevant, not the defined length; this means that trailing blanks are not taken into account. Combined usage of CURRENCY, DECIMALS and ROUND The rounding factor (from the right) in WRITE price CURRENCY c ROUND r DECIMALS d results from the formula rounding factor = c + r - d. If DECIMALS is not specified, d = c applies. You read this formula in the following manner: The field price is supposed to be of ABAP/4 type P (or I); it contains a currency amount. The CURRENCY specification expresses how many decimal places price is to have and may differ from the definition of price (the decimal point is not stored internally, but comes from the type attributes of price). Normally, price is output with as many decimal places as the field has internally according to the type attributes or the CURRENCY specification. You can override this number of output decimal places with DECIMALS. The addition ROUND addition moves the decimal point r places to the left, if r is positive, otherwise to the right. This means that a $ amount is output with ROUND 3 in the unit 1000 $. According to the above formula, there can also be a "negative" rounding factor; then, the corresponding number of zeros is appended to the amount price on the right using the "rounding factor". However, the value of "rounding factor" must be at least equal to -14. Currency fields and DATA with DECIMALS If the field price is normally formatted with decimal places (e.g. fields for currency amounts), these are treated like a CURRENCY specification when rounding, if CURRENCY was not expressly specified. If present, the DECIMALS specification defines how many decimal places are to be output after rounding. If the DECIMALS and the (explicit or implicit) CURRENCY specifications are different, rounding takes place according to the above formula, even if no ROUND specification was made (i.e. r = 0). If a field in the DATA statement was declared with DECIMALS n, WRITE treats it like a currency field with n decimal places. Examples Sales in pfennigs or lira: 246260 Unit TDM or TLira with 1 decimal place. DATA SALES TYPE P VALUE 246260. WRITE SALES CURRENCY 'DEM' ROUND 3 DECIMALS 1. " 2,5 TDM WRITE SALES CURRENCY 'ITL' ROUND 3 DECIMALS 1. " 246,3 TLira Sales in pfennigs or lira: 99990 Unit TDM or TLira with 1 decimal place. SALES = 99990. WRITE SALES CURRENCY 'DEM' ROUND 3 DECIMALS 1. " 1,0 TDM WRITE SALES CURRENCY 'ITL' ROUND 3 DECIMALS 1. " 100,0 TLira Sales in pfennigs or lira: 93860 Unit 100 DM or 100 lira with 2 decimal places: SALES = 93860. WRITE SALES CURRENCY 'DEM' ROUND 2 DECIMALS 2. " 9,38 HDM WRITE SALES CURRENCY 'ITL' ROUND 2 DECIMALS 2. " 938,60 HLira Sales in pfennigs: 93840 Unit 1 DM without decimal places. SALES = 93860 WRITE SALES CURRENCY 'DEM' DECIMALS 0. " 938 DM Sales in pfennigs: 93860 Unit 1 DM without decimal places. SALES = 93860. WRITE SALES CURRENCY 'DEM' DECIMALS 0. " 939 DM Note Runtime errors: - WRITE_CURRENCY_ILLEGAL_TYPE: CURRENCY parameter with WRITE is not type C - WRITE_ROUND_TOO_SMALL: Rounding parameter is less than -14 - WRITE_UNIT-ILLEGAL_TYPE: UNIT parameter with WRITE is not type C WRITE - Output as symbol Effect You can output certain characters as symbols using the addition ... AS SYMBOL. You should only address these characters with their system-defined names. The include (or the more comprehensive include ) contains the relevant identifiers as constants, e.g. SYM_PHONE, SYM_CIRCLE. Example INCLUDE . WRITE: / SYM_RIGHT_HAND AS SYMBOL, " output as symbol 'Tip, Note', SYM_LEFT_HAND AS SYMBOL. " output as symbol Note An output length of one character is enough for most symbols, but some (e.g. SYM_FAX) are twice as long. You can determine the length of a symbol with DESCRIBE FIELD SYM_... OUTPUT-LENGTH ... WRITE - Output to a variable Variants: 1. WRITE f TO g[+off][(len)]. 2. WRITE f TO itab[+off][(len)] INDEX idx. Variant 1 WRITE f TO g[+off][(len)]. Addition: ... option Effect Assigns the contents of the source field f to the target field g as a new value. In contrast to MOVE, the format of the target field g is the same as when outputting to a list with WRITE. The field type C is always used, regardless of the actual data type. As with list output, the settings in the user's master record for decimal point (period or comma) and date format are taken into account. Other formatting options are also possible with list output. Instead of specifying a static source field f, you can make a dynamic source field specification (name). In this case, the contents of the field name is interpreted as the source field name at runtime and the contents are formatted accordingly. You can identify the target field g more precisely by specifying the offset and/or length in the form g+off(len). Both the offset and the length specifications off and len can also be dynamic. The return code value SY-SUBRC is undefined Example WRITE ... TO with dynamic source field specification and dynamic offset and length specification for the target field: DATA: NAME(5) VALUE 'FIELD', FIELD(5) VALUE 'Harry', DEST(18) VALUE 'Robert James Smith', OFF TYPE I, LEN TYPE I. OFF = 7. LEN = 8. WRITE (NAME) TO DEST+OFF(LEN). The field DEST noew contains the value "Robert Harry ith". Notes 1. Only values between 0 and the length of the target field g are allowed as offset specifications. Any other offset specifications result in a runtime error. 2. Only values >= 0 are allowed as length specifications. Negative length specifications result in a runtime error. Excessive length specifications are automatically truncated. 3. If you specify the field length as the offset or the value 0 as the length, the target field is blank. In this case, the statement has no effect. Addition ... option Effect Modifies the output format with the aid of special formatting options. Variant 2 WRITE f TO itab[+off][(len)] INDEX idx. Additions like variant 1. Effect Like variant 1, except that output is to the idx-th line of the internal table itab. Ayn offset and/or length specifications refer to the table line used for output. The return code value is set as follows: SY-SUBRC = 0: Valid index specification, i.e. the internal table itab contains a line with the index idx. SY-SUBRC = 4: Index specification is too large, i.e. the internal table itab contains fewer than idx entries. Note Invalid index specifications, i.e. idx <= 0, result in a runtime error. Note Runtime errors: - WRITE_TO_LENGTH_NEGATIVE: Negative length specification in len. - WRITE_TO_OFFSET_NEGATIVE: Negative offset specification in off. - WRITE_TO_OFFSET_TOOLARGE: Offset specification in off is greater than field length. - TABLE_INVALID_INDEX: Invalid index specification <= 0 in idx (variant 2 only). Related MOVE, WRITE