0% found this document useful (0 votes)
20 views

Ex 4 Local Data and Control Statements

This document contains exercises on local data and control statements in ABAP: 1. It asks the reader to identify errors in sample data definitions and explains a program that outputs the values of a structure before and after it is changed. 2. It provides instructions to create a program that selects airline data based on a carrier code parameter, with the parameter default set to "SQ". 3. It asks the reader to create a basic calculator program that takes two integer values and an operator as selection screen parameters, uses a CASE statement to perform the math operation, and outputs the result to two decimals, with an error message for invalid operators.

Uploaded by

vinh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

Ex 4 Local Data and Control Statements

This document contains exercises on local data and control statements in ABAP: 1. It asks the reader to identify errors in sample data definitions and explains a program that outputs the values of a structure before and after it is changed. 2. It provides instructions to create a program that selects airline data based on a carrier code parameter, with the parameter default set to "SQ". 3. It asks the reader to create a basic calculator program that takes two integer values and an operator as selection screen parameters, uses a CASE statement to perform the math operation, and outputs the result to two decimals, with an error message for invalid operators.

Uploaded by

vinh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Exercise 4: Local Data and Control Statements

1.
What is wrong with the following data definitions? (There can be more than
one error in each, and some do not have errors.) Write the correct definitions.
a.

data first-name(5) type c.

b.

data a1 type character.

c.

data a1 (20) type c.

d.

data 1b(5) type i.

Consider the program below. What is the output of this program?


report yxx33.

Use your student identifier in place of xx


if you are going to test this program

data: begin of fs1,


b1 value D,
b2 value E,
b3 value F,
end of fs1.
write: / fs1-b1, fs1-b2, fs1-b3,
/ fs1.
fs1 = XYZ.
write: / fs1-b1, fs1-b2, fs1-b3,
/ fs1.
2.

Write a program named yxx401 where xx is your assigned identifier (e.g.


A003). Your program should perform the following:
Create a list containing data from the table spfli for a selected airline.
The airline carrier code should be entered as a parameter on a selection
screen. Set the parameter attributes by using a like clause in the
parameters statement, linking the parameter to an appropriate table field.
Also set the default value of the parameter to SQ.
After using the like clause in the parameters statement, you can change your parameters label which will appear on the
selection screen, to one associated with the table field defined in the Data Dictionary by:
First ACTIVATE your program by pressing the Activate Button

on the Application Toolbar or Ctrl-F3.

In ABAP editor, choose the menu path: Goto >> Text elements >> Selection texts.
SAP UA Conference Hong Kong 3-7th July 2012

Page

Your parameter should be listed in the Selection texts table.


Press the Change button
on the Application Toolbar.
To assign a label from a table field in the Data Dictionary, check the Dictionary ref. Checkbox

Activate this change press the Activate Button


Go back to your program.

on the Application Toolbar or Ctrl-F3.

The output list should include the fields:


airline carrier
flight connection code
departure city
destination city
3.

Create a calculator to handle the four basic operations and two integer values.
Both values and the operator ( +, -, *, / ) are to be entered as parameters on a
selection screen. This can be achieved with the following code:
parameters : value1 type i,
operator,
value2 type i.
Output the result with two decimal places.
The case statement should be used to test the operator. If the operator is
invalid, display an error message.

SAP UA Conference Hong Kong 3-7th July 2012

Page

You might also like