项目作者: parcelLab

项目描述 :
Parsing EDI IFTMIN and IFTSTA messages properly. Yes, EDI. You're welcome.
高级语言: JavaScript
项目地址: git://github.com/parcelLab/edi-iftmin.git
创建时间: 2016-04-07T07:27:55Z
项目社区:https://github.com/parcelLab/edi-iftmin

开源协议:MIT License

下载


EDI IFTMIN and IFTSTA

So that’s basically these specifications here:
UN/EDIFACT IFTMIN and
UN/EDIFACT IFTSTA.

How to use

This is how you parse EDI files:

  1. var ediParser = require('edi-iftmin');
  2. // first load the raw EDI file into memory
  3. var rawEdi = fs.readFileSync('./some-edi-file', 'utf8');
  4. // this parses the raw EDI message and creates a nice JSON object for you to use
  5. var edi = ediParser.parseEdi(rawEdi);

Then you can inspect it to see what information is in there.

  1. ediParser.inspectEdi(edi);

Quick sidenote: You can drop files you want to inspect in inspect/files and run cd inspect && node . to use our prepared inspector.

This will print a structure of the EDI file to your console showing all messages, e.g. like this:

  1. Message 0
  2. UNH: Message header (raw: UNH+553416+IFTMIN:2:912:UN)
  3. 010: Message reference number # 553416
  4. 020 # IFTMIN:2:912:UN
  5. 0 # IFTMIN
  6. 1 # 2
  7. 2 # 912
  8. 3 # UN
  9. BGM: Beginning of message (raw: BGM+700:::ZFT+663424234)
  10. 010: Document/message name # 700:::ZFT
  11. 0 # 700
  12. 1
  13. 2
  14. 3 # ZFT
  15. 020 # 663424234
  16. LOC: Place/location identification
  17. 36:GB: 36:GB (raw: LOC+36:GB)
  18. 010: Location function code qualifier # 36:GB
  19. 0 # 36
  20. 1 # GB

This gives you a better understanding of what’s in there, and you can also extract it like this, e.g. if you want to extract the message number 663424234.

  1. ediParser.selectWithPath(edi, 'BGM.020.value');