I don't think I can do better than what I have already offered. With an input file of three similar records with different transnums, it extracts the desired one:
transnum=ABC160120XYZ0983920
sed -n "/~${transnum}~/{H;g;}; /~${transnum}~/,/EOT/p; h" file
##PAYMNT,ABCDEFGH, , ,TEST01 ,0000004308,0000004216,1104 ,000000, ,00110,USD, ,T,TESTST008 ,2016-01-18T09:30:47 ,pain.001.001.03 ,00000000000000001200,00000000000000018.00
%%YEDTRN~0000004646~ABC160120XYZ0983920~20160120_085131~20160120_085021~20160120_085021_41222370 ~20160120_084728_15401168 ~20160120_084728~0000004644~ ~TEST01 ~pain.001.001.03 ~U ~0.02 ~C~FWT ~ ~SFTS ~99999999801 ~WireCmpIDa ~021000018 ~99999998799002 ~20020101~Payee Name 1104 ~TstTrceNbr1104 ~PR ~USD~ ~ ~Y~US~PmtGrpWire0b ~OOXXMXM ~TestWirePay002 ~Y~01~HARDCOPY ~pain.001.001.03 ~TESTST008 ~2016-01-18T09:30:47 ~00000000000000000000000000000000001200~0000000000000018.00~N~ ~00~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~00~ ~ ~00~ ~ ~ ~ ~ ~ ~ ~
0000ISA00 00 ZZABCDETEST01 ZZABCDEFGHI 1601200849U005010000043080T
0000GSRA 201601200849 000004216X 005010
0000ST<>820<>1104<>PmtGrpWire0b<>
0010BPR<>U<>0000000000000000.02C<>FWT<><>01<>043000261<>DA<>99999999801<>WireCmpIDa<><>01<>021000018<>DA<>99999998799002<>20020101<><><><><>
0010TRN<>1<>TstTrceNbr1104<><>OOXXMXM<>
0010CUR<>PR<>USD<>00000000000<><><><>00000000 <>00000000 <>00000000 <>00000000 <>00000000
0010REF<>TN<>TestPay002<><><><><><><><>
0020N1<>O2<>Test Initiating Party<><><><><>
0020N1<>O1<>Test Debtor Bank<>13<>043000261<><><>
0020N4<><><><>US<><><><>
0020N1<>PR<>Debtor Pyr Nm 0a<><><><><>
0020N3<>Payer Address 00a Line1<><>
0020N3<>Payer Address 00a Line2<><>
0020N4<>Payer City<>PA<>12345<>US<><><><>
0020N1<>BK<>Test Payee Bank 002<><><><><>
0020N1<>PE<>Payee Name 1104<><><><><>
0020N3<>Payee Address 002 Line1<><>
0020N3<>Payee Address 002 Line2<><>
0020N4<>Payee Town 002<>PA<>12345<>US<><><><>
0000SE<>00000000001104<>
0000GE<>000001000004216
0000IEA<>00001000004216
0000EOT<><>000000000000019000000000000000000000000000019<><><>
What else can I do?