Previous Topic Next topic Print topic


Example 2 - Compiling with the WHEN XFD Directive

Restriction: This topic applies only when a Database Connectors license has been installed via the Micro Focus License Management System.

This example (order2.cbl) enables you to override the default table build; it allows you to force certain columns to be built that would be built by default. Add the WHEN XFD directive in front of each record, which results in the underlined fields being entered into the table:

fd p-o-file.
$xfd when p-o-record-type = "h"
 01  p-o-record.
     03  p-o-division-number                       pic 9(3).
     03  p-o-record-type                           pic x.
         88  header-record                         value "h".
         88  detail-record                         value "d".
     03  p-o-number                                pic 9(10).
     03  p-o-number-detail redefines p-o-number.
         05  picking-ticket-number                 pic 9(6).
         05  shipping-region                       pic 9(2).
         05  p-o-customer-type                     pic 9(2).
         05  p-o-customer-breakdown redefines 
               p-o-customer-type.
             07  customer-category                 pic x.
                 88  p-o-customer-retail           value "r".
                 88  p-o-customer-whlsale          value "w".
             07  customer-pay-format               pic x.
                 88  is-net-30                     value "3".
                 88  is-net-10                     value "1".
     03  p-o-date.
         05  p-o-yy                                pic 9(2).
         05  p-o-mm                                pic 9(2).
         05  p-o-dd                                pic 9(2).
$xfd when p-o-record-type = "d"
 01  p-o-detail-record.
     03  p-o-dept-number                           pic 9(3).
     03  p-o-record-type                           pic x.
     03  detail-p-o-number                         pic 9(10).
     03  p-o-shipping-info.
         05  p-o-quantity-to-ship                  pic s9(4) comp.
         05  p-o-total-quantity                    pic s9(4) comp.
     03  p-o-notes.
         05  notes-line occurs 3 times             pic x(40).
Note: p-o-record-type is entered into the table only once. The detail-p-o-number field is not part of the table, because the key overlays this area.

The following table is built in the database:

Column Name Type
p_o_division_number number(3)*
p_o_record_type char(1)
p_o_number number(10)*
p_o_yy number(2)*
p_o_mm number(2)*
p_o_dd number(2)*
p_o_dept_number number(3)*
p_o_quantity_to_ship      number(4)*
p_o_total_quantity number(4)
notes_line_1 char(40)
notes_line_2 char(40)
notes_line_3 char(40)

* The actual database data type may vary.

Note: When p_o_record_type is h, p_o_dept_number, p_o_quantity_to_ship, p_o_total_quantity, and notes_lines_1, 2, and 3 become NULL. When p_o_record_type is d, p_o_division_number, p_o_yy, p_o_mm and p_o_dd become NULL.
Previous Topic Next topic Print topic