0% found this document useful (0 votes)
163 views2 pages

Exercise - ABAP Commands

The document provides examples of string operations in ABAP including shifting strings, replacing values, translating case, overlaying strings, searching strings, getting string lengths, condensing strings, concatenating strings, splitting strings, moving parts of strings, and checking if strings contain other strings or values. The examples demonstrate commands like MOVE, TRANSLATE, OVERLAY, and CONTAINS using defined character-type variables of different lengths and values.

Uploaded by

Ram
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
163 views2 pages

Exercise - ABAP Commands

The document provides examples of string operations in ABAP including shifting strings, replacing values, translating case, overlaying strings, searching strings, getting string lengths, condensing strings, concatenating strings, splitting strings, moving parts of strings, and checking if strings contain other strings or values. The examples demonstrate commands like MOVE, TRANSLATE, OVERLAY, and CONTAINS using defined character-type variables of different lengths and values.

Uploaded by

Ram
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

ABAP Commands - Exercise

ABAP COMMANDS EXERCISE 1 – STRING OPERATIONS

1. Shifting strings by a given number of places


- Define variable t1 length 10 type c value ‘abcdefghij’.
- Define string1 like t1.
- Assign t1 to string1.
- Shift string1 by a single place
- Shift string1 by 3 places in all possible ways (left, right, circular)
- Display the output after each operation

2. Shifting up to a given string


- Define str2(2) type c value ‘ef’
- Shift string1 upto str2
- Repeat for left, right, circular.
- Display the outputs

3. Shifting depending on first or last character


- Define t3 length 14 value ‘ abcdefghij’
- Define string3 like t3.
- Define str3 value ‘ghij’.
- Print string3 without the leading space.
- Print string3 without ‘ghij’ and right-aligned

4. Replacing values
- Define a string with value ‘PUPPY’.
- Change it to ‘MUMMY’ using ABAP command

5. Translate
- Define t5(10) value ‘aBcDeFgHiJ’.
- Define string5 like t5.
- Assign t5 to string5. Translate to uppercase
- Assign t5 to string5. Translate to lowercase

6. Overlay strings
- Define t6(10) TYPE c VALUE 'a c e g i ',
string6 LIKE t6,
over6(10) TYPE c VALUE 'ABCDEFGHIJ'
- Assign value of t6 to string6
- Overlay string6 with over6 and output the result

7. Search strings
- Define string7(30) TYPE c VALUE 'This is a little sentence.'

ABAP Training Page 1 of 2


ABAP Commands - Exercise

- Search string for ‘itt’.


- If found, print the position at which the substring is found.

8. Length of a string
- Define word1(20) TYPE c VALUE '12345',
word2(20) TYPE c ,
word3(20) TYPE c VALUE ' 4 '.
- Get the lengths of strings word1, word2, word3.
- Display the result.

9. Condensing strings
- Define string9(25) TYPE c VALUE ' one two three four'.
- Condense the above string
- Condense string specifying no gaps
- Display the results along with the string length in each case.

10. Concatenating strings


- Define c1(10) TYPE c VALUE 'Sum',
c2(3) TYPE c VALUE 'mer',
c3(5) TYPE c VALUE 'holi ',
c4(10) TYPE c VALUE 'day',
sep(3) TYPE c VALUE ' - '
- Output a variable so that it contains ‘Summerholiday’
- Output a variable so that it contains ‘Sum - mer - holi – day’

11. Splitting strings


- Split the variable obtained in the second case above into variables
containing ‘Sum’, ‘mer’, ‘holi’ and ‘day’.

12. Moving parts of string


- Define mc1(10) TYPE c VALUE 'ABCDEFGHIJ'
- Use MOVE cmd with PERCENTAGE addition to display output ‘ABCD’
left-aligned & right-aligned

13. Contains Operations


- Define a variable with value ‘Today is a wonderful day’.
- Check if it contains any numeric character
- Check if it contains the string ‘day’
- Define a variable ‘121314’
- Check if it contains all numeric values

ABAP Training Page 2 of 2

You might also like