0% found this document useful (1 vote)
187 views

ABAP Basics - Modularization

The document provides instructions and examples for modularizing ABAP programs using subroutines and function modules. It includes 11 exercises to write subroutines and function modules to perform tasks like validating input, calculating values, populating internal tables, and handling exceptions. The exercises cover basics of modular programming concepts in ABAP like passing values between main programs and subroutines/function modules, error handling, and reusability.

Uploaded by

graj469
Copyright
© Attribution Non-Commercial (BY-NC)
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 (1 vote)
187 views

ABAP Basics - Modularization

The document provides instructions and examples for modularizing ABAP programs using subroutines and function modules. It includes 11 exercises to write subroutines and function modules to perform tasks like validating input, calculating values, populating internal tables, and handling exceptions. The exercises cover basics of modular programming concepts in ABAP like passing values between main programs and subroutines/function modules, error handling, and reusability.

Uploaded by

graj469
Copyright
© Attribution Non-Commercial (BY-NC)
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/ 5

Exercise 02.

04- ABAP Basics


Modularizing ABAP programs

Exercise 02.04 - Modularizing ABAP programs


Note: All the following objects to be created should follow a naming convention YEMPID_##$ $%%. ##$$ indicates the exercise number where as %% indicates the question number in the exercise. Use the function group ZYASHSAPTRAINEES to create the function modules.

Exercise on Subroutines:
1) Write a subroutine to print the user name, run date, and run time and invoke the subroutine. 2) Write a program to accept two numbers and an arithmetic operator. Perform the specified arithmetic operation on the number inputs, in a subroutine by passing the accepted inputs by value. Print the numbers, the operator and the result in the main program. If the accepted values are invalid, display that information on the list. (Use another subroutine to validate the inputs). 3) Accept a number N from the user and print the first N numbers of the fibonacci series using a subroutine. Implement this using recursion technique. 4) Do the necessary modularization for the following requirement: Create internal tables to populate the following data: Contents of the first internal table. Plant 0100 0110 0200 Description YASH plant1 YASH plant2 Test plant

Contents of the second internal table. Material MAT001 MAT002 MAT001 MAT001 MAT002 MAT003 MAT002 MAT001 MAT002 Material type Raw material Trading goods Raw material Raw material Trading goods Finished goods Trading goods Raw material Trading goods Plant 0100 0300 0110 0400 0110 0100 0100 0100 0110 Quantity in CA 20 10 15 10 5 12 5 10 6

Display the contents of the second internal table, only when there are corresponding entries in the first internal table.

Exercise 02.04 - Modularizing ABAP programs


Plant: 0100 YASH plant1 Material Material type MAT001 Raw material MAT002 Trading goods MAT003 Finished goods Total Qty for plant 0100 Quantity 30 5 12 47

Plant: 0110 YASH plant2 Material Material type Quantity MAT001 Raw material 15 MAT002 Trading goods 11 Total Qty for plant 0110 Gross total quantity 26 73

5) Write two include programs to perform the following: a) Create an internal table with the structure as specified below: Field Name Data Type Length Airline_Carrier_id C 2 Flight_Connection_id N 4 Flight_Date D b) Write a subroutine to populate the internal table with the data as specified below: Airline Carrier id AA DL AA UA LH Flight Connection id 0017 1984 0026 0941 1699 Flight Date 12.12.1999 06.05.2000 04.08.1999 11.11.2000 01.02.2000

6) Create a program to output the contents of the internal table created in the previous question as specified below. Print user details like the user name, run date and run time using the subroutine, which is created in question 1. <User details should be displayed here> Flight Connection Details Airline Carrier id AA AA DL LH Flight Connection id 0017 0026 1984 1699 Flight Date 12.12.1999 04.08.1999 06.05.2000 01.02.2000

Exercise 02.04 - Modularizing ABAP programs


UA 0941 11.11.2000

Exercise on Function Modules:


Note: All the following function modules need to be called from within a program and the programs should be as generic as possible. 7) Write a function module to determine whether a given year is a leap year or not. 8) Write a function module to generate a random number. (You are at your liberty to use any logic to generate a random number). 9) Write a function module to accept a date and display the date in the following format. Ex: Wednesday September 18, 2002 * For invalid date input raise the exceptions appropriately 10) Write a program to populate the internal table with the following data and calculate the loss/gain and display the contents of the internal table. Use a function module to calculate the loss or gain by passing the internal table by value to the function module. Airline Carrid LH AI LH UA SQ AI Output: Airline Carrid LH LH SQ AI AI UA Connection Id 0400 0009 0404 0007 0786 0987 Connection Id 0400 0404 0786 0987 0009 0007 Payment sum 10000 3000 7000 1000 2000 1000 Loss/Gain Gain Gain Gain Gain Loss Loss Seats Occupied 10 9 10 10 10 10 Price 900 1000 700 500 100 100

11) Write a program to populate an internal table with the following data: Name Employee1 Employee2 Employee3 Age 30 10 25 Over time in Hours 7 3 15

Exercise 02.04 - Modularizing ABAP programs


Employee4 Employee5 Employee6 Employee7 Employee8 45 15 32 25 32 10 4 8 16 5

Use a function module to calculate the amount considering the pay per hour as 150/-, by accepting the Age and over time. Handle the following exceptions in the function module: a. If employee age is less than 18 Child labor b. If the employee works for more than 10 hours as over-time Over strain Display the contents of the internal table as follows: Name Employee1 Employee2 Employee3 Employee4 Employee5 Employee6 Employee7 Employee8 Age 30 10 25 45 15 32 25 32 Over time 7 3 15 10 4 7 16 5 Amount 1050 1500 Child labor 1200 Over strain 750 Comments Child labor Over strain

You might also like