This would work if the file contained only 1 ISA. For Carlos' scenario, one would have to split the file based on the ISA and then apply this command for each file. ________________________________
From: Thomas Trank [mailto:[EMAIL PROTECTED] Sent: Wednesday, April 11, 2007 3:23 PM To: [EMAIL PROTECTED]; Tembe, Suhas Cc: [email protected] Subject: RE: [EDI-L] Gentran edifrmat replacement on Unix? I use the following: term=`cat inputfile | awk '{if (NR == 1) {t=substr($0, 106, 1); print t}}'` tr "\$term" "\n" < inputfile >> outputfile This works well for me. Hope this helps Thanks Tom ________________________________ From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: Wednesday, April 11, 2007 3:16 PM To: Tembe, Suhas Cc: [email protected] Subject: RE: [EDI-L] Gentran edifrmat replacement on Unix? That's fine if I know what the terminators are to begin with. But what I really need is to get ISA106 to identify the terminator, and then do the replace. This is what the Gentran edifrmat utility does (among other things). Carlos M. Garcia 305-552-4549 [EMAIL PROTECTED] <mailto:carlos_m_garcia%40fpl.com> "Tembe, Suhas" <[EMAIL PROTECTED] To: [EMAIL PROTECTED] <mailto:carlos_m_garcia%40fpl.com> astics.com> cc: [email protected] <mailto:EDI-L%40yahoogroups.com> Subject: RE: [EDI-L] Gentran edifrmat replacement on Unix? 04/11/2007 03:10 PM Assuming that the segment terminator will not appear anywhere else in the data, why not use the 'tr' command: tr '}' '\n' < inpfile > t_outfile tr '@' '\n' < t_outfile > outfile Not elegant, but should work. There is no need to look at ISA106. If it finds '}', the tr command is going to replace it. If not, nothing happens. You can have the above commands in a shell script, pass the input file name to it & let it create a output file. You just have to account for all the different types of segment terminators. You could also have just one tr command in a for loop passing it the character to be replaced. From: [email protected] <mailto:EDI-L%40yahoogroups.com> [mailto:[email protected] <mailto:EDI-L%40yahoogroups.com> ] On Behalf Of [EMAIL PROTECTED] <mailto:carlos_m_garcia%40fpl.com> Sent: Wednesday, April 11, 2007 2:42 PM To: Hurd, Richard [SLCUS] Cc: [email protected] <mailto:EDI-L%40yahoogroups.com> Subject: RE: [EDI-L] Gentran edifrmat replacement on Unix? The softshare tool is Windows-based. I need to write a Unix script (AWK?, SED?) to parse a file with multiple ISAs and multiple ISA106 characters, as occurs when I receive a file from the VAN with multiple partners' data. I've played around with td and some other native Unix, and I can handle the situation where the ISA106 is consistent, but not when it changes from ISA to ISA. In a nustshell, what I need to do is capture the ISA106 of the first ISA and replace the entire envelope with a \015, then capture the ISA106 from the next ISA, and so on. It'll be clearer from the example below. In here, I have 2 ISAs, one with ISA106=} and another with [EMAIL PROTECTED] The end result I want is also below: Input: ISA~00~ ~00~ ~01~123456789 ~16~999999999 ~070410~0928~U~00400~000000277~0~P~>}GS~FA~123456789~999999999~20070410~ 0928~277~X~004010}ST~997~0419}AK1~PO~809}AK2~850~0001}AK5~A}AK9~A~1~1~1} SE~6~0419}GE~1~277}IEA~1~000000277}ISA~00~ ~00~ ~14~222222222 ~16~999999999 ~070410~0831~U~00400~000013464~0~P~>@GS~PR~222222222~999999999~20070410~ [EMAIL PROTECTED]@BAK~06~AC~3000111134~20070406~~~~~200704 [EMAIL PROTECTED] [EMAIL PROTECTED]@[EMAIL PROTECTED] [EMAIL PROTECTED]@[EMAIL PROTECTED]@[EMAIL PROTECTED] EA~1~000013464@ Output: ISA~00~ ~00~ ~01~123456789 ~16~999999999 ~070410~0928~U~00400~000000277~0~P~> GS~FA~123456789~999999999~20070410~0928~277~X~004010 ST~997~0419 AK1~PO~809 AK2~850~0001 AK5~A AK9~A~1~1~1 SE~6~0419 GE~1~277 IEA~1~000000277 ISA~00~ ~00~ ~14~222222222 ~16~999999999 ~070410~0831~U~00400~000013464~0~P~> GS~PR~222222222~999999999~20070410~0831~13464~X~004010 ST~855~0001 BAK~06~AC~3000111134~20070406~~~~~20070410 N1~ST~COMPANY NAME~92~096600 N1~VN~VENDORXXXXXX PID~F~~~~TEXT DESCRIPTION ACK~AC~1~EA~017~20070417 CTT~1 SE~9~0001 GE~1~13464 IEA~1~000013464 "Hurd, Richard [SLCUS]" To: "ec_edi" <[EMAIL PROTECTED] <mailto:carlos_m_garcia%40fpl.com> >, [email protected] <mailto:EDI-L%40yahoogroups.com> <[EMAIL PROTECTED] <mailto:rhurd3%40CSCUS.JNJ> cc: .com> Subject: RE: [EDI-L] Gentran edifrmat replacement on Unix? 04/11/2007 02:11 PM I remember doing something like that with 'awk' but it wouldn't be as nice as a fullblown tool. With awk, if you set the record separator to the 106th byte in the ISA record, and the field separator to the fourth byte, you can use it to do rudimentary parsing. Much easier to use a tool like the Softshare one. Must go find that one on their web site. :) -----Original Message----- From: [email protected] <mailto:EDI-L%40yahoogroups.com> [mailto:[email protected] <mailto:EDI-L%40yahoogroups.com> ] Sent: Wednesday, April 11, 2007 8:54 AM To: [email protected] <mailto:EDI-L%40yahoogroups.com> Subject: [EDI-L] Gentran edifrmat replacement on Unix? I'm looking to mimic what Gentran's edifrmat command does using a unix script or command. We are removing Gentran but would like the functionality provided by edifrmat, for example, when viewing EDI files, we run edifrmat on the file and redirect the output to a text file that we can then read, with carriage returnes, etc. We'd like to have a similar capability with simple command line Unix. My thinking is we need to parse through an EDI file, extract poswition 106 from the ISA, and replace it with a CR. I have a simple td command that works, but only when the ISA06 field is consistent throughout the file. ... Please use the following Message Identifiers as your subject prefix: <SALES>, <JOBS>, <LIST>, <TECH>, <MISC>, <EVENT>, <OFF-TOPIC> Job postings are welcome, but for job postings or requests for work: <JOBS> IS REQUIRED in the subject line as a prefix. Yahoo! Groups Links [Non-text portions of this message have been removed] This message (including any attachments) is intended solely for the specific individual(s) or entity(ies) named above, and may contain legally privileged and confidential information. If you are not the intended recipient, please notify the sender immediately by replying to this message and then delete it. Any disclosure, copying, or distribution of this message, or the taking of any action based on it, by other than the intended recipient, is strictly prohibited. [Non-text portions of this message have been removed] ... Please use the following Message Identifiers as your subject prefix: <SALES>, <JOBS>, <LIST>, <TECH>, <MISC>, <EVENT>, <OFF-TOPIC> Job postings are welcome, but for job postings or requests for work: <JOBS> IS REQUIRED in the subject line as a prefix. Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/EDI-L/ <*> Your email settings: Individual Email | Traditional <*> To change settings online go to: http://groups.yahoo.com/group/EDI-L/join (Yahoo! ID required) <*> To change settings via email: mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
