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 values and Padding zeros

Former Member
0 Likes
2,297

Hi Experts!,

<b> I want to increment the numbers by padding zeros on the left. for example 00000001, 00000002,...... 00000010 with max of 8 digits, could any one answer me with the correct answer. Helpful answers will be rewarded.

Thanks and regards,

Sunil</b>

8 REPLIES 8
Read only

former_member386202
Active Contributor
0 Likes
1,295

Hi,

First declare that variable as type Currency, it will work

Regards,

Prashant

Read only

0 Likes
1,295

Hi,

Thanks for your reply, could you pass the codes to me, that will be more helpful for me.

regards,

Sunil

sapsuni@gmail.com

Read only

former_member404244
Active Contributor
0 Likes
1,295

Hi,

Use conversion_exit_alpha_input to pad the zero's.

so first increment the number and then call this FM..u work will be done

Reagrds,

Nagaraj

Read only

balbino_soaresferreirafil
Active Participant
0 Likes
1,295

data: NUMBER(8) VALUE 0, "Original number without zeros

NUMBER2(8). "numbers with zeros

*Incrementing value.

NUMBER = NUMBER + 1.

*Padding zeros

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

input = NUMBER

IMPORTING

OUTPUT = NUMBER2.

WRITE: / 'Number 1 ', NUMBER,

'Number 2 ', NUMBER2.

Read only

Former Member
0 Likes
1,295

REPORT ZTEST_USERCOMMAND .

*data: count type c,

  • count1 type c.

data: NUMBER(8) VALUE 0, "Original number without zeros

NUMBER2(8). "numbers with zeros

do 10 times.

number = number + 1.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

INPUT = NUMBER

IMPORTING

OUTPUT = NUMBER2.

write:/ number2.

it is workin iam checked

Read only

Former Member
0 Likes
1,295

Hi Experts!,

Thanks for the reply, by your codes I am able to generate the output as 0000001 and 000000005. so on.. but when I m storing it in Z-TABLE. Its not at all incrementing, so could any one tel how to do it, I have used

CALL FUNCTION 'NUMBER_GET_NEXT'

EXPORTING

nr_range_nr = lc_number_range

object = lc_cond_object

IMPORTING

number = c_knumv.

but its generating numbers without zeros, so could please elaborate your answers so that I can solve the issue.

regards,

Sunil

Read only

0 Likes
1,295

Hi sunil,

Try to change in abap dictionary SE11, the data type to "NUMC" size 8

Regards

Balbino

Read only

Former Member
0 Likes
1,295

hi sunil,

change the Domain of ur field to "NUMC"...

maybe it's solve ur problem

Regards

Allan Cristian