Home > AS/400 Tips > iSeries programmer tips > Back up to multiple member file
iSeries 400 Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

ISERIES PROGRAMMER TIPS

Back up to multiple member file


Robert DeSotle
04.08.2002
Rating: -3.71- (out of 5)


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


This command creates a multiple member file and will remove the oldest member when max members is reached. We use it to back up before and after images of a file for quick recovery, or accumulate a weeks worth of files for reporting on Sunday. Example, you want to keep six copies of a file for reporting or recovery. When the command runs the seventh time, the oldest member will be removed and the seventh will be added. We also use the command to save copies of spool files so we can reprint a report x days from now. The command writes to a data area in QTEMP so you can pass Library, File, Member, Number Of Records, Date and Time to another program.

Example 1: Save spool for 50 cycles.

 
    CPYSPLF    FILE(QSYSPRT) TOFILE(fromLIB/PRINT133) +
              SPLNBR(*LAST)

     BKMBRRN    FILE(PRINT133) FLIB(fromLIB) +
              BLIB(bkupLIB) NFLE(bkpfile) MBR(50) /* +
              Backup Report For 50 Batch Runs */ 

Example 2: Save file for weekly run.

   BKMBRRN    FILE(NR24P07) FLIB(*LIBL) BLIB(bkupLIB) +
              NFLE(NR24P07BK) MBR(7) /* Back Weekly +
              Accume */ 


Code

  COMMAND Code:
