Move all fields in a record format at once.

15 pts.
Subfile Record Format
How can I move all the fields of a single record format at once? I need to move fields totalling 712 positions to a single flat-file record that is also 712 positions long. I really don't want to move one-field-at-a-time into a data structure if I can help it.

Answer Wiki

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

You can use a technique called a “Program Described File.”

Basically, you tell RPG to use the format you describe within your RPG. And in your case, you’d tell RPG that your externally described input file was one 712 length record and write that record to your flat file. See examples.

Best wishes: Craig



You can also externally describe a data structure

Ddsname E DS EXTNAME(filename:rcdfmt:*ALL)

This will create a data structure with all the fields in your file as subfields in the data structure. When you read your file, the data structure will be populated. Then you can do whatever you like with the data structure like moving it to a single field that can be written to your flat file.


Do you need to do this in RPG? Would a simple CPYF command be acceptable or is this part of a larger RPG program? If a program-described file is a useful solution, then it seems that a program isn’t even needed.

As for the alternative DS method… Note that if you create a DS that holds the structure of an externally described file, you might not need to ‘move’ anything. You might be able to also define a 712-byte field that overlays the DS. Simply use that field rather than moving the DS to a separate field.


Discuss This Question: 2  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.
  • Mahler2
    This is my first time using this forum, so I'm not sure if this is the proper place to respond to ElTerrifico, but I wanted thank him (her?) for the tip. It worked great! Who knew that going "old school" and processing an externally-described file as a program-described file would be the easy answer? ElTerrifico, that's who! Thanks again.
    15 pointsBadges:
  • ElTerrifico
    While I'd like to credit, that part of the answer was provided by Chatmaker (Craig), not myself. My suggestion was to use an externally described data structure. I am also new to ths forum and didn't realize that by adding to Craig's answer, it would appear that the whole answer came from me. I didn't intend to take Craig's answer, I just wanted to offer an alternative. And yes, sometimes the old ways work quite well.
    620 pointsBadges:

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.


Share this item with your network: