Sie sind auf Seite 1von 9

The WRITE Statement The basic ABAP statement for displaying data on the screen is WRITE.

Syntax WRITE <f>. This statement writes field <f> to the current list in its standard output format. By default, the list is displayed on the screen. Chained Statements To concatenate a sequence of separate statements, write the identical part only once and place a colon (:) after it. Ex: WRITE FIRST PROGRAM. WRITE NAME. WRITE : FIRST PROGRAM , NAME.

Positioning WRITE Output on the List You can position the output of a WRITE statement on the list by making a format specification before the field name as follows: Syntax WRITE [/] [<pos>] <f>. where

the slash '/' denotes a new line, <pos> is a number or variable up to three digits long denoting the position on the screen,

Horizontal lines You can generate horizontal lines on the output screen by using the following syntax: Syntax ULINE [AT [/][<pos>][(<len>)]]. Vertical lines You generate vertical lines on the output screen by using the following syntax: Syntax WRITE [AT [/][<pos>]] SY-VLINE. Blank lines You can generate blank lines on the screen by using the following syntax: Syntax SKIP [<n>]. Starting with the current line, this statement generates <n> blank lines on the output screen.

ASSIGNMENT STATEMENTS CLEAR MOVE MOVE-CORRESPONDING CLEAR Sets a variable to its initial value. Syntax CLEAR <f>.

The variable <f>, which can have any data type, is set to an initial value appropriate to its type. Clear V1 MOVE Statement To move a value from one field to another, use the MOVE statement. Instead of move, you can use the assignment operator = Syntax MOVE V1 TO V2. OR V2 = V1 Move-corresponding Statement : To perform a move from one field string to another where the data types and/or lengths do not match, use the move-corresponding statement. Syntax MOVE-CORRESPONDING V1 TO V2 CALCULATIONS COMPUTE Performs numeric operations. Syntax COMPUTE <n> = <expression>. The result of the mathematical operation specified in <expression> is assigned to the field <n>. The keyword COMPUTE is optional. VALID OPERATORS FOR THE COMPUTE STATEMENT

OPERATOR + * / ** DIV MOD

OPERATION Addition Subtraction Multiplication Division Exponentiation Integer division Remainder of integer division

ADD Adds two fields. Syntax ADD <n> TO <m>. The contents of <n> are added to the contents of <m> and the results are stored in <m>. This is equivalent to: <m> = <m> + <n>. ADD-CORRESPONDING Adds subfields of structures. Syntax ADD-CORRESPONDING <struc1> TO <struc2>. All the subfields of the structures <struc1> and <struc2> having the same name are added and the results are stored in <struc2>. SUBTRACT Subtracts two fields. Syntax

SUBTRACT <n> FROM <m>. The contents of <n> are subtracted from the contents of <m> and the results are stored in <m>. This is equivalent to: <m> = <m> - <n>. SUBTRACT-CORRESPONDING Subtracts components of structures. Syntax SUBTRACT-CORRESPONDING <struc1> FROM <struc2>. All the subfields of the structures <struc1> and <struc2> having the same name are subtracted and the results are stored in <struc2>. Note : In ADD and SUBTRACT the values will store in right side In MULTIPLY and DIVIDE the value will store in left side. MULTIPLY Multiplies two fields. Syntax MULTIPLY <n> BY <m>. Multiplies the content of <n> by <m>, and stores the result in <n>. This is equivalent to: n =m*n. MULTIPLY-CORRESPONDING Multiplies components of structures. Syntax MULTIPLY-CORRESPONDING <struc1> BY <struc2>. All the identically-named subfields of the structures <struc1> and <struc2> are multiplied and the results are stored these subfields of <struc1>.

DIVIDE Divides one field by another. Syntax DIVIDE <n> BY <m>. Divides the content of <n> by <m>, and places the result in <n>. This is equivalent to: n=n/m. DIVIDE-CORRESPONDING Divides matching components of structures. Syntax DIVIDE-CORRESPONDING <struc1> BY <struc2>. All the identically-named subfields of the structures <struc1> and <struc2> are divided and the results are stored these subfields of <struc1>.

COMMON CONTROL STATEMENTS IF Conditional branch. Syntax IF <logexp>. [ELSEIF <logexp>] [ELSE. ] ENDIF. Opens an IF control structure that ends with an ENDIF statement. The system evaluates the logical expression <logexp>, and processes different statement blocks depending on the result.

ELSEIF AND ELSE are optional. CASE Statement Conditional branch The CASE statement performs a series of comparisons. CASE v1. WHEN v2 [ or vn ]. WHEN v3 [ or vn]. [WHEN others. ..] ENDCASE Opens a CASE control structure that ends with an ENDCASE statement. The CASE control structure allows you to control which statement blocks (introduced by WHEN) are processed, based on the contents of a data object.

DO Introduces a loop. Syntax DO [<n> TIMES] [VARYING <f> FROM <f1> NEXT <f2>] [EXIT.] .. ENDDO. Introduces a statement block that ends with ENDDO. If you omit the TIMES addition, the statement block is repeated until it reaches a termination statement such as EXIT or CHECK. Use the TIMES addition to restrict the number of loop passes to <n>. The VARYING addition allows you to process fields the same distance apart in memory.

Do loops can be nested an unlimited number of times. Exit prevents further loop processing and exits immediately out of the current loop.

WHILE The WHILE statement is a looping mechanism similar to DO Syntax WHILE <logexp> [VARY <f> FROM <f1> NEXT <f2>]. [EXIT.] . ENDWHILE. Introduces a statement block that ends with ENDWHILE. The statement block between WHILE and ENDWHILE is repeated as long as the logical expression <logexp> is true, or until a termination statement such as EXIT or CHECK occurs. The VARY addition allows you to process fields the same distance apart in memory.

CHECK Conditionally leaves a loop or processing block. Syntax CHECK <logexp>. If the logical expression <logexp> is true, the system continues with the next statement. If it is false, processing within the loop is interrupted at the current loop pass, and the next loop pass is performed. Otherwise the system leaves the current processing block.

EXIT Leaves a loop or processing block. Syntax EXIT. Within a loop: The entire loop is terminated, and processing continues with the first statement following the loop Exit VS Check EXIT works similar to CHECK except that it doesn't check a given condition. CONTINUE 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. SYNTAX CONTINUES

Das könnte Ihnen auch gefallen