Setting lower limits In CL

1780 pts.
Tags:
CL
CL Commands
RPG
SETLL
I know how to declare a file and read through the data in CL....but how can you reset it? Like setll in CL. I have searched and searched but nothing works. I have closed opend...etc.. Any ideas? Example: PGM DCLF FILEA Loop: RCVF FILEA If %EOF ne '0' DO Goto Loop: Enddo. Now I want to read through it again for something else here... ???????? ENDPGM

Answer Wiki

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

Hi,

Have you tried POSDBF?

Regards,

Martin Gilbert.

Yes I have. That does not work either. Its like once its at end of file there is no way to reset it.

Thanks
Ron

There is another suggestion as per one of the forums. Try this and see.

1. Use the Number of current records (NBRCURRCD) parameter of the Retrieve Member Description (RTVMBRDR) command to determine the number of active records in the member.

2. Override the database file to SHARE(*YES). This establishes an open data path (ODP) and allows the Position Database File (POSDBF) command to function properly.

3. Use the Open Database File (OPNDBF) to establish a file ID link that can be referenced by POSDBF.

4. Count the records as you process them.
5. When the record counter matches the number of active records, you have processed the last record. Use the POSDBF command to reset the file pointer to the first record.

Be aware that this technique won’t work correctly if other jobs are adding records to the file, or deleting records from the file, at the same time

Regards,

Discuss This Question: 4  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.
  • graybeard52
    Another workaround that works in some cases is to declare a second file and point it to the same file. Since you can only declare 5 files in CL, this works for up to 5 reads. For more than 5 reads, you probably will want to re-write the applicaton using either RPG or another way . CL is not really designed for reading files.
    3,115 pointsBadges:
    report
  • anandx
    CLLE cannot open a dbf more than once within a single pgm, that's a constraint. Once the file pointer hits eof, the file is dead, period, no more re-positioning, no more reopening. Beside the two workarounds suggested earlier, a third options wd be: Create two separate CLLE pgms. 
    Let the called do the opening dbf and re-positioning.the file pointer. Caller can supply the *key to the called to instruct where to start (if dbf is *keyed) using ovrdbf's position KW and let ODP be NOT *shared. Caller, as an option, can have a dspf and get different key values each time prior to calling the called. This way dbf can be opened and read unlimited number of times and each time start positioning can be different. 
    As graybeard rightly said, CL's line of business is focused on jobs, objects, messages, queues, devices and such and not at dbf record levels, though, I agree, attempts such as these are good to have as they highlight/bring out the maxim where not to use CL.
    435 pointsBadges:
    report
  • ToddN2000
    CL / CLLE programs are not designed for handling indexing. Without knowing the function of the program and why the need to go back through the processing of data a second time, why not just move that logic to the RPG/ILE level? Then if you need to create separate spool files it's much easier to do at this level of code.
    89,455 pointsBadges:
    report
  • Splat
    Using OPNQRYF might work, using one OPNID for the first pass, and another OPNID for the second.
    11,455 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: