Suppose you have written a large script that loads a number of files directly into ACL. As part of your validating the results, you want to create an ACL file to verify the validity of the data in each of the tables. This code was written to create a .fil table that contains the table that was being reviewed, the number of errors identified, the record on which the error occured, and the field name identified.
To get this code to work, you either need to assign a variable "Logname" or replace "%logname% with the log's name that is being reviewed.
SET FOLDER /TEMP
IMPORT PRINT TO TEMP1 "TEMP1.FIL" FROM "%logname%.LOG" 0 RECORD "Detail" 0 1 0 TEST 0 0 AT 1,1,0 7 "Invalid field" FIELD "Field_Name" C AT 1,47 SIZE 25,1 DEC 0 WID 25 PIC "" AS "" FIELD "Record_Number" X AT 1,42 SIZE 7,1 DEC 0 WID 7 PIC "" AS "" RECORD "Header1" 1 1 1 TEST 0 0 AT 1,20,0 7 "OPEN" FIELD "Table_name" C AT 1,25 SIZE 35,1 DEC 0 WID 35 PIC "" AS "" \
OPEN TEMP1
DEFINE FIELD f_Record_number COMP STRING(ABS(Record_number),10)
DEFINE FIELD f_Field_name COMP ALL(SPLIT(SPLIT(field_name,"field",2),")",1))
IMPORT PRINT TO TEMP2 "TEMP2.FIL" FROM "%logname%.LOG" 0 RECORD "Detail" 0 1 0 TEST 0 0 AT 1,5,0 7 "data validity errors detected" FIELD "Errors" C AT 1,1 SIZE 5,1 DEC 0 WID 5 PIC "" AS "" RECORD "Header1" 1 1 1 TEST 0 0 AT 1,20,0 7 "OPEN" FIELD "Table_Name" C AT 1,25 SIZE 35,1 DEC 0 WID 35 PIC "" AS ""
OPEN TEMP2
DEFINE FIELD f_Errors COMP VALUE(INCLUDE(errors,"0987654321"),0)
OPEN TEMP1
OPEN TEMP2 SEC
JOIN PKEY table_name FIELDS Table_name f_record_number f_field_name SKEY table_name WITH table_name f_errors PRIMARY SECONDARY TO TEMP3 PRESORT SECSORT OPEN
DEFINE FIELD f_table_name COMP Table_name2
EXTRACT FIELDS f_table_name F_errors f_field_name F_record_number to TEMP4 OPEN