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: 

does not sort table maintanance generator even with EVENTS or PBO

former_member317781
Active Participant
0 Kudos

Hi Good day,

i have created a custom table with 2 fields

ex : number and name

i have created table maintanance generator and i have written logic in PBO for sort but does not work.

COPY_EXTRACT[] = extract[].

SORT COPY_EXTRACT[] BY AFNAM ASCENDING.

EXTRACT[] = COPY_EXTRACT[].

can anyone help me out.

thankyou,

jacob.

1 ACCEPTED SOLUTION

raymond_giuseppi
Active Contributor
0 Kudos

It works, alphabetically C1 < C10 < C2, else use C01 < C02 < C10 ?

(But AFAIK the generated program expect this table to be sorted by key of the view and use many READ BINARY-SEARCH, and your modification should give unpredictable result ?)

Regards,

Raymond

10 REPLIES 10

raymond_giuseppi
Active Contributor
0 Kudos

It works, alphabetically C1 < C10 < C2, else use C01 < C02 < C10 ?

(But AFAIK the generated program expect this table to be sorted by key of the view and use many READ BINARY-SEARCH, and your modification should give unpredictable result ?)

Regards,

Raymond

0 Kudos

it should sort C01< C02 < C03 < C04 etc and not C01 , C10 and C02...

it does not sort likewise

ex : if i capture data

C01

C02

C03

T01

T03

C04

It just takes as it is and does not sort. please have look at screen shot

0 Kudos

I think you're "torturing" that poor generated report, if you want the display by AFNAM, create a maintenance views with AFNAM as first key, and use this view to create the maintenance dialog.

Regards,

Raymond

0 Kudos

Hi,

in your 1st picture you have C1, C10, and C2 which are sorted correct. You need to have C01, C02 and C10 for the sort order you want.

In your 2nd picture you have TP1 and c101, which is also sorted correct, because c101 is lower case. Use C101 to get the right order. C101 and c101 have a different sort value.

But C101 will we sorted between C1 and C2 or C10 and C11. If you need 3 numbers, then use C001, C002, C010, C101 for the right order ...

Regards,

Klaus

0 Kudos

hi Klaus,

Thank you much appriciated for the response,

however i want the sort order to be

C1, then C2,,C3 etc, and that C10 comes after C9

now it sorts in C1,C10,C101.

How can i get that order if want to, your input is highly appreciated.


0 Kudos

thank you for your input.

yes i do agree that it sorts in alphabetical order but the way it displays the data is...

C1, C10 and C101 (is not what i want)

C1, then C2,,C3 etc, and that C10 comes after C9 (this is what i want)

jacob.

0 Kudos

Hi Jacob,

the best way you can do it is to split your alphanumeric number field into two key fields in yout table.

The 1st field should contain the alphanumeric part (one or more characters containing 'C', 'F'. ...) and the other key field of numeric type (length 3 or more).

Then your sort will be automatically correct.

If you need it, you can also add a 4th field containing the original number (for example 'C101') as a non-key field and create a secondary index on it if needed for other applications).

Regards,

Klaus

0 Kudos

Hi Jacob,

best way is to change your table to three or four fields.

Split your alphanumeric number field into 1st field with alphanumeric part of your number (length 1 or more containing 'C' or ''F') for the alphanumeric number part and a second field (length 3 or more) with the numeric part ('001', '002', '010', '100'). Both fields should become key fields.

Keep your name field as 3rd field.

As a 4th field you can add your original alphanumeric number field (for example containing 'C101) and add a secondary index if needed.

So all sort should be done automatically correct in the sort order you want to have.

Regards,

Klaus  

0 Kudos

Or you could try a conversion-exit on the domain of your field, the conversion exits could look like

function conversion_exit_Zxxxx_output.

*"--------------------------------------------------------------------

*"*"Interface locale :

*"  IMPORTING

*"     VALUE(INPUT) TYPE  CLIKE

*"  EXPORTING

*"     VALUE(OUTPUT) TYPE  CLIKE

*"--------------------------------------------------------------------

  output = input.

  call 'CONVERSION_EXIT_ALPHA_OUTPUT' id 'INPUT'  field input+1

                                     id 'OUTPUT' field output+1.

endfunction.

function conversion_exit_Zxxxx_input .

*"--------------------------------------------------------------------

*"*"Interface locale :

*"  IMPORTING

*"     VALUE(INPUT) TYPE  CLIKE

*"  EXPORTING

*"     VALUE(OUTPUT) TYPE  CLIKE

*"--------------------------------------------------------------------

  output = input.

  call function 'CONVERSION_EXIT_ALPHA_INPUT'

    exporting

      input  = input+1

    importing

      output = output+1.

endfunction.

So a value like 'C10' would internally be a 'C0000010' (depending on length of domain) and you could sort it by internal value

Regards,

Raymond

former_member317781
Active Participant
0 Kudos

Thank you for your support and i have managed the business.