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: 

Sort Character type in alv Grid

Former Member
0 Kudos

Hi Gurus,

I have a issue of sorting a field in ALV GRID of Type LFA1-LIFNR(Char - 10), which has numbers as well as characters. The requirement is to remove the leading zeroes from the numbers. But when I do so using SHIFT (variable name) LEFT DELETING LEADING ZEROES, the sort order is disrupted in output. Hence following this statement I also included SHIFT (variable name) RIGHT DELETING TRAILING SPACE. But now the filter in ALV GRID does not work for this field. Please find my code below:

SHIFT i_final-vend_num LEFT DELETING LEADING '0'.

SHIFT i_final-vend_num RIGHT DELETING TRAILING space.

Thanks in advance!

5 REPLIES 5

Former Member
0 Kudos

Hi,

Try using the Fm CONVERSION_EXIT_ALPHA_OUTPUT, to suppress leadinf zeros.

Regards,

Surinder

Former Member
0 Kudos

Hi,

Kindly use no_zero parameter in filed catalog. it will omit leading zeros.

ex.

alv_wcat-fieldname = 'MATNR'.

alv_wcat-seltext_m = 'Material Number'.

alv_wcat-no_zero = 'X'

alv_wcat-col_pos = col_pos.

APPEND alv_wcat TO alv_fcat.

CLEAR:alv_wcat.

IF useful ..........

Regards,

S.Senthil kumar

0 Kudos

I have already tried these. The sort order gets disrupted in the ALV output then.

The sort order becomes:

112

113

2

21

3

34

Former Member
0 Kudos

Hi,

Kindly remove all ur shift statements. leave lifnr as its(with leading zeros), then use as i said. Here working fine.

Regards,

senthil kumar.s

0 Kudos

But then the requirement given by client is to remove leading zeroes. And its somehow possible, because there is an SAP transaction FBL1N that has this kind of output for Account(Characters and numbers both), but still the sorting and filtering works correctly.