/**********************************/    
/* BACKUP TO MULTIPLE  MEMBER FILE*/                                  
/* CALL CL BKMBRL10               */                                  
/**********************************/                                  
                                                                      
 CMD        PROMPT('File Backup To Member')               
             PARM       KWD(FILE) TYPE(*CHAR) LEN(10) MIN(1) MAX(1) + 
                          CHOICE('*CHAR') PROMPT('From File Name')    
             PARM       KWD(FLIB) TYPE(*CHAR) LEN(10) MIN(1) MAX(1) + 
                          CHOICE('*CHAR') PROMPT('From Library')      
             PARM       KWD(BLIB) TYPE(*CHAR) LEN(10) MIN(1) MAX(1) + 
                          CHOICE('*CHAR') PROMPT('To Library')        
             PARM       KWD(NFLE) TYPE(*CHAR) LEN(10) MIN(1) MAX(1) + 
                          CHOICE('*CHAR') PROMPT('To File Name')      
             PARM       KWD(MBR) TYPE(*DEC) LEN(3) RTNVAL(*NO) +      
                          RSTD(*NO) MIN(1) MAX(1) PROMPT('Maximum +   
                          Members')




CL Code
/*********************************************************************/
/* THIS CL WILL CREATE A MULTIPLE MEMBER FILE FOR BACKUP             */
/* IT IS CALLED FROM COMMAND BKMBRRN                         */
/*                                                                   */
/* PROGRAMMER:    R. DESOTLE                                         */
/* DATE      :    03/19/98                                           */
/*                                                                   */
/*********************************************************************/

             PGM        PARM(&FILE &FLIB &BLIB &NFLE &MBRS)

/***********************/
/* OUTPUT FROM DSPFD   */
/***********************/

             DCLF       FILE(BKPFA)

             DCL        VAR(&FILE)    TYPE(*CHAR) LEN(10)
             DCL        VAR(&FLIB)    TYPE(*CHAR) LEN(10)
             DCL        VAR(&BLIB)    TYPE(*CHAR) LEN(10)
             DCL        VAR(&NFLE)    TYPE(*CHAR) LEN(10)
             DCL        VAR(&MBRS)    TYPE(*DEC)  LEN(2 0)
             DCL        VAR(&NBRMBRS) TYPE(*DEC)  LEN(10 0)
             DCL        VAR(&NBRRECS) TYPE(*DEC)  LEN(10 0)
             DCL        VAR(&NBRREC)  TYPE(*CHAR) LEN(10)
             DCL        VAR(&MAXMBRS) TYPE(*DEC)  LEN(10 0)
             DCL        VAR(&RTNMBR)  TYPE(*CHAR) LEN(10)
             DCL        VAR(&BMBR)    TYPE(*CHAR) LEN(10)
             DCL        VAR(&JOBTIM)  TYPE(*CHAR) LEN(6)
             DCL        VAR(&JOBDAT)  TYPE(*CHAR) LEN(6)
             DCL        VAR(&DAYOFW)  TYPE(*CHAR) LEN(4)
             DCL        VAR(&STAMP)   TYPE(*CHAR) LEN(10)

             OVRDBF     FILE(BKPFA) TOFILE(QTEMP/BKPFA)

/***********************/
/* RETRIEVE SYSTEM TIME*/
/***********************/

             RTVSYSVAL  SYSVAL(QTIME) RTNVAR(&JOBTIM)
             RTVSYSVAL  SYSVAL(QDATE) RTNVAR(&JOBDAT)
             RTVSYSVAL  SYSVAL(QDAYOFWEEK) RTNVAR(&DAYOFW)

             CHGVAR VAR(&STAMP) VALUE(%SST(&DAYOFW 2 2) +
                    || %SST(&JOBDAT 3 2) || &JOBTIM)


/***********************/
/* DOES FILE EXISTS ?  */
/***********************/

             RTVOBJD    OBJ(&BLIB/&NFLE) OBJTYPE(*FILE)

/***********************/
/* CREATE IF NOT EXISTS*/
/***********************/

             MONMSG     MSGID(CPF9812) EXEC(DO)
             CRTDUPOBJ  OBJ(&FILE) FROMLIB(&FLIB) OBJTYPE(*FILE) +
                          TOLIB(&BLIB) NEWOBJ(&NFLE)

/***********************/
/* CHANGE # MEMBERS    */
/***********************/

             CHGPF      FILE(&BLIB/&NFLE) MAXMBRS(&MBRS)
             ENDDO

/***********************/
/* RETRIEVE FILE INFO  */
/***********************/

             DSPFD      FILE(&BLIB/&NFLE) TYPE(*ATR) +
                          OUTPUT(*OUTFILE) FILEATR(*PF) +
                          OUTFILE(QTEMP/BKPFA)

/***********************/
/* READ FILE INFO REC. */
/***********************/

             RCVF

/*******************************/
/* IF FILE REACHED MAX MEMBERS */
/*   REMOVE OLDEST MEMBER      */
/* ELSE                        */
/*   ADD NEW MEMBER            */
/* ENDIF                       */
/*******************************/

             CHGVAR     VAR(&NBRMBRS) VALUE(&PHNOMB)
             CHGVAR     VAR(&MAXMBRS) VALUE(&PHMAXM)

             IF COND(&NBRMBRS *GE &MAXMBRS) THEN(DO)
             RTVMBRD    FILE(&BLIB/&NFLE) RTNMBR(&RTNMBR)
             RMVM       FILE(&BLIB/&NFLE) MBR(&RTNMBR)
             ENDDO

             CHGVAR VAR(&BMBR) VALUE(&STAMP)
             CPYF       FROMFILE(&FLIB/&FILE) TOFILE(&BLIB/&NFLE) +
                          TOMBR(&BMBR) MBROPT(*ADD)
             RTVMBRD    FILE(&FLIB/&FILE) NBRCURRCD(&NBRRECS)
             CHGVAR     VAR(&NBRREC) VALUE(&NBRRECS)

/*************************/
/* WRITE NEW MEMBER INFO */
/* TO DATA AREA. FOR     */
/* PASSING TO OTHER PGMS */
/*************************/

             DLTDTAARA  DTAARA(QTEMP/BKMBRRN)

             MONMSG     MSGID(CPF2105)

             CRTDTAARA  DTAARA(QTEMP/BKMBRRN) TYPE(*CHAR) LEN(52) +
                          VALUE(&BLIB || &NFLE || &BMBR || &NBRREC +
                          || &JOBTIM || &JOBDAT)

 END:        RETURN
  
						

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.




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



RELATED CONTENT
iSeries CL programming
Taking advantage of CL advancements, starting with V5R3
Checking in on your IBM i authorization lists
Running PHP open source applications: NOBODY needs authority
Simplify the process of converting a spool file from iSeries into an Excel spreadsheet
CL program for daily backups
An automated CL method of moving a query from AS/400 to Excel
Changing user password expiration
Eight steps for creating program documentation using AS/400 utilities
DAYSPAST CLLE program for AS/400: Compares object creation date with today's date
Advanced Job Scheduler help

iSeries programmer tips
Enhancing RPG with external SQL stored procedures
Tracking data changes on IBM i with triggers
Introduction to SQLRPGLE on IBM i: Making a report
Implementing a browser interface in COBOL: Displaying database fields
Taking advantage of CL advancements, starting with V5R3
TAATOOL: Useful tools for programmers on IBM i
Implementing a browser interface in COBOL: Creating your graphic Web page
Implementing a browser interface in COBOL: Getting started
Making the most of RPG data handling on IBM i
Groovy programming on IBM i

Application Development
iSeries calling an .exe
Top 10 programmer tips
Formatted work job scheduler
Convert system date and time
Mixing free format code with embedded SQL
SQL update a field in one file from a field in another file
Webcasts for iSeries programmers
Programming advice from the pros
Easy code copying via the drag and drop method
Setting FTP time-outs

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