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: 

For all entries in itab.....error in length mismatch

ekansh1
Explorer
0 Kudos

image-1.png

In this select query following error is taking place ..." When using the option FOR ALL ENTRIES IN itab the fields username and lt_user_c-slguser must be of same type and same length ......can anyone help me fix this error

11 REPLIES 11

shraddha_mundwadkar
Participant

Hi ekansh,

The length and type of the username and lt_user_c-slguser which you are passing in where clause should be same.

Kindly make slguser type and length same as username if not possible add one column as username in lt_user_c and copy slguser in lt_user_c-username and then pass lt_user_c-username in the where clause.

Thanks,

Shraddha

Sandra_Rossi
Active Contributor

Isn't it clear, what means "the fields username and lt_user_c-slguser must be of same type and same length"?

You must provide same type and same length. Is there any issue to change the type and length of lt_user_c-slguser?

ekansh1
Explorer
0 Kudos

Yes there is an issue ..username belongs to table CDHDR and it's of type char of length 12 and internal table field lt_user_c-slguser is of type char of length 40 ...so it is giving length mismatch error ....I can't change the fields of tables ....is there any way we can rectify this

DominikTylczyn
Active Contributor
0 Kudos

You can rectify this by aligning the types and lengths of both fields as sandra.rossi advised. If you can not change lt_user_c-slguser definition then you may add a new field for user name of length 12 chars to lt_user_c or build a new internal table with user name of 12 chars and use it instead of lt_user_c in the query.

DominikTylczyn
Active Contributor
0 Kudos

sandra.rossi Your comments are as good as answers. You should definitely post them as answers.

Sandra_Rossi
Active Contributor

3a9e4ce873a94034b33dc62b0ce600ee

I don't create an answer if the question is not clear (I ask for complements), or when the question has already been asked and answered many times in the forum.

Sandra_Rossi
Active Contributor

Possible alternatives:

  1. Avoid for all entries, like JOIN, GTT, AMDP or whatever
  2. Copy to an internal table with right length and type
  3. etc.

former_member9115
Participant

Hi,

If

LT_USER_C-SLGUSER has total length > 12 but

first 12 character same as field USERNAME

Try as below in your query

Where username = lt_user_c-slguser+0(12) 

0 Kudos

Could you confirm whether it will be +0(12) or +28(12) where slguser field is of 40 characters?

0 Kudos

IF first 12 characters same as field USERNAME then +0(12) same as else if its last 12 characters then do accordingly means from its value position you have to consider accordingly.

0 Kudos