· Apr 26, 2016

X12 Acknowledgements - How to set Filename?

I'm trying to find a good way to control the Filename for X12 Acknowledgement files, but there doesn't seem to be a way to do that without custom coding.  Here's what I figured out so far:

EnsLib.EDI.X12.Service.FileService allows you to set a Reply Target Config, which would likely be an X12 File Operation.  The Service doesn’t have any settings related to the name of the Acknowledgement file though.  That’s determined entirely by the Operation.

The Operation allows the outbound filename to be derived from the X12 Document’s Source property, by including %f in the File Name spec.  The Source property is something you can set, such as in a DTL, but the File Service doesn’t set it when generating the Reply document.

The result is that Reply files consist of a timestamp and unique counter only, as defined by the Operation’s default File Name spec, %f_%Q%!+(_a).

I want to derive the Reply file’s name from the original’s name, but to do that in the Operation I need the original filename in the Reply document.

The only way I could find to do this is to extend EnsLib.EDI.X12.Service.FileService and override the OnConstructReply callback.  That's declared in EnsLib.EDI.X12.Service.Standard, which is a base class of the X12 File, FTP, and TCP Services.

If you override OnConstructReply, you're taking responsibility for constructing the whole reply though.  That's more work than I want to do, but I was able to simplify by calling the standard constructBatchReply method.  That built the default reply doc for me in the usually way, and I just added Source to what it created for me.

For this usage, the call to constructBatchReply method should only be done if the original doc is the Interchange.  For Groups and TransactionSets you just return a success code from OnConstructReply.  The default processing will create default child docs in the reply in that case.

Here's my callback method, which is the only thing I have in my custom Service:

Method OnConstructReply(
 Output pReplyDoc As EnsLib.EDI.Document,
 pOriginalDoc As EnsLib.EDI.Document,
 ByRef pReplyCode As %String,
 ByRef pSC As %Status,
 pEarlyReply As %Boolean) As %Status
 if (pOriginalDoc.Name = "Interchange") {
  set pReplyDoc = ..constructBatchReply(pOriginalDoc, .pSC, pEarlyReply)
  set pReplyDoc.Source = pOriginalDoc.Source _ "-REPLY"
 Quit $$$OK

For more info, look at constructReply in EnsLib.EDI.X12.Service.Standard.  That's what calls OnConstructReply and constructBatchReply.

This gets the job done, but all I want to do is set the filename, so I'd much prefer if there was a simple config setting.  If anyone has an approach that doesn't require code please let me know.

Discussion (1)1
Log in or sign up to continue