Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

My first ABAP program

Former Member
0 Kudos

Dear Sirs,

I am trying to learn ABAP, working with documentation on help.sap.com and also refering to this group.

I am attempting to write a program that calculates squares of numbers. It is not working. Can you give me some pointers?

ABAP Code::

  • Calculate Squares of numbers *

data output type i.

Write 'Calculate Square? (Y/N)'.

parameter : square type c.

While square = 'y' or square = 'Y'.

parameters : input type i.

output = input * input.

Write : 'The square of ', input, 'is ', output.

parameter : square.

EndWhile.

End ABAP Code.

Regards,

Al Lal

www.olap.wetpaint.com

p.s. I have already ordered a ABAP book costing USD 120, so you can rest assured that I am trying other sources before imposing questions to this forum

5 REPLIES 5

andreas_mann3
Active Contributor
0 Kudos

try:

PARAMETERS input TYPE i.

DATA output TYPE i.

output = input ** 2.

WRITE : / 'The square of ', input, 'is ', output.

greetings

0 Kudos

Thanks for your quick reply. I am able to calculate the square of a single number. What I would like the program to do is to keep calculating as many squares as the user wants. The parameter statement is giving error, and is not working as I hoped.

Al Lal

www.olap.wetpaint.com

Former Member
0 Kudos

Hi Abhinav,

This is the piece of code to calculate the square of a number.

Report square.

parameters : square type c.

data output type i.

start-of-selection.

output = square * square.

Write : 'The square of ', square, 'is ' output.

Regards,

Charumathi.B

Former Member
0 Kudos

Try this link

http://saptechnical.com/Tutorials/Tutorials.htm

it's very good site for new comers.

Just try it once.

vinod_vemuru2
Active Contributor
0 Kudos

Hi,

Try this.

PARAMETERS: po_num TYPE p DECIMALS 2.

DATA w_square TYPE p DECIMALS 2.

w_square = po_num * po_num.

WRITE: 'The square of the number', po_num, 'is', w_square.

Thanks,

Vinod.