Tuesday, April 9, 2013

Simple Calculator Program In ABAP

*---Simple Calculator Program In ABAP using parameter passing.--*

REPORT  ZTFIVE.

PARAMETERS:
pa_int1 TYPE i,
pa_op TYPE c Length 1,
pa_int2 TYPE i.

DATA gv_result TYPE p LENGTH 16 DECIMALS 2.

IF ( pa_op = '+' OR
   pa_op = '-' OR
  pa_op = '*').

  CASE pa_op.
    WHEN '+'.
      gv_result = pa_int1 + pa_int2.
    WHEN '-'.
      gv_result = pa_int1 - pa_int2.
    WHEN '*'.
      gv_result = pa_int1 * pa_int2.
  ENDCASE.

  WRITE: 'Result'(res), gv_result.
  ENDIF.


OUTPUT


4 comments:

  1. hi, how should we catch the error in case of division by zero, can anyone help?

    ReplyDelete
  2. to write lost of the programe.

    when others.

    write 'what ever you want write errors'.
    endif.

    ReplyDelete
  3. I'm not getting result box. It just taking inputs plz let me know solution

    ReplyDelete
  4. How to design calculator and to call function module in main program

    ReplyDelete