Recovering data
The data formatting or data recovery concepts are identical for all of the products in the ARCAD-Transformer suite.
The data recovery managed in ARCAD Transformer Field has the objective to allow you to carry out the automatic execution of a process from a list of physical file fields. The process will be the same (or nearly the same) for each field on the list.
The process is executed by the programs generated by ARCAD (one program per file). This program declares the file as primary and in update (or as read only, if requested). Each file record is, therefore, read once.
The process to carry out for each field is found in the main part of the program. Each record is updated at the end of the process (if the file was open in update). Unlike other transformer processes, it is possible to use this command from a list of fields of physical files without source.
The data formatting commands can be used to:
- fill in the extended part of fields (following an extension of a file’s fields). The previous data having already been copied (in *MAP *DROP, aligned on the left for an alphanumeric field, aligned on the point for a numeric field).
- build the new fields (following a field addition in the files). The old data having already been copied (in *MAP *DROP).
- carry out an update process (conversion) for the value of certain fields (In this case, there is no modification of the file structure).
- carry out an update process (conversion) for the values of certain fields while keeping a trace, in an associated file, of the old field value (or the conversion difference.
- automate the starting of a process which must be run for each one of the values in a complete series of physical file fields.
- etc...
Using a standard routine written in RPGLE, you can describe (for one copy only) the process to carry out. It is also possible to create an associated file for each file processed.
The following two commands allow data recovery:
- Generation of PF data field formatting -
AGENFMTPGM
- Execution of data formatting programs for PF fields -
AEXCFMTPGM
These two commands are executed at different times in different environments. It is also necessary to pre-configure them.
Using the AWRKSTDRTN
command, you must write (or check the existence of) a standard routine in RPGLE and only containing C cards.
This routine contains the part of the source corresponding to the process to execute for each file field.
In this routine, you can use the FRM ($$) variable names which will be substituted by the variable names of your files (and also the field length, nb. of decimals, field format, etc...).
You can also anticipate the different parts of source code according to certain cases, by testing with the Routine Check language that lead to the insertion of such and such blocks of code contained in the routine.
If you have already generated recovery programs from a routine and find that the generated code does not respond to your needs, you can modify the routine again; you must then re-generate the recovery programs.
The generation and execution of recovery programs is based on a list of physical file fields to process. This list can:
- already have been used by the propagation without modification.
- already have been used by the propagation with modification of the PF sources.
- be specifically created for generating recovery programs, without going through propagation.
For more information on the physical file fields, see Field lists.
You can copy the list, modify its contents (notably LST_CSST
and LST_JZSEL2
) before using it for generating recovery programs.
Do not hesitate to modify the LST_CSST
and LST_JZSEL2
fields, if necessary, to put either other file fields or even the values which will be tested in the standard routine in order to insert a block of code according to the case.
In the list of fields, the fields given in the below table will be used to generate the recovery programs.
Field | Length/Type | Variable | Contents |
---|---|---|---|
LST_JOBJ | 10A | $$F1 | File field to process |
LST_CSST | 10A | $$F2 | New file field |
LST_JZSEL2 | 30A | $$F3 | Third file field |
LST_CTYPE | 10A | $$TY,$$LG,$$LD | Field type, length and Nb. of decimals |
LST_CCPLT | 7A | $$FM | Field format (in transformer terms) |
LST_CTXT | 50A | $$TX | Text of complete field |
LST_CTXT | 5x10A | $$T1,$$T2,$$T3,$$T4,$$T5 | Each of the 5 parts of the text field, with 10 characters (from 1 to 10, 11 to 20, etc.…) |
LST_JLIB | 10A | $$DM | File record format |
LST_JSRCF | 10A | $$DF | File name |
LST_CATR | 10A | $$DT | Type of file (PF,PF38 or PF36) |
LST_JXLIB | 10A | File library (for FMTFLDDTAX with *FROMLIST) | |
LST_JZSEL1 | 10A | Receives the name of the recovery program generated by file. |
Objective: To automate the writing of similar programs processing the file fields.
This command is run in a development environment (ARCAD or possibly one not managed by ARCAD).
It generates program sources (and objects) dedicated to the task defined in the standard routine.
If the files to be processed undergo modification (extension or addition of fields) via ARCAD Transformer Field, you must wait until the new files are created (application of modifications + compilation) before starting the generation and compilation of these recovery programs. Otherwise, the compilations will be carried out according to the previous file description.
Correction – Personalization of generated programs
If you wish, you can modify the generated programs and recompile them afterwards.
For more information about AGENFMTPGM, refer to Generating data formatting programs – AGENFMTPGM
Objective: To automate the execution of recovery programs, file by file, member by member.
This command can be run:
- In the version where the recovery programs are generated.
- In the test environment.
- In the production environment.
- With an online list of libraries, chosen at the start up.
- On the AS400 where the programs are generated.
- On another AS400 if the generated programs were distributed.
This command does not require an ARCAD Transformer Field license; you just need to have installed ARCAD with an ARCAD Process Manager license.
It is necessary to have the same list of fields for executing the process as for generating the recovery programs.
At the beginning of the process, there is a quick verification for the presence of recovery programs (and possibly any associated files); any anomaly will stop the process from beginning.
In case of failure at the program’s execution on a file, the process continues on to the next part; the non-processed file fields change to status Abn. Once the problem is corrected, it is possible to restart the process in the list while specifying Restart after abnormal end = *YES.
For more information about AEXCFMTPGM, refer to Executing data formatting programs – AEXCFMTPGM.
Objective: To store information coming from the processed file.
For each record processed, a record can be created in an associated file.
Each field of the processed file has a corresponding field (with the same name) in the associated file. Furthermore, the associated file also includes the primary keys of the processed file in its description. The other fields of the processed file are not present in the associated file.
Utilization cases of an associated file:
- To keep an old value of fields before conversion.
- To trace the records which will be detected by the recovery program process.
- To show the recovery program’s use on the records of the processed file.
- etc.…
These associated files are not generally used directly in the application. They can be consulted via SQL, Query or by program.
The associated file has the same name as the processed file, but its description (source and object) is placed in a different library (associated file description library).
Therefore, there are as many associated files as there are processed files.
Its source is generated which contains the following fields:
- Primary keys of the processed file (same name, type and length as in the processed file; the field name is preceded with a K if the key field is also processed).
- Processed fields (same name as the field of the processed file (
LST_JOBJ
), same text. The type, length and number of decimals can be identical to the field of the processed file or the same everywhere).
To use the associated files, you must specify two library names when running the AEXCFMTPGM
command:
- Associated file description library: here you will find the empty file object generated by the associated file.
- Associated file data library: the empty associated files will be created in this library, then filled by the process of recovery programs.
These two libraries can be the same; however, you should verify that the associated file data library corresponds to the environment for which you ran the process. There are normally as many associated file data libraries as there are different executions of recovery programs.
Never put these two libraries online – there would be a risk of confusion between the file to process and the associated file (description or data).
In this case, a new FRM variable is available:
$$A1 - Indicates the field of the associated file which has the same name in the PF, but which is prefixed by FI2_ in the generated RPGLE program.
Furthermore, to create the record in the associated file, insert the following process to the standard routine:
C Eval CreateAssF = '*YES'
The record creation is only made after the processing of all the fields and only if the CreateAssF variable is at *YES.
Also, before writing, the keys of the associated file are loaded from the corresponding fields in the processed file.
Description of primary keys
To obtain a complete associated file, you must know the list of file fields which are considered as primary keys.
The primary keys correspond to the list of file fields which are considered to be the only identifier of the file’s record.
Command N° + Line N° for a command line file.
These primary keys are loaded after running the command Create database links - AUPDFLDDBR
. In this loading process, the following are considered as primary keys:
- the PF keys if they exist with the key word UNIQUE.
- if these are absent, then the keys of the first LF with the key word UNIQUE (by looking at the file xxxL1, xxxL2, then xxxLA, xxxxLB, then the others).
- if also absent, then the PF keys if they exist without the keyword UNIQUE.
- if also absent, then the keys of the first LF without the key word UNIQUE (by looking at the file xxxL1, xxxL2, then xxxLA, xxxxLB, then the others).
- if also absent: No primary key is found.
The method for finding the primary keys does not necessarily correspond to the way your physical and logical files were conceived; it is necessary to verify all the primary keys of all the physical files by:
ADSPFLDDCT
– Field Database Repository- Option 35 DSPPFKEY – Display the Primary Keys
- Option 32 WRKPFKEY – Work with the Primary Keys
Modify the primary keys if they don’t correspond to what was expected. Your modifications will be retained even if you restart the AUPDFLDDBR
command.
The AGENFMTPGM
command allows you to generate programs for formatting the data of the physical file fields from the database. By formatting, we mean all the processing to be carried out from the PF fields, whether its updates, check processes or even program calls to run for each field.
You can also automate the creation of recordings in an associated file which is also generated.
Once generated, these programs can be executed by the AEXCFMTPGM
command based on the same list.
For the generation of programs, the physical files should have already been created in a new format if you want to run the compilation of these recovery programs.
The source programs (and object, if the PGMCPL parameter is at *YES) are generated in the library indicated at the PGMLIB parameter.
These generated programs are named according to the PGMNAM and PGMNUM parameters (for example: FMTF0001, FMTF0002 etc...).
A program is generated for each file present in the field list.
Run this process in batch to avoid answering questions concerning the destination library, of the source and object, for each program (as can be the case interactively!).
The following table presents the different parameters of the AGENFMTPGM
command.
- List of impacted fields (LIST)
- Enter the name of the list file library that contains the database fields for which you wish to carry out the field formatting.
- Sub-routine for process (STDRTN)
-
Specify here, the name of the standard code routine which will be inserted into the data formatting programs for each field to be processed. To work with routines, use the
AWRKSTDRTN
command.This routine must be written in RPGLE.
- Propagation group (PRPGRP)
-
*ANY: All the files present in the fields list are processed (whatever the contents of the field
LST_CCPLT
– Field format are).Propagation group + Identification letter : Only those fields with a field format including the specified identification letter are processed.
- Work with associated files (ASSFILE)
-
Specify if you want to work with an associated file for each file processed.
*NO: No associated file is generated.
*YES: An associated file is generated for each file processed. In this case you should fill in the parameters concerning the associated file.
- Associated File-Description Library (ASSFDSCLIB)
-
This parameter is obligatory when you want to work with an associated file.
Enter the name of a library which is not part of your application; if the indicated name doesn’t exist, it will be created automatically.
In this library, the
AGENFMTPGM
command creates the source of the new associated files having the same name as each processed file. This file will contain, for every processed field, a field having the same name and text but for which the description (Type and Length) can be different. Furthermore, this file will also contain the primary keys of the processed file which allows the correspondence between the original file and the associated file. (The definition of these primary keys is accessible with the commandAWRKPFKEY
.) - Associated file-Text (ASSFTEXT)
-
Obligatory parameter for generating an associated file.
Specify the text that will be given to the associated files generated; the name of each processed file will be placed at the end of this text.
- Associated file-Indexed (ASSFKEYED)
-
Obligatory parameter for generating an associated file.
*NO: The associated file generated is not indexed on the key fields.
*YES: The associated file generated is indexed on the key fields.
- Associated file-Field type (ASSFLDTYPE)
-
Obligatory parameter for generating an associated file.
Specifies the type, that every processed field in the associated file, will have (except the keys).
*SAME: The field type will be the same as the one in the original file.
Type: Enter the type of the PF field which will be valid for all the fields of the associated file.
- Associated file-Field length (ASSFLDLEN)
-
Obligatory parameter for generating an associated file.
Specifies the length that every processed field in the associated field will have (except the keys).
*SAME. The length of the field will be the same as the one in the original file.
Length: The indicated length will be valid for all the fields of the associated file.
- Associated file-Field dec.# (ASSFLDDEC)
-
Obligatory parameter for generating an associated file.
Specifies the number of decimals for every field processed in the associated file (except the keys).
*SAME: The number of field decimals will be the same as the one in the original file.
Length: The number of indicated decimals will be valid for all the fields of the associated file.
- Name of the programs created (PGMNAME)
-
This is a model of the name of the recovery programs which will be generated.
Three or four consecutive dots must be in this model. These will be replaced by a chronological number for each program to generate.
ExamplePG...R1
orPGM....
- First program number (PGMNBR)
-
This is the starting value for the chronological number allowing you to create the generated program names.
ExampleWith the 'PG...R1' model and the starting N° 251, the programs will be named PG251R1, PG252R1, etc...
- Generated program text (PGMTEXT)
-
Enter the text that will be given to the generated programs; the name of each processed file will be placed at the end of this text.
- Recovery programs library (PGMLIB)
-
This is the library name that will receive the sources and objects of the recovery programs.
The value *CURENV corresponds to the current version library.
NoteThis library does not have to be managed by ARCAD. If it doesn’t exist, it will be created.
- Target release (TGTRLS)
-
Indicates under which OS edition the created object must be processed.
NoteThis parameter only applies to generated programs.
The possible values are as follows:
*DFT: The
ACPLOBJ
command will use the default value which was applied to the corresponding compilation command (CRTBNDRPG
).V3R2M0: Indicating this system version leads to restrictions on the lengths of fields in generated RPGLE programs: the lengths of field names are limited to 10 characters; if you generate an associated file, the names of RPGLE fields of the associated file are renamed in the I card.
ReferenceFor more information on the other possible values, refer to the IBM documentation.
- Compile generated programs (PGMCPL)
- This parameter indicates if you should compile (or not) the generated recovery programs. You can compile them later using option 9 in the
AWRKOBJARC
command. - File is being updated (UPDATE)
-
Indicates if the generated process must open the file being updated and carry out an UPDATE for every read record (after processing).
*YES: The file is opened in update in the recovery program. Each read record is therefore locked; it is updated once again after the processes are carried out on each field.
*NO: The file is opened in read-only in the recovery program. There won’t be any locking of records or updates. This is useful for processes that must not modify the contents of fields in the file; however you can work with an associated file (for which records are being added to) in this case.
- Reference document (REFDOC)
-
It is possible to specify from this command, which user document you want the generated programs attached to. If you leave the default value *NONE, you will be asked for this information once you enter one of the source editors (if you generate your programs to a version managed by ARCAD).
- Restart after abnormal end? (RUNAFTABN)
-
Allows recoveries in the case where the command was not run on all the required items.
NoteYou can check the non-processed items by displaying the list (command
AEDTLST
orADSPLST
).
The AEXCFMTPGM
command allows you to link up the execution of programs allowing the formatting of database physical file fields. The execution of recovery programs will take place file by file, data member by data member. By formatting we mean all the process to be carried out from the PF fields, whether updates, verification processes or even program calls to execute for each field.
This command can be used on a remote machine that only has ARCAD Process Manager (without ARCAD Transformer Field).
The programs to run were generated by the AGENFMTPGM
command (or even created or modified by the user). Their names are in the list of PF fields (one program per file) in the LST_JZSEL1
field (selection field).
This process first checks (before any execution) that all the necessary programs exist as objects (and also the descriptive objects of associated files, if requested).
When this is done after a database modification, the process should only be run once the data has been retrieved from the new files (with the option *MAP *DROP).
In the case of non-database files (Type PF36), the generation command (AGENFMTPGM
) can be run at any time.
However, for the execution by AEXCFMTPGM
it will be necessary to verify beforehand (and update) the actual name of each file (and possibly its library too) in the list of fields to process, as the name memorized in the list may contain “Joker” characters instead of their real value.
In this case, it is recommended to copy the list of fields in order to keep the original too (by a CRTDUPOBJ
or an AEXTLST
but not by a CPYF
).
Here are the different parameters of the AEXCFMTPGM
command.
- List of impacted fields (LIST)
-
Indicates the name and library of the list file containing the database fields for which you wish to carry out field formatting.
- Database file library (DTALIB)
-
The DTALIB parameter allows you to indicate in which library, the physical files to process, are found.
There are 2 possible values for this parameter:
*LIBL: The physical files are found in one of the libraries of the job libraries list. (Recommended option as long you have correctly verified the libraries list.)
*FROMLIST: The name of the library containing each physical file is the one present in the Fields List file (indicated in the LIST parameter).
- Identification letter (PRPLET)
-
*ANY: All the fields on the fields list are processed.
Identification letter: Only the fields, having a field format with the specified identification letter, will be processed. There is no existence check for this letter in a propagation group.
- Work with associated files (ASSFILE)
-
Specify if you wish to work with an associated file for each processed file.
*NO. No associated file is given.
*YES: Each associated file will be created and filled in relation to its description.
Of course, you must have planned this associated file directly after the command for generating formatting programs (
AGENFMTPGM
). In this case you must fill in the parameters concerning the associated file. - Associated file-description library (ASSFDSCLIB)
-
This parameter is obligatory when you want to work with an associated file.
When executing, you must re-indicate the library name, already indicated in
AGENFMTPGM
, so thatAEXCFMTPGM
can find the descriptions of associated files. - Associated file-data library (ASSFDTALIB)
-
This parameter is obligatory when you want to work with an associated file.
When running recovery programs, this library will regroup the data of associated files.
The associated files in this library will be cleared before executing the recovery programs if they are already present; however, if they don’t exist, they will be created using the object present in the descriptive library of associated files.
You can indicate the same name as the descriptive library of associated files or a different name, at each execution. The library will be created at execution if it doesn’t exist.
- Restart program library (PGMLIB)
-
This parameter is obligatory.
This is the name of the library that contains the recovery program objects.
The *CURENV value corresponds to the current object library.
The *LIBL value indicates that the recovery programs will be searched for in the libraries in the job LIBL.
- Output library non DB file (OUTLIB)
-
If not given, you must indicate the name of a library that will receive the formatted files.
If this library doesn’t exist, it will be created.
The new formatted files are created without a DB description, in the form of one single field for the entire record.
Once the
AEXCFMTPGM
process has finished, you must delete the old files (and their eventual index) in the original library, then re-create them taking into account the new description (same for the eventual index) and then re-copy the data from the OUTLIB library by a CPYF at LVLCHK(*NO).Important!This parameter is only necessary for the execution of data formatting for non-database files, that is, those having the attribute "PF36" in the fields list. If there are none in your fields list, leave this field empty.
- Recovery after abnormal end? (RUNAFTABN)
-
Allows recoveries in the case where the command was not run on all the items.
You can check the non-processed items by displaying the list (
AEDTLST
orADSPLST
).*NO: No recovery after abnormal end. If you re-run the command, it will be re-executed on all selected items.
*YES: A recovery is carried out. The command will be applied to all items on the list not having the Ok status.
Objective: To write recovery programs that allow you to carry out a calculation (default currency -> alternate currency) for each file field; the results are placed in the new file field. The conversion difference is placed in the 3rd file field.
The routine for this process
C*%CM===================================================================
C* Lines automatically inserted by ARCAD-FRM - copyright ARCAD Software
C* Calcul. DIFFERENCE field and file field allocations before file UPDATE
C CALL 'CVZECRFI'
C PARM $$F1 WCVTIN 30 9
C $$F2 PARM $$F2 WCVTAL 30 9
C $$F3 PARM WCVTEC 30 9
C PARM $$LD WCVTDC 2 0
C*%EXIT
Contents of the Field list to process
File Utilization Field
Origin Field field Selection 2 Type
CLIENTP1 CLIASS CLIAAS CLIAES P(10,0) Amt diff. Euro to Fr. Insur.
CLIENTP1 CLICAF CLIAAF CLIAEF P(15,2) Amt diff. Euro to Fr. T.O.
Generated recovery program
FCLIENTP1 UP E DISK
C*
C***********************************************************************
C* Field CLIASS : Amt diff. Euro to Fr.
C* Format T Type P(10,0)
C*
C* Lines automatically inserted by ARCAD-FRM - copyright ARCAD Software
C* Calcul. DIFFERENCE field and file field allocations before file UPDATE.
C CALL 'CVZECRFI'
C PARM CLIASS WCVTIN 30 9
C CLIAAS PARM CLIAAS WCVTAL 30 9
C CLIAES PARM WCVTEC 30 9
C PARM 0 WCVTDC 2 0
C***********************************************************************
C* Zone CLICAF : Amt diff. Euro to Fr. T.O.
C* Format T Type P(15,2)
C*
C* Lines automatically inserted by ARCAD-FRM - copyright ARCAD Software
C* Calcul. DIFFERENCE field and file field allocations before file UPDATE.
C CALL 'CVZECRFI'
C PARM CLICAF WCVTIN 30 9
C CLIAAF PARM CLIAAF WCVTAL 30 9
C CLIAEF PARM WCVTEC 30 9
C PARM 2 WCVTDC 2 0
C************************************************************************
The called program (CVZECRFI) is given the task of carrying out the conversion.
Objective: To carry out a conversion of “Franc -> Euro” in a file with a non-modified structure, while keeping the traces of conversion differences in an associated file (in a packed field of 5, including 4 decimals).
The routine for this process
C*%CM==================================================================*/
C*%CM Routine calculation for Big Bang, with associated file */
C*%CM====================================================================
C* Lines automatically inserted by ARCAD-FRM - copyright ARCAD Software
C* Calculation amount in Euro, differences stored in associated file.
C CALL 'CVZECRFI'
C PARM $$F1 WCVTIN 30 9
C $$F1 PARM 0 WCVTAL 30 9
C PARM WCVTEC 30 9
C PARM $$LD WCVTDC 2 0
C Z-ADD WCVTEC $$A1
C Eval CreateAssF = '*YES'
C*%EXIT
Contents of the Field list to process
File Utilization Field
Origin Field field Selection 2 Type Text CLIENTP1 CLIASS CLIAAS CLIAES P(10,0) Amt dif. Euro in fr. Insur.
CLIENTP1 CLICAF CLIAAF CLIAEF P(15,2) Amt dif. Euro in T.O.
Primary keys of the File
CLICOD
-> Client CodeCLIASS
-> Insurance amount (show the particularity of also being in the list of fields to process). This field is only keyed for the example as generally the only identifier for the Client file is the Client Code!
Generated associated file
A R CLIENTF1
A* Primary Keys
A CLICOD 8A TEXT('Code Client ')
A KCLIASS 10P 0 TEXT('Insurance amount ')
A* Fields
A CLIASS 5P 4 TEXT('Insurance amount ')
A CLICAF 5P 4 TEXT('T.O. amount ')
A* Keys
A K CLICOD
A K KCLIASS
Generated recovery program
FCLIENTP1 UP E DISK
F* %EXEC OVRDBF FILE(ASSFILE ) TOFILE(BIBDESC/CLIENTP1 )
FASSFILE UF A E DISK
F Rename(CLIENTF1 :ASSFILEFMT)
F Prefix(FI2_)
IASSFILEFMT
I KCLIASS FI2_$K0011
C Movel '*NO ' CreateAssF 4
C*
C***********************************************************************
C* Field CLIASS : Amount difference of Euro in Franc insurance
C* Format T Type P(10,0)
C*
C* Lines automatically inserted by ARCAD-FRM - copyright ARCAD Software
C* Calcul. DIFFERENCE field and file field allocations before file UPDATE.
C CALL 'CVZECRFI'
C CLIAAS PARM CLIASS WCVTIN 30 9
C CLIASS PARM CLIAAS WCVTAL 30 9
C CLIAES PARM WCVTEC 30 9
C PARM 0 WCVTDC 2 0
C Z-ADD WCVTEC FI2_CLIASS
C Eval CreateAssF = '*YES'
C***********************************************************************
C* Zone CLICAF : Amt difference euro in f T.O.
C* Format T Type P(15,2)
C*
C* Lines automatically inserted by ARCAD-FRM - copyright ARCAD Software
C* Calcul. DIFFERENCE field and file field allocations before file UPDATE.
C CALL 'CVZECRFI'
C CLIAAF PARM CLICAF WCVTIN 30 9
C CLICAF PARM CLIAAF WCVTAL 30 9
C CLIAEF PARM WCVTEC 30 9
C PARM 2 WCVTDC 2 0
C Z-ADD WCVTEC FI2_CLICAF
C Eval CreateAssF = '*YES'
C***********************************************************************
C If CreateAssF = '*YES'
C Eval FI2_CLICOD = CLICOD
C Eval FI2_$K0011 = CLIASS
C Write ASSFILEFMT
C Endif
C UPDATE CLIENTF1
The called program (CVZECRFI) is given the task of carrying out the conversion.