Move all fields in a record format at once.

15 pts.
Tags:
RPG
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

References

——

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.

Tom

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.

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
  • 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:
    report
  • 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:
    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