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

ALV Grid Filter problem

Former Member
0 Likes
2,290

Hi,

I'm having problems filtering columns of type 'CHAR' that contain numbers (for instance aufk-aufnr); initially the filter was not working, that is, I was filtering by an existing value and the result was no rows returned. Then I discovered that in the database there were leading zeroes not shown in the grid, so it made sense why there was no result.

I need to keep the datatype as 'CHAR' in order to allow wildcards in the filter (something like '6001*' as a filter criteria, for instance) and I would be happy even with allowing the leading zeroes to be shown in the grid (ugly, but it would be at least consistent for the user). I tried setting the following properties and it didn't work (I'm using 4.6C):

s_fieldcat-lzero = 'X'. "I know it works only for numeric types, but I tried anyway

s_fieldcat-NO_CONVEXT = 'X'.

Here is the code for that column's definintion:

................................................

CLEAR s_fieldcat.

s_fieldcat-col_pos = l_col_count.

l_col_count = l_col_count + 1.

s_fieldcat-tabname = 'I_PROJECT'.

s_fieldcat-fieldname = 'AUFNR'.

s_fieldcat-datatype = 'CHAR'.

s_fieldcat-outputlen = '12'.

s_fieldcat-seltext_l = 'Internal Order'.

s_fieldcat-seltext_m = 'Internal Order'.

s_fieldcat-seltext_s = 'Internal Order'.

s_fieldcat-just = 'C'.

  • s_fieldcat-lowercase = 'X'.

s_fieldcat-no_zero = ''.

s_fieldcat-lzero = 'X'.

s_fieldcat-NO_CONVEXT = 'X'.

APPEND s_fieldcat TO gt_fieldcat.

.......................

I discovered a half-solution: if we force that field to be numeric (s_fieldcat-inttype = 'N'.), the filter will work for numeric selection, but the wildcards are not allowed.

Anyway, the final question is: is there a way to make it work without forcing the numeric type? Even allowing leading zeroes would be OK.

Thanks,

Dinu

1 ACCEPTED SOLUTION
Read only

Former Member
1,301

Hello Dinu,

I have a field for ekko ebeln on my report output. (this is also char field..has con exit alpha, same as ur field )

while displaying on screen, it is displayed without leading zeroes.

i tried filtering with leading zeroes..without leaidng zeros... with wildcard it is working perfect for all cases...

ie.. filter for 0042000003 and 42000003... got in both cases..

this is all i have for that field.

COL_POS = COL_POS + 1.

GT_FIELDCAT-COL_POS = COL_POS.

GT_FIELDCAT-FIELDNAME = 'EBELN'.

GT_FIELDCAT-TABNAME = P_DETAIL.

GT_FIELDCAT-REF_FIELD = 'EBELN'.

GT_FIELDCAT-REF_TABLE = 'EKKO'.

GT_FIELDCAT-KEY = 'X'.

APPEND GT_FIELDCAT.

CLEAR GT_FIELDCAT.

can u please modify ur fieldcat ? remove all this..

s_fieldcat-datatype = 'CHAR'.

s_fieldcat-no_zero = ''.

s_fieldcat-lzero = 'X'.

s_fieldcat-NO_CONVEXT = 'X'.

2 REPLIES 2
Read only

Former Member
1,302

Hello Dinu,

I have a field for ekko ebeln on my report output. (this is also char field..has con exit alpha, same as ur field )

while displaying on screen, it is displayed without leading zeroes.

i tried filtering with leading zeroes..without leaidng zeros... with wildcard it is working perfect for all cases...

ie.. filter for 0042000003 and 42000003... got in both cases..

this is all i have for that field.

COL_POS = COL_POS + 1.

GT_FIELDCAT-COL_POS = COL_POS.

GT_FIELDCAT-FIELDNAME = 'EBELN'.

GT_FIELDCAT-TABNAME = P_DETAIL.

GT_FIELDCAT-REF_FIELD = 'EBELN'.

GT_FIELDCAT-REF_TABLE = 'EKKO'.

GT_FIELDCAT-KEY = 'X'.

APPEND GT_FIELDCAT.

CLEAR GT_FIELDCAT.

can u please modify ur fieldcat ? remove all this..

s_fieldcat-datatype = 'CHAR'.

s_fieldcat-no_zero = ''.

s_fieldcat-lzero = 'X'.

s_fieldcat-NO_CONVEXT = 'X'.

Read only

0 Likes
1,301

Thanks a lot Sujamol, it works now; the key components that solved the problem were:

GT_FIELDCAT-REF_FIELD = '<fieldname>'.

GT_FIELDCAT-REF_TABLE = '<tablename>'.

Cheers,

Dinu