Register Login

Calculator using Parameters, ABAP Program

Updated May 18, 2018

REPORT  ycalci_prathyusha                       .
PARAMETERS: pa_val1 TYPE p DECIMALS 4,
            operator,
            pa_val2 TYPE p DECIMALS 4.
DATA: RESULT TYPE P DECIMALS 2,
      ERRORFLAG.
      IF PA_VAL1 IS INITIAL OR
      PA_VAL2 IS INITIAL.
      WRITE: / TEXT-INI.
      ERRORFLAG = 'X'.
      ELSE.
      CASE OPERATOR.
      WHEN '+'.
      RESULT = PA_VAL1 + PA_VAL2.
       WHEN '-'.
      RESULT = PA_VAL1 - PA_VAL2.
       WHEN '*'.
      RESULT = PA_VAL1 * PA_VAL2.
      WHEN '/'.
      IF PA_VAL2 = 0.
      WRITE / TEXT-DBZ.
      ERRORFLAG = 'X'.
      ELSE.
      RESULT = PA_VAL1 / PA_VAL2.
      ENDIF.
      WHEN OTHERS.
      WRITE:/ TEXT-OTH.
      ERRORFLAG = 'X'.
      ENDCASE.
      ENDIF.
      IF ERRORFLAG IS INITIAL.
      WRITE:/ PA_VAL1,  OPERATOR , PA_VAL2 , '=' , RESULT.
      ELSE.
      WRITE: / TEXT-ERR.
      ENDIF.

 

 


Comments

  • 25 Oct 2013 10:40 am Guest
    Wow That was very much useful

×