Subfiles sometimes have extra data trailing after the desired content. This article discusses the cause and solution.
When creating a subfile you may see extra data trailing after the desired content. This can be caused by specifying DCB characteristics on the DD statement that conflict with the record length VISION:Builder expects. By default VISION:Builder will try to allocate a subfile with DCB characteristics that match the output requirements, so no DCB need be specified on the DD for a subfiles. If conflicting DCB attributes are encountered, the following warning message is issued:
MK4DC03 TYPE 1 LRECL DISCREPANCY M4SUBFn -- LRECL OF nnnnn FROM DD/HEADER LABEL USED
VISION:Builder does not clear the subfile buffer area before populating it, so if the LRECL specified by the user in the DCB is larger than the sum of the fields, the unused part will contain whatever was in that area of storage.
The simplest solution is to not specify the DCB on the DD and let VISION:Builder handle it.
If for some reason the file has other DCB requirements, the user must initialize the unused trailing area.
This could be accomplished by defining a temporary field of the appropriate length which are initialized to blanks and making that the last output field to the subfile.