‎2014 Jun 27 7:06 AM
Hi,
I want to create simple arithmatic operation program, in that I want to use radiobutton for selection of type of arithmatic( addition or subtraction etc) and display output. This output is concerned about the selection of radioutton. please anyone give me idea about this.
‎2014 Jun 27 7:30 AM
PARAMETERS: A TYPE I,
B TYPE I.
DATA: C TYPE I.
PARAMETERS: R1 RADIOBUTTON GROUP RB,
R2 RADIOBUTTON GROUP RB,
R3 RADIOBUTTON GROUP RB,
R4 RADIOBUTTON GROUP RB.
FORM CALCULATE.
IF R1 = 'X'.
C = A + B.
ELSEIF R2 = 'X'.
C = A - B.
ELSEIF R3 = 'X'.
C = A * B.
ELSEIF R4 = 'X'.
C = A / B.
ENDIF.
WRITE: C.
ENDFORM.
START-OF-SELECTION.
PERFORM CALCULATE.
Regards,
Philip.
‎2014 Jun 27 7:10 AM
Hello Khamkar,
For each PAI processing, check which of the four object (Add, Subtract, Multiply, Divide) is not intial. After that include the corresponding logic.
Eg:
if add = 'X'.
......
if sub = 'X'.
.....
etc...
Hope it helps!!!
Regards,
Deepak Mohan
‎2014 Jun 27 7:16 AM
I prefer this Simple GUI Calculator using ABAP using pushbuttons for numbers and operators.
Regards,
Raymond
‎2014 Jun 27 7:20 AM
Hi,
Group all radio buttons and assign a Function code, which will help you to trigger the code while choosing each radio button.
‎2014 Jun 27 7:30 AM
PARAMETERS: A TYPE I,
B TYPE I.
DATA: C TYPE I.
PARAMETERS: R1 RADIOBUTTON GROUP RB,
R2 RADIOBUTTON GROUP RB,
R3 RADIOBUTTON GROUP RB,
R4 RADIOBUTTON GROUP RB.
FORM CALCULATE.
IF R1 = 'X'.
C = A + B.
ELSEIF R2 = 'X'.
C = A - B.
ELSEIF R3 = 'X'.
C = A * B.
ELSEIF R4 = 'X'.
C = A / B.
ENDIF.
WRITE: C.
ENDFORM.
START-OF-SELECTION.
PERFORM CALCULATE.
Regards,
Philip.
‎2014 Jun 27 1:17 PM
‎2014 Jun 27 7:44 AM
Hi khamkar,
This code may be help you,
parameters: a(10) type i ,
b(10) type i .
data: c type int4.
parameters : Plus radiobutton group rad1,
Minus radiobutton group rad1 default 'X',
Multi radiobutton group rad1,
Other radiobutton group rad1.
if plus = 'X' or Other = 'X'.
c = a + b.
write:/ c.
if sy-subrc <> 0.
* Implement suitable error handling here
endif.
elseif
Minus = 'X' or Other = 'X'.
c = a - b.
write:/ c.
if sy-subrc <> 0.
* Implement suitable error handling here
endif.
elseif
Multi = 'X' or Other = 'X'.
c = a * b.
write:/ c.
if sy-subrc <> 0.
* Implement suitable error handling here
endif.
endif.
Thanks and Regards
Niraj Sinha
‎2014 Jun 27 7:46 AM
Hi,
this is an example (sum and subtract) that you could extend
DATA W_NUM TYPE I.
SELECTION-SCREEN BEGIN OF BLOCK BL1 WITH FRAME TITLE TEXT-001.
PARAMETERS: P_NUM1 TYPE I OBLIGATORY,
P_NUM2 TYPE I OBLIGATORY.
SELECTION-SCREEN SKIP.
PARAMETERS : P_ADD RADIOBUTTON GROUP GR1, "sum
P_SUB RADIOBUTTON GROUP GR1. "subtract
SELECTION-SCREEN END OF BLOCK BL1.
START-OF-SELECTION.
CLEAR W_NUM.
PERFORM CALCULATE USING P_NUM1 P_NUM2.
WRITE W_NUM.
*&---------------------------------------------------------------------*
*& Form CALCULATE
*&---------------------------------------------------------------------*
FORM CALCULATE USING PR_NUM1
PR_NUM2.
IF P_ADD EQ ABAP_ON.
COMPUTE W_NUM = PR_NUM1 + PR_NUM2.
ENDIF.
IF P_SUB EQ ABAP_ON.
COMPUTE W_NUM = PR_NUM1 - PR_NUM2.
ENDIF.
*others operation
ENDFORM. " CALCULATE
Regards
Ivan
‎2014 Jun 27 7:50 AM
There are too many examples available related to radio buttons. A little bit of research on your own will help you to learn as well