I never had issues with a string that was too long, not sure what’s going on.
I tried a few casts to String, for example like command = String("R7+WHNC=") + hexMessage
just don't concatenate Arduino Strings (Strings).
At least use .reserve()
Better, avoid Strings at all.
In your example you want to use the buffer for an output to Serial which is a stream.
Use the Streaming.h library and just stream the output.
for example
Serial << "R7+WHNC=" << hexMessage << ",ID=10\r";
Furthermore, also read about the F-Makro and put fix text blocks into the F-Makro.
So your problem is not that part of the program. I suggest that you post the full program. You might be running low on memory without realising it or have a bug elsewhere causing the symptoms that you experience.
If it's 7, then the issue is not with print, but with the concatenation.
(A quick glance at the source says that once you have an invalid String, further calls to concat, either directly or the StringSumHelper, should just fail and not "add", so it's interesting if the result is just the last part.)
Thank you everybody for the replies and your help. I finally had some time to test your solutions. The problem seemed to be that I was low on memory like @sterretje suggested.
I removed a couple of extra functions/instructions, and it works fine