Grouping related fields with FFlist and Gflist
The FFlist Format specification and the GFlist Get specification might be used to control the grouping of related fields, especially repeating fields. This section is not the definitive description of FFlist and GFlist; for the formal syntax see Format-specifications and Get-specifications.
For the purposes of this discussion assume an event type defined as TSample. Assume that the event records contain a repeating section based on a triplet at offset 28. Assume the sections consist of two 8-byte fields, a first name and a last name. Assume OPTIONS SIEMTYPE(RFC3164) and that OPTIONS DELIMIT() has been allowed to default.
Assume an event record with three such sections:
Joelle | Faucher |
Vince | Hammond |
Charles | Mills |
If you define the fields in the most obvious fashion as the following:
DEF LAST Last TSample() FChar(8) GTriplet(28 8)
and then code FIELDS(... FIRST LAST ...) for the event in the parameter file, the preceding event record would format as the following:
This formatting is not an ideal one. You might say that the first and last name fields are not properly grouped, and that triplet repetition has occurred at the individual field level rather than at the section level.
You can solve that problem through the use of FFlist and GFlist. If you define the fields as the following:
DEF LAST Last TSample() FChar(8) GFlist(8)
DEF NAME Name TSample() FFlist(Inner FIRST LAST) GTriplet(28 0)
and then code FIELDS(... NAME ...) for the event in the parameter file (note the use of GFlist and FFlist(Inner ...)), then the preceding event record would format as the following:
This is an improvement.
If you wish to format each section as Name: Last, First. You can define the fields as the following:
DEF FIRST '' TSample() FChar(8) GFlist(0)
DEF LAST '' TSample() FChar(8) GFlist(8)
DEF NAME Name TSample() FFlist(None LAST MYDELIM FIRST) + GTriplet(28 0)
The record now formats as the following:
The fields FIRST and LAST have no identifying tags. You might want to prevent users from referencing them in a parameter file FIELDS() operand because the lack of tags could be confusing if the fields are used on their own outside of NAME. To do so, code NOPARM() in the context parameter of DEF. Refer the following example:
DEF FIRST '' Sample(NOPARM()) FChar(8) GFlist(0)
DEF LAST '' Sample(NOPARM()) FChar(8) GFlist(8)
DEF NAME Name Sample() FFlist(None LAST MYDELIM FIRST) +
GTriplet(28 0)
There is no difference in the formatted message.
If you need to format the names as an array, like in the following instance:
All that is necessary is to add ARRAY() to the context parameter of the NAME field, and change the tag to Names. See the following example:
Related topic