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

Get number multiples

Former Member
0 Likes
1,754

Hi Gurus,

Is there a way to get the multiples for a number? Any FM?

For example:

For number 12, multiples would be: 12, 24, 36, 48, 60, etc.

I have been looking what found nothing.

Hope you can help me.

J. Garibaldi

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,277

Hi!

try something like this



DATA: aux TYPE i,
           num type i.

aux = 2.
num = 0.
DO 10 TIMES.
num = num + aux.
ENDDO.

4 REPLIES 4
Read only

Former Member
0 Likes
1,277

Hi,

It´s impossible. The multiples of a number are infinite.

(may you are talking about the divisors of a number?)

Best regards,

Leandro Mengue

Read only

Former Member
0 Likes
1,278

Hi!

try something like this



DATA: aux TYPE i,
           num type i.

aux = 2.
num = 0.
DO 10 TIMES.
num = num + aux.
ENDDO.

Read only

0 Likes
1,277

Thanks for your replys, but I get a way to confirm if a number is multiple of other one.

First divide this two number (number i want to know if is mutiple / base number). Then check if the result is an integer..if it is, then I can say, the number is multiple of base number 😃

Weird...but my way. 😃

Read only

CorradoScarf1
Discoverer
0 Likes
1,277

Hi,
You can try something like this:

CONSTANTS: lv_base TYPE i VALUE 12.

DATA: lv_number(10) TYPE p DECIMALS 2.
DATA: lv_integer(10) TYPE c,
lv_decimal(2) TYPE c.
DATA: lv_split(16) TYPE c.
CLEAR p_check.
IF p_index NE 0.
lv_number = p_index / lv_base.
MOVE lv_number TO lv_split.
CONDENSE lv_split NO-GAPS.
SPLIT lv_split AT '.' INTO lv_integer lv_decimal.
IF lv_decimal NE '00'.
p_check = abap_true.
ENDIF.
ENDIF.