· Feb 7, 2020

Ignore Control Characters (Carriage Return and Line Feed) in Complex Record Map

I understand RecordMaps can be used to send delimited files through a production without custom coding. The data segments are delimited by tilde character followed by $Char(10) in Linux/Unix. When I test the same IO data in Windows, I have $Char(13) and $Char(10) instead of just $Char(10). I like to use just tilde character for record delimiter and ignore $Char(13) and $Char(10) between the tilde and the leading data of the next segment / record. Is this good idea or not if someone wants to generate classes will it override code? I believe in X12 schema it ignored leading control characters. What are best practices for ComplexRecordMap?

Discussion (2)2
Log in or sign up to continue

I decided to create a new FileService class extending EnsLib.RecordMap.Service.ComplexBatchFileService.

The intention is to strip any $Char(13) out of the stream that gets parsed / passed to Re3cordMap.

I found CopyReplace() method in %IO.I.Stream class. I try to overwrite OnProcessInput() in FileService class. I try pInput.CopyReplace() but that method does not exist for pInput stream.

Is this a good solution approach? What am I missing? Any Stream objects experts available to help out?

Thank you for your attention

All I need to do is create a new stream and write the contents of pInput stream with $Char(13) removed and then pass the new stream to the superclass:

Class Utility.RecordMap.Service.ComplexBatchFileService Extends EnsLib.RecordMap.Service.ComplexBatchFileService
{ /// Parse the incoming file and send the resulting ComplexBatch to the targets in TargetConfigNames.
/// *** In Windows strip out any Char(13) *** Oliver T Wilms *** 2/11/2020
Method OnProcessInput(
pInput As %Stream.Object,
Output pOutput As %RegisteredObject,
ByRef pHint As %String) As %Status

Set tStatus = $$$OK
Try {
Set tLookAhead = ""
Set tmpStream = ##class(%Stream.GlobalCharacter).%New()
While 'pInput.AtEnd {
Set = pInput.Read(.len,.tStatus)
If ([ $Char(13)) {
Set = $Translate(x,$Char(13))
Do tmpStream.Write(x)
Set tStatus = ##super(tmpStream,.pOutput,.pHint)
Catch ex {
Set tStatus = $$$EnsSystemError
Quit tStatus
} }