Copy from Stream file (CPYFRMSTMF) in IBM i

This article will explain the use of CPYFRMSTMF command in IBM i.
Copy from Stream file CPYFRMSTMF in IBM i, CPYFRMSTMF, Automatic Conversion, Database File , database file member, save file, nput/output (I/O) operations, source member, stream file, current working directory, Current Directory, Home Directory, ifs, ifs directory, ifs directories, directory, directories, Absolute IFS path, Relative IFS path, DSPCURDIR command, Current Working Directory, Stream file,ibmi,as400,iseries,systemi, working with ifs,as400 and sql tricks, as400 tutorial, ibmi tutorial, crtsavf, savobj, savlib, wrklnk, ifs, integrated file system, save file, copy save file to the stream file, copy pf to stream file, stmf in ifs as400, ifs ibmi, save file, savobj, savlib, cpyfrmstmf, copy from ifs stream file to save file in ibmi as400, dspsavf, display save file, qsys, copy from stream file to save file from ifs as400, working with ifs, working with integrated file system
Copy from Stream file CPYFRMSTMF in IBM i

Copy From Stream File (CPYFRMSTMF)

The Copy From Stream File (CPYFRMSTMF) command copies the data in a stream file to either a database file member or a save file. The database member pathname must be of the form name.object-type. For example:

/QSYS.LIB/LIBNAME.LIB/FILENAME.FILE/MBRNAME.MBR

Copying Data from a Stream File to a Database File Using Automatic Conversion

                       Copy From Stream File (CPYFRMSTMF)                       
                                                                                
 Type choices, press Enter.                                                     
                                                                                
 From stream file . . . . . . . . FROMSTMF     > '/HOME/EASYCLASS/CPYTOSTMF1'   
                                                                                
 To file member or save file  . . TOMBR        > '/QSYS.LIB/EASYCLASS1.LIB/DDSTODDL2.FILE/MBR1.MBR'                                                              
 Member option  . . . . . . . . . MBROPT       > *REPLACE                       
 Data conversion options  . . . . CVTDTA         *AUTO                         
 Stream file CCSID  . . . . . . . STMFCCSID      *STMF                          
 Database file CCSID  . . . . . . DBFCCSID       *FILE                          
 End of line characters . . . . . ENDLINFMT      *CRLF                           
 Tab character expansion  . . . . TABEXPN        *YES                           

Here, This command copies the data contained in stream file /HOME/EASYCLASS/CPYTOSTMF1 in the current working directory to database file member named /QSYS.LIB/EASYCLASS1.LIB/DDSTODDL2.FILE/MBR1.MBR. Automatic conversion of data takes place using the stream file data CCSID and the database file CCSID.

You can refer the article, how to copy database file member to the stream file in IFS

 Parameters or command            
 ===>                             
 F3=Exit   F4=Prompt   F5=Refresh 
 F22=Display entire field 
 
Stream file copied to object.
 
                           Work with Members Using PDM       
                                                             
 File  . . . . . .   DDSTODDL2                               
   Library . . . .     EASYCLASS1           Position to  . . 
                                                             
 Type options, press Enter.                                  
  2=Edit         3=Copy  4=Delete 5=Display       6=Print    
  8=Display description  9=Save  13=Change text  14=Compile  
                                                             
 Opt  Member      Type        Text                           
      APIPGM      SQLRPGLE    QSQGNDDL API                   
      APIPGM#1    SQLRPGLE    QSQGNDDL API                   
      APIPGM#2    SQLRPGLE    QSQGNDDL API                   
      APIPGM2     SQLRPGLE    QSQGNDDL API                   
      DDLG1       SQL                                        
      MBR                                                    
      MBR1                                                   
      MBR2                                                   
                                                             

Take option 5 to display the content of the stream file

 Columns . . . :    1 100                                      Browse                                          EASYCLASS1/DDSTODDL2 
 SEU==>                                                                                                                        MBR1 
 FMT **  ...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... 8 ...+... 9 ...+... 0                        
        *************** Beginning of data ***************************************************************************************   
0001.00       * format of Input Tempalate parameter of SQLR0100 format                                           000000             
0002.00      D SQLR0100        DS                                                                                000000             
0003.00      D databaseobjectname...                                                                             000000             
0004.00      D                              258a                                                                 000000             
0005.00      D databaseobjectlibraryname...                                                                      000000             
0006.00      D                              258a                                                                 000000             
0007.00      D databaseobjecttype...                                                                             000000             
0008.00      D                               10a                                                                 000000             
0009.00      D databasesourcefilename...                                                                         000000             
0010.00      D                               10a                                                                 000000             
0011.00      D databasesourcefilelibraryname...                                                                  000000             
0012.00      D                               10a                                                                 000000             
0013.00      D databasesourcefilemembername...                                                                   000000             
0014.00      D                               10a                                                                 000000             
0015.00      D severitylevel...                                                                                  000000             
0016.00      D                               10i 0 INZ(30)                                                       000000             
0017.00      D replaceoption...                                                                                  000000             
0018.00      D                                1a   INZ('0')                                                      000000             
0019.00      D statementformattingoption...                                                                      000000             

Copying Data from a Stream File to a Data-base File Without Data Conversion

                        Copy From Stream File (CPYFRMSTMF)                       
                                                                                
 Type choices, press Enter.                                                     
                                                                                
 From stream file . . . . . . . . FROMSTMF     > '/HOME/EASYCLASS/CPYTOSTMF1'   
                                                                                
 To file member or save file  . . TOMBR        > '/QSYS.LIB/EASYCLASS1.LIB/DDSTODDL2.FILE/MBR2.MBR'                                                            
 Member option  . . . . . . . . . MBROPT         *REPLACE                       
 Data conversion options  . . . . CVTDTA         *NONE                          
 Stream file CCSID  . . . . . . . STMFCCSID      *STMF                          
 Database file CCSID  . . . . . . DBFCCSID       *FILE                          
 Conversion table . . . . . . . . TBL                                           
                                                                                
 End of line characters . . . . . ENDLINFMT      *CRLF                          
 Tab character expansion  . . . . TABEXPN        *YES                           
 Stream file code page  . . . . . STMFCODPAG     *STMF                          
                                                                                
                                                                                

