XCOM™ Data Transport® for z/OS
XCOM™ Data Transport® for Windows
XCOM traces for both z/OS and Windows show that XCOM is sending/receiving the same number of records and blocks on each side of the transfer i.e. no extra bank record is being written by XCOM to the Windows file.
When Windows writes the file it adds a CRLF (Carriage Return and Line Feed) to the end of each line in the file including the last one.
If the transferred file is opened in a Windows editor like Notepad/Notepad++ the last CRLF appears to be an extra blank line e.g. file test1.txt contains 5 lines with "ABC" on each line but shows 6 lines with the last blank line:
When examining the file in hex e.g. PowerShell command "format-hex" it will show the hex characters 0D 0A (CRLF) at the end of the last line:
PS C:\temp> format-hex test1.txt
Path: C:\temp\test1.txt
00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
00000000 41 42 43 0D 0A 41 42 43 0D 0A 41 42 43 0D 0A 41 ABC..ABC..ABC..A
00000010 42 43 0D 0A 41 42 43 0D 0A BC..ABC..
Therefore the solution is that the Windows application that is processing the file needs to be able to handle the CRLF at the end of the last line.
One alternative option is to use an XCOM post-processing script to remove the final CRLF after the file has been transferred e.g. customize xcomend.bat to call a script to remove the final CRLF.
See this PowerShell script xcomend.ps1 I created after finding references on the web on how to Remove last line from file with Powershell (including checking if the CRLF exists):
$file = $args.get(0).Substring(1)
write-host "-file: " $file
$stream = [System.IO.File]::Open($file,[System.IO.FileMode]::Open)
$stream.Position = $stream.Length - 2
$bytes = 0..1 | %{ $stream.ReadByte() }
$compareBytes = 13,10 # CR,LF
if ("$bytes" -eq "$compareBytes") {
$stream.SetLength($stream.Length - 2)
}
$stream.Close()
$stream.Dispose()
powershell.exe -command "& '%XCOM_HOME%\xcomend.ps1' \"-%file%\"" >> c:\temp\xcomend.out
PS C:\temp> format-hex test1.txt
Path: C:\temp\test1.txt
00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
00000000 41 42 43 0D 0A 41 42 43 0D 0A 41 42 43 0D 0A 41 ABC..ABC..ABC..A
00000010 42 43 0D 0A 41 42 43 BC..ABC
Note this is an example and XCOM Support does not provide any support for custom post-processing scripts.