Two OPNQRYF on same file

2505 pts.
Tags:
AS/400
OPNQRYF
RPG Program
I have a file which has account opened date and account changed date. In my RPG program, I need to extract all those accounts opened today. and do some calculations. Then I need to extract all those accounts that are changed today and status is not 'Cancelled' My file doesn't have either opened date or changed date. so am thinking to use an OPNQRYF to extract the records. The issue is can I use two difference OPNQRYF on the same file? One with account opened date today and another with account changed today and call the RPG program to process them separately. How can I achieve this?

Software/Hardware used:
AS400

Answer Wiki

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

Discuss This Question: 8  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've never seen it done, but I can't think of any reason it shouldn't work. It's not clear yet why OPNQRYF is used at all, nor why the dates aren't both simply added to the OPNQRYF. Why not simply put the dates in the current query? . It would be done with two OPNQRYF files in the same way you do it with one; just add the new commands and the new F-spec, and process the second file like any second file is processed. A RPG program doesn't care nor even know if OPNQRYF is being used. . Personally, I'd dump the OPNQRYF and do it in a more efficient way. It's bad enough doing it with one. Adding a second makes it twice as bad. . Tom
    125,585 pointsBadges:
    report
  • RamvishakRamesh
    I cannot build a logical on the file and dont want to change the type from RPGLE to SQLRPGLE for this.
    2,505 pointsBadges:
    report
  • TomLiotta
    That's your choice. I just wouldn't want to keep giving my employer old technology if I could make improvements. I figure I'm paid to do what's best for the employer, and I want to make myself more valuable. . However, it does take time and effort; and it's not something to do without some experience. But even in that case, I'd make a copy of the program and study how to do it in spare time. . Tom
    125,585 pointsBadges:
    report
  • philpl1jb
    You could use CPYFRMQRYF to create the file(s) in qtemp and then process those...that would allow you to create one opnqryf copy if close it then do the next. then call the rpg program ..
    49,560 pointsBadges:
    report
  • CharlieBrowne
    Another option is to use SQL without changing your program from RPGLE to SQLRPGLE. You can use build your SQL statements and use QCMDEXC to run the RUNSQL command. Or you can have a seperate program that uses SQL to build your file(s) in QTEMP and then you process them with your RPG program.
    41,370 pointsBadges:
    report
  • philpl1jb
    Charlie I like your answer.. either a runsql's or a qmqry. Phil
    49,560 pointsBadges:
    report
  • TomLiotta
    You said both of these statements: "I have a file which has account opened date and account changed date" and "My file doesn't have either opened date or changed date". Can you explain how they can both be true? -- Tom
    125,585 pointsBadges:
    report
  • PGMBOB

    OPNQRYF will be perfect for this. First select todays Added records.

    Your RPG program might need to know if  you want to process the added date.

    Clos the file

    OPNQRYF again to select the changed today with the active status.  

    Your RPG program might need to know now you want to process the changed date.

    Good Luck!

    980 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