Move (or Eval) between record formats

200 pts.
Tags:
RPG
Isn't it possible to move a database file record format to a different format in one statement? I have tried move, movel, and eval, and still get errors. It seems it should be possible. Thanks!

Answer Wiki

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

Assuming your record formats are identical, you can define external data structures for each format in your D specs. Then do something like this.

/free
RcdFmt2DS = RcdFmt1DS;
/end-free

============================================================

It’s not clear, but it sounds like you are looking for the EVAL-CORR op-code. EVAL-CORR provides essentially what a MOVE CORRESPONDING statement in COBOL would provide.

Tom

Discuss This Question: 6  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
  • PAVERS
    Example: FKLCUSFIL IF E K DISK FCAPIHC UF A E K DISK PREFIX(H) D CUSREC_DS E DS EXTNAME(CAPIHC) D CAPIHC_DS E DS EXTNAME(CAPIHC) Prefix(H) MOVEL CUSREC_DS CAPIHC_DS
    0 pointsBadges:
    report
  • Bdfgsbw
    What error are you getting? It is possible to move the data in one format to another, but you cannot use the file format name. The better solution is to use data structures to move the data. Then in the program, MOVE one data structure to the other. The only rule you need to follow is to insure the fields within the data structures line up. Ex1. D FLDATA E DS EXTNAME(FILE1) D FLSAVE E DS EXTNAME(FILE1) PREFIX(SV) . . . C MOVEL FLDATA FLSAVE In the above example, the DS's have the same format (reference the same file), and as long as the data structures have the same field positioning (definition) as the other, then the logic works. Ex2. D DS1 DS D FLD1 1 35 D FLD2 36 70 D FLD3 71 105 . . D DS2 DS D FFLD1 1 35 D FFLD2 36 70 . . C MOVEL DS1 DS2 This will work also. If the fields in the data structures do not line up, the you run the risk of corrupting the data. Hope this helps.
    0 pointsBadges:
    report
  • naren1336
    How can i write a file with just DS. I have to again move it to a records format
    10 pointsBadges:
    report
  • TheRealRaven
    You can't with "just a DS". We need to see more of the code and a better description of the output file, and also something of the process, in order to say much that's useful.
    4,940 pointsBadges:
    report
  • philpl1jb

    You would have F specs for both and data structures based on each file

    Read f1

    Eval f2ds = f1ds

    Write f2

     

    52,720 pointsBadges:
    report
  • TheRealRaven
    naren1336 hasn't said if one file is being generated, if data from one file is copied to another, if multiple files are being combined, if there is a single DS or multiple DSs (and if multiple, whether any have the same structure), if any DSs match any record formats. Lots of possibilities.
    4,940 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:

Share this item with your network:

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