Application Development and Automation 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: 
Read only

My first ABAP Programme - error

Former Member
0 Likes
3,534

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

13 REPLIES 13
Read only

Phillip_Morgan
Contributor
0 Likes
3,499

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?

Read only

Former Member
0 Likes
3,499

Hi ABAP KID ,

Declare C before adding them.

In the space provided blank there. see below.

Regards,

AKS

Read only

0 Likes
3,499

Thanks Amit and Purnand

I have done it!

Thanks,

Kid

Read only

Phillip_Morgan
Contributor
0 Likes
3,499

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?

Read only

0 Likes
3,499

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

Read only

0 Likes
3,499

See the screen shot which I have given u .... and declare there itself.

After the parameters.

Regards,

AKS

Read only

Former Member
0 Likes
3,499

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

Read only

0 Likes
3,499

Hi Purnand ,

I think U have answered to the wrong person.

Regards,

AKS

Read only

Former Member
0 Likes
3,499

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

Read only

JoffyJohn
Active Contributor
0 Likes
3,499

Check Tcode: ABAPDOCU aswell for more real time inputs

about programming

Read only

Former Member
0 Likes
3,499

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.

Read only

0 Likes
3,499

Thanks to all.

Read only

0 Likes
3,499

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.