Application Development 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: 

problem in no genereation in char field

Former Member
0 Kudos

i have used a char field length 10 in my ztable as gate pass no.

also created a module pool which generates gate pass no.

commands used.

select max(gatepass no) from ztable into var.

it select 9 as max however maximum gate pass no currently present in ztable is 10.

also when i sort my ztable in ascending:

it sorts like this:

1

10

2

3

4

5

6

7

8

9.

instead if i use numeric in case of char then gate pass no generates like this 0000000009. after condense statement.

suggest some solution.

1 ACCEPTED SOLUTION

former_member222709
Contributor
0 Kudos

Hi Abhishek,

This is happening because you haven't used any conversion routines while inserting records into your table. What this means is that wherever you are Inserting/updating/modifying your table, you need to use the FM 'CONVERSION_EXIT_ALPHA_INPUT' and then insert records. What happens with this is the number 1 in character is saved as '0000000001' and 10 in character mode is saved as '0000000010'. Now, if your use your select max or sort, then, it will work as you need it.

Hope this helps. For further clarity post the issues.

Regards,

Pranav.

10 REPLIES 10

Former Member
0 Kudos

Hi,

First take data element for the field as KUNNR and try, then also you are not getting then use MAX( [DISTINCT] col )

former_member222709
Contributor
0 Kudos

Hi Abhishek,

This is happening because you haven't used any conversion routines while inserting records into your table. What this means is that wherever you are Inserting/updating/modifying your table, you need to use the FM 'CONVERSION_EXIT_ALPHA_INPUT' and then insert records. What happens with this is the number 1 in character is saved as '0000000001' and 10 in character mode is saved as '0000000010'. Now, if your use your select max or sort, then, it will work as you need it.

Hope this helps. For further clarity post the issues.

Regards,

Pranav.

0 Kudos

problem still not resolved:

its converting char 10 into '0000000010'. but when i insert this into char field of my ztable. and then check entries in ztable.

it is still showing 10 instead of '0000000010'.

therefore the problem still persists as it was before.

on executing select max(gate pass no) it is still fetching max as 9 instead of 10.

suggest soem solution man!

0 Kudos

Hi,

Solution has been provided: use numeric fields in your ztable...

Kr,

Manu.

0 Kudos

Change the type of the field from Char to numeric, it will solve problem

0 Kudos

Dear Abhishek,

You have 2 options,

1. As suggested, you can convert the data type of the field into numeric. If not feasible, then,

2. As suggested earlier about using the Conversion Routine and you still facing the error, I'll explain you by an example. If you refer the Table "VBAK" and field "VBELN", the domain "VBELN" has a conversion routine "ALPHA". If you sort data in "VBAK" or try to the get max., it works as you need.

For further queries, do post.

Regards,

Pranav.

Former Member
0 Kudos

Hi Abhishek,

Please keep conversion routine as ALPHA to the domain attached to the data element of gatepass no field and check once.

Regards,

Arun

Former Member
0 Kudos

Dear abhishek,

convert your field to numc data type.

your problem will be solved without any other alteration.

let me know the status

- avirat

kesavadas_thekkillath
Active Contributor
0 Kudos

As said use a numeric field because you will face such problem like me in future

Former Member
0 Kudos

Hello friend,

Just try to move the z table into a internal table and process it i think it will work bec see my example scenario which i worked and got the output.

data : x_char(10) TYPE c.

data : t_char like TABLE OF x_char.

x_char = 1.

append x_char to t_char.

x_char = 2.

append x_char to t_char.

x_char = 3.

append x_char to t_char.

x_char = 4.

append x_char to t_char.

x_char = 5.

append x_char to t_char.

x_char = 6.

append x_char to t_char.

x_char = 7.

append x_char to t_char.

x_char = 8.

append x_char to t_char.

x_char = 9.

append x_char to t_char.

x_char = 10.

append x_char to t_char.

sort t_char ASCENDING.

Its correctly displaying. Please try this.

Thanks,

Sri Hari