Read the same file twice in a loop

2505 pts.
Tags:
AS/400
RPG Program
RPGLE
I have a scenario like this. FileA has a keyfield MVDT(8A - it has a character field which has date in yyyymmdd). I have an RPG program which accepts start date as parameter. I do a SETLL with the start date and reading the file till eof. Inside the loop, am reading another file which has another date field in it. Now I want to check the main file again with the new date(inside the main loop). If records exists in that file with the new date, I want to skip that record. How can I achieve this without breaking the first loop?

Software/Hardware used:
AS400

Answer Wiki

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

What I read is you have FileA and FileB.

You receive a parm with a date and do a DO loop over fileA.

Inside your loop, you process fileB. For every record in fileB, you need to see if a record with that date is in fileA. If so, do not process the record from fileB.

Your concern is that if you use fileA to check for the existence of the record, you will lose your pointer in the initial DO loop.

Is that correct?

If so, all you need to do is to use a different LF over fileA to do the check for record existence. If through both views of fileA will share the same access path, they will have there own pointers in the PAG for you program.

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.

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
  • TomLiotta
    I want to skip that record.   How do you expect to "skip" a record?   Tom
    125,585 pointsBadges:
    report
  • philpl1jb
    I'm confused ..
    It sound to me like you want to:
    - process all records in fileA
    - from startDate
    - except for those where the date exists in fileB
    
    Is fileB keyed on the date field?
    
    
    51,355 pointsBadges:
    report
  • TomLiotta
    Easiest might just be to use SQL and select WHERE FileADate not = FileBDate ORDER BY FileADate. The purpose of the program should be described rather than describing a portion of a hypothetical algorithm. -- Tom
    125,585 pointsBadges:
    report
  • RamvishakRamesh
    Thanks  Michael Tidmarsh, thats working.
    2,505 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