Example 25

  OPTION COPY
  OUTFIL HEADER2=(1:'First',13:'Initial',22:'Last',37:'Score',/,
                  1:10'-',13:7'-',22:11'-',35:7'-'),
     PARSE=(%00=(STARTAFT=C'LAST-> ',ENDBEFR=C' ',FIXLEN=11),
            %01=(STARTAFT=C'FIRST-> ',ENDBEFR=C' ',FIXLEN=11),
            %02=(STARTAFT=C'INITIAL-> ',ENDBEFR=C' ',FIXLEN=7),
            %03=(STARTAFT=C'SCORE-> ',FIXLEN=7)),
     BUILD=(1:%01,13:%02,22:%00,
            35:%03,SFF,EDIT=(SIIIT.T),SIGNS=(,-))

This example illustrates how you can create a report from FB input records with variable position/length fields, such as keyword delimited values.

The 70-byte input records might look like this:
     LAST-> Clark   FIRST-> Oscar     INITIAL-> D   SCORE-> +98.2
  LAST-> Roberts  FIRST-> Harriet   INITIAL->    SCORE-> -152.6
   LAST-> Stein FIRST-> Gertrude INITIAL-> V SCORE-> +5.1

Note that each record has four variable fields each identified by a specific keyword. The fields do not start and end in the same position in every record and they have different lengths in different records.

The output report has RECFM=FBA and LRECL=42 and looks like this:
First       Initial  Last           Score
----------  -------  -----------  -------
Oscar       D        Clark           98.2
Harriet              Roberts       -152.6
Gertrude    V        Stein            5.1

In order to create a report like this from variable position/length fields, we use HEADER2 to create the page header, and PARSE and BUILD to create a fixed parsed field from each variable field. We use %00 to create an 11-byte fixed parsed field with the extracted 'LAST-> ' value. We use %01 to create an 11-byte fixed parsed field with the extracted 'FIRST-> ' value. We use %02 to create a 7-byte fixed parsed field with the extracted 'INITIAL-> ' value. We use %03 to create a 7-byte fixed parsed field with the extracted 'SCORE-> ' value. Since the fourth field (%03) is extracted as signed and padded on the right with blanks, we treat it as SFF format in order to edit it.