Ü  COPY FILE (CPYF)

 

 

AMINEM / ACCOUNT

ACCOUNT (MEMBER)

       ACLEVELID  ACORGCOD       ACCOUNTNUM   ACCURRENCY  ACNAME
000001      7        190    100,000,000,001      EUR      SURESH
000002      7        190    100,000,000,002      EUR      SHRI
000003      7        190    100,000,000,003      EUR      UPI              
000004      7        190    100,000,000,004      EUR      ABHI             
000005      7        190    100,000,000,005      EUR      AMI              
000006      7        190    200,000,000,002      EUR      JAPY             
000007      7        190    200,000,000,003      USD      KAPIL            
000008      7        190    200,000,000,004      USD      TQNGO  

 

 

 

 

¤  1st example

 

 

CPYF FROMFILE(AMINEM/ACCOUNT) TOFILE(AMINEM/ACCOUNTCPY) FROMMBR(ACCOUNT) TOMBR(*FIRST) MBROPT(*ADD) CRTFILE(*YES) FROMRCD(3)                      

     

       Physical file ACCOUNTCPY created in library AMINEM.                      

      Member ACCOUNT added to file ACCOUNTCPY in AMINEM.                       

      6 records copied from member ACCOUNT.  

    

 

 

AMINEM / ACCOUNTCPY

ACCOUNT (1ST MEMBER)     

       ACLEVELID  ACORGCOD       ACCOUNTNUM   ACCURRENCY  ACNAME           
000001      7        190    100,000,000,003      EUR      UPI              
000002      7        190    100,000,000,004      EUR      ABHI             
000003      7        190    100,000,000,005      EUR      AMI              
000004      7        190    200,000,000,002      EUR      JAPY             
000005      7        190    200,000,000,003      USD      KAPIL            
000006      7        190    200,000,000,004      USD      TQNGO   

                                     

 

 

 

¤  2nd example

 

     

CPYF FROMFILE(AMINEM/ACCOUNT) TOFILE(AMINEM/ACCOUNTCPY) FROMMBR(ACCOUNT)

TOMBR(MBR2CPY) MBROPT(*ADD) CRTFILE(*NO) FROMRCD(7) 

                       

      Member MBR2CPY added to file ACCOUNTCPY in AMINEM.                       

      2 records copied from member MBR2.        

 

 

AMINEM/ACCOUNTCPY

MB2CPY (2ND MEMBER)

       ACLEVELID  ACORGCOD       ACCOUNTNUM   ACCURRENCY  ACNAME
000001      7        190    200,000,000,003      USD      KAPIL
000002      7        190    200,000,000,004      USD      TQNGO

 

 

 

 

¤  3rd example

 

 

 

CPYF FROMFILE(AMINEM/ACCOUNT) TOFILE(AMINEM/ACCOUNTCPY) FROMMBR(ACCOUNT) TOMBR(MBR2CPY) MBROPT(*REPLACE) CRTFILE(*NO) FROMRCD(*START) INCCHAR(ACNAME 1 *EQ 'S') 

                                                             

2 records copied from member MBR2.                                       

 

          

AMINEM/ACCOUNTCPY

MB2CPY (2ND MEMBER)

       ACLEVELID  ACORGCOD       ACCOUNTNUM   ACCURRENCY  ACNAME           
000001      7        190    100,000,000,001      EUR      SURESH           
000002      7        190    100,000,000,002      EUR      SHRI             

 

 

 

 

 

¤  4th example

 

 

CPYF FROMFILE(AMINEM/ACCOUNT) TOFILE(AMINEM/ACCOUNTCPY) FROMMBR(MBR*) TOMBR(MBR2CPY) MBROPT(*REPLACE) CRTFILE(*NO) FROMRCD(*START) INCREL((*IF ACNAME *EQ 'S') (*AND ACCOUNTNUM *GT 100000000001))  

                     

       ACLEVELID  ACORGCOD       ACCOUNTNUM   ACCURRENCY  ACNAME  
000002      7        190    100,000,000,002      EUR      SHRI             

                                          

 

 

           

Ü  Record format field mapping (FMT)

*MAP                

Fields with the same name in the from-file and to-file record formats are copied, and any fields in the to-file that do not exist in the from-file format are set to the default value specified on the DFT keyword for the data description specification (DDS) of the to-file or zero for numeric fields, blanks for character fields, current date/time for date/time fields, or null value for null-capable fields.

If *MAP is specified, *DROP can also be specified.

 

*DROP

This value must be specified for field-level mapping if any of the field names in the from-file record format do not exist in the to-file format. If *DROP is specified, *MAP can also be specified. When *DROP is specified, all the field names that exist in both record formats must have the same attributes and relative positions in the from-file and to-file record formats, or *MAP must also be specified. Null values are copied.

 

*NOCHK

 

If the record formats of the database files are different, the copy operation continues despite the differences. Record data is copied directly (left to right) from one file to the other. FMTOPT (*NOCHK) is required when copying all record formats from a logical file with multiple formats (when RCDFMT (*ALL) is specified) to a physical file that is of the same type (source or data) as the from-file.

 

*CVTSRC

This value is used to copy between database files, from a source file to a data file, or from a data file to a source file. It is valid only when the from-file and to-file are different types (source and data). The file type conversion is done as follows:

 

 

Ü  Include records by char test (INCCHAR)

Specifies that records are copied based on a comparison of a character string value and the data in some position of either a field in the record or the entire record.

   Element 1: Field

   Element 2: Character position

   Element 3: Relational operator

   Element 4: Value

 

 

Ü  Difference between CRTDUPOBJ and COPYF

 

In CRTDUPOBJ for a logical file the created duplicate file will be also logical file and for a physical file the created file will also be a physical file. Even the record format identifier will also be the same. While in case of COPYF, if we are copying a logical file then the created file be a physical file not a logical file.





User Comments:





Copyright © Go4as400.com, 2013-2016. Copyright notice