Professional Documents
Culture Documents
String Manipulation
String Manipulation
Examples
Example
system adds a new line to the internal table <itab> for each part of the
string
Example
Now Internal Table itab has three rows. The first row
contains “One”, second row contains “Two” and third row
contains “Three”.
LEFT shifts the field contents <n> places to the left and adds
<n> blanks at the right-hand end of the field (default).
RIGHT shift <n> positions to the right and adds <n> blanks at
the left-hand end of the field.
searches the field contents of <c> until it finds the string <str> and
shifts the field <c> up to the edge of the field.
SHIFT <c> LEFT DELETING LEADING <str>.
SHIFT <c> RIGHT DELETING TRAILING <str>.
shifts the field <c> to the left or to the right, provided the first
character on the left or the last character on the right occur in <str>.
The right or left of the field is then padded with blanks.
field <c> must be of type C and the field <sc> must be of type X with a
minimum size of 16 times the size of <c>.
Example
DATA : fname(50) VALUE ‘/tmp/mat&.txt’.
Syntax
IF <condition1>.
<statement block>
ELSEIF <condition2>
<statement block>.
ELSEIF <condition3>.
<statement block>
.....
ELSE.
<statement block>
ENDIF.
Syntax
CASE <f>.
WHEN <f11> [OR <f 12> OR ...].
<Statement block>
WHEN <f21>.[OR <f 22> OR ...]
<Statement block>
WHEN <f31> [OR <f 32> OR ...].
<statement block>
WHEN ...
......
WHEN OTHERS.
<statement block>
ENDCASE.
Unconditional Loops
Syntax
DO [<n> TIMES] [VARYING <f> FROM <f1> NEXT <f 2>].
<Statement block>
ENDDO.
Conditional Loops
Syntax
WHILE <condition> [VARY <f> FROM <f1> NEXT <f 2>].
<statement block>
ENDWHILE.
02-Sep-09 Kaavian Systems 19
Comparison Operators
IS INTIAL
IS BETWEEN
NOT
Comparing Character fields
CO ------Contains only
CN-------Contains not only
CA-------Contains Any
NA-------Contains not any
CS-------Contains String
NS-------Contains Not string
CP-------Contains pattern
NP-------Contains no pattern
Get two values and the operation (+, -, /, *) to be carried out from the
user, based on the input, use the CASE statement to perform the
action. If the output is greater than 50, print “The <output> is greater
than 50”, If it is between 25 and 50, print “The <output> is between
25 and 50”, If the less than 25 print “The <output> is less then 25”.
Get a number from the user n and print 1 to n. If the number is less
than 50, print from n to 50.