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

Incrementing Counter

Former Member
0 Likes
5,673

Hi All,

I declared gv_count as const.

DATA: gv_count type c value 1,

and in the if stmt, I incremented it

gv_count = gv_count + 1.

It is incrementing gv_count upto 9 properly, but 9 + 1 it is taking as '*' instead of 10.

Can you please help me, why it is happening like this.

Thank you

Veni.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,082

Hi,

In your data declaration, <b>gv_count</b> is of type <b>C</b> and length <b>1</b>. Therefore, after 9, it is not taking 10. So, declare the variable of more length.

<b>DATA : gv_count(3) TYPE C VALUE '1'.</b>

Also, if you want to use it as a counter, why are u declaring it of type C, declare it of type I.

<b>DATA : gv_count TYPE i VALUE '1'.</b>

Reward points if the answeR is helpful.

Regards,

Mukul

4 REPLIES 4
Read only

Former Member
0 Likes
2,082

HI,

-->

DATA: gv_count<b>(5)</b> type c value 1,

( If you don't give a length, the default lenght is one so after '9' the field isn't large enough to pu '10' ! )

But I suggest you to declare like an integer :

DATA: gv_count type <b>i</b> value 1,

Erwan

Read only

Former Member
0 Likes
2,082

Hi,

Because you have a character data type which is of length 1..

Change it to INT4.

<b>DATA: gv_count type INT4.</b>

Thanks,

Naren

Read only

Former Member
0 Likes
2,083

Hi,

In your data declaration, <b>gv_count</b> is of type <b>C</b> and length <b>1</b>. Therefore, after 9, it is not taking 10. So, declare the variable of more length.

<b>DATA : gv_count(3) TYPE C VALUE '1'.</b>

Also, if you want to use it as a counter, why are u declaring it of type C, declare it of type I.

<b>DATA : gv_count TYPE i VALUE '1'.</b>

Reward points if the answeR is helpful.

Regards,

Mukul

Read only

Former Member
0 Likes
2,082

Hi Veni,

Please try to declare like this.

DATA: gv_count type i value 1.

or

DATA: gv_count type n value 1.

Regards,

Ferry Lianto