Start of change

Example: Apply journaled changes

The following are examples of the Apply Journaled Changes (APYJRNCHG) command applied to a database physical file, integrated file system object, data queues, and data area.

The following examples show database physical files, data areas, and integrated file system objects being processed separately. However, you can use one APYJRNCHG command if you use the OBJ parameter for files and data areas, and the OBJPATH parameter for the integrated file system objects on one command call.
Note: By using the code examples, you agree to the terms of the Code license and disclaimer information.

All journaled objects

This example recovers all objects that are journaled to the journal JRN2 in one apply operation. For this example, assume that journal JRN2 is using the receiver size-option RCVSIZOPT(*MAXOPT3). Since the ending sequence number is greater than 9 999 999 999, the TOENTLRG parameter is required. The example starts applying journaled changes from the last save of the objects, to entry sequence number 500 000 000 000.

Start of changeBy default, the system honors the commitment boundaries. So if there is an object whose commitment boundary ends after sequence number 500 000 000 000, the the apply operations will not apply any changes to that object for any commit cycles that end after sequence number 500 000 000 000. The apply operation continues for the other objects that are journaled to the journal.End of change

       APYJRNCHG JRN(JRN2) OBJ(*ALLJRNOBJ)
                 FROMENT(*LASTSAVE) TOENTLRG(500000000000)
                 RCVRNG(*LASTSAVE)

Database physical file

The following command applies the changes in journal JRNA to all the members of all files in the library DSTPRODLIB that are being journaled to journal JRNA.

APYJRNCHG JRN(JRNLIB/JRNA) FILE((DSTPRODLIB/*ALL))
          FROMENTLRG(*LASTSAVE) TOENTLRG(*LASTRST)

Start of changeBecause the RCVRNG parameter is not specified, the system determines the range of journal receivers to use as a result of the save information for the files. The FROMENTLRG parameter defaults to apply the changes that begin with the first journal entry after the save of the object. The earliest required receiver is the receiver that contains the D DW journal entry indicating the earliest start of save entry for any file in DSTPRODLIB.End of change

If the file was last saved with the save-while-active function, the saved copy of each file member includes all object-level changes in the journal entries up to the corresponding F SS journal entry. In this case, the system applies changes that begin with the first journal entry that follows the F SS entry.

If the file was last saved when it was not in use (normal save), the saved copy of each member includes all object-level changes in the journal entries up to the corresponding F MS member saved journal entry. In this case, the system applies changes that begin with the first journal entry that follows the F MS entry.

The following command applies the changes to the file from the journal receiver that is currently attached to the journal:

APYJRNCHG JRN(JRNLIB/JRNA) FILE((LIBA/FILEA MBR1))
          RCVRNG(*CURRENT) FROMENTLRG(*FIRST)
          TOENTLRG(*LASTRST) OUTPUT(*OUTFILE)
          OUTFILE(MYFILE) DETAIL(*ERR)

The *CURRENT journal receiver is the journal receiver that is attached to journal JRNA at the beginning of the operation. The system applies the changes from the first journal entry in this receiver to the entry before the object was last restored. Changes are applied to member MBR1 of the file FILEA.

Because OUTPUT(*OUTFILE) is specified, an output file with the name MYFILE is created. The output file contains a record for each object, if any, for which the apply ends early because DETAIL(*ERR) is specified.

The following command applies the changes in the journal JRNA to all members of the file FILEA beginning with the first journal entry after the file member was last saved:

APYJRNCHG JRN(JRNLIB/JRNA) FILE((LIBA/FILEA *ALL))
          TOJOBC(000741/USERP/WORKSTP)

The operation continues until the specified job closes any of the members in the file that it opened. The operation is not restricted only to those journal entries that are recorded by the specified job.

Note: This example works only if you do not specify OMTJRNE (*OPNCLO) when starting journaling for the file and you did not specify RCVSIZOPT(*MINFIXLEN) or you did not use a FIXLENDTA option that would have omitted the job name for the journal at any time while the file was journaled).

Integrated file system object

The following command applies the changes in journal JRNA to the objects in the directory MyDirectory, and its subdirectories, that are being journaled to journal JRNA:

APYJRNCHG JRN(JRNLIB/JRNA) OBJPATH(('/MyDirectory')) SUBTREE(*ALL)

Because the RCVRNG parameter is not specified, the system determines the range of journal receivers to use as a result of the save information for the objects. Because the FROMENT or the FROMENTLRG parameters are not specified, the system applies the changes that begin with the journal entry for the last save of each of the objects.

If the object was last saved with the save-while-active function, the saved copy of each object includes all changes in the journal entries up to the corresponding B FW journal entry. In this case, the system applies changes that begin with the first journal entry that follows the B FW entry.

If the object was last saved when it was not in use (normal save), the saved copy of each object includes all changes in the journal entries up to the corresponding B FS saved journal entry. In this case, the system applies changes that begin with the first journal entry that follows the B FS entry.

Data area

The following command applies the changes to the data area DATA1 from the journal receiver that is currently attached to the journal:

APYJRNCHG JRN(JRNLIB/JRNA) OBJ((LIBA/DATA1 *DTAARA))
          RCVRNG(*CURRENT) FROMENTLRG(*FIRST)
          TOENTLRG(*LASTRST)

The *CURRENT journal receiver is the journal receiver that is attached to journal JRNA at the beginning of the operation. The system applies the changes from the first journal entry in this receiver to the entry before the object was last restored. Changes are applied to data area DATA1.

Note: Read the Code example disclaimer for important legal information.
Related reference
Apply Journaled Changes (APYJRNCHG) command
End of change