INVCURSTA

The state of the cursor (such as OPENed, CLOSEd) is not valid for the current operation.

Resolution:

Make sure you've executed the necessary steps before calling this function.