How to retrieve all the records using CL program?

60 pts.
Tags:
CL Program
How do I retrieve all the records using CL program?
1

Answer Wiki

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

Declare your file

DCLF FILE(YOURLIB/YOURFILE)
You can also assign an Open ID if you have multiple files:
DCLF FILE(YOURLIB/YOURFILE1) OPNID(FILE1)
DCLF FILE(YOURLIB/YOURFILE2) OPNID(FILE2)
Then you read your file using RCVF and monitor for message CPF0864.
If you have just one file without an Open ID:
RCVF
MONMSG CPF0864 EXEC(do something to end…)
or with an Open ID:
RCVF OPNID(FILE1)
MONMSG CPF0864 EXEC(do something to end…)
Personally I like to do a DOWHILE LOOP.
I declare a logical variable called &EOF:
—————————————————
DCL &EOF TYPE(*LGL) VALUE(‘0’)
DOWHILE (*NOT &EOF)
RCVF
MONMSG CPF0864 EXEC(CHGVAR &EOF VALUE(‘1’))
IF (*NOT &EOF) THEN(DO)
/* Process your record here */
ENDDO
/* Program loops back to read the next record */
ENDDO
——————————————————–
Some people just use GOTO:
——————————————————–
READREC:
RCVF
MONMSG CPF0864 EXEC(GOTO NEXTSTEP)
/* Process your record here */
GOTO READREC /* Go get next record */
NEXTSTEP:

Discuss This Question: 5  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.
  • philpl1jb

    retrieve??? I'm not understanding the question.

    What do you want to do with the records?


    54,090 pointsBadges:
    report
  • vishwaraj
    I want to read records one by one of the database file using CL.
    60 pointsBadges:
    report
  • yaazhisai
    Declare your file in your program, RCVF in a loop. Monitor for CPF0864 (EOF) and do what you want with your records.
    260 pointsBadges:
    report
  • ToddN2000
    What do you plan on doing with the records. You can read them all one at a time by using the RCVF command. Doing this in a CL does limit your options as to what you can do easily.
    134,635 pointsBadges:
    report
  • vishwaraj
    https://itknowledgeexchange.techtarget.com/profile/iansimmons/ : thanks a lot..

    60 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.

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

Following

Share this item with your network: