- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Formatting of text EDI acknowledgement file..
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-18-2004 08:33 AM
тАО05-18-2004 08:33 AM
Formatting of text EDI acknowledgement file..
I have a text EDI ack file. One long stream of text.
However, certain sequences of letters signify, for example, beginning of a record (ST), BAK, addressee (N1), line item (P01), transaction totals (CTT) and so on.
I have been formatting these files in Windows Notepad by inserting carriage returns at these sequences.
This produces readable output for the business analyst.
Surely this can be automated?
I would like to run a script to format the file, then email it.
I am fairly proficient in shell scripting, but I don't think Bourne/POSIX will do it for the formatting.
Neither will awk.
I am thinking sed, which I have never used, or Perl.
Anyone done anything like this?
Point me in the right direction?
Raw EDI text files can be 1K to 50K in size.
Sample 1K file is attached.
Thanks,
Ken Banyas
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-18-2004 08:42 AM
тАО05-18-2004 08:42 AM
Re: Formatting of text EDI acknowledgement file..
anything else your going to have to break it up into chunks, process the chunks and having to deal with chunk boundaries, then pasting back together. uggh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-18-2004 09:01 AM
тАО05-18-2004 09:01 AM
Re: Formatting of text EDI acknowledgement file..
HTH
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-18-2004 09:16 AM
тАО05-18-2004 09:16 AM
Re: Formatting of text EDI acknowledgement file..
http://hpux.connect.org.uk/hppd/hpux/Gnu/gawk-3.1.3/
As a Plan C: Develop in gawk (it's generally a much shallower learning curve that that of Perl) and then run a2p to convert your awk code to Perl.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-18-2004 12:44 PM
тАО05-18-2004 12:44 PM
Re: Formatting of text EDI acknowledgement file..
$file = shift or die "Please provide filename";
open (FILE, "<$file") or die "Could not open $file";
binmode (FILE);
while ($len = read FILE, $chunk, 1024) { # any size goes
$_ .= $chunk; # glue to remainder
while (/ST~|N1~|PO1~|CTT~/) {
print "$`\n$&"; # print pre-match, newline and match
$_ = $'; # continue work on post-match
}
print "$_\n"; # last bit
}
- I think I got the boundaries right (Seperator accross two chuncks being read)
- You can run this on hpux or the pc.
hth,
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-20-2004 08:43 AM
тАО05-20-2004 08:43 AM
Re: Formatting of text EDI acknowledgement file..
Solution turned out to be very simple.
No awk, no Perl (although I spent many hours playing with Perl scripting)
Shell script:
for file in *.edi
do
if [ -f "$file" ]
then
tr "*" "\012" < "$file" > "$file".txt
echo "$file".txt
fi
done
tr command. The * is the character in the EDI raw text file which ends a data segment. The \012 inserts the newline.