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

Funtion module for maximum number

Former Member
0 Likes
689

Hi Guys,

I need to pick the maximum number from the database table and increment by 1. I am using select max ..... but it is not picking the maximum number from the database table.

<u><b>s.no</b></u>

0001

0002

0003

0004

5

6

7

Data in the field is like this, we changed the field data type and again we assigned the same data type as before even though we are getting the number like 5,6,7, instead of 0005,0006,0007,....

Please tell me how to solve this problem, as the object has been send to production.

All answers are rewarded.

Regards,

Line

1 ACCEPTED SOLUTION
Read only

JozsefSzikszai
Active Contributor
0 Likes
668

hi Line,

I guess this is a Z... table and the field is C type. In this case change the field to N type (and adjust the table, no concern, it won't be deleted). Now all values will look like (because the initial value of an N type variabnle is '0')

0001

0002

...

0006

0007

and it will give back the value you need.

hope this helps

ec

hi Line,

I guess this is a Z... table and the field is C type. In this case change the field to N type (and adjust the table, no concern, it won't be deleted). Now all values will look like (because the initial value of an N type variabnle is '0')

0001

0002

...

0006

0007

and it will give back the value you need.

hope this helps

ec

5 REPLIES 5
Read only

JozsefSzikszai
Active Contributor
0 Likes
669

hi Line,

I guess this is a Z... table and the field is C type. In this case change the field to N type (and adjust the table, no concern, it won't be deleted). Now all values will look like (because the initial value of an N type variabnle is '0')

0001

0002

...

0006

0007

and it will give back the value you need.

hope this helps

ec

Read only

0 Likes
668

No the datatype of the field is NUMC, But I get the values like this, Can any one help me.

Regards,

Line

Read only

0 Likes
668

can you check the values in SE16? what do you see? Did you click on adjust the table after you changed it (in SE11 database utility)?

Read only

Former Member
0 Likes
668

Suppose a database table TEST, consisting of two columns and 10 lines:

COL_1 COL_2

1 3

2 1

3 5

4 7

5 2

6 3

7 1

8 9

9 4

10 3

The following coding demonstrates the aggregate functions:

DATA RESULT TYPE P DECIMALS 2.

SELECT <agg>( [DISTINCT] COL_2 )

INTO RESULT

FROM TEST.

WRITE RESULT.

The following table shows the results of this program extract according to different combinations of aggregate expressions <agg> and the DISTINCT option.

Aggregate expression

DISTINCT

Result

MAX

no

9.00

MAX

yes

9.00

MIN

no

1.00

MIN

yes

1.00

AVG

no

3.80

AVG

yes

4.43

SUM

no

38.00

SUM

yes

31.00

COUNT

yes

7.00

COUNT( * )

---

10.00

reward points if helpful.........

Read only

Former Member
0 Likes
668

Hi Line,

Please use the FM NUMBER_GET_NEXT. You have to pass the Number range number and the Object which you can find in SNRO.

Regards,