Former Member

### Recreating ABAP Calculator with F4

I built finally a calculator (yep, still new to ABAP but I'm trying). Now i want to recreate it with "F4"-Button.

The code without looks like this:

```REPORT ZCALC.
PARAMETERS Zahl1 TYPE i.
PARAMETERS Zahl2 TYPE i.

IF plus = 'X'. add Zahl2 to Zahl1.
WRITE : 'Das Ergebnis der Addition lautet: ' , Zahl1.
ENDIF.

IF minus = 'X'. SUBTRACT Zahl2 FROM Zahl1. WRITE : 'Das Ergebnis der Subtraktion lautet: ' , Zahl1.
ENDIF.

IF mal = 'X'. MULTIPLY Zahl2 by Zahl1. WRITE : 'Das Ergebnis der Multiplikation lautet: ' , Zahl1.
ENDIF.

IF durch = 'X'. IF zahl2 = 0. WRITE 'Division durch 0 nicht möglich. Bitte nochmal versuchen!'. ELSE. DIVIDE Zahl1 by Zahl2. WRITE : 'Das Ergebnis der Division lautet: ' , Zahl1. ENDIF.
ENDIF.```

All works like it should (I now, some things are double but I first want it to work).. Even Division with 0 is cleared.

Now I added the new Parameter:

`PARAMETERS auswahl TYPE ZCALC_OPERATOREN.`
I know I have to deactivate the Radiobuttons but I am not sure what comes next.
10|10000 characters needed characters exceeded

• Jan 26, 2018 at 12:18 PM

You could replace the radiobuttons by an input field with a dropdown list of values, fill values with FM RM_SET_VALUES in the PBO (AT SELECTION-SCREEN OUTPUT) attach a function code to this field. In the PAI (AT SELECTION-SCREEN) use a CASE auswahl WHEN '+', etc. ENDCASE syntax.

10|10000 characters needed characters exceeded
• Former Member

Not exactly what I want to do I think.

I create a ned menu where I can enter +, -, *, / and next to that field is the seleciton Box where I could also choose one of those 4 (or that box openes with F4).
This Function works with 'PARAMETERS auswahl TYPE ZCALC_OPERATOREN.' but I want to edit the Code.

Or maybe you said it right but i am not familiar with your shortcuts (Sry if so :D )

• Jan 26, 2018 at 02:35 PM

I have a calculator in different versions in a subpackage of SABAPDEMOS, Check it out.