Giter Club home page Giter Club logo

Comments (6)

MikeEdgar avatar MikeEdgar commented on August 13, 2024 1

@softmade-timobruentjen - thank you for the example. I've added it to the Wiki with some modifications: https://github.com/xlate/staedi/wiki/Writing-EDI-Data-(Simple)#edifact-example. Please take a look at how the composite elements are written. That may simplify your process. As always, please open up a new issue if you have any problems. Thanks

from staedi.

softmade-timobruentjen avatar softmade-timobruentjen commented on August 13, 2024

Havent´t seen so far. Is it possible for you to add an example to the wiki pages for a regular UN-EDIFACT Message like INVOIC? I stumbled to the code to get it running, maybe others won´t have to. I can send you my example to take it over to the wiki pages?

from staedi.

MikeEdgar avatar MikeEdgar commented on August 13, 2024

@softmade-timobruentjen - I would be happy to add to the wiki and if you have an example that would be great. Are you using a validation schema for INVOIC as well?

from staedi.

softmade-timobruentjen avatar softmade-timobruentjen commented on August 13, 2024

Well, i´ve use the one given by StAEDI. It was very strictly against errors ;-) in the EDIFACT Code.

Here is what i´ve done to get the main EDI Part running for INVOIC 96A Standard:
` // (1) Create an EDIOutputFactory
EDIOutputFactory factory = EDIOutputFactory.newFactory();

    // (2) Optionally specify delimiters - here the given values are the same as default
    factory.setProperty(EDIStreamConstants.Delimiters.SEGMENT, '\'');
    factory.setProperty(EDIStreamConstants.Delimiters.DATA_ELEMENT, '+');
    factory.setProperty(EDIStreamConstants.Delimiters.COMPONENT_ELEMENT, ':');
    factory.setProperty(EDIStreamConstants.Delimiters.RELEASE, '?');
    factory.setProperty(EDIStreamConstants.Delimiters.REPETITION, ' ');
    
    // Write each segment on a new line
    //factory.setProperty(EDIOutputFactory.PRETTY_PRINT, true);

    // (3) Create an EDIStreamWriter. Any OutputStream may be used - here we are writing to a file
    OutputStream stream = null;
	try {
		stream = new FileOutputStream("someFileNameYouPrefer");
	} catch (FileNotFoundException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
    EDIStreamWriter writer = factory.createEDIStreamWriter(stream);

    // (4) Start the interchange
    writer.startInterchange();

    // (5) Write the three segments necessary for the INVOIC (UNA, UNB, UNH)
    writer.writeStartSegment("UNA").writeEndSegment();
	
    writer.writeStartSegment("UNB");
    writer.writeStartElement().writeElementData("UNOC");
    writer.writeEmptyComponent().writeComponent("3");
    writer.endElement();
    writer.writeStartElement().writeElementData("0123456789012");
    writer.writeEmptyComponent().writeComponent("14");
    writer.endElement();
    writer.writeStartElement().writeElementData("0123456789012");
    writer.writeEmptyComponent().writeComponent("14");
    writer.endElement();
    writer.writeStartElement().writeElementData("200702");
    writer.writeEmptyComponent().writeComponent("0734");
    writer.endElement();
    writer.writeStartElement().writeElementData("00000563").endElement();
    writer.writeEndSegment();
    
    writer.writeStartSegment("UNH");
    writer.writeStartElement().writeElementData("0001").endElement();
    writer.writeStartElement().writeElementData("INVOIC");
    writer.writeEmptyComponent().writeComponent("D");
    writer.writeComponent("96A");
    writer.writeComponent("UN");
    writer.writeComponent("EAN008");
    writer.endElement();
    writer.writeEndSegment();
    
    //Begin Message BGM
    writer.writeStartSegment("BGM");
    writer.writeStartElement().writeElementData("380").endElement();
    writer.writeStartElement().writeElementData("1676245").endElement();
    writer.writeStartElement().writeElementData("9").endElement();
    writer.writeEndSegment();

   //From Here do further INVOIC related segments like DTM and so on

 // (6) End the interchange
    writer.endInterchange();

    // (7) Close the EDIStreamWriter. This must be done to ensure the output is written
    writer.close();`

from staedi.

softmade-timobruentjen avatar softmade-timobruentjen commented on August 13, 2024

Great Work, Thanks

from staedi.

MikeEdgar avatar MikeEdgar commented on August 13, 2024

Closing this issue for now due to lack of interest for EDIFACT interactive messages. This may be revisited in the future if there is interest.

from staedi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.