This example shows how to print records based on selection using the Open Query File (OPNQRYF) and Copy from Query File (CPYFRMQRYF) commands.
OPNQRYF FILE(FILEA) QRYSLT('CITY *EQ "CHICAGO"') CPYFRMQRYF FROMOPNID(FILEA) TOFILE(*PRINT)