CPYF command

40 pts.
Tags:
AS/400
AS/400 commands
CPYF
I'm running multiple jobs one by one. each job is writing data into one particular(A) file. Next doing coping the data into B from A And data is cleared from A file One job Again same is repeating couple of times each job. Finally I want to copy the data from B to A all the records. The order of B record will copy the way which initial copy from A to B. or how it is? How we can keep same order which is already there in B? Please suggest.

Software/Hardware used:
AS/400

Answer Wiki

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

IF order is important to you, I suggest you use SQL instead of DDS to create your table(file).

Then you can use the IDENTITY keyword and have a sequence number put in the file automatically as records are added. This is also very useful when you have multiple records with the same key and you need to get to a specific record..

Discuss This Question: 7  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

    The order will be the same if the copy operations are the same. What does the order have to do with anything? The order of records in a file should have no meaning. However, the order of various indexes over a file is very meaningful.

    A big problem with "order of records" is that it cannot be guaranteed. Simple and easy programming can change the order of records without any indication that it has been done. If the order has meaning, then the meaning would be changed without anyone knowing.

    Note that if the from-file is a keyed LF, then the copy order can not be guaranteed to be the order of records. For a PF, you can generally use the FROMRCD(1) parameter value to force copy by record number.

    Tom

    125,585 pointsBadges:
    report
  • gaganas

    Hy Questions is that,

    If policy has change the status from 42 to 45, then we are writting record in A file, Same policy mode changed, again  writting another record. etc.

    Finally we are copiying A to B, After completion of each job, data copy is doing & clear data from A. Finally B is having all the records. Now While reading those records in program  mode change record is coming first, status record is coming second, its causign the error.

    Please suggest its very urgent.............................

     

    40 pointsBadges:
    report
  • TomLiotta

    The best suggestion is to change the file structure so that the order of the records doesn't matter. The application shouldn't care what the order is of the records in the file is. It should rely on the order of keys and the keys would control the order.

    But you don't actually want the best suggestion. And so far it doesn't seem that you actually have problem.

    There is no reason yet to think that your CPYF is doing anything to the order. If there is no problem, there is no suggestion for a way to fix it.

    Why do you think there is any problem?

    Tom

    125,585 pointsBadges:
    report
  • gaganas

    Now entire applciation is writting the data into A.  I cann't change the strcture of the file. If i change that file, entire application in trouble

     

     

    40 pointsBadges:
    report
  • TomLiotta

    That's understood. What isn't understood is why you think there is any problem. So far you have only asked us if a problem might happen.

    You haven't shown us any code and you haven't shown us any file definitions. We can't guess if there will be a problem. We can only say that there will be a problem if you do it wrong.

    We don't know the right way to do it unless we know all of the definitions and all the processing requirements. You have to give us a lot more detail, or you need to write it and try it. Ans after you try it, show us any results that are wrong and we can help find a solution.

    Tom

    125,585 pointsBadges:
    report
  • ToddN2000
    If either of your files are defined with keys, then I do not see a way to  be 100% sure you maintain the RRN sequence copying the accumulative data in file B back into file A. What is the reason for maintaining this order? Could you create another logical to put the records in the desired sequence?
    8,925 pointsBadges:
    report
  • TomLiotta

    The FROMRCD(1) parameter can be used to force copying in arrival sequence regardless of keys, as long as the files are not keyed LFs. But the whole idea of maintaining arrival sequence through multiple versions of a file is just asking for trouble and ought to be thrown out.

    It doesn't matter if an "entire applciation" relies on that sequence. Or actually, the more programs rely on it, the more important it becomes to change it to be something reasonable. The points of reference, the more points of failure. The application becomes fragile, and the effort needed for maintenance goes up. (Not to mention that it's harder to create the application in the first place.)

    Tom

    125,585 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