Amr:
One way to do this is to stack all the responses that CPFMTXA is expecting and then invoke the command. For example, I use this EXEC to define and format a paging volume for a second-level z/VM:
/* */
Parse Arg size
If size = ''
Then size = 100
'CP DETACH 940'
'CP DEFINE T3390 940' size
If RC <> 0
Then Exit RC
user = USERID()
Queue 'YES'
Queue 'PERM 0 0'
Queue 'PAGE 1' (size-1)
Queue 'END'
'EXEC CPFMTXA 940 XAPAGE'
'EXEC CPFMTXA 940 XAPAGE OWNER VMPLEX.'user
Romney White, IBM