ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Cpyf

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Cpyf

    Hi,

    Suppose there are 2 files File A and B and both have few common fields in just terms of data types but their names are not same.


    So how can we copy all the records from file B to file A provided whatever data gets copied in File A has just that data for which both the files have com mon data types and no extra field in File A be appended from file B after this CPYF command is executed.


    Thanks

  • #2
    I think you could create a logical file over A with fields renamed to match the fields in B and use CPYF with FMTOPT(*MAP *DROP) to copy the data.

    I would use SQL, not CPYF.

    Code:
    File A      File B
    ========== ==========
    CUST       CUSTOMER
    ITEMNBR    ITEMNBR
    QTY        QUANTITY
    PRICE      doesn't exist
    
    insert into A (cust, itemnbr, qty)
    select customer, itemnbr, quantity from B

    Comment

    Working...
    X