Another point I noticed in your code is,
IF OPT-FLD1 = SPACES
MOVE LOW-VALUES TO WS-OPT-FID1-FROM
MOVE HIGH-VALUES TO WS-OPT-FID1-TO
MOVE OPT-FLD1 TO WS-OPT-FID1-FROM
why are you using a range of values for an option field OPT-FLD when it contains only one value entered by user?
For example, OPT-FLD1 will have only one value when entered by user, so why did you code moving FLD1 to range fields FROM and TO fields? You can use "=" when you know the value!!!
Since you said you need to use the query in the cursor, to my knowledge the best is using dynamic sql.. check the following example... and the link is http://supportline.microfocus.com/Documentation/books/sx40sp2/spudsc.htm
Fixed-List Select Statements
A fixed-list SELECT statement is a statement that returns a predictable number of data items of a known type from an open cursor. For each of these items, a host variable is required to accommodate incoming data.
To issue a fixed-list SELECT statement dynamically:
(Optional) Test each SQL statement using Interactive SQL to see that proper results are obtained.
Load the SQL statement into a data area.
Use PREPARE to validate the statement and translate it into an executable form.
Use DECLARE to declare a cursor for the statement.
Use OPEN to open the cursor.
Use FETCH to retrieve a row into a fixed list of variables.
When the end of data is reached, use CLOSE to close the cursor.
Be sure to handle any errors.
The following example shows how to execute a fixed-list SELECT statement dynamically.
* include SQLDA copybook
* assign value to variable sqlcmd.
MOVE 'select e_no, lname from employee where dept="1050"' TO sqlcmd.
* prepare SELECT command.
PREPARE q1 FROM :sqlcmd
* declare cursor for SELECT command.
DECLARE c1 CURSOR FOR q1
* open cursor.
* fetch data into program variables EMPNO, LASTNME and FIRSTNME.
FETCH c1 INTO :EMPNO, :LASTNME
* close cursor.
I hope this helps to resolve your problem...