BizTalk macro for datetime with 12 digit date - biztalk

I want the macro to use send port to generate a file with file name Timestamp must be 12 characters in length
eg: 201904060232_testfile.csv
I tried to us %datetime_bts2000% but it have 15 digit.
can anybody help me here?

Here is a list of all the Send Port Macros. BizTalk Server: List of Macros
Unfortunately there isn't one that matches what you want, but the usual work around is to set the File.ReceivedFileName property (either in an Orchestration or using BRE Pipeline Framework) and use the %SourceFileName% macro.

Related

How can I write a DB2 pl/sql script in DBeaver/DBVisualizer

How can I write a simple DB2 pl/sql script in DBeaver/DBVisualizer? I am basically trying to create dynamic SQL (in a loop) and then run it. So for this I will need variables such as the SQL string, build, etc. and then run the script that was created dynamically.
Here is an example in SQL Server. I want to write something like this for DB2:
BEGIN
DECLARE #example VARCHAR(15) ;
SET #example = 'welcome' ;
SELECT #example;
END
dbvis lets you develop scripts for Db2.
You need to know some basics.
First you need to tell dbvis that there is an additional statement delimiter other than the default ; semi-colon. Db2 needs to know the difference between the end of an interim-statement and the end of a compound block and for this Db2 uses an additional delimiter/terminator for the end of a block.
You can either specify this block delimiter/terminator inside the script with the #delimiter command (specific to dbvis), or you can configure the delimiter via the dbvis settings GUI (this is the better approach). This depends on the version of your dbvis.
Many people use the # character as the block delimiter when writing compound SQL for Db2 although other characters are possible (as long as it is different from the default semi-colon).
If you want your scripts to be runnable by Db2 command line processor directly without using dbvis (i.e. to run the scripts from the command line shell (cmd.exe or bash/ksh etc) then you would not use the #delimiter command because that is only known to dbvis. The Db2 command line processor understands the syntax --#SET TERMINATOR # to change the delimiter on the fly inside scripts, and it also has a command line option (-td#) to let you specify the alternative delimiter via the command line.
Second you need to be aware of which platform (Db2-for-Z/OS, Db2-for-i, Db2-for-Linux/Unix/Windows/Cloud) that you are targetting, because the features and syntax can differ per platform. When asking for help with Db2 you should always specify the target platform, and stackoverflow has dedicated tags for db2-luw, db2-400, db2-zos.
Third you need to follow either ANSI SQL PL syntax rules (i.e. not transact SQL as used in Microsoft SQL Server), which includes rules on the valid characters for identifier names. On Db2 variables cannot begin with #. If your Db2-server runs on Linux/Unix/Windows, and it has been specially configured in advance, then you can also write your blocks in Oracle PL/SQL syntax and Db2 will emulate that. But at the present time there is no ability in Db2 to emulate Transact-SQL.

HL7 to SQLite with Mirth Connect

I'm trying to build a channel to read an HL7 ADT text file, extract an MRN and write output to a SQLite table (Database Writer).
My SQLite table contains my data but all my PatientIDs are appearing as a concatenated string in one very wide column. As opposed to a PatientID per row/record.
I'm noticing some weird illegal(?) characters in my HL7 file (which come from a Meditech EMR). In QuickViewHL7 they appear in the MSH-22 and MSH-30.
In the VIM editor -
My question is, are these supposed to be delimiters? If so, what are they? Carriage Returns?
I've posted this question on the Mirth Connect forums but seen little but tumbleweeds. I'm hoping someone here might have seen this before and tell me what's going on.
UPDATE: Hex dump suggests it's a 0x7f (0111 1111). This looks like a backspace character. Should I simply strip it or substitute it with something?
This illegal character should be a line feed carriage return to delimit the start of the next HL7 segment.
Using VIM, highlight the illegal character and press 'ga'. This will tell you the hex value of the character. In my case 0xfa (which appears to be a back space!?).
Again in Vim, do a global substitute for a \r
:%s/\%x7f/\r/g
Then save the file.
Everything parses out nicely now.

Extra char(s) found in EDI.ISASegment

When I was inbounding trading partner's X12 file using biztalk. I am required to store the ISA segment of the file in a db table.
I am using the promoted property EDI.ISA_Segment to get the ISA string.
Recently, I noticed for one trading partner. There're extra chars found in the ISA segment:
The ISA segment shall look like this:
ISA*00* *00* *ZZ*######## *ZZ*##### *150105*0606*^*00501*000000936*1*P*>~
But the ISA_segment using the promoted property was:
ISA*00* *00* *ZZ*######## *ZZ*##### *150105*0606*^*00501*000000936*1*P*>~
G
There's extra < LF >+G in the ISA segment.
The trading partner do send the X12 file with segment suffix and it was also configed in the BizTalk Agreement correctly.
It looks BizTalk takes 2 extra chars to the ISA_segment after reached the "~", I am wondering if this is a bug or it is caused some mis-configuation?
You need to look at the original EDI using a good text editor such as Notepad++ so you can see exactly what those characters are.
The X12 spec allows the use of CR and/or LF as part of the Segment Terminator so it might be a side effect of changing encodings from EDI to the database.

Some special characters are added in the BizTalk output file

I have put an XML into a receive location using the Microsoft BizTalk default pipeline "XMLReceive" and then use PassThroughTransmit to output the file to a directory.
However, if hex editor to check the output file, I found that there are three special characters  are found at the beginning of the output file.
The ASCII of  is EF BB BF.
Is there any idea why there are 3 control characters are added at the beginning of the output file?
Those characters are the Byte Order Mark which tell the receiving application how to interpret the text stream. They are not junk but are optional.
I recommend you always send the BOM unless the recieving system cannot accept them (which is really their problem ;).
I have googled the solution myself and shared to others.
Removing the BOM from Outgoing BizTalk Files
http://mindovermessaging.com/2013/08/06/removing-the-bom-from-outgoing-biztalk-files/
The three special characters are BOM (Byte Order Mark), set the PreserveBOM to false in sendport XMLTransmit pipeline will remove these three characters.

Setting the output file name in a biztalk send port

Good afternoon,
I'm trying to set the output file name in a send port and the available file name macros won't quite work.
I need something of the form "file.YYYYMMDD_HHMMSS". There's a datetime combined macro (with the wrong format), a time only macro, but no date only macro.
I don't have an orchestration for this process.
Is there any way I can set the file name from within a map or a pipeline?
Thanks!
You can achieve filename in this format YYYYMMDD_HHMMSS using following.
Use expression shape in orchestration and create four variables.
varDateTime=System.DateTime.Now; //varDateTime is datetime type
strDate=varDateTime.ToString("yyyyMMdd"); //strDate is string type
strTime=varDateTime.ToString("HHmmss"); //strTime is string type
outboundfilename= ""+strDate + " _ " +strTime +" "; //outboundfilename is the string variable.
Use the following code in Message Assignment Shape
msgOutbound(FILE.ReceivedFileName)=outboundfilename+".xml";
//File extension can be any based on your requirement. I have xml file type.
You don't need custom pipeline to do this.
You can do it with a custom pipeline or an orchestration but not with a map. Info on building a custom pipeline can be found here:
BizTalk MSDN Blogs
This can be set by setting the FILE.ReceivedFileName (instead of BTS.ReceiveFileName).
You can create a custom pipeline component to be placed on the send side (say encode stage), and then set the BTS.ReceiveFileName property to the custom file name value that needs to be set.
After this is done, you can use the %SourceFileName% macro in the Send Port. You can also refer to this MSDN forum link for more details

Resources