ballerina-platform / ballerina-library

The Ballerina Library
https://ballerina.io/learn/api-docs/ballerina/
Apache License 2.0
136 stars 64 forks source link

Researching Various Implementation Guides and Adding Support for Limitations in Ballerina EDI Tool #6789

Open RDPerera opened 3 months ago

RDPerera commented 3 months ago

Description: We need to research various implementation guides for EDI (Electronic Data Interchange) and identify any limitations or gaps in our current Ballerina EDI tool/module. Once identified, we aim to enhance our tool to address these limitations and ensure comprehensive support for different EDI implementation guides.

RDPerera commented 3 months ago

During the initial implementation of the Ballerina EDI schema for Amazon's X12 850 Purchase Order, the following considerations were identified:

  1. Duplicate Segment Names:

    • The implementation guide often lists segments with duplicate names. For example, the REF (Reference Identification) segment appears multiple times in the Heading section, each with different qualifiers.
    • Example:
      REF*CR*123456789
      REF*PD*PROMO123
    • We can handle such segments with the repeat keyword in the ballerina schema to repeat but we can't define appropriate limits for how many times it can repeat.
  2. Include Line Number of the Schema When Printing Errors:

    • To enhance debugging and validation, it's crucial to include the line number of the schema where an error occurs.
    • Example: If there's an error in segment PO1 (Baseline Item Data), the error message should reference the line number in the schema for quick identification and resolution.
  3. Add Support for Conditional Segments and Fields:

    • Many segments and fields in the guide are conditional, meaning their presence depends on certain conditions.
    • Example:

      DTM*063*20090731
      DTM*064*20090725

      In the above example, the DTM (Date/Time Reference) segment appears twice with different qualifiers and conditions for when each should be used:

      • DTM01: 063 (Do Not Deliver After)
      • Specifies the latest date that Amazon expects the freight to be delivered.
      • DTM01: 064 (Do Not Deliver Before)
      • Specifies the earliest date that Amazon expects the freight to be delivered.

      These segments must be conditionally handled based on their qualifiers to ensure accurate processing of the EDI message.