08-24-2022 8:31 AM
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
08-24-2022 9:02 AM
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
08-24-2022 10:31 AM
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?
08-24-2022 11:26 AM
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
08-24-2022 12:23 PM
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.
08-24-2022 12:23 PM
sandra.rossi Your comments are as good as answers. You should definitely post them as answers.
08-24-2022 12:31 PM
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.08-24-2022 12:34 PM
Possible alternatives:
08-24-2022 1:24 PM
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)
08-24-2022 9:06 PM
Could you confirm whether it will be +0(12) or +28(12) where slguser field is of 40 characters?
08-25-2022 7:18 AM
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.
08-25-2022 8:40 AM
ABAP documentation: Offset/Length Specifications for Substring Access