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

NUMC data type - Sort issue

Former Member
0 Likes
3,306

Hi,

In my internal table I have 1 field with data type NUMC - 5, it gives me a problem while sorting.

For Ex: my internal data is like this

A - Field

11

12

1

3

4

When I sort internal table by the Field A, it gives

1

11

12

3

4

But we expect

1

3

4

11

12

Pls let me know how to solve this and the feild I use is similar to EBELP field in - EKKO table

regards

Prabhu

11 REPLIES 11
Read only

Former Member
0 Likes
2,277

Hi,

I suppose you meant EKPO-EBELP.I dint find any problem with sorting a numc type. Check this sample



data: begin of itab occurs 0,
      f1 type ekpo-ebeln,
      end of itab.
      
      itab-f1 = 11.
      append itab.
      
        itab-f1 = 12.
      append itab.
      
       itab-f1 = 1.
      append itab.
      
       itab-f1 = 3.
      append itab.
      
      sort itab.
      
      loop at itab.
      write:/ itab-f1.
      endloop.

Regards,

Vikranth

Read only

Former Member
0 Likes
2,277

Hi,

This type of issue would arise only if the data type of the field is type C, if you use type EKPO-EBELP, then the record will be appended with 0's in the front, i.e, 11 will be 00011,1 will be 00001 and so on. If you sort the table on this field you will get the correct output. I have tried the same ans is working fine for me.

Regards,

Sachin

Read only

Former Member
0 Likes
2,277

I am getting the sorted output as follows:

1

3

4

11

12

EKKO does not have EBELP. If you use datatype n and length 5 in declaration, you will get output as

00001

00003

00004

00011

00012

I see no problem in sorting. Can you give code sample of what you have written??

Read only

0 Likes
2,277

Hi,

I am using a customized structure where I have declared a customized field whose data element is standard - EBELP and I face this issue.

regards

Prabhu

Read only

0 Likes
2,277

Check this :

DATA: begin of itab occurs 0,
        A TYPE EBELP,
      end of itab.

itab-A = 11.
append itab.

itab-A = 12.
append itab.

itab-A = 1.
append itab.

itab-A = 3.
append itab.

sort itab.

loop at itab.
  write:/ itab-A.
endloop.

Read only

0 Likes
2,277

Hi Prabhu ,

As per my understanding : It can be due to following reason :

Sort condition considering only first character of your field. You should check your code , by mistake you might have used one char somewhere.

Read only

0 Likes
2,277

Post the code you are using. There is nothing worng with the sort on the NUMC type. It must be due to some other error

Read only

Former Member
0 Likes
2,277

Hi,

After filling the data in Internal table (ITAB).

use :

Sort ITAB by Field_name ascending.

Read only

Former Member
0 Likes
2,277

I AM FACING THE SAME ISSUE.

SORTING FOR NUMC FIELD TYPE IS NOT WORKING.

code:-

EBELP TYPE ESSR-EBELP,

EXTROW TYPE ESLL-EXTROW,

SORT INTAB4 BY EBELP EXTROW ASCENDING.

this shows results in :-

10

100

20

30

40

50

kindly advise as to what the problem might be!

Thanks in advance!

Read only

0 Likes
2,277

Hello,

The solution is to use the funcion :

CONVERSION_EXIT_ALPHA_INPUT'


Regards,

Read only

0 Likes
2,277

Hi,

Please use INT2 data type for that field, it resolves the sorting issue 🙂

Regards,

Sai Kalyan