IFTRAIL parameter is used to update count and total values in an existing trailer (last) record to reflect the actual data records in the output data set using COUNT and TOTAL features of TRAILER1. TRAILER1 lets you build a new trailer record but IFTRAIL lets you update an existing trailer record. When you specify IFTRAIL
in DFSORT, it means “If Trailing,” It controls the processing of trailing records in the input data. So, if your input data contains trailing records (records that do not conform to the standard length), the IFTRAIL
parameter allows you to include them in the output.
The syntax for the IFTRAIL operand of the OUTFIL statement is:
IFTRAIL=(TRLID=(logexp),TRLUPD=(c:item,…),HD=YES)
Note: TRLID and TRLUPD are mandatory. HD=YES is optional.
IFTRAIL can’t be used with HEADER1, TRAILER1, HEADER2, TRAILER2, NODETAIL, SECTIONS, LINES, SPLIT, SPLITBY, SPLIT1R, REPEAT, FTOV, VTOF, VLTRIM or VLFILL in OUTFIL.
TRLID=(logexp)
The criteria to be tested to determine if a record is the trailer record.
e.g. TRLID=(1,2,CH,EQ,C’99')
TRLUPD=(c:item,…)
The position where each count or total is to be updated in the trailer record.
c: specifies the output position (column) in the trailer record to be updated. If not specified it defaults to 1:
Any of the following count and total items can be used as described for TRAILER1
COUNT=(edit) COUNT=(to) COUNT+n=(edit) COUNT+n=(to) COUNT-n=(edit) COUNT-n=(to) TOTAL=(p,m,f,edit) – TOTAL=(p,m,f,to) – TOT=(p,m,f,edit) TOT=(p,m,f,to)
HD=YES: The header (first) record will not be used to determine the count or totals. In IFTRAIL identified trailer record will not be used to determine the count or totals.
Note: For HD=YES, OUTFIL processing for INCLUDE, OMIT, BUILD, OVERLAY etc. will be bypassed for the header record. If HD=YES is specified, the TRLID test will not be applied to the first record.
IFTRAIL
, you have the flexibility to tailor the treatment of trailing records based on your specific sorting or merging requirements.Example 1: FB file with Header & Trailer splitted into two output files.
INPUT: H 2020/01/06 D Field1 0100 D Field2 0200 D Field2 0118 D Field1 0150 D Field1 0025 D Field2 1000 D Field2 0310 T X 0007 QR 001903 D52-007-321-7526
OPTION COPY OUTFIL FNAMES=OUTFIL1, INCLUDE=(3,6,CH,EQ,C'Field1'), IFTRAIL=(HD=YES,TRLID=(1,1,CH,EQ,C'T'), TRLUPD=(6:COUNT=(M11,LENGTH=4), 14:TOT=(10,4,ZD,TO=ZD,LENGTH=6))) OUTFIL FNAMES=OUTFIL2, INCLUDE=(3,6,CH,EQ,C'Field2'), IFTRAIL=(HD=YES,TRLID=(1,1,CH,EQ,C'T'), TRLUPD=(6:COUNT=(M11,LENGTH=4), 14:TOT=(10,4,ZD,TO=ZD,LENGTH=6)))
OUTPUT: OUTFIL1 H 2020/01/06 D Field1 0100 D Field1 0150 D Field1 0025 T X 0003 QR 000275 D52-007-321-7526 The trailer record has a count (0003) and total (000275) for the three included data records. OUTFIL2 H 2020/01/06 D Field2 0200 D Field2 0118 D Field2 1000 D Field2 0310 T X 0004 QR 001628 D52-007-321-7526 The trailer record has a count (0004) and total (001628) for the four included data records.
Example 2: VB file with trailer and without header.
INPUT Len|Data 14 D52 Frank 13 D51 Marc 16 E07 William 15 C21 Martin 17 H05 Sri Hari 37 999 2020-07-01 2020-07-06 3
SORT FIELDS=(5,3,CH,A) OUTFIL IFTRAIL=(TRLID=(5,3,CH,EQ,C'999'), TRLUPD=(34:COUNT+1=(EDIT=(IIIT)))) Note: As IFTRAIL does not process the trailer record as a data record & as we want the trailer record included in the count, we use COUNT+1 in TRLUPD.
OUTPUT Len|Data 15 C21 Martin 13 D51 Marc 14 D52 Frank 16 E07 William 17 H05 Sri Hari 37 999 2020-07-01 2020-07-06 6
Example 3: Multiple FB files with header and trailer merged into one file.
INPUT FILE-1 0 27-80273-5218 1 MORGAN HILL CA -3.01 -1.07 1 ARMONK NY +6.22 +1.52 1 DETROIT MI +3.05 -5.61 9 COUNT=0003 TOTAL1=+06.26 TOTAL2=-05.16 FILE-2 0 27-80273-5218 1 BUFFALO NY -8.05 +3.83 1 GILROY CA +2.75 +1.97 9 COUNT=0002 TOTAL1=-05.30 TOTAL2=+05.80
SORT FIELDS=(1,1,CH,A,17,2,CH,A,3,12,CH,A) OUTFIL OMIT=(1,1,CH,EQ,C'0'), IFTRAIL=(HD=YES,TRLID=(1,1,CH,EQ,C'9'), TRLUPD=(9:COUNT=(M11,LENGTH=4), 22:TOT=(21,5,SFF,EDIT=(STT.TT),SIGNS=(+,-)), 37:TOT=(28,5,SFF,EDIT=(STT.TT),SIGNS=(+,-))))
OUTPUT 0 27-80273-5218 1 GILROY CA +2.75 +1.97 1 MORGAN HILL CA -3.01 -1.07 1 DETROIT MI +3.05 -5.61 1 ARMONK NY +6.22 +1.52 1 BUFFALO NY -8.05 +3.83 9 COUNT=0005 TOTAL1=+00.96 TOTAL2=+00.64
Understanding and effectively using the IFTRAIL
parameter in DFSORT is crucial for managing trailer records during data processing tasks. Whether you are sorting, merging, or performing other operations, incorporating IFTRAIL
appropriately ensures that your processing is thorough and accurate.
Read Trailer & Header – Click Here SyncSort Manual: Click Here
A well-maintained product backlog is crucial for successful product development. It serves as a single…
Incremental value to the customer refers to the gradual delivery of small, functional parts of…
A Product Market refers to the group of potential customers who might be interested in…
The Professional Agile Leadership - Evidence-Based Management (PAL-EBM) certification offered by Scrum.org is designed for…
The Professional Agile Leadership (PAL I) certification, offered by Scrum.org, is designed to equip leaders…
Choosing the right Scrum Master Certification depends on your current experience and career goals. If…