03-03-2008 11:58 AM
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
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
03-03-2008 12:06 PM
try:
PARAMETERS input TYPE i.
DATA output TYPE i.
output = input ** 2.
WRITE : / 'The square of ', input, 'is ', output.
greetings
03-03-2008 12:20 PM
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
03-03-2008 12:09 PM
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
03-03-2008 12:09 PM
Try this link
http://saptechnical.com/Tutorials/Tutorials.htm
it's very good site for new comers.
Just try it once.
03-03-2008 12:18 PM
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.