DCLF in CL

20 pts.
Tags:
AS/400
RPG
RPG ILE
Hi! Can I open two database files in a CL program using DCLF? I've been trying to do it, but I receive an error related to OPNID. If you could send me an example, it would be greatly appreciated. Thanxs. Melissa

Answer Wiki

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

You may have up to 5 DCLF statements in a CL as display files or database file.

Here is IBM documentation to support this.

The Declare File (DCLF) command declares one file (by name) to a Control Language (CL) program. Up to five DCLF commands are allowed in a CL program or ILE CL procedure. Each DCLF command specifies the name of a display file or database file, the file record formats to be used in the program, and an optional open file identifier which is used to uniquely identify the declared instance of the file within the CL program or ILE CL procedure. Multiple DCLF commands can reference the same file, so long as the value specified for the Open file identifier (OPNID) parameter is unique. Following the DCLF command for a file, the CL program or ILE CL procedure can contain data manipulation commands. For display files, the following commands can be used to send data to a workstation and receive data from a workstation: Send File (SNDF), Receive File (RCVF), Send/Receive File (SNDRCVF), End Receive (ENDRCV), and Wait (WAIT). For database files, the RCVF command can be used to read records from the file.

=====================================================

You can do it if you have V5R3 or later. Before V5R3, the limit is one DCLF per CL module.

Your error message indicates that you possibly have V5R3, but that you aren’t using the DCLF OPNID() parameter properly. Have you prompted DCLF to see what all of the parameters are?

Tom

Discuss This Question: 11  Replies

 
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
  • FrancisLapeyre
    No, you can't. I think you might be able to in the next release, but currently that's not possible. I either accomplish what I want using RPG or call another CL with the second file declared in that one.
    0 pointsBadges:
    report
  • Jrepoley
    This is from the IBM manual: The Declare File (DCLF) command declares one file (by name) to a control language (CL) program. Only one DCLF command is allowed in a CL program.
    0 pointsBadges:
    report
  • Averageprogrammer
    Francis is correct, from what I remember about what is coming for CLP, multiple file support is going to be in the next release. It is long over due. Outfile processing will be much easier then.
    0 pointsBadges:
    report
  • Dushan
    I believe it depends on the version of the OS. You could only declare one file (although multiple formats are allowed) until V5R2. We're still on V5R2, but I gather V5R3 supports multiple file declarations. If you're on V5R2 or below, you could declare your files in multiple CLLE modules and compile them into one program, or better still, write an RPGLE procedure/program. Good luck.
    0 pointsBadges:
    report
  • Brami06
    if you are at V5 you can open up to five files. You need to include the opnid parm in your DCLF statement. Then you need to add the opnid value to the fields you use from each file. dclf file(chgownrfm) rcdfmt(dsp01) opnid(dspf) dclf file(mhb6398/objtbyownr) rcdfmt(qsydsupo) opnid(objf) dclf file(mhb6398/singleprfl) rcdfmt(qsydsupb)opnid(sngl) . . . call pgm(ChgOwnR) parm(&dspf_resn &objf_ooobj &sngl_type)
    0 pointsBadges:
    report
  • FrancisLapeyre
    I just looked it up on IBM's InfoCenter - you have to be at V5R3 to use multiple files: http://publib.boulder.ibm.com/infocenter/iseries/v5r3/index.jsp?topic=/cl/dclf.htm
    0 pointsBadges:
    report
  • McSick
    Thanks for the question. I have been coding CL, COBOL, and RPG on System 3, System 38, AS/400 and iSeries since 1979. My current shop is at V5R3 but I wasn't aware I could use more than one DCLF in CL. Woohoo. More fun!
    50 pointsBadges:
    report
  • Birddon
    The CL improvements that allow access to 5 files have another uniqueness. IBM made the release backwards compatable, so even if you aren't on V5R3 you can apply a PTF for prior releases to update the CL.
    45 pointsBadges:
    report
  • TheQuigs
    What's the PTF? My search of the V5R2 cover letters for anything related to opening more than one file in CL/CLP returns nothing.
    0 pointsBadges:
    report
  • JohnDavid
    Hi, In V5r3 you can process up to 5 files in a CL program. The files are identified by the open id that is a simple name up to 10 characters long used to identify the file. This same name will be used in the corresponding RCVF. The following is a copy from the ITSO power point presentation on this subject: Supports up to five file instances using DCLF Instances can be for the same or different files New OPNID (Open identifier) parameter added to the DCLF statement Default for OPNID is *NONE Only one DCLF allowed with OPNID(*NONE) OPNID accepts 10-character name (*SNAME Hope this helps. Following is a code sample of a CL to demonstrate: DCLF FILE(QGPL/DSPPTF) OPNID(DSPPTF) DCLF FILE(QGPL/DSPUSRPRF) OPNID(USRPRF) PTF: RCVF OPNID(DSPPTF) MONMSG MSGID(CPF0864) EXEC(GOTO CMDLBL(USRPRF)) MONMSG MSGID(CPF0000) GOTO CMDLBL(PTF) USRPRF: RCVF OPNID(USRPRF) MONMSG MSGID(CPF0864) EXEC(GOTO CMDLBL(RETURN)) MONMSG MSGID(CPF0000) GOTO CMDLBL(USRPRF) RETURN: RETURN ENDPGM Best of luck
    5 pointsBadges:
    report
  • TomLiotta
    IBM made the release backwards compatable, so even if you aren’t on V5R3 you can apply a PTF for prior releases to update the CL. The PTFs only allow CL programs on V5R3 (or V5R4) to be compiled back to and run on V5R2. The V5R3 enhancements for structured programming in particular are what are approved for previous release support. The new commands get added to the QSYSV5R2M0 previous-release commands on the V5R3 system in order to convince the compiler that they're okay to include in the source and to compile. V5R4 enhancements such as the new *PTR data type are not approved. Tom
    125,585 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