Tuesday, November 12, 2013

EDI - Copy only specific transaction to a folder


Here is a simple tutorial how to copy only a specific functional group type of EDI transaction.

In my example I need to copy all the 997 ( Functional Acknowledgment) to a specific folder.

My folder hierachy is /myhome/source/folder/CLIENT / (job / folder-in / folder-out) / YEAR / MONTH / DAY / myfile

where myfile is a single ISA per file and could be gzipped.

1 - Extract all gzipped EDI files under folder-in and folder-outfind /myhome/source/folder -type f -iwholename *folder* -iwholename *.gz  -exec zgrep -l '^ISA' {} \; -exec gunzip {} \;

2 - Copy all the 997 to /home/MY_FOLDER (Where FA is the GS Transaction code of the 997)find /myhome/source/folder -type f -iwholename *folder* -exec pcregrep -Ml '^ISA.*GS.FA'  {} \; -exec cp -rf {} /home/MY_FOLDER/ \;

No comments:

Post a Comment