Start of change

Example: MINENTDTA (*FLDBDY)

The following SQL script provides an example of the of the *FLDBDY value used with the Minimized entry specific data (MINENTDTA) parameter for the CRTJRN and CHGJRN commands.

Note: By using the code examples, you agree to the terms of the Code license and disclaimer information.
/* Setup of environment */
create collection payroll
create table payroll/wages (employee int, wages char(10), 
    startdate date, benefits char(50))
create index payroll/wageix on payroll/wages (employee)
CL:CHGJRN payroll/QSQJRN jrnrcv(*GEN) minentdta(*FLDBDY)

/* Changes against files to be audited */
insert into payroll/wages values (1001, '22.00/hour', 
     '01/01/2003', 'Qualifies for health benefits, 401k match')
insert into payroll/wages values (1002, '18.00/hour', 
     '10/01/2004', 'Qualifies for health benefits')
update payroll/wages set wages = '24.50/hour' where employee = 1001
update payroll/wages set wages = '19.00/hour' where employee = 1002

/* Auditing procedure */
CL:DSPJRN JRN(PAYROLL/QSQJRN) JRNCDE((R)) OUTPUT(*OUTFILE) OUTFILFMT(*TYPE5)
   OUTFILE(PAYROLL/DSPJRNOUT) ENTDTALEN(*CALC) NULLINDLEN(4)           
create table payroll/auditfile (fixeddata char(555), nvi char(4), 
   employee int, wages char(10), startdate char(10), benefits char(50))
CL:CPYF FROMFILE(PAYROLL/DSPJRNOUT) TOFILE(PAYROLL/AUDITFILE) 
   MBROPT(*ADD) OUTFMT(*HEX) FMTOPT(*NOCHK)
select nvi, employee, wages, startdate, benefits 
   from payroll/auditfile

Note: the NVI (Null value indicator) field houses metadata which reveals which columns residing within 
the journal entry were collected and what variety of data they house.  Some columns will house null 
values for fields which were collected, some will house a copy of the data deposited during the update 
operation, while others will house filler values representing the default value for that column.  Such 
filler values will appear on behalf of those columns whose contents were not changed and were not 
required to be collected.  These are the same columns which did not consume space within the journal 
entry because a copy of their value was not collected.  In order to recognize the difference between these 
three varieties, refer to the table below. The first NVI character corresponds to the first field (EMPLOYEE
), the second NVI character 
corresponds to the second field (WAGES), etc.  When the NVI value is a '0', it signifies that an exact copy 
of the field is present.  When the NVI value is a '1', the corresponding field houses a null.  When the
NVI value is a '9', the corresponding field was not collected (because it was minimized) and, therefore,
what will be displayed is the default value.

NVI        EMPLOYEE   WAGES       STARTDATE   BENEFITS                                          
0000          1,001   22.00/hour  2004-01-01  Qualifies for health benefits, 401k match         
0000          1,002   18.00/hour  2004-10-01  Qualifies for health benefits                     
0099          1,001   22.00/hour  0001-01-01                                                    
0099          1,001   24.50/hour  0001-01-01                                                    
0099          1,002   18.00/hour  0001-01-01                                                    
0099          1,002   19.00/hour  0001-01-01
The first 2 entries are for the inserts. The second 2 entries are the update before image and update after image for the first update. The last 2 entries are the update before image and update after image for the final update. Notice that the update entries have real data for the first 2 fields and default data for the second 2 fields as indicated by the null value indicators. The first field is collected because it is a key field. The second field is collected because the data within the field has changed. Any of the fixed journal entry information (for example, sequence number, journal code) can also be included by either substringing the fixed field in the audit file or creating the audit file with fields formatted such as the *TYPE5 outfile.
End of change