› Clovertech Forums › Read Only Archives › Cloverleaf › Cloverleaf › Converting EBCDIC HL7 message to ASCII HL7 message
The interface is receiving an inbound EBCDIC message and it needs to be distributed as ASCII to several outbound interfaces.
Where do I set up conversion and are there any cloverleaf procs that will help in the conversion?
Sincerely
Pascal Lafond
Try hcitpstblconvert (you will find it in $HCIROOT/tclprocs/tps.tcl).
You will need to provide a name of a datamap you wish to use. Look in the reference guide for more info but one commonly used is ‘ibme2a’.
Jim Kosloskey
email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.
Oh I forgot use it at the Inbound Tab (of the inbound thread) at the ‘Tps Inbound Data’ UPoC.
Jim Kosloskey
email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.
However, the SMAT file will still be EBCDIC.
Here is a script I wrote to convert an EBCDIC SMAT file to a new-line terminated ASCII file that you might find usefull.
I give Charlie Bursell most of the credit on this one because my script is a wrapper around his script that does most of the real work.
ebcdic_smat_to_nl.ksh
#!/usr/bin/ksh
#
# Begin Module Header ==============================================================================
#
#——
# Name:
#——
#
# ebcdic_smat_to_nl.ksh
#
#———
# Purpose:
#———
#
# Convert an EBCDIC SMAT file to an ASCII new-line terminated file.
#
#——–
# Inputs:
#——–
#
# $1 = filename of the SMAT file without the .idx or .msg extension
#
#———
# Outputs:
#———
#
# $1.len10 (smat message file converted to len10 file)
# $1.nl (smat message file converted to new-line terminated file)
#
#——-
# Notes:
#——-
#
# Example of Normal Usage:
#
# mkdir /hcitest/smat
# cd /hcitest/smat
# cp /oldmsgs/prod_real/smsadt/ob_pathnet_8014.out.20001031_1300.idx.gz .
# cp /oldmsgs/prod_real/smsadt/ob_pathnet_8014.out.20001031_1300.msg.gz .
# gzip -d *.gz
#
# ebcdic_smat_to_nl.ksh ob_pathnet_8014.out.20001031_1300
#
#———
# History:
#———
#
# 2000.10.31 Russ Ross
# – wrote initial version
#
# End of Module Header =============================================================================
idx_file=$1.idx
msg_file=$1.msg
len10_file=$1.len10
nl_file=$1.nl
hcismat -i $idx_file -orsf $len10_file -sall
len10_to_nl.pl -i $len10_file -o $nl_file -c ASCII
len10_to_nl.pl
#!/quovadx/qdx5.2/integrator/bin/perl
#
# Quick and dirty to convert Length-Encoded records to New
# Line delimited records. Optionally converts EBCDIC to
# ASCII
#
# C. Bursell 07/01/1998
#
require “getopts.pl”;
require 5.002;
#
# Get input options.
#
&Getopts(’chi:o:’) || &usage;
&usage if $opt_h;
$opt_h && &usage;
$opt_c && $convert++;
&usage unless ($inputFile = $opt_i);
&usage unless ($outputFile = $opt_o);
#
# Don’t overwrite existing files without asking
#
if( -e $outputFile ) {
print “nnOutput file $outputFile already exists.nOverwrite?
$ans = getc;
print “n”;
exit 0 unless $ans =~ /^Y/i;
system “rm -f $outputFile”;
}
#
# If the input file is EBCDIC (-c flag on) we terminate the line
# with a “%” character (Hex 25) so the dd command will convert it
# to a new line (Hex 0A)
#
$term = “n”; # Default is newline (ASCII)
$term = “%” if $convert; # Hex 25 if EBCDIC
#
# Make a temporary file
#
$workFile = “work.$$”;
#
# Read 10 bytes, which is the record length. Remove leading zeroes.
# Read that many bytes. Write record with terminator to temporary file.
# Continue till we have read the entire file
#
open( LEN10, “<$inputFile" ) || die "Can't open '$inputFile': $!n";
open( WORK, ">$workFile” ) || die “Can’t create ‘$workFile’: $!n”;
while (! eof LEN10 ) {
read LEN10, $cnt, 10; # Get the record size
$cnt =~ s/0*([1-9][0-9]*)/$1/; # Remove leading zeroes
read LEN10, $line, $cnt; # Get record
print WORK “$line$term”; # Put it in temp file
}
close LEN10; # Close both files
close WORK;
#
# If we are converting from EBCDIC to ASCII, we run the file
# through the dd command and llet it do the work. Else,
# we just move the temporary file to the output file
#
if ( $convert ) {
system “dd if=$workFile of=$outputFile conv=ascii”;
} else {
system “mv $workFile $outputFile”;
}
#
# Get rid of the temporary file and we are done
#
unlink $workFile;
################################################################################
# usage- Print a usage message and die
#
sub usage {
my($myname);
($myname = $0) =~ s#.*/(.*)$#$1#;
print STDERR <<"EOF";
Usage: $myname -i -o
-o = The full path name of the file to be created to contain
new line records
-c = Convert from EBCDIC to ASCII (OPTIONAL)
-h = This help screen (OPTIONAL)
EOF
print “n”;
exit;
}
I also have a script for converting an ASCII SMAT file to an ASCII new-line terminated file that you might find handy, too
ascii_smat_to_nl.ksh
#!/usr/bin/ksh
#
# Begin Module Header ==============================================================================
#
#——
# Name:
#——
#
# ascii_smat_to_nl.ksh
#
#———
# Purpose:
#———
#
# Convert an ASCII SMAT file to an ASCII new-line terminated file.
#
#——–
# Inputs:
#——–
#
# $1 = filename of the SMAT file without the .idx or .msg extension
#
#———
# Outputs:
#———
#
# $1.len10 (smat message file converted to len10 file)
# $1.nl (smat message file converted to new-line terminated file)
#
#——-
# Notes:
#——-
#
# Example of Normal Usage:
#
# mkdir /hcitest/smat
# cd /hcitest/smat
# cp /oldmsgs/prod_real/smsadt/ob_pathnet_8014.out.20001031_1300.idx.gz .
# cp /oldmsgs/prod_real/smsadt/ob_pathnet_8014.out.20001031_1300.msg.gz .
# gzip -d *.gz
#
# ascii_smat_to_nl.ksh ob_pathnet_8014.out.20001031_1300
#
#———
# History:
#———
#
# 2000.10.31 Russ Ross
# – wrote initial version
#
# End of Module Header =============================================================================
idx_file=$1.idx
msg_file=$1.msg
len10_file=$1.len10
nl_file=$1.nl
hcismat -i $idx_file -orsf $len10_file -sall
len10_to_nl.pl -i $len10_file -o $nl_file
Russ Ross
RussRoss318@gmail.com
If you use SMAT to view the inbound SMAT file, you can click on the EBCDIC format and it will view in ASCII.
Jim Kosloskey
email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.