This example shows how to create a copy of the output of a dynamic join using the Open Query File (OPNQRYF) and Copy from Query File (CPYFRMQRYF) commands.
FILEA FILEB JOINAB Cust Cust Cust Name Amt Name Addr AmtThe join field is Cust, which exists in both files. To join the files and save a copy of the results in a new physical file MYLIB/FILEC, you can specify:
OPNQRYF FILE(FILEA FILEB) FORMAT(JOINAB) + JFLD((FILEA/CUST FILEB/CUST)) + MAPFLD((CUST 'FILEA/CUST')) OPNID(QRYFILE) CPYFRMQRYF FROMOPNID(QRYFILE) TOFILE(MYLIB/FILEC) CRTFILE(*YES)
The file MYLIB/FILEC will be created by the CPYFRMQRYF command. The file will have file attributes like those of FILEA although some file attributes might be changed. The format of the file will be like JOINAB. The file will contain the data from the join of FILEA and FILEB using the Cust field. File FILEC in library MYLIB can be processed like any other physical file with control language (CL) commands, such as the Display Physical File Member (DSPPFM) command and utilities, such as Query.