how to write all the matching records in to antoher file in CL program

85 pts.
Tags:
CL
CLLE
FNDSTRPDM
hi, i am having a pf in that pf contain many members, using display file i have to search a perticular string in all the members if it is found these matching records want to write into another file this is my requirement. in CL grogram how to do this? using FNDSTRPDM can we do that, please replay me if any other solution please send me with example.

Answer Wiki

Thanks. We'll let you know when a new response is added.

Hi,

I don’t think you can do this using CL, I think you’ll need to get into using another programming language for this.

What you can try is using FNDTRPDM to a spooled file, and copy the spooled file to a physical file. But this is going to give you all the formatting that you have in a FNDSTRPDM print.

Regards,

Martin Gilbert.

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • 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
    2,195 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following