‎2013 Feb 01 4:06 PM
Hi,
I have just started ABAP programming.
I am trying to learn by reading some notes got it from my mate.
my first ever code in ABAP is as follows:
REPORT Z95.
parameter: a type i,
b type i.
c=a+b.
data c type i.
WRITE c.
I am getting output as 0
why this programme is not adding up the value?
Please help me to move forward.
Regards,
Kid
Moderator Message: Very basic, removed points and marking as assumed answered.
Message was edited by: Kesavadas Thekkillath
‎2013 Feb 01 4:11 PM
Kid,
SCN is a good place to start.
Do not forget help.sap.com.
About your code, you may want to define the variable C before using it. Sure it runs that way? no syntax error?
‎2013 Feb 01 4:12 PM
Hi ABAP KID ,
Declare C before adding them.
In the space provided blank there. see below.
Regards,
AKS
‎2013 Feb 01 5:03 PM
‎2013 Feb 01 4:12 PM
Kid,
SCN is a good place to start.
Do not forget help.sap.com.
About your code, you may want to define the variable C before using it. Sure it runs that way? no syntax error?
‎2013 Feb 01 4:19 PM
Thanks Phillip & Amit,
Yes I am getting the error:
so should I declare C just below b type i. as c type i. ?
Regards,
Kid
‎2013 Feb 01 4:22 PM
See the screen shot which I have given u .... and declare there itself.
After the parameters.
Regards,
AKS
‎2013 Feb 01 4:27 PM
Hi Amit,
Give proper spacing. Write your code as
c = a + b.
After getting the answer dont forget to close the thread.
Regards
Purnand Dhingra
‎2013 Feb 01 4:45 PM
Hi Purnand ,
I think U have answered to the wrong person.
Regards,
AKS
‎2013 Feb 04 5:44 AM
Hi,
You should declare a variable before using it. Here You have used 'C' before declaring.
Here its giving you zero because when you declare a variable using 'DATA' it is initialized to zero.
Make it a practice to write all your declarations at TOP of the report.
Good Day
‎2013 Feb 04 5:49 AM
Check Tcode: ABAPDOCU aswell for more real time inputs
about programming
‎2013 Feb 04 11:34 AM
Hi,
You should declare a variable before using it.
So correct the code as follows:
parameter: a type i,
b type i.
data c type i.
c = a + b.
WRITE c.
‎2013 Feb 18 12:46 AM
‎2015 Apr 23 10:48 AM
TRY THIS CODE:
ZFIRST_PROG.
DATA: C TYPE I.
PARAMETERS: A TYPE I,
B TYPE I.
*---Enter your Inputs on Selection-screen parameters
*--- A as 10 and B as 20.
*----CALCULATION
C = A + B.
*---Display C variable Data
WRTE: C.