
Sloopy |
There is a way to do what you want, using the CPYF (Copy File) command.
CPYF will copy from multiple members in a file, and you can search for a string too. So, to get what you want, use something like this (my test program for this problem) :
PGM
DCL VAR(&CHAR) TYPE(*CHAR) LEN(20)
CRTPF FILE(QTEMP/TEMP1) RCDLEN(200)
MONMSG MSGID(CPF0000)
CHGVAR VAR(&CHAR) VALUE(’Programmer’)
CPYF FROMFILE(TGSMSRCDEV/QCLSRC) +
TOFILE(QTEMP/TEMP1) +
FROMMBR(*ALL) +
MBROPT(*REPLACE) +
FMTOPT(*CVTSRC) +
INCCHAR(*RCD 1 *CT &CHAR)
DSPPFM FILE(TEMP1)
ENDPGM
Notes:
- The scan is case-sensitive; there is nothing you can do about that.
- In the example, I create a TO file. Because it is a different format to the FROM file, and the FROM file is a SOURCE file, I have to use the parameter FMTOPT(*CVTSRC), which ‘converts’ the source data in the FROM file to a string which is placed into the first (or only) field in the TO file.
- If the FROM file and the TO file are both ‘ordinary’ database files, and not SOURCE files, you must use FMTOPT(*NOCHK) if their formats are different.
- If the FROM and TO files have the same format (either the TO file was created using CRTDUPOBJ from the FROM file, or you let CPYF create it by specifying CRTFILE(*YES)), you do not need the FMTOPT parameter.
If the CPYF command is not able to do what you want, you may be able to get somewhere using SQL - but that will be a lot more complicated.
Regards,
Sloopy JB