Q: Can I use 'dynamic column names' in Begin-Select (versions prior to v3.0)?
A: Yes, see following workaround. This SQR report will actually write another SQR code with column names supplied by the user and execute it. Note that in SQR Version 3.0, dynamic columns are directly supported.
---------------------------- Example code begins here ------------------------- begin-report do main end-report begin-procedure main move 'DEPTNO' to $col1 ! You might use INPUT here to prompt the user move 'ENAME' to $col2 ! to enter the column and table names instead. move 'EMP' to $tab move 'sqrout.sqr' to $sqrpgmnam let $syscmd = 'sqr '||$sqrpgmnam||' user/password' move 100 to #flatfileid open $sqrpgmnam as #flatfileid for-writing record=132 write #flatfileid from 'BEGIN-REPORT' write #flatfileid from ' DO MAIN' write #flatfileid from 'END-REPORT' write #flatfileid from 'BEGIN-PROCEDURE MAIN' write #flatfileid from 'BEGIN-SELECT' write #flatfileid from $col1 ' (+1,1)' write #flatfileid from $col2 ' (,30)' write #flatfileid from 'from ' $tab write #flatfileid from 'END-SELECT' write #flatfileid from 'END-PROCEDURE MAIN' close #flatfileid call system using $syscmd #status display 'Status of call is ' noline display #status end-procedure