ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Regarding Journaling

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Regarding Journaling

    Hi All Dear Friends,

    I am having one query that is as follows.

    Why to use *calc when we are taking the outformat of any journal?


    Can anybody elaborate on the same.


    Thanks in advance,


    Rgds,
    Sandeep

  • #2
    Re: Regarding Journaling



    Code:
    
    ENTDTALEN 
    Specifies the maximum field length of the entry-specific data 
    portion of the journal entry when the output file is created 
    by the system. This field contains part of the variable portion 
    of the journal entries (such as the after image of records for 
    update journal entries). If the output file exists, this 
    parameter is ignored. 
    
    The range of allowable values for this parameter is shown in 
    the table at the end of this parameter description. 
    A single value or a single list of three elements can be specified. 
    
    Single Values 
    
    *OUTFILFMT: The length of the entry-specific data field in the 
    output file depends on the value specified on the OUTFILFMT 
    parameter. The attributes of this field are the same as those 
    of the entry-specific data field in the corresponding 
    system-supplied model output file. 
    
    If *TYPE1 or *TYPE2 is specified on the OUTFILFMT parameter, 
    the entry-specific data field in the output database file will 
    be a fixed length field 100 characters in length. 
    
    If *TYPE3 or *TYPE4 is specified on the OUTFILFMT parameter, the 
    entry-specific data field in the output file is a variable-length 
    field with a maximum field length of 100 characters and an allocated 
    length of 100 characters. The buffer is 2 bytes longer than the 
    maximum field length to include the length portion of the 
    variable-length field. 
    
    [COLOR=DarkRed]
    *CALC: The system calculates the length of the entry-specific data 
    field to accommodate the longest entry-specific data of all journal 
    entries in the specified receiver range. In this case, the entry-specific 
    data field is a fixed-length character field. The minimum length of the 
    field is 130 characters. If the length calculated by the system causes 
    the record format length to exceed the maximum record length, a message 
    is sent and the entry-specific data field is truncated. See the table 
    at the end of this parameter description for the possible maximum 
    record lengths of the various data types that can be specified. 
    [/COLOR]
    
    field-length: Specify the number of characters for the field length. 
    In this case, the field is a fixed-length character field. The maximum 
    value prevents the total record length of the output file from being 
    greater than the length allowed for physical database files. A 
    nonzero value is required by the system to ensure that the field 
    exists when the output file is created. 
    
    See the table at the end of this parameter description for the allowable 
    field lengths of the various data types that can be specified 
    
    Element 1: Variable-Length Field 
    
    To specify a variable-length field, specify *VARLEN for the first 
    element and length values for the last two elements (or let the 
    system use the default values). 
    
    *VARLEN: The entry-specific data field is a variable-length field. 
    This value can be specified only when OUTFILFMT(*TYPE3) or 
    OUTFILFMT(*TYPE4) is specified. 
    
    Element 2: Maximum Field Length 
    
    The maximum length of the variable-length, entry-specific data field. 
    
    [COLOR=DarkRed]
    *CALC: The system calculates the maximum length of the entry-specific 
    data field to accommodate the longest entry-specific data of all 
    journal entries in the specified receiver range. The minimum length 
    of this field is 130 bytes. The corresponding buffer length 
    is 132 bytes: 130 bytes of data and 2 bytes for the length portion 
    of the variable-length field. [/color]
    
    field-length: Specify the number of characters for the maximum 
    field length. See the table at the end of this parameter description 
    for the allowable field lengths of the various data types that can 
    be specified. 
    
    Element 3: Allocated Length 
    
    The allocated length of the variable-length entry-specific 
    data field. 
    
    *FLDLEN: The allocated length is the same as the maximum 
    length of the field. 
    
    allocated-length: Specify the number of characters for 
    the allocated length. 
    
    [COLOR=DarkRed]
    If *CALC is specified for the second element and the system-calculated 
    maximum field length is smaller than the specified allocated length, 
    the allocated length is set to the maximum field length. If the 
    maximum field length is specified, the allocated length cannot 
    exceed the maximum field length. [/color]
    
    
    Table 5. Range of Values for ENTDTALEN Parameter Output 
    File Format  Entry- Specific Data Format  Null Value Indicators Format  
    
    
    Entry 	Data 			Length  	Maximum Record Length  
    *TYPE1  Fixed  Not applicable                  1-32641  			32766  
    *TYPE2  Fixed  Not applicable                  1-32611  			32766  
    *TYPE3  Fixed  Fixed                                1-32596  			32766  
    *TYPE3  Fixed  Variable                           1-32570  			32740  
    *TYPE3  Variable  Fixed                           1-32570  			32740  
    *TYPE3  Variable  Variable                       1-32568  			32738  
    *TYPE4  Fixed  Fixed                                1-32596  			32766  
    *TYPE4  Fixed  Variable                            1-32570  	 		32740  
    *TYPE4  Variable  Fixed                            1-32570  			32740  
    *TYPE4  Variable  Variable                       1-32568  			32738  
    
    Note: When the file contains variable-length fields, the maximum  
    record length does not include the 2 bytes per variable-length field.  
    
    
    
    
    ***More Information***
    
    
    After all these years, journaling is still a seldom-used and rarely understood 
    feature of OS/400-i5/OS and its integrated database, DB2 UDB for iSeries 
    formally DB2/400). Many sites simply don't know how to set it up properly 
    to perform its chief function of providing another level of data protection. 
    Here, and in the next few installments, we'll discuss what journaling is, 
    how it works, and how to set it up to give you the greatest level of 
    data protection.
    
    What journaling is and how it works
    
    Journaling, generally speaking, is a process of recording activity. In accounting, 
    it is the process of recording financial activity -- monies in and monies out. 
    On the iSeries, journaling refers to the process of recording object activity.
    
     
      
    Journaling on the iSeries typically involves the recording of the activity related 
    to files, namely, physical files. When a file is being journaled, activity such as 
    file-opens, file-closes and data updates are recorded. For example, when a program 
    writes out a new record or updates an existing one, the system makes an entry in 
    the associated journal. The entry contains such information as the job name and 
    program name that made the change(s) to the file, as well as a copy of the record 
    that was changed. (Note: Journaling can be configured to record a copy of the 
    record before it is changed and/or to record a copy of the record after it 
    is changed.)
    
    How to set up journaling in three easy steps
    
    
    
    Create one or more journal receivers. Use the Create Journal Receiver (CRTJRNRCV) 
    command to create a journal receiver. Think of the journa as a notebook binder and 
    the journal receiver as the pages (i.e., the notebook paper where information is written). 
    The journal receiver is where the journal entries are actually recorded. The journal 
    "connects" the receiver to the file. It's a good habit to name the journal receiver 
    the same as the journal, plus a numeric suffix such as 0 or 1. (See the next step 
    on what to name the journal.) Also, you should put journal receivers in the 
    same library as the file. (This is very important in order to simplify recovery 
    procedures, which we will discuss in Part III.) For maximum protection, consider 
    storing the journal receiver in a different ASP than the file so that their storage 
    will not be on the same disk unit.
    
    
    Create a journal. Use the Create Journal (CRTJRN) command to create a journal and 
    specify the receiver created in step 1. Although you can journal multiple files to 
    the same journal (and, in some cases, that is actually preferable), you will generally 
    want to have a journal "serving" a single file. A good practice is to name the journal 
    the same as the file and put it in the same library as the file, but store it in the 
    same ASP as the journal receiver.
    
    
    Start journaling the file. This is done by using the Start Journal Physical File 
    (STRJRNPF) command. This is how you associate a file to a journal. Once the association 
    is made, the system will record in the journal receiver a copy of any record added, 
    updated or deleted from the file. Other activity, such as when the file is opened 
    and closed, can also be recorded in the journal receiver if you choose by selecting 
    the appropriate options on the STRJRNPF command.
    
    For more information on the journal commands mentioned above and other journal-related 
    commands, please see the subsequent section "Quick reference to journaling commands."
    
    Four basic journal entry categories
    The most common journal entries fall into four basic categories. Each category is 
    represented by a one-character code (shown in parenthesis in the following list). 
    Within each category are a number of different journal entry types. Each journal 
    entry type is represented by a two-character entry code (also shown in parenthesis 
    within the category descriptions below).
    
    
    Journal and journal receiver operations (J). These include such things as references 
    to the previous receiver (PR) or the next receiver (NR) in a chain. Also, at IPL-time, 
    an entry is made (e.g., an IN entry for IPL after normal end) marking a critical 
    chronological boundary in the file activity.
    
    
    File operations (F). This category includes file opens (OP) and file closes (CL).
    
    
    Record operations (R). Record updates (UP), deletes (DL), and new records written 
                          (PT and PX) all fall into this category.
    
    
    Commitment control (C). Anything related to commitment control falls into this category. 
                            Some examples are begin commitment control (BC), 
                            start a commit cycle (SC), commit operation (CM) 
                            and rollback operation (RB).
    
    There are other categories and entry types in addition to those listed above. However, 
    those are what you will come across most often. For a complete listing, see the  
    documentation or online help.
    
    Quick reference to journaling commands
    
    
    APYJRNCHG.  Uses the journal entries to apply changes that have occurred since a 
                database file was saved or some other specified time.
    
    CHGJRN.     Use this command to change the attributes of a journal or to attach new journal 
                receivers to a journal.
    
    CMPJRNIMG.  This command compares and lists the difference between the before-image and 
                after-image of a record, or between the current after-image of a record and 
                the previous after-image of the record.
    
    CRTJRN.     Use this command to create a journal.
    
    CRTJRNRCV.  Use this command to create a journal receiver.
    
    DLTJRN.     Use this command to delete a journal.
    
    DLTJRNRCV.  Use this command to delete a journal receiver.
    
    DSPJRN.     This command displays or prints the journal entries that are in the journal 
                receivers associated with the specified journal. This command has outfile 
                support so you can list the journal entries to a database output file for 
                further processing or analysis.
    
    DSPJRNRCVA. Use this command to display the attributes of a journal receiver.
    
    ENDJRNPF.   This command ends journaling for the specified physical file.
    
    RCVJRNE.    This command allows a specified user program to continuously receive 
                journal entries one at a time as they are written to the journal. 
                The behavior is similar to an exit program.
    
    RMVJRNCHG.  Use this command to remove changes that have occurred to a database 
                file from a specified point in time to some previous point in time 
                (allowed only if before-images were recorded during the time).
    
    RTVJRNE.    Use this command to retrieve a journal entry and place it in CL 
                program variables.
    
    SNDJRNE.    Use this command to write user-defined entries to a journal 
                (i.e., journal receiver).
    
    STRJRNPF.   Use this command to start journaling for the physical file.
    
    WRKJRN.     This command displays a menu from which you can perform many 
                journal-related functions, such as system-assisted recovery of 
                journaled files.
    
    WRKJRNA.    This command displays the attributes of a journal and the 
                associated receivers.
    All my answers were extracted from the "Big Dummy's Guide to the As400"
    and I take no responsibility for any of them.

    www.code400.com

    Comment


    • #3
      Re: Regarding Journaling

      Thank you ,

      Rgds
      Sandeep

      Comment


      • #4
        Re: Regarding Journaling

        Hi Sandeep,
        *CALC parameter is very useful in extracting the journal entries. This will contain the fields value (all fields in the file ). Though these entries are not in format which you can see and analyze the values. As packed fields will appear like junk values.
        take that part into some file. (Specific Data part of the outfile)

        Now copy that data into structure of the file with option *NOMAP and that will exactly map to file for which you gathered the entries.

        I hope this cleared your doubt. Please let me know if you need any more information

        Comment

        Working...
        X