Cybersecurity
DevOps Cloud (ADM)
IT Operations Cloud
This article describes how to use the WHEN directive to address this issue.
A FILE SECTION field that is redefined by another field that is specified as a key, or part of a key, is not being added as a column in database tables. As an example, in the following FD the t_cod_tra and t_cgc_tra fields do not get created as table columns:
fd trans_fil.
01 reg_tra.
05 t_cod-tra pic 9(03).
05 xt_cod_tra redefines t_cod_tra pic x(03).
05 t_nom_tra pic x(40).
05 t_end_tra pic x(40).
05 t_bai_tra pic x(25).
05 t_cep_tra pic 9(08).
05 t_mun_tra pic x(25).
05 t_uf_tra pic x(02).
05 t_tel_tra pic x(11).
05 t_col_tra pic x(11).
05 t_con_tra pic x(20).
05 t_mai_tra pic x(50).
05 t_cgc_tra pic 9(14).
05 xt_cgc_tra redefines t_cgc_tra pic x(14).
05 t_ins_tra pic x(14).
05 t_hor_tra pic 9(04).
05 filler pic x(23).
This is correct behavior as the documentation for the Database Connectors explains:
REDEFINES Clause
Fields contained in a redefining item occupy the same positions as the fields being redefined. The Compiler needs to select only one of the field definitions to use. The default rule that it follows is to use the fields in the item being redefined as column names; the XFD maps fields that appear subordinate to a REDEFINES clause to column names.
The way to make this work is to use the WHEN directive:
fd trans_fil.
01 reg_tra.
$XFD WHEN xt_cod_tra != "."
05 t_cod-tra pic 9(03).
05 xt_cod_tra redefines t_cod_tra pic x(03).
05 t_nom_tra pic x(40).
05 t_end_tra pic x(40).
05 t_bai_tra pic x(25).
05 t_cep_tra pic 9(08).
05 t_mun_tra pic x(25).
05 t_uf_tra pic x(02).
05 t_tel_tra pic x(11).
05 t_col_tra pic x(11).
05 t_con_tra pic x(20).
05 t_mai_tra pic x(50).
$XFD WHEN xt_cgc_tra != "."
05 t_cgc_tra pic 9(14).
05 xt_cgc_tra redefines t_cgc_tra pic x(14).
05 t_ins_tra pic x(14).
05 t_hor_tra pic 9(04).
05 filler pic x(23).
All of the fields will now appear in the XFD generated by the Compiler and will be created as table columns in the database.
Incident Number: 2285090