Monday, April 14, 2014

ABAP - Case Statement



  REPORT  ZMYSAPLIBRARY.

parameters :  x type i,
              y type i,
              ch type i.

data z type i.

case ch.
  when 1.
    z = x + y.      write :/ 'Sum is ',z.
  when 2.
    z = x - y.      write :/ 'Difference is ',z.
  when 3.
    z = x * y.
    write :/ 'Product is ',z.
  when 4.
    z = x / y.      write :/ 'Division is ',z.
  when others.
    write :/ 'Invalid choice, please enter 1,2,3,4'.
endcase.

No comments:

Post a Comment