Professional Documents
Culture Documents
01 - ABAP Basics
Data Handling
Note: All the following objects to be created should follow the naming convention
YEMPID_##$$%%. ##$$ indicates the exercise number (01.01 for this assignment) and %%
indicates the question number in the exercise. EMPID indicates the Employee ID.
1) Which of the following are invalid data object names and why?
a) InterestPaid
b) A1234bCDef
c) Si-int
d) percent.
e) SPACE
f) Dist in km
g) Ot+pay
h) Na,me
i) DATA:OBJECT
5) Write a program to display the date, month and year of the current date on separate lines. For
example if the current date is December 5, 2000, then the output should be as follows:
Date : 05
Month : 12
Year : 2000
7) Write a program to display the decimal equivalent values of the following hexadecimal
numbers. The output should be as follows:
Hexadecimal value Decimal equivalent
A01
BDF
12345
1F80
8) Write a program to display the hexadecimal equivalent values of the following decimal
numbers. The output should be as follows:
Decimal value Hexadecimal equivalent
984601
21589
2642345
15680
9) What is the maximum permissible value for a hexadecimal data object with length 4?
10) Write a program to display the last day of the next month and display it in DD/MM/YYYY
format.
Using the above variables, do the following and explain the output.
Move F1 to I1 and display both the variables.
Move I2 to F2 and display both the variables.
Move C1 to C2 and display both the variables.
Move C1 to N1 and display both the variables.
Move F1 to P1 and display both the variables.
Move F1 to P2 and display both the variables.
ADDRESS
FIRSTNAME(20) type C
SURNAME(20) type C
INITIALS(4) type C
STREET(20) type C
NUMBER type I
POSTCODE type N
CITY(20) type C
NAME
SURNAME(20) type C
FIRSTNAME(20) type C
POSTCOD type N
INITIALS(4) type C
TITLE(10) type C
CITY(20) type C
Initialize the field string ADDRESS with the respective data and fill the corresponding fields
in field string NAME and display both the field strings.
14) Declare the following variables.
a) NUMBER TYPE F VALUE '4.3',
b) TEXT (10),
c) FLOAT TYPE F,
d) PACK TYPE P DECIMALS 1.
Do the following using WRITE TO statement with above variables and explain the output.
Display the output YASH INDIA by using only TARGET field in WRITE statement.
(Dont use MOVE)
Fill the FULL_NAME field with Robert James Smith and display. (Dont use
MIDDLE_NAME field while moving the contents to FULL_NAME)
Name Salary
Abc 1000
Xyz 2000
Total 3000
Output the above data and print the sum of salary under the salary statement without using
position in write statement.
STRING (20),
NUMBER (8) TYPE C VALUE '123456',
Using the above variables and the WRITE TO statement, do the following.
21) Implement the following piece of code in ABAP with the following values for the data
objects W_FLOAT1 and W_FLOAT2. What are your observations and justify the results.
W_FLOAT1 W_FLOAT2
9.6 3.2
-9.6 3.2
9.6 -3.2
-9.6 -3.2
24) Display the date and time after PI days from now. Output the current date, current time,
future date and future time. (PI = 22 / 7). Explain the result.
25) What are all the data types that are right justified in the output?
26) Using only assignment operators and starting with the float value 45.2347, get the following
outputs.
a) ***
b) 45234700
c) 000045
d) 34700001
27) Write a program to find and display the greatest prime number less than the number entered
by the user. Optimize the program so that the run time is less.
28) Write a program to convert a given number from the specified source number system to the
specified target number system. Take the source number, source number system and target
number system as inputs.
29) Given a string of numerals, write a program that calculates and displays the maximum
number possible using those numerals.
For example, if the string entered is 368824, the output should be 886432.
30) Given an integer, write a program to output the number with the digits reversed.
For example, if the number entered is 23987446, the output should be 64478932.
31) Write a program to accept a number range and an exception range (in the form of 4
parameters). Display the numbers in the given range excluding those specified in the
exception range.
For example, if the user enters 23, 69, 26 and 67 then the output should be 23, 24, 25, 68 and
69.
32) Write a program to accept a string and a character from the user and display the total number
of times that character appears in the string. Also display the position and word in which the
character appears.
33) Write a program to find the sum & product of the first N Armstrong numbers. The user
should enter a value for N. (Word of caution: See that the user should not enter a value for
N which is more than 5).
34) Write a program to accept a string from the user and display all the possible string
combinations that can be made using the characters of the given string. For example if the
user enters a string A1C, then the program should display
A1C
AC1
1CA
1AC
CA1
C1A.
1 2 3 4 5
5 4 3 2
2 3 4
4 3
3