Follow

Translate COBOL Occurs clause for RecordEditor/VSQL usage

COBOL Occurs Clause

The  “$XFD USE OCCURS” directive has been introduced in order to handle COBOL occurs clause. The default behavior of the compiler when generating xfd files is to flatten out the occurs field. For e.g.

       01 A.

          03 B pic x occurs 2 times.

          03 C occurs 2 times.

                05 D pic x(2).

will translate to the following columns and (lengths)  in the table

B(2) , C(4)

This is similar to specifying the “$XFD USE GROUP”directive for the B and C fields.

So for example

       01 A.

$XFD USE GROUP

          03 B pic x occurs 2 times.

$XFD USE GROUP

          03 C occurs 2 times.

                05 D pic x(2).

 

will translate to same as above. i.e  B(2) and  C(4) columns.

The “$XFD USE OCCURS” directive instructs the compiler to generate xfd xml that specifies the inclusion of the occurs fields. The COBOL runtime then uses the xfd xml to generate columns that represent the occurs instances.

For e.g.

       01 A.

      $XFD USE OCCURS

          03 B pic x occurs 2 times.

      $XFD USE OCCURS

          03 C occurs 2 times.

                05 D pic x(2).

 

translates to the following columns and (lengths) in the table.

B_1(1), B_2(1), D_1(2), D_2(2)

Note the usage of the  _<idx> as the suffix to the column names. The new columns get created with the index as prefix values.

For e.g.

       01 A.

      $XFD USE OCCURS

          03 B occurs 2 times.

      $XFD USE OCCURS

              04 C occurs 2 times.

                     05 D pic x(2).

05 E pic x(2).

translates to the following columns and (lengths) in the table.

D_1_1(2), E_1_1(2), D_1_2(2), E_1_2(2), D_2_1(2), E_2_1(2), D_2_2(2) D_2_2(2),

The “$XFD USE OCCURS” directive and the “$XFD USE GROUP” directive can be combined to partially flatten out the occurs field.

For e.g.

       01 A.

      $XFD USE OCCURS

          03 B pic x occurs 2 times.

      $XFD USE GROUP OCCURS

          03 C occurs 2 times.

                05 D pic x(2).

                05 E pic x(2).

translates to the following columns and (lengths) in the table.

            B_1(1), C_1(4), B_2(1), C_2(4)

Note: occurs fields that have a dependency clause will always be flattened to the max possible value irrespective of any directives specified.

 

 

Was this article helpful?
1 out of 1 found this helpful
Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.
Powered by Zendesk