My bet is you have a test file that either has LF at the end of each segment or you are on Windows and Microsoft is trying to be your friend.
Certainly you can do this in Tcl but, as Jim said, if you are using an Xlate for this route why do it in Tcl?
Tcl
run {
# Message handle
keylget args MSGID mh
# Get msg and split into a list of segs
set msg [msgget $mh]
set segList [split $msg r]
# Get field and subfield separator characters
set fldSep [string index $msg 3]
set subSep [string index $msg 4]
# Location of PID
set pidLoc [lsearch -regexp $segList {^PID}]
# get and split PID into fields
set PID [split [lindex $segList $pidLoc] $fldSep]
# Get and split field 5
set fld5 [split [lindex $PID 5] $subSep]
# Get just first subfield
set first [lindex $fld5 0]
# Replace field 5 with just first subfield
set PID [lreplace $PID 5 5 $first]
# Join PID and put back in segment list
set segList [lreplace $segList $pidLoc $pidLoc [join $PID $fldSep]]
# New message
msgset $mh [join $segList r]
# send it on
return “{CONTINUE $mh}”
}