For reference here is part of the code snippet I have at the beginning of my first Business Process. The key item here is to get the SessionId from the request header, then cache all the configuration information in ^EDI.Temp. This way as the messages flow around the various business processes and operations I can lookup any of the configuration data by grabbing the session ID from the message and looking it up in ^EDI.Temp(<sessionID>,…).
// Get Buisness Process Settings
//
// Look at the incoming request message to find the cleint ID then use that to access
// the customer specific parameters requried to create the basic X12 837 document.
//
// This data is cached into ^EDI.Temp("Request Data",<ClientID>,...) so that other parts
// of the production can work with the same set of settings and not have to look them up each time.
//
// This roughly equivalent to the ##class(Ens.Director).GetHostSettings function except we need
// settings based on the client and not on the Process.
//
#dim request As EDI.TransactionSetHeader
#dim process As Ens.BusinessProcess
Set tTimeStamp=$Translate($ZDateTime($Horolog,8,2),":")
Set tConfigName=process.%ConfigName
Set tBusinessName=request.BusinessName
Set tClientID=request.ClientID
Set tSessionID=process.%PrimaryRequestHeader.SessionId
//
Set tTable="EDI_Customer_"_tClientID
If '$Data(^Ens.LookupTable(tTable)) {
Set status=$$$ERROR($$$GeneralError,"Lookup table '"_tTable_"' not defined")
Quit
}
Set tClearingHouse=$Get(^Ens.LookupTable(tTable,"ClearingHouse"))
Set tCHSTable="EDIClearingHouse_"_tClearingHouse
If '$Data(^Ens.LookupTable(tCHSTable)) {
Set status=$$$ERROR($$$GeneralError,"Lookup table '"_tCHSTable_"' not defined")
Quit
}
//
// Save the settings in the temporary cache, merge the two tables so the cache contains
// the entries for both the client and the clearing house settings.
//
Merge ^EDI.Temp("Request Data",tSessionID)=^Ens.LookupTable(tTable)
Merge ^EDI.Temp("Request Data",tSessionID)=^Ens.LookupTable(tCHSTable)
//
// Add dynamic data to the table so we don't have to look it up again as well
//
Set ^EDI.Temp("Request Data",tSessionID,"ConfigName")=tConfigName
Set ^EDI.Temp("Request Data",tSessionID,"BusinessName")=tBusinessName
Set ^EDI.Temp("Request Data",tSessionID,"ClientID")=tClientID
Set ^EDI.Temp("Request Data",tSessionID,"TimeStamp")=tTimeStamp
Then to use it in later Business Processes (or Operation) I have this code at the beginning.
// Get Buisness Process Settings
//
// Look at the incoming request message to find the business name then use that to access
// the customer specific parameters requried to create the Interchange wrapper ISA/GS..GE/IEA
//
;Set tTimeStamp=$Translate($ZDateTime($Horolog,8,2),":")
#dim request As EDI.TransactionSetHeader