Cobol/AS400 – Copy DDS Replacing Fields Names

95 pts.
Tags:
AS/400
COBOL
Language: Cobol
Platform: iSeries (AS/400)
Is there a way to replace in Cobol the first two characters of all fields from a file by other two characters?
What I mean is this: I have a copy-dds from a file that all the fields have TRxxxx (where 'xxxx' is different from field to field). What I want is to replace the 'TR' by 'SP'.
The goal is to make a move corr from one other file to this one, instead of moving field by field, If I could make a move corr would be better.

Answer Wiki

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

.take the source program and copy file a and create file b     if fielda = ‘tr’ move ‘sp’ to fieldb     

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
  • TomLiotta
    I'm not aware of any good way to replace only a portion (or an existing 'prefix') of a name in a COPY DDS statement. But as long as you want the names to be the same, all you need to do is use essentially the same COPY DDS statement for both files. -- Tom
    125,585 pointsBadges:
    report
  • TomLiotta
    ...or are the record formats structured differently? If they are, then you might want to make source member from one of the files and change the prefix characters with an editor, e.g., with SEU. Use the modified COPY member instead of the COPY DDS member. -- Tom
    125,585 pointsBadges:
    report
  • ITTechPT
    Thanks Tom, I will try the first option. I probably will make the two physical files with the same fields names. I will have two different files but they have some common fields with the same name. In Cobol I can move the entire record from one file to another.
    95 pointsBadges:
    report
  • TomLiotta

    Note that the COPY DDS statements should create structures in WORKING STORAGE, not under the FD entries. Use READ INTO and WRITE FROM statements to get a record into and out of the structures.

    Of course, if you are simply copying the record formats, you only one structure. Just READ INTO it and WRITE FROM it. You could even change some of the values in between those statements. With a single structure, the MOVE CORR isn't necessary.

    Tom

    125,585 pointsBadges:
    report
  • MDratwa
    Try using "copy dds-all-formats of filename replacing == TR== by == SP==" (I think it will allow a blank in front of "TR" and "SP".  If it will not allow the blank, it will all "TR" with "SP" within the field name too.  This will replace the "TR" in the front with "SP" (if the blank is allowed).
    785 pointsBadges:
    report
  • TomLiotta

    Unfortunately, the COBOL Reference states:

    However, I haven't had reason to actually test results.

    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