Abap Objects - Exercise 4 - Calcolatrice (local).docx

  • Uploaded by: Dario Calì
  • 0
  • 0
  • May 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Abap Objects - Exercise 4 - Calcolatrice (local).docx as PDF for free.

More details

  • Words: 278
  • Pages: 3
Excercise 4 - Calcolatrice •

Definire un parametro per Operando1 ed un parametro per Operando2



Definire un radiobutton per la selezione della operazione



Implementare con ABAP OOP il calcolo del risultato



Istanziare Operando1 e Operando2, istanziare il risultato



Calcolare il risultato con un metodo e visualizzarlo con un altro metodo

REPORT

Z_CALCOLATRICE.

PARAMETERS: p_op1 TYPE i, p_op2 TYPE i. PARAMETERS: p_1 RADIOBUTTON GROUP g1, "+ p_2 RADIOBUTTON GROUP g1, "p_3 RADIOBUTTON GROUP g1, "* p_4 RADIOBUTTON GROUP g1. "/ *---------------------------------------------------------------------* *

CLASS calcolatrice DEFINITION

*---------------------------------------------------------------------* CLASS calcolatrice DEFINITION. PUBLIC SECTION. METHODS: somma

IMPORTING value(op1) TYPE i value(op2) TYPE i,

sottr

IMPORTING value(op1) TYPE i value(op2) TYPE i,

molt

IMPORTING value(op1) TYPE i value(op2) TYPE i,

div

IMPORTING value(op1) TYPE i value(op2) TYPE i,

result EXPORTING value(va_res) TYPE i. PRIVATE SECTION. DATA va_result TYPE i. ENDCLASS.

"calcolatrice DEFINITION

*---------------------------------------------------------------------* *

CLASS calcolatrice IMPLEMENTATION

*---------------------------------------------------------------------* CLASS calcolatrice IMPLEMENTATION. METHOD somma. va_result = p_op1 + p_op2. ENDMETHOD.

"somma

METHOD sottr. va_result = p_op1 - p_op2. ENDMETHOD.

"sottr

METHOD molt. va_result = p_op1 * p_op2. ENDMETHOD. METHOD div. va_result = p_op1 / p_op2.

"molt

ENDMETHOD.

"div

METHOD result. va_res = va_result. ENDMETHOD. ENDCLASS.

"result "calcolatrice IMPLEMENTATION

START-OF-SELECTION. DATA: Calc type ref to calcolatrice. data: va_result type i.

CREATE OBJECT Calc. IF p_1 EQ 'X'. CALL METHOD calc->somma EXPORTING op1 = p_op1 op2 = p_op2. ELSEIF p_2 EQ 'X'. CALL METHOD calc->sottr EXPORTING op1 = p_op1 op2 = p_op2. ELSEIF p_3 EQ 'X'. CALL METHOD calc->molt EXPORTING op1 = p_op1 op2 = p_op2. ELSEIF p_4 EQ 'X'. CALL METHOD calc->div EXPORTING op1 = p_op1 op2 = p_op2. ENDIF. CALL METHOD calc->result IMPORTING va_res = va_result . WRITE: va_result. END-OF-SELECTION.

Related Documents


More Documents from ""