Home > AS/400 Tips > iSeries administrator tips > Who said you can't write to file from CL?
iSeries 400 Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

ISERIES ADMINISTRATOR TIPS

Who said you can't write to file from CL?


Clive Griffiths
09.23.2002
Rating: -3.27- (out of 5)


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


Here you'll learn how to write to a specified physical file from within CL. I have added the command WRTREC with parameters of DATA (what you want to write to the file.) And TOFILE with TOLIB naming the file you want to write to. You can amend or enhance the CL to your hearts content as the basics work fine.



Code

  
/***********************************************************************/  
/* PGM    - WRTRECCPP                                                  */  
/* AUTHOR - CLIVE GRIFFITHS                                            */  
/* DESC   - WRITE A RECORD TO SEPCIFIED FILE                           */  
/* PARMS  - &RECORD 100 CHARACTER - DATA TO BE WRITTEN TO FILE         */  
/*        - &TOLIB 10 CHARACTER   - LIBRARY NAME OF FILE TO BE WRITTEN */  
/*        - &TOFILE 10 CHARACTER  - NAME OF FILE TO BE WRITTEN TO      */  
/***********************************************************************/  
PGM (&RECORD &TOFILE &TOLIB)                                               
DCL &RECORD *CHAR 100                                                      
DCL &TOFILE *CHAR 10                                                       
DCL &TOLIB  *CHAR 10                                                       
DCL &NBRCURREC *DEC 10 0                                                   
DCL &RCDNBR *DEC 10 0                                                      
CRTPF QTEMP/QMHMDT RCDLEN(100)                                             
MONMSG CPF0000                                                             
SNDPGMMSG  MSG(&RECORD)                                                    
DSPJOBLOG  OUTPUT(*OUTFILE) OUTFILE(QTEMP/TEMPF)                           
CPYF FROMFILE(QTEMP/TEMPF) TOFILE(QTEMP/QMHMDT) +                             
  MBROPT(*ADD) NBRRCDS(1) INCREL((*IF QMHMDT *EQ &RECORD)) FMTOPT(*MAP *DROP) 
RTVMBRD FILE(QTEMP/QMHMDT) NBRCURRCD(&NBRCURREC)                              
CPYF FROMFILE(QTEMP/QMHMDT) TOFILE(&TOLIB/&TOFILE) MBROPT(*ADD) +             
  FROMRCD(&NBRCURREC) FMTOPT(*NOCHK)                                          
ENDPGM                                                                        


/***********************************************************************/ 
/* CMD    - WRTREC  - COMMAND FOR CPP WRTRECCPP                        */ 
/* AUTHOR - CLIVE GRIFFITHS                                            */ 
/* DESC   - WRITE A RECORD TO SEPCIFIED FILE                           */ 
/* PARMS  - DATA 100 CHARACTER - DATA TO BE WRITTEN TO FILE            */ 
/*        - TOFILE 10 CHARACTER  - NAME OF FILE TO BE WRITTEN TO       */ 
/*        - TOLIB 10 CHARACTER   - LIBRARY NAME OF FILE TO BE WRITTEN  */ 
/***********************************************************************/ 
CMD PROMPT                                                                
             PARM       KWD(DATA) TYPE(*CHAR) LEN(100) +                  
                          CHOICE('Enter data to be written') +            
                          PROMPT(DATA)                                    
             PARM       KWD(TOFILE) TYPE(*NAME) LEN(10) +                 
                          CHOICE('Target file name') PROMPT(TOFILE)       
             PARM       KWD(TOLIB) TYPE(*NAME) LEN(10) +                  
                          CHOICE('Library name') PROMPT(TOLIB)    

==================================
MORE INFORMATION ON THIS TOPIC
==================================

The Best Web Links: Tips, tutorials and more.

Ask your systems management questions--or help out your peers by answering them--in our live discussion forums.

Read this Search400.com Featured Topic: Managing your iSeries.

Ask the Experts yourself: Our systems management gurus are waiting to answer your technical questions.


Rate this Tip
To rate tips, you must be a member of Search400.com.
Register now to start rating these tips. Log in if you are already a member.


Submit a Tip




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



RELATED CONTENT
iSeries administrator tips
Translating Linux for IBM i admins: Using GUI to make it easy
Translating Linux for IBM i admins: Working with jobs and networking
OpenOffice: What to know before making the transition from Microsoft Office
OpenOffice: An enterprise open source solution
Database performance comparisons on IBM i
Translating Linux for IBM i admins: User profile commands
Modern System i reports using Client Access
Tips for installing Lotus Domino server on a System i partition
The iSeries Blog has a new home on IT Knowledge Exchange
Virtualization for IBM i: Backups

Performance
Will overloaded discs impact iSeries performance?
Extend storage capacity on an IBM i without negatively effecting system performance
Database drivers on the i: MySQL vs. IBM Toolbox
Performance tuning for IBM i: The basics and beyond
IBM releases new Power products for the midrange
Top System i admin tips for 2006
Catholic Charities keeps track of homeless with iSeries
i5 error messages: What you need to know
IBM races for clock speed
System shutting down after cleanup

iSeries system performance and monitoring
Translating Linux for IBM i admins: Working with jobs and networking
Database performance comparisons on IBM i
How to: Monitoring job activity on the AS/400
Performance tuning for IBM i: The basics and beyond
How to: Reduce the percentage of ASP used on the AS/400
Detecting system changes made by outside IP address
AS/400 system values quiz
Checking on System i disk space requires creating a new command: XRTVSYSSTS
Drive space management commands
Viewing netstat information

RELATED GLOSSARY TERMS
Terms from Whatis.com − the technology online dictionary
CIW  (Search400.com)

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



iSeries Security - Security Tools, Physical Security and System Security
HomeNewsTopicsITKnowledge ExchangeTipsBlogsAsk the ExpertsMultimediaWhite PapersProducts
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 1999 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts