› Clovertech Forums › Read Only Archives › Cloverleaf › Cloverleaf › How to Generate a Message control ID
Is there any ways to generate a Message Control ID in MSH10 while inbound message hits the interface eninge, the reason is the inbound system doesnot have a msg control id in it? Thanks
Here is one way …
… code …
# Get the message ID
set midList [msgmetaget $mh MID]
keylget midList NUM mid
set msgId $timeStamp$mid
… code …
-- Max Drown (Infor)
-- Max Drown (Infor)
######################################################################
# Name: tps_setMsgId
# Purpose:
# UPoC type: tps
# Args: tps keyedlist containing the following keys:
# MODE run mode (”start”, “run” or “time”)
# MSGID message handle
# ARGS user-supplied arguments:
#
#
# Returns: tps disposition list:
#
#
proc tps_setMsgId { args } {
keylget args MODE mode ;# Fetch mode
set dispList {} ;# Nothing to return
switch -exact — $mode {
start {
# Perform special init functions
# N.B.: there may or may not be a MSGID key in args
}
run {
# ‘run’ mode always has a MSGID; fetch and process it
keylget args MSGID mh
set messageTs [clock format [clock seconds] -format %Y%m%d%H%M%S]
# Get the Cloverleaf message ID (mid)
set midList [msgmetaget $mh MID]
keylget midList NUM mid
puts “MSH.10: $mid$messageTs”
lappend dispList “CONTINUE $mh”
}
time {
# Timer-based processing
# N.B.: there may or may not be a MSGID key in args
}
shutdown {
# Doing some clean-up work
}
}
return $dispList
}
-- Max Drown (Infor)
To get MID in Xlate:
set klst [msgmetaget $xlateId MID]
set MID [keylget klst NUM]
But I would use a counter to build a Message Control ID
Charlie,
Why use a counter instead of the approach Max proposed?
The engine uses some sort of internal counter for the NUM component of the msgMid, no?
Plus, using a counter implies you have now performed a read/write disk io.
Or maybe you’re thinking of a tcl variable that gets incremented as needed?
Seem more efficient to use Max’s approach.
Curious minds…
thanks,
Steve
Depending on the receiving system, they may expect a sequential Control ID, or you may want to have a unique counter related to the specific interface. Lots of reasons to do it either way, but the right way is whichever best meets the need… 🙂
Jim Cobane
Henry Ford Health
I could not get this to work as
set klst [msgmetaget $xlateId MID]
set MID [keylget klst NUM]
received the following error
[xlt :xlat:ERR /0:initiate_xlate:08/04/2010 15:14:08] [0.0.1083320] Xlate ‘InitiateA30ToCe.xlt’ failed: Tcl callout error
erroCode: NONE
errorInfo:
bad msgId “xpm0”
while executing
“msgmetaget $xlateId MID”
I changed the xlate to use:
set klst [xpmmetaget $xlateId MID]
set MID [keylget klst NUM]
no errors and a display shows:
+++DEBUG the metadata MID value is 1083391
+++DEBUG the metadata MID value is 1083393
+++DEBUG the metadata MID value is 1083395
+++DEBUG the metadata MID value is 1083397
+++DEBUG the metadata MID value is 1083399
+++DEBUG the metadata MID value is 1083401
+++DEBUG the metadata MID value is 1083403
I do not need a sequential value, I just need a unique ID when sending the merge message to GE Centricity Enterprise. So, it’s like the previous post, what works best for the situation and done in the GUI.