As to why, I suggest that you read Help! In this case you can add a space after ALI.
>Dear Experts
>
>Please check this
>
>
> A=STRTRAN('KHALID','ALI','123 ')
> MESSAGEBOX(A)
>
>
>it replace ALI as
>
>KH123D
>
>I do not need it, it must search word ALI as whole word as
>
>NASIR ALI
>
>In above case it must replace ALI with 123
>
>Why it is picking up word ALI from a complete string KHALID
>
>What other function should I use?
>
>Please help