Below is a section of code where we create the file and add the fhs/bhs segments. This snippet is in the RUN section of a tps proc. Hope this helps.
set slash “\”
set carrot “^”
set rep “~”
set sub “&”
set field “|”
set sendApp $systemName
set fhs “FHS”
set bhs “BHS”
set recApp “BAR”
set msgCtl “”
set segEnd r
# set directory path
set root_path [exec env HCIROOT]
#echo “ROOTpath: $root_path”
set site_path [exec env HCISITEDIR]
#echo “SITEpath: $site_path”
append site_path “/billingOUT/”
#echo “SITEpath: $site_path”
;# Get the time in system seconds
set systemTime [clock seconds]
;# Set the time using the hour, minute and second descriptors.
set CurDate [clock format $systemTime -format {%Y%m%d}]
set CurDateTime [clock format $systemTime -format {%Y%m%d%H%M}]
#echo “CurDate: $CurDate”
# set the user data… for the message
set filename [append systemName “.” $hosp “.” $CurDate]
set fullname $site_path$filename
if {![file exists $fullname] } {
echo “File doesn’t exist”
set curFileID [open $fullname a+]
puts $curFileID $fhs$field$carrot$rep$slash$sub$field$sendApp$field$hosp$field$recApp$field$hosp$field$CurDateTime$segEnd
puts $curFileID $bhs$field$carrot$rep$slash$sub$field$sendApp$field$field$field$field$CurDateTime$segEnd
close $curFileID
}