OPNQRYF and CPYFRMQRYF

15 pts.
Tags:
AS/400
CL Program
CPYFRMQRYF
OPNQRYF
I am writing a CL program in which I do OPNQRY file based on status field in the file. After this data selection, an RPG program is called which processes the data and changes the status to next status. After the execution of this I call another CL program. In this CL program, I want to copy query file to a temporary file. After positioning the pointer to starting of file using POSDBF, I do CPYFRMQRYF but it does not copy any records. However, if in data selection in first CL program, if I give order numbers instead of status, the logic work fine. Can anyone please advise what am I missing here.

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.

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.
  • CharlieBrowne
    We would need to see the all the code to assist you with this. Otherwise we are just guessing and that may not help you.
    62,340 pointsBadges:
    report
  • pdraebel
    Your Query selection is based on status, a field that you update in the RPG. The Copy Query in the second CL based on the original status is empty due to the RPG update.
    7,545 pointsBadges:
    report
  • ToddN2000
    pdraebel's answer sounds like it may be the reason. We would need to see your code to be sure there is nothing else going on like Charlie said.
    107,875 pointsBadges:
    report
  • philpl1jb

    I haven't used OpnQryf in a very long time. 

    I would use that command if I have an existing RPG program and wanted to provide it a special subset of the data but if I were writing this entire process, that command wouldn't be high on my list.

    If there is a logical based on the status field .. I would access the data that way, if there weren't, I would consider an access through SQL.


    54,090 pointsBadges:
    report
  • abhinavpassi
    Thank you all. Apparently the problem was that the data selection criteria does not find any data as it has already been updated. It seems that my understanding of OPNQRYF was not correct and I assumed that a data set has been selected and will be copied. However, I think the command works on access path logic and the access path has no data when I try to copy in CL program.

    Thank you all for providing your valuable suggestions.
    15 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: