Hi,
I have some EDI data which 830, 862 and 997. Here is the sample data:
ISA~00~ ~00~ ~ZZ~F159B ~ZZ~U1CAD ~051215~184
3~U~00200~000011432~0~P~<
GS~FA~TC11A~U1CAD~051215~1843~000011432~X~002002
ST~997~0001
AK1~SH~1168
AK2~856~11680001
AK5~A
AK9~A~1~1~1
SE~6~0001
GE~1~000011432
IEA~00001~000011432
The text starts from 997. Right now the way I am extracting is look for 997 and then look for ISA and extract the text containing ISA, right before the new segment starts with the following command.
/usr/bin/gawk -v RS='ISA' '/997/ {print RS $0}' myfile.txt.
Vergsh one of the member on this forum helped me with this. Now the only problem I am facing is, it extracts the contents for other transactions too if they have 997 in the data. So I have to add one more condition to this along with the above mentioned command, that look for "ST~" right before 997 only then extract the contents otherwise ignore it.
for e.g. ST~997~0001
TIA,
Inder