Here, This command copies the data contained in stream file /HOME/EASYCLASS/CPYTOSTMF1 in the current working directory to database file member named /QSYS.LIB/EASYCLASS1.LIB/DDSTODDL2.FILE/MBR2.MBR without data conversion.

                           Work with Members Using PDM       
                                                             
 File  . . . . . .   DDSTODDL2                               
   Library . . . .     EASYCLASS1           Position to  . . 
                                                             
 Type options, press Enter.                                  
  2=Edit         3=Copy  4=Delete 5=Display       6=Print    
  8=Display description  9=Save  13=Change text  14=Compile  
                                                             
 Opt  Member      Type        Text                           
      APIPGM      SQLRPGLE    QSQGNDDL API                   
      APIPGM#1    SQLRPGLE    QSQGNDDL API                   
      APIPGM#2    SQLRPGLE    QSQGNDDL API                   
      APIPGM2     SQLRPGLE    QSQGNDDL API                   
      DDLG1       SQL                                        
      MBR                                                    
      MBR1                                                   
      MBR2                                                   
                                                             

Take option 5 to display the content of the stream file

 Columns . . . :    1 100                                      Browse                                          EASYCLASS1/DDSTODDL2
 SEU==>                                                                                                                        MBR2
 FMT **  ...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... 8 ...+... 9 ...+... 0                       
        *************** Beginning of data ***************************************************************************************  
0001.00       * format of Input Tempalate parameter of SQLR0100 format                                           000000            
0002.00      D SQLR0100        DS                                                                                000000            
0003.00      D databaseobjectname...                                                                             000000            
0004.00      D                              258a                                                                 000000            
0005.00      D databaseobjectlibraryname...                                                                      000000            
0006.00      D                              258a                                                                 000000            
0007.00      D databaseobjecttype...                                                                             000000            
0008.00      D                               10a                                                                 000000            
0009.00      D databasesourcefilename...                                                                         000000            
0010.00      D                               10a                                                                 000000            
0011.00      D databasesourcefilelibraryname...                                                                  000000            
0012.00      D                               10a                                                                 000000            
0013.00      D databasesourcefilemembername...                                                                   000000            
0014.00      D                               10a                                                                 000000            
0015.00      D severitylevel...                                                                                  000000            
0016.00      D                               10i 0 INZ(30)                                                       000000            
0017.00      D replaceoption...                                                                                  000000            
0018.00      D                                1a   INZ('0')                                                      000000            
0019.00      D statementformattingoption...                                                                      000000            
                                                                                                                                   

Using Copy from Stream file CPYFRMSTMF command to copy data in a stream file to a save file

  • First we need to create a save file named TESTSAV3 in library EASYCLASS1 using CRTSAVF command.
  • CRTSAVF FILE(EASYCLASS1/TESTSAV3)

    Save file created successfully.

                                   Work with Objects                     
                                                                         
     Type options, press Enter.                                          
       2=Edit authority        3=Copy   4=Delete   5=Display authority   
       8=Display description   13=Change description                     
                                                                         
     Opt  Object      Type      Library     Attribute   Text             
          TESTSAV3    *FILE     EASYCLASS1  SAVF

    Display save file data using DSPSAVF command. Currently, save file is empty.

    dspsavf testsav3
                               Display File Information    
                                                           
    Save file  . . . . . . . . . . . . . . :   TESTSAV3    
      Library  . . . . . . . . . . . . . . :     EASYCLASS1
      Records  . . . . . . . . . . . . . . :     0         
                                                           
                                                           
                                                           
                                                           
                                                           
    (No records in save file)
  • Execute Below CPYFRMSTMF command to copy stream file to a save file created above.
  •                        Copy From Stream File (CPYFRMSTMF)                       
                                                                                    
     Type choices, press Enter.                                                     
                                                                                    
     From stream file . . . . . . . . FROMSTMF     > '/HOME/EASYCLASS/SAVF1'        
                                                                                    
     To file member or save file  . . TOMBR        > '/QSYS.LIB/EASYCLASS1.LIB/TESTS
    AV3.FILE'                                                                       
     Member option  . . . . . . . . . MBROPT       > *REPLACE

    This command copies the data contained in stream file /HOME/EASYCLASS/SAVF1 to the save file /QSYS.LIB/EASYCLASS1.LIB/TESTSAV3.FILE.

    You can refer the article, How to copy save file to stream file in IFS.

     Selection or command                
     ===>                                
                                         
     F3=Exit   F4=Prompt   F9=Retrieve   
     F23=Set initial menu                
     Stream file copied to object.       
    
  • Display save file data using DSPSAVF command. After executing above command stream file data being copied to the savefile TESTSAV3.
  • dspsavf testsav3
                                Display Saved Objects                   
                                                                        
    Library saved . . . . . . . :   EASYCLASS1                          
                                                                        
    Type Options, press Enter.                                          
      5=Display                                                         
                                                                        
    Opt  Object      Type      Attribute   Owner          Size (K)  Data
         EXTPGM5     *PGM      RPGLE       EASYCLASS           136  YES

    Post a Comment

    © AS400 and SQL Tricks. All rights reserved. Developed by Jago Desain