The problem is that you have a "mixture" of blanks. Leading and embedded blanks, which are significant, and trailing blanks which are not.
If we take just one column, this input:
Needs to give you this output:
AAAA;
AAA;
AA;
A;
;
AAA;
A AA;
There's no short-cut to coding it.
INREC IFTHEN=(WHEN=INIT,
BUILD=(1,4,C';')),
IFTHEN=(WHEN=(1,4,CH,EQ,C' '),
BUILD=(5,1)),
IFTHEN=(WHEN=(2,3,CH,EQ,C' '),
BUILD=(1,1,5,1)),
IFTHEN=(WHEN=(3,2,CH,EQ,C' '),
BUILD=(1,2,5,1)),
IFTHEN=(WHEN=(4,1,CH,EQ,C' '),
BUILD=(1,3,5,1))
So:
INREC IFTHEN=(WHEN=INIT,
BUILD=(1,4,C';',5,2,C';',7,1,C';',8,3)),
Then, starting from the right, you need to apply the above to your data:
* Last field, starts at 11, length of three, not delimiter
IFTHEN=(WHEN=(11,3,CH,EQ,C' '),
BUILD=(1,10),HIT=NEXT),
IFTHEN=(WHEN=(12,2,CH,EQ,C' '),
BUILD=(1,10,11,1),HIT=NEXT),
IFTHEN=(WHEN=(13,1,2,CH,EQ,C' '),
BUILD=(1,10,11,2),HIT=NEXT),
* Third field, starts at nine, length of one, delimiter and required data follow
IFTHEN=(WHEN=(9,1,CH,EQ,C' '),
BUILD=(1,8,10,4),HIT=NEXT),
* Second field, starts at six, length of two, delimiter and required data follow
IFTHEN=(WHEN=(6,2,CH,EQ,C' '),
BUILD=(1,5,8,6),HIT=NEXT),
IFTHEN=(WHEN=(7,1,CH,EQ,C' '),
BUILD=(1,5,6,1,8,6),HIT=NEXT),
* First field, starts at one, length of four, delimiter and required data follow
IFTHEN=(WHEN=(1,4,CH,EQ,C' '),
BUILD=(5,9)),
IFTHEN=(WHEN=(2,3,CH,EQ,C' '),
BUILD=(1,1,5,9)),
IFTHEN=(WHEN=(3,2,CH,EQ,C' '),
BUILD=(1,2,5,9)),
IFTHEN=(WHEN=(4,1,CH,EQ,C' '),
BUILD=(1,3,5,9))
The HIT=NEXT is required when further IFTHEN=(WHEN=(logical expression tests are needed to be carried out on the same record.
That's untested, but should be close.