Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

SAP - ABAP: I need to rework the following program to abide by the following rules. Rewrite the program so that the appropriate actual parameters

SAP - ABAP:

I need to rework the following program to abide by the following rules.

Rewrite the program so that the appropriate actual parameters are passed to subroutines within which the mathematical calculations take place. No write statements are allowed inside your subroutines. After being rewritten, it should look and function exactly the same as the original from the user's perspective.

*-------------- parameters -------------------------------------------*

PARAMETERS par_num1(2) TYPE p. PARAMETERS par_num2(2) TYPE p. PARAMETERS par_code(1) TYPE c.

*-------------- variables --------------------------------------------*

DATA calc_result(6) TYPE p decimals 2.

*-------------- constants --------------------------------------------*

CONSTANTS con_num1(12) TYPE c VALUE 'Number One: '. CONSTANTS con_num2(12) TYPE c VALUE 'Number Two: '.

CONSTANTS con_result(8) TYPE c VALUE 'Result: '.

CONSTANTS con_add(1) TYPE c VALUE 'A'. CONSTANTS con_sub(1) TYPE c VALUE 'S'. CONSTANTS con_mult(1) TYPE c VALUE 'M'. CONSTANTS con_div(1) TYPE c VALUE 'D'.

CONSTANTS con_error(17) TYPE c VALUE 'Invalid Operation'.

* ------------- main program -----------------------------------------*

* performing the calculation using a case

CASE par_code.

* perform the add

WHEN con_add. COMPUTE calc_result = par_num1 + par_num2.

FORMAT COLOR 1 INVERSE.

WRITE: /, con_num1, par_num1. WRITE: /, con_num2, par_num2. WRITE: /, con_result, calc_result.

FORMAT COLOR OFF INVERSE OFF.

* perform the subtract

WHEN con_sub. COMPUTE calc_result = par_num1 - par_num2.

FORMAT COLOR 2 INVERSE.

WRITE: /, con_num1, par_num1. WRITE: /, con_num2, par_num2. WRITE: /, con_result, calc_result.

FORMAT COLOR OFF INVERSE OFF.

* perform the multiply

WHEN con_mult. COMPUTE calc_result = par_num1 * par_num2. FORMAT COLOR 3 INVERSE.

WRITE: /, con_num1, par_num1. WRITE: /, con_num2, par_num2. WRITE: /, con_result, calc_result.

FORMAT COLOR OFF INVERSE OFF.

* perform the divide

WHEN con_div. COMPUTE calc_result = par_num1 / par_num2.

FORMAT COLOR 4 INVERSE.

WRITE: /, con_num1, par_num1. WRITE: /, con_num2, par_num2. WRITE: /, con_result, calc_result.

FORMAT COLOR OFF INVERSE OFF.

* invalid operation code

WHEN OTHERS. WRITE / con_error. FORMAT COLOR 5 INVERSE.

WRITE: /, con_num1, par_num1. WRITE: /, con_num2, par_num2. WRITE: /, con_result, calc_result.

FORMAT COLOR OFF INVERSE OFF.

ENDCASE.

* end of program

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Hands-On Database

Authors: Steve Conger

2nd Edition

0133024415, 978-0133024418

Students also viewed these Databases questions

Question

LO6 List the components of job descriptions.

Answered: 1 week ago

Question

LO3 Define job design and identify common approaches to job design.

Answered: 1 week ago