Parsing a long header field into separate fields

Override tables can be used to parse long header fields into separate fields. This is helpful, for example, when the job name is embedded in a long header field. The job name can be extracted from the header field, assigned to a field, and used for routing or printing on a banner page. When you create an override table, the parsing command should be entered into the Value field on the Rule Actions dialog box.

The following links provide descriptions and examples of the three methods for parsing data.

See also:


Using a character offset

The character offset method is used to parse data starting at the first position specified and proceeding until the length specified.

Command Syntax

parse(FieldSource, FirstPosition, Length)

Parameters

FieldSource – The field that contains the string to be parsed.

FirstPosition – The first position of the string to be extracted.

Length – The length of the string to be extracted. If the length specified is zero (0) or if the length is greater than the remaining data, then all data to the last character will be used.

Example

Data: PRINT100STD0C

Command

Result

parse(NDHBDNAM,1,8)

PRINT100

parse(NDHBDNAM,9,4)

STD0

parse(NDHBDNAM,13,0)

C

Using a single delimiter

The single separator method is used parse data based on the delimiter, the field number, and the length.

Command Syntax

parse(FieldSource, Delimiter, FieldNumber, Length)

Parameters

FieldSource – The field that contains the string to be parsed.

Delimiter – The character the marks the beginning and the end of the field. If a comma or backslash is used as the first character of the delimiter, then a backslash must precede the delimiter in the command. For example, a backslash delimiter will be show in the command as \\.

FieldNumber – The first position of the field used for extraction based on the delimiter specified.

Length – The length of the string to be extracted. If the length specified is zero (0), then all data from the FieldNumber through to the last character will be used.

Example

Data: PRINT1,STD,CDATA

Command

Result

parse(NDHBDNAM, \,, 1, 0)

PRINT1

parse(NDHBDNAM, \,, 2, 0)

STD

parse(NDHBDNAM, \,, 3, 1)

C

Using double delimiters

The double separator method is parse data based on the starting delimiter, the ending delimiter, the field number, and the length.

Command Syntax

parse(FieldSource, StartingDelimiter, EndingDelimiter, Length)

Parameters

FieldSource – The field that contains the string to be parsed.

StartingDelimiter – The character that marks the beginning of the string. If a comma or backslash is used as the first character of the delimiter, then a backslash must precede the delimiter in the command. For example, a backslash delimiter will be shown in the command as \\.

EndingDelimiter – The character that marks the end of the string. Again backslash is required when using a comma or backslash as a delimiter.

Length – The length of the string to be extracted. If zero (0) is specified as the length, then the full string between the delimiters will be used.

Example

Data: CJ,P038,FC=6,F=OCR1,ID=J0006600,ACCOUNT=DC

Command

Result

parse(NDHBDNAM, \,F=, \,, 0)

OCR1

parse(NDHBDNAM, \,ACCOUNT=, \,, 0)

DC

parse(NDHBDNAM, \,P, \,, 10)

038

Common scenario

When receiving a print job from a mainframe using BARR/PRINT TCP/IP (the Barr LPD service), the mainframe LPR software often sends a very long job name in the following form:

JESNAME.USERNAME.JOBNAME.JOBID.DATASET.?

For example, the following job name was received from IP Printway, the IBM LPR software:

BAR6JES2.MARKD.APSIVP.JOB08025.D0000108.?

Operators would like to see the actual job name (that is, APSIVP) and the Job ID parsed into a separate fields. This scenario assumes that the user name is already received in another field; therefore, that field will not be parsed.

The parse operation is typically used in an action statement of the Override Table, in the following manner:

FIELD2 = parse(FIELD1,x,1,0)

Here is a sample Override Table that separates out the JESNAME, the JOBID, and finally the JOBNAME into separate fields. JOBNAME is done last because it is configured to write back into the same field from which it came from and actually overwrite the long job name.

Rules Editor Dialog Box

All the actions parse on the NDHDJNAM (LPD Custom Job Name) field.