FILES

285 pts.
Tags:
FILES
I have two physical files are PF1 & PF2 ,in that i need to copy the records from PF! file to PF2 file but tw0 files have different field names and have same attributes. Example: PF1: Name 25 A Code 10 S 0 Location 30 A PF2: LCode 10 S 0 LLocation 30 A LName 25 A plz guide me and thanks in advance...

Software/Hardware used:
AS400

Answer Wiki

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

PF1:
Name 25 A
Code 10 S 0
Location 30 A

PF2:
LCode 10 S 0
LLocation 30 A
LName 25 A

we can’t copy pf1 to pf2, because pf1 and pf2 field are interchanged. so we can’t copy..
if you try to copy your records, it ll show like this ‘+++++++’

best you try to change field order like this.. (must change the field order PF1 or PF2)

PF2:
LName 25 A
LCode 10 S 0
LLocation 30 A

after using cpyf command… don’t forget the below step to fill….
<b>Record format field mapping . . > *NOCHK</b>

Discuss This Question: 4  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
  • SMisar
    Hi, Use the fallowing command CPYF FROMFILE(QTEMP/PF1) TOFILE(QTEMP/PF2) MBROPT(*ADD) FMTOPT(*NOCHK)
    130 pointsBadges:
    report
  • SMisar
    But Before Using this command your PF2 fiedl sequence is same as PF1 field sequence
    130 pointsBadges:
    report
  • BigKat
    you can:
    1. write a program to move the data to the corresponding fields and write the PF2 records
    2. use an INSERT SQL statement to select the data from PF1 in the proper sequence for PF2
    8,090 pointsBadges:
    report
  • TomLiotta
    Since the field names are different and the fields are in different locations, you can't directly use simple tools like CPYF. SQL could help though:
    CREATE VIEW mylib/PF1V AS
     SELECT CODE as LCODE, LOCATION as LLOCATION, NAME as LNAME FROM mylib/PF1
    Then you can do this:
    CPYF FROMFILE( mylib/PF1V ) TOFILE( mylib/PF2 ) MBROPT( *ADD ) FMTOPT( *MAP )
    By creating a VIEW over PF1 that presents the columns with new names, you can use the *MAP option of the CPYF command. 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