problem with awk for file split

Hi all,

i have a .ksh script which is, among other stuff, splitting a file and saveing the filenames into variables for further processing:

# file split before ftp and put result filenames into variables
if [[ ${_ftpfile} = @(ORD*) || ${_ftpfile} = @(SHP*) ]]; then
awk '{close(f);f=$1}{sub("^[A-Z][A-Z][A-Z]","");print > f".TXT"}' $_ftpfile
set B*.TXT
i=1
c=$#
x=$((c+1))
echo "$x"
while [[ $x -gt $i ]] ; do
eval _ftpfile$i="$"$i
i=$((i+1))
done
backup_files
fi

My problem now is, that the file format has changed means first there was a prefix per line and an ID followed by a space:

B1234 XXYYZZ ...
B4567 XXYYZZ ...

That worked perfekt, and the file split automatically generated a filename B1234.txt, B5678.txt etc. Now the space is gone, and when I do the file split, the filename is B1234XXYYZZ.txt, which is not good. I have now tried to add [0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9] in the sub, but for some reason that does not really work.

Can anyone